@selesai/code 0.13.13 → 0.13.14
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/dist/bun/cli.d.ts +2 -0
- package/dist/bun/cli.js +10 -0
- package/dist/bun/register-bedrock.d.ts +1 -0
- package/dist/bun/register-bedrock.js +3 -0
- package/dist/bun/restore-sandbox-env.d.ts +16 -0
- package/dist/bun/restore-sandbox-env.js +35 -0
- package/dist/cli/args.d.ts +59 -0
- package/dist/cli/args.js +428 -0
- package/dist/cli/args.test.d.ts +1 -0
- package/dist/cli/args.test.js +32 -0
- package/dist/cli/config-selector.d.ts +15 -0
- package/dist/cli/config-selector.js +30 -0
- package/dist/cli/credential-print.d.ts +22 -0
- package/dist/cli/credential-print.js +116 -0
- package/dist/cli/file-processor.d.ts +14 -0
- package/dist/cli/file-processor.js +69 -0
- package/dist/cli/initial-message.d.ts +17 -0
- package/dist/cli/initial-message.js +21 -0
- package/dist/cli/list-models.d.ts +8 -0
- package/dist/cli/list-models.js +97 -0
- package/dist/cli/project-trust.d.ts +9 -0
- package/dist/cli/project-trust.js +47 -0
- package/dist/cli/session-picker.d.ts +9 -0
- package/dist/cli/session-picker.js +35 -0
- package/dist/cli/startup-ui.d.ts +22 -0
- package/dist/cli/startup-ui.js +172 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +17 -0
- package/dist/config.d.ts +181 -0
- package/dist/config.js +788 -0
- package/dist/core/agent-session-auto-handoff.test.d.ts +1 -0
- package/dist/core/agent-session-auto-handoff.test.js +183 -0
- package/dist/core/agent-session-length-continuation.test.d.ts +1 -0
- package/dist/core/agent-session-length-continuation.test.js +107 -0
- package/dist/core/agent-session-runtime.d.ts +118 -0
- package/dist/core/agent-session-runtime.js +305 -0
- package/dist/core/agent-session-services.d.ts +84 -0
- package/dist/core/agent-session-services.js +132 -0
- package/dist/core/agent-session-skill-block.test.d.ts +1 -0
- package/dist/core/agent-session-skill-block.test.js +19 -0
- package/dist/core/agent-session.d.ts +713 -0
- package/dist/core/agent-session.js +3054 -0
- package/dist/core/agents.d.ts +52 -0
- package/dist/core/agents.js +237 -0
- package/dist/core/auth-guidance.d.ts +4 -0
- package/dist/core/auth-guidance.js +20 -0
- package/dist/core/auth-storage.d.ts +61 -0
- package/dist/core/auth-storage.js +249 -0
- package/dist/core/bash-executor.d.ts +31 -0
- package/dist/core/bash-executor.js +110 -0
- package/dist/core/built-in-extensions.d.ts +2 -0
- package/dist/core/built-in-extensions.js +2 -0
- package/dist/core/cache-stats.d.ts +48 -0
- package/dist/core/cache-stats.js +100 -0
- package/dist/core/compaction/branch-summarization.d.ts +97 -0
- package/dist/core/compaction/branch-summarization.js +246 -0
- package/dist/core/compaction/compaction.d.ts +141 -0
- package/dist/core/compaction/compaction.js +659 -0
- package/dist/core/compaction/index.d.ts +6 -0
- package/dist/core/compaction/index.js +6 -0
- package/dist/core/compaction/utils.d.ts +37 -0
- package/dist/core/compaction/utils.js +141 -0
- package/dist/core/defaults.d.ts +3 -0
- package/dist/core/defaults.js +10 -0
- package/dist/core/diagnostics.d.ts +15 -0
- package/dist/core/diagnostics.js +1 -0
- package/dist/core/event-bus.d.ts +8 -0
- package/dist/core/event-bus.js +24 -0
- package/dist/core/exec.d.ts +28 -0
- package/dist/core/exec.js +74 -0
- package/dist/core/experimental.d.ts +5 -0
- package/dist/core/experimental.js +7 -0
- package/dist/core/export-html/ansi-to-html.d.ts +21 -0
- package/dist/core/export-html/ansi-to-html.js +248 -0
- package/dist/core/export-html/index.d.ts +36 -0
- package/dist/core/export-html/index.js +225 -0
- package/dist/core/export-html/template.css +1066 -0
- package/dist/core/export-html/template.html +55 -0
- package/dist/core/export-html/template.js +1864 -0
- package/dist/core/export-html/tool-renderer.d.ts +33 -0
- package/dist/core/export-html/tool-renderer.js +107 -0
- package/dist/core/export-html/vendor/highlight.min.js +1213 -0
- package/dist/core/export-html/vendor/marked.min.js +78 -0
- package/dist/core/extensions/index.d.ts +11 -0
- package/dist/core/extensions/index.js +8 -0
- package/dist/core/extensions/loader.d.ts +22 -0
- package/dist/core/extensions/loader.js +632 -0
- package/dist/core/extensions/loader.test.d.ts +1 -0
- package/dist/core/extensions/loader.test.js +21 -0
- package/dist/core/extensions/runner.d.ts +176 -0
- package/dist/core/extensions/runner.js +1016 -0
- package/dist/core/extensions/types.d.ts +1313 -0
- package/dist/core/extensions/types.js +44 -0
- package/dist/core/extensions/wrapper.d.ts +19 -0
- package/dist/core/extensions/wrapper.js +40 -0
- package/dist/core/footer-data-provider.d.ts +63 -0
- package/dist/core/footer-data-provider.js +337 -0
- package/dist/core/git-command.d.ts +8 -0
- package/dist/core/git-command.js +48 -0
- package/dist/core/handoff.d.ts +11 -0
- package/dist/core/handoff.js +49 -0
- package/dist/core/http-dispatcher.d.ts +21 -0
- package/dist/core/http-dispatcher.js +90 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +12 -0
- package/dist/core/keybindings.d.ts +421 -0
- package/dist/core/keybindings.js +295 -0
- package/dist/core/llama/client.d.ts +66 -0
- package/dist/core/llama/client.js +308 -0
- package/dist/core/llama/huggingface.d.ts +22 -0
- package/dist/core/llama/huggingface.js +140 -0
- package/dist/core/llama/index.d.ts +2 -0
- package/dist/core/llama/index.js +207 -0
- package/dist/core/llama/provider.d.ts +11 -0
- package/dist/core/llama/provider.js +143 -0
- package/dist/core/llama/ui.d.ts +41 -0
- package/dist/core/llama/ui.js +415 -0
- package/dist/core/messages.d.ts +76 -0
- package/dist/core/messages.js +122 -0
- package/dist/core/model-config.d.ts +547 -0
- package/dist/core/model-config.js +278 -0
- package/dist/core/model-registry.d.ts +45 -0
- package/dist/core/model-registry.js +107 -0
- package/dist/core/model-resolver.d.ts +122 -0
- package/dist/core/model-resolver.js +558 -0
- package/dist/core/model-runtime.d.ts +86 -0
- package/dist/core/model-runtime.js +472 -0
- package/dist/core/models-store.d.ts +16 -0
- package/dist/core/models-store.js +44 -0
- package/dist/core/output-guard.d.ts +6 -0
- package/dist/core/output-guard.js +88 -0
- package/dist/core/package-manager.d.ts +221 -0
- package/dist/core/package-manager.js +2232 -0
- package/dist/core/package-manager.test.d.ts +1 -0
- package/dist/core/package-manager.test.js +58 -0
- package/dist/core/project-trust.d.ts +14 -0
- package/dist/core/project-trust.js +58 -0
- package/dist/core/prompt-templates.d.ts +53 -0
- package/dist/core/prompt-templates.js +235 -0
- package/dist/core/provider-attribution.d.ts +3 -0
- package/dist/core/provider-attribution.js +71 -0
- package/dist/core/provider-composer.d.ts +54 -0
- package/dist/core/provider-composer.js +387 -0
- package/dist/core/radius.d.ts +1 -0
- package/dist/core/radius.js +1 -0
- package/dist/core/remote-catalog-provider.d.ts +4 -0
- package/dist/core/remote-catalog-provider.js +119 -0
- package/dist/core/resolve-config-value.d.ts +29 -0
- package/dist/core/resolve-config-value.js +246 -0
- package/dist/core/resource-loader.d.ts +256 -0
- package/dist/core/resource-loader.js +974 -0
- package/dist/core/runtime-credentials.d.ts +16 -0
- package/dist/core/runtime-credentials.js +41 -0
- package/dist/core/sdk.d.ts +107 -0
- package/dist/core/sdk.js +279 -0
- package/dist/core/session-cwd.d.ts +18 -0
- package/dist/core/session-cwd.js +37 -0
- package/dist/core/session-manager.d.ts +355 -0
- package/dist/core/session-manager.js +1339 -0
- package/dist/core/settings-manager-auto-handoff.test.d.ts +1 -0
- package/dist/core/settings-manager-auto-handoff.test.js +42 -0
- package/dist/core/settings-manager.d.ts +350 -0
- package/dist/core/settings-manager.js +1076 -0
- package/dist/core/skills.d.ts +70 -0
- package/dist/core/skills.js +401 -0
- package/dist/core/slash-commands.d.ts +14 -0
- package/dist/core/slash-commands.js +27 -0
- package/dist/core/source-info.d.ts +17 -0
- package/dist/core/source-info.js +18 -0
- package/dist/core/system-prompt.d.ts +30 -0
- package/dist/core/system-prompt.js +129 -0
- package/dist/core/system-prompt.test.d.ts +1 -0
- package/dist/core/system-prompt.test.js +94 -0
- package/dist/core/telemetry.d.ts +2 -0
- package/dist/core/telemetry.js +8 -0
- package/dist/core/timings.d.ts +9 -0
- package/dist/core/timings.js +40 -0
- package/dist/core/tools/bash.d.ts +86 -0
- package/dist/core/tools/bash.js +409 -0
- package/dist/core/tools/edit-diff.d.ts +105 -0
- package/dist/core/tools/edit-diff.js +423 -0
- package/dist/core/tools/edit.d.ts +50 -0
- package/dist/core/tools/edit.js +285 -0
- package/dist/core/tools/file-mutation-queue.d.ts +5 -0
- package/dist/core/tools/file-mutation-queue.js +51 -0
- package/dist/core/tools/find.d.ts +34 -0
- package/dist/core/tools/find.js +304 -0
- package/dist/core/tools/grep.d.ts +36 -0
- package/dist/core/tools/grep.js +303 -0
- package/dist/core/tools/index.d.ts +42 -0
- package/dist/core/tools/index.js +119 -0
- package/dist/core/tools/ls.d.ts +36 -0
- package/dist/core/tools/ls.js +166 -0
- package/dist/core/tools/output-accumulator.d.ts +51 -0
- package/dist/core/tools/output-accumulator.js +183 -0
- package/dist/core/tools/path-utils.d.ts +9 -0
- package/dist/core/tools/path-utils.js +98 -0
- package/dist/core/tools/powershell.d.ts +15 -0
- package/dist/core/tools/powershell.js +38 -0
- package/dist/core/tools/powershell.test.d.ts +1 -0
- package/dist/core/tools/powershell.test.js +20 -0
- package/dist/core/tools/read-vision.test.d.ts +1 -0
- package/dist/core/tools/read-vision.test.js +122 -0
- package/dist/core/tools/read.d.ts +46 -0
- package/dist/core/tools/read.js +327 -0
- package/dist/core/tools/render-utils.d.ts +23 -0
- package/dist/core/tools/render-utils.js +64 -0
- package/dist/core/tools/tool-definition-wrapper.d.ts +13 -0
- package/dist/core/tools/tool-definition-wrapper.js +35 -0
- package/dist/core/tools/truncate.d.ts +69 -0
- package/dist/core/tools/truncate.js +214 -0
- package/dist/core/tools/write.d.ts +25 -0
- package/dist/core/tools/write.js +198 -0
- package/dist/core/trust-manager.d.ts +35 -0
- package/dist/core/trust-manager.js +201 -0
- package/dist/core/usage-totals.d.ts +20 -0
- package/dist/core/usage-totals.js +61 -0
- package/dist/core/vision-caption.d.ts +30 -0
- package/dist/core/vision-caption.js +62 -0
- package/dist/defaults/models.json +335 -0
- package/dist/defaults/settings.json +61 -0
- package/dist/extensions/agent-browser.test.ts +371 -0
- package/dist/extensions/agent-browser.ts +160 -0
- package/dist/extensions/auto-session-name.test.ts +169 -0
- package/dist/extensions/auto-session-name.ts +100 -0
- package/dist/extensions/context-compaction-reminder.test.ts +82 -0
- package/dist/extensions/context-compaction-reminder.ts +28 -0
- package/dist/extensions/copy-turn.test.ts +383 -0
- package/dist/extensions/copy-turn.ts +146 -0
- package/dist/extensions/cost-reconcile.test.ts +272 -0
- package/dist/extensions/cost-reconcile.ts +264 -0
- package/dist/extensions/grep-app/index.test.ts +406 -0
- package/dist/extensions/grep-app/index.ts +216 -0
- package/dist/extensions/handoff-new.test.ts +434 -0
- package/dist/extensions/handoff-new.ts +129 -0
- package/dist/extensions/herdr-agent-state.ts +310 -0
- package/dist/extensions/inline-skills.test.ts +204 -0
- package/dist/extensions/inline-skills.ts +102 -0
- package/dist/extensions/package.json +32 -0
- package/dist/extensions/pi-hermes-memory/CHANGELOG.md +371 -0
- package/dist/extensions/pi-hermes-memory/LICENSE +21 -0
- package/dist/extensions/pi-hermes-memory/README.md +643 -0
- package/dist/extensions/pi-hermes-memory/docs/0.1/TASKS.md +197 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/PLAN.md +290 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/TASKS.md +134 -0
- package/dist/extensions/pi-hermes-memory/docs/0.2/TEST-PLAN.md +216 -0
- package/dist/extensions/pi-hermes-memory/docs/0.3/PLAN.md +330 -0
- package/dist/extensions/pi-hermes-memory/docs/0.3/TASKS.md +125 -0
- package/dist/extensions/pi-hermes-memory/docs/0.4/PLAN.md +160 -0
- package/dist/extensions/pi-hermes-memory/docs/0.4/TASKS.md +113 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/CHANGELOG.md +57 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/PLAN.md +202 -0
- package/dist/extensions/pi-hermes-memory/docs/0.6/TASKS.md +144 -0
- package/dist/extensions/pi-hermes-memory/docs/0.7/PLAN.md +349 -0
- package/dist/extensions/pi-hermes-memory/docs/0.7/TASKS.md +110 -0
- package/dist/extensions/pi-hermes-memory/docs/PUBLISHING.md +149 -0
- package/dist/extensions/pi-hermes-memory/docs/ROADMAP.md +468 -0
- package/dist/extensions/pi-hermes-memory/docs/images/memory-architecture.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi-logo.svg +22 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi_memory.png +0 -0
- package/dist/extensions/pi-hermes-memory/docs/images/pi_memory.svg +19 -0
- package/dist/extensions/pi-hermes-memory/docs/images/security-flow.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/session-lifecycle.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/images/source-architecture.svg +1 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/memory-architecture.mmd +49 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/security-flow.mmd +40 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/session-lifecycle.mmd +56 -0
- package/dist/extensions/pi-hermes-memory/docs/mermaid/source-architecture.mmd +54 -0
- package/dist/extensions/pi-hermes-memory/package-lock.json +3799 -0
- package/dist/extensions/pi-hermes-memory/package.json +66 -0
- package/dist/extensions/pi-hermes-memory/scripts/check-min-sdk.mjs +99 -0
- package/dist/extensions/pi-hermes-memory/scripts/ensure-dev.mjs +57 -0
- package/dist/extensions/pi-hermes-memory/src/auto-consolidation-warning.ts +6 -0
- package/dist/extensions/pi-hermes-memory/src/config.ts +178 -0
- package/dist/extensions/pi-hermes-memory/src/constants.ts +424 -0
- package/dist/extensions/pi-hermes-memory/src/extension-root-migration.ts +639 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/auto-consolidate.ts +401 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/background-review.ts +297 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/child-process-watchdog.mjs +90 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/correction-detector.ts +300 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/index-sessions.ts +86 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/insights.ts +78 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/interview.ts +37 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/learn-memory.ts +186 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/message-parts.ts +27 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/pi-child-process.ts +485 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/preview-context.ts +105 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/review-memory-ops.ts +506 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-backfill.ts +145 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-flush.ts +151 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/session-live-index.ts +94 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/skills-command.ts +1334 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/standing-pin.ts +111 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/switch-project.ts +75 -0
- package/dist/extensions/pi-hermes-memory/src/handlers/sync-markdown-memories.ts +266 -0
- package/dist/extensions/pi-hermes-memory/src/index.ts +384 -0
- package/dist/extensions/pi-hermes-memory/src/lifecycle-timing.ts +54 -0
- package/dist/extensions/pi-hermes-memory/src/paths.ts +61 -0
- package/dist/extensions/pi-hermes-memory/src/project-context.ts +13 -0
- package/dist/extensions/pi-hermes-memory/src/project-memory-migration.ts +93 -0
- package/dist/extensions/pi-hermes-memory/src/project.ts +157 -0
- package/dist/extensions/pi-hermes-memory/src/prompt-context.ts +55 -0
- package/dist/extensions/pi-hermes-memory/src/store/atomic-lock-coordinator.ts +375 -0
- package/dist/extensions/pi-hermes-memory/src/store/canonical-storage-path.ts +54 -0
- package/dist/extensions/pi-hermes-memory/src/store/content-scanner.ts +101 -0
- package/dist/extensions/pi-hermes-memory/src/store/db.ts +1180 -0
- package/dist/extensions/pi-hermes-memory/src/store/fts-query.ts +101 -0
- package/dist/extensions/pi-hermes-memory/src/store/markdown-mutation-lock.ts +38 -0
- package/dist/extensions/pi-hermes-memory/src/store/memory-lookup.ts +24 -0
- package/dist/extensions/pi-hermes-memory/src/store/memory-store.ts +1191 -0
- package/dist/extensions/pi-hermes-memory/src/store/recovery-maintenance.ts +66 -0
- package/dist/extensions/pi-hermes-memory/src/store/schema.ts +118 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-anchor-search.ts +472 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-indexer.ts +511 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-parser.ts +213 -0
- package/dist/extensions/pi-hermes-memory/src/store/session-search.ts +234 -0
- package/dist/extensions/pi-hermes-memory/src/store/skill-store.ts +950 -0
- package/dist/extensions/pi-hermes-memory/src/store/skill-utils.ts +133 -0
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-memory-store.ts +1002 -0
- package/dist/extensions/pi-hermes-memory/src/store/sqlite-native.ts +241 -0
- package/dist/extensions/pi-hermes-memory/src/store/standing-instructions.ts +247 -0
- package/dist/extensions/pi-hermes-memory/src/tools/memory-search-tool.ts +95 -0
- package/dist/extensions/pi-hermes-memory/src/tools/memory-tool.ts +469 -0
- package/dist/extensions/pi-hermes-memory/src/tools/session-search-tool.ts +246 -0
- package/dist/extensions/pi-hermes-memory/src/tools/shared-output-view.ts +170 -0
- package/dist/extensions/pi-hermes-memory/src/tools/skill-tool.ts +333 -0
- package/dist/extensions/pi-hermes-memory/src/tools/tool-result-views.ts +105 -0
- package/dist/extensions/pi-hermes-memory/src/types.ts +214 -0
- package/dist/extensions/pi-hermes-memory/tests/config.test.ts +434 -0
- package/dist/extensions/pi-hermes-memory/tests/extension-root-migration.test.ts +368 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/auto-consolidate.test.ts +984 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/background-review.test.ts +950 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/correction-detector.test.ts +671 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/insights.test.ts +157 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/interview.test.ts +127 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/pi-child-process.test.ts +905 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/preview-context.test.ts +152 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/prompt-context.test.ts +166 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/resources-discover.test.ts +71 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/review-memory-ops.test.ts +614 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-backfill.test.ts +192 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-flush.test.ts +677 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/session-live-index.test.ts +225 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/skills-command.test.ts +827 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/standing-pin.test.ts +134 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/sync-markdown-memories.test.ts +491 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/system-prompt.test.ts +199 -0
- package/dist/extensions/pi-hermes-memory/tests/handlers/thinking-max.test.ts +64 -0
- package/dist/extensions/pi-hermes-memory/tests/index.test.ts +30 -0
- package/dist/extensions/pi-hermes-memory/tests/integration/flow.test.ts +126 -0
- package/dist/extensions/pi-hermes-memory/tests/lifecycle-timing.test.ts +76 -0
- package/dist/extensions/pi-hermes-memory/tests/paths.test.ts +23 -0
- package/dist/extensions/pi-hermes-memory/tests/project-memory-migration.test.ts +80 -0
- package/dist/extensions/pi-hermes-memory/tests/project-rebinding.test.ts +115 -0
- package/dist/extensions/pi-hermes-memory/tests/project.test.ts +120 -0
- package/dist/extensions/pi-hermes-memory/tests/run-all-timeout.test.ts +107 -0
- package/dist/extensions/pi-hermes-memory/tests/run-all.sh +45 -0
- package/dist/extensions/pi-hermes-memory/tests/store/atomic-lock-coordinator.test.ts +381 -0
- package/dist/extensions/pi-hermes-memory/tests/store/content-scanner.test.ts +388 -0
- package/dist/extensions/pi-hermes-memory/tests/store/db.test.ts +1046 -0
- package/dist/extensions/pi-hermes-memory/tests/store/markdown-mutation-lock.test.ts +34 -0
- package/dist/extensions/pi-hermes-memory/tests/store/memory-store.test.ts +2150 -0
- package/dist/extensions/pi-hermes-memory/tests/store/recovery-maintenance.test.ts +170 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-anchor-search.test.ts +210 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-indexer.test.ts +643 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-parser.test.ts +282 -0
- package/dist/extensions/pi-hermes-memory/tests/store/session-search.test.ts +287 -0
- package/dist/extensions/pi-hermes-memory/tests/store/skill-store.test.ts +678 -0
- package/dist/extensions/pi-hermes-memory/tests/store/skill-utils.test.ts +21 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-lazy-load.test.ts +78 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-memory-store.test.ts +543 -0
- package/dist/extensions/pi-hermes-memory/tests/store/sqlite-native.test.ts +164 -0
- package/dist/extensions/pi-hermes-memory/tests/store/standing-instructions.test.ts +171 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-search-tool.test.ts +84 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/memory-tool.test.ts +709 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/session-search-tool.test.ts +345 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/shared-output-view.test.ts +362 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/skill-tool.test.ts +478 -0
- package/dist/extensions/pi-hermes-memory/tests/tools/tool-result-renderer-wiring.test.ts +40 -0
- package/dist/extensions/pi-hermes-memory/tsconfig.json +19 -0
- package/dist/extensions/pi-intercom/CHANGELOG.md +321 -0
- package/dist/extensions/pi-intercom/LICENSE +21 -0
- package/dist/extensions/pi-intercom/README.md +598 -0
- package/dist/extensions/pi-intercom/banner.png +0 -0
- package/dist/extensions/pi-intercom/broker/broker.ts +1721 -0
- package/dist/extensions/pi-intercom/broker/client-liveness.test.ts +173 -0
- package/dist/extensions/pi-intercom/broker/client.test.ts +83 -0
- package/dist/extensions/pi-intercom/broker/client.ts +793 -0
- package/dist/extensions/pi-intercom/broker/extension-state.ts +197 -0
- package/dist/extensions/pi-intercom/broker/extension.test.ts +486 -0
- package/dist/extensions/pi-intercom/broker/framing.test.ts +114 -0
- package/dist/extensions/pi-intercom/broker/framing.ts +115 -0
- package/dist/extensions/pi-intercom/broker/paths.test.ts +153 -0
- package/dist/extensions/pi-intercom/broker/paths.ts +134 -0
- package/dist/extensions/pi-intercom/broker/protocol.ts +208 -0
- package/dist/extensions/pi-intercom/broker/runtime-claim.test.ts +34 -0
- package/dist/extensions/pi-intercom/broker/runtime-claim.ts +21 -0
- package/dist/extensions/pi-intercom/broker/spawn.test.ts +252 -0
- package/dist/extensions/pi-intercom/broker/spawn.ts +420 -0
- package/dist/extensions/pi-intercom/config.test.ts +104 -0
- package/dist/extensions/pi-intercom/config.ts +163 -0
- package/dist/extensions/pi-intercom/cwd.test.ts +40 -0
- package/dist/extensions/pi-intercom/cwd.ts +31 -0
- package/dist/extensions/pi-intercom/extension-api.ts +84 -0
- package/dist/extensions/pi-intercom/format-context.test.ts +31 -0
- package/dist/extensions/pi-intercom/format-context.ts +32 -0
- package/dist/extensions/pi-intercom/index.ts +2821 -0
- package/dist/extensions/pi-intercom/intercom.integration.test.ts +4232 -0
- package/dist/extensions/pi-intercom/package.json +49 -0
- package/dist/extensions/pi-intercom/project-agent.test.ts +145 -0
- package/dist/extensions/pi-intercom/project-agent.ts +324 -0
- package/dist/extensions/pi-intercom/reply-tracker.test.ts +239 -0
- package/dist/extensions/pi-intercom/reply-tracker.ts +160 -0
- package/dist/extensions/pi-intercom/skills/pi-intercom/SKILL.md +452 -0
- package/dist/extensions/pi-intercom/test/inline-message.test.ts +184 -0
- package/dist/extensions/pi-intercom/test/overlay-width.test.ts +66 -0
- package/dist/extensions/pi-intercom/types.ts +165 -0
- package/dist/extensions/pi-intercom/ui/compose.ts +143 -0
- package/dist/extensions/pi-intercom/ui/inline-message.ts +118 -0
- package/dist/extensions/pi-intercom/ui/session-list.ts +166 -0
- package/dist/extensions/pi-rewind-hook/README.md +248 -0
- package/dist/extensions/pi-rewind-hook/index.ts +1575 -0
- package/dist/extensions/pi-rewind-hook/package.json +31 -0
- package/dist/extensions/pi-subagents/.github/assets/subagent-fleet-inspector.png +0 -0
- package/dist/extensions/pi-subagents/.github/workflows/release.yml +28 -0
- package/dist/extensions/pi-subagents/.github/workflows/test.yml +51 -0
- package/dist/extensions/pi-subagents/.greptile/config.json +33 -0
- package/dist/extensions/pi-subagents/.greptile/files.json +8 -0
- package/dist/extensions/pi-subagents/.greptile/rules.md +16 -0
- package/dist/extensions/pi-subagents/.oxlintrc.json +43 -0
- package/dist/extensions/pi-subagents/AGENTS.md +5 -0
- package/dist/extensions/pi-subagents/CHANGELOG.md +2325 -0
- package/dist/extensions/pi-subagents/LICENSE +21 -0
- package/dist/extensions/pi-subagents/README.md +126 -0
- package/dist/extensions/pi-subagents/VISION.md +92 -0
- package/dist/extensions/pi-subagents/agents/delegate.md +14 -0
- package/dist/extensions/pi-subagents/agents/oracle.md +78 -0
- package/dist/extensions/pi-subagents/agents/researcher.md +52 -0
- package/dist/extensions/pi-subagents/agents/reviewer.md +89 -0
- package/dist/extensions/pi-subagents/agents/scout.md +50 -0
- package/dist/extensions/pi-subagents/agents/worker.md +60 -0
- package/dist/extensions/pi-subagents/async-retention-discovery-worker.mjs +180 -0
- package/dist/extensions/pi-subagents/docs/agents.md +382 -0
- package/dist/extensions/pi-subagents/docs/configuration.md +534 -0
- package/dist/extensions/pi-subagents/docs/extension-api.md +443 -0
- package/dist/extensions/pi-subagents/docs/missions.md +121 -0
- package/dist/extensions/pi-subagents/docs/models.md +258 -0
- package/dist/extensions/pi-subagents/docs/observability.md +265 -0
- package/dist/extensions/pi-subagents/docs/tool-reference.md +482 -0
- package/dist/extensions/pi-subagents/docs/watchdog.md +154 -0
- package/dist/extensions/pi-subagents/docs/workflows.md +475 -0
- package/dist/extensions/pi-subagents/index.ts +10 -0
- package/dist/extensions/pi-subagents/inspector-runner.mjs +11 -0
- package/dist/extensions/pi-subagents/install.mjs +93 -0
- package/dist/extensions/pi-subagents/package-lock.json +1872 -0
- package/dist/extensions/pi-subagents/package.json +109 -0
- package/dist/extensions/pi-subagents/prompts/council.md +60 -0
- package/dist/extensions/pi-subagents/prompts/gather-context-and-clarify.md +13 -0
- package/dist/extensions/pi-subagents/prompts/parallel-cleanup.md +59 -0
- package/dist/extensions/pi-subagents/prompts/parallel-research.md +50 -0
- package/dist/extensions/pi-subagents/prompts/parallel-review.md +58 -0
- package/dist/extensions/pi-subagents/prompts/review-loop.md +47 -0
- package/dist/extensions/pi-subagents/skills/council-mode/SKILL.md +59 -0
- package/dist/extensions/pi-subagents/skills/council-mode/references/pass-contracts.md +150 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/SKILL.md +103 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/constraints-and-recipes.md +70 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/execution-controls.md +539 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/management-authoring-rpc.md +161 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/multi-lane-orchestration.md +51 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/prompting-and-roles.md +295 -0
- package/dist/extensions/pi-subagents/skills/pi-subagents/references/review-and-validation.md +73 -0
- package/dist/extensions/pi-subagents/src/agents/agent-management.ts +1373 -0
- package/dist/extensions/pi-subagents/src/agents/agent-memory.ts +254 -0
- package/dist/extensions/pi-subagents/src/agents/agent-refinements.ts +624 -0
- package/dist/extensions/pi-subagents/src/agents/agent-scope.ts +6 -0
- package/dist/extensions/pi-subagents/src/agents/agent-selection.ts +25 -0
- package/dist/extensions/pi-subagents/src/agents/agent-serializer.ts +179 -0
- package/dist/extensions/pi-subagents/src/agents/agents.ts +2790 -0
- package/dist/extensions/pi-subagents/src/agents/builtin-names.ts +9 -0
- package/dist/extensions/pi-subagents/src/agents/chain-serializer.ts +280 -0
- package/dist/extensions/pi-subagents/src/agents/frontmatter.ts +153 -0
- package/dist/extensions/pi-subagents/src/agents/identity.ts +30 -0
- package/dist/extensions/pi-subagents/src/agents/proactive-skills.ts +194 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-events.ts +70 -0
- package/dist/extensions/pi-subagents/src/agents/runtime-agent-registry.ts +429 -0
- package/dist/extensions/pi-subagents/src/agents/skills.ts +754 -0
- package/dist/extensions/pi-subagents/src/api/agents.ts +12 -0
- package/dist/extensions/pi-subagents/src/api/background-work.ts +206 -0
- package/dist/extensions/pi-subagents/src/api/capability-ceiling.ts +17 -0
- package/dist/extensions/pi-subagents/src/api/control-channel.ts +4 -0
- package/dist/extensions/pi-subagents/src/api/delegation.ts +112 -0
- package/dist/extensions/pi-subagents/src/api/external-job-provider.ts +195 -0
- package/dist/extensions/pi-subagents/src/api/external-runs.ts +282 -0
- package/dist/extensions/pi-subagents/src/api/intercom-bridge.ts +3 -0
- package/dist/extensions/pi-subagents/src/api/pi-args.ts +5 -0
- package/dist/extensions/pi-subagents/src/api/preflight.ts +501 -0
- package/dist/extensions/pi-subagents/src/api/project-panes.ts +32 -0
- package/dist/extensions/pi-subagents/src/api/shared-types.ts +27 -0
- package/dist/extensions/pi-subagents/src/extension/config.ts +255 -0
- package/dist/extensions/pi-subagents/src/extension/control-notices.ts +58 -0
- package/dist/extensions/pi-subagents/src/extension/doctor.ts +278 -0
- package/dist/extensions/pi-subagents/src/extension/fanout-child.ts +205 -0
- package/dist/extensions/pi-subagents/src/extension/index.ts +1093 -0
- package/dist/extensions/pi-subagents/src/extension/public-execution.ts +210 -0
- package/dist/extensions/pi-subagents/src/extension/rpc.ts +860 -0
- package/dist/extensions/pi-subagents/src/extension/schemas.ts +419 -0
- package/dist/extensions/pi-subagents/src/extension/steering-notices.ts +35 -0
- package/dist/extensions/pi-subagents/src/extension/subagent-guide.ts +39 -0
- package/dist/extensions/pi-subagents/src/extension/tool-description.ts +204 -0
- package/dist/extensions/pi-subagents/src/extension/tool-result.ts +19 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/actions.ts +235 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/client.ts +130 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/focus.ts +55 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/inspector-runner.ts +153 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/project-panes.ts +730 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/session-roots-codec.ts +42 -0
- package/dist/extensions/pi-subagents/src/inspectors/herdr/shell-command.ts +16 -0
- package/dist/extensions/pi-subagents/src/integrations/herdr-status.ts +396 -0
- package/dist/extensions/pi-subagents/src/intercom/intercom-bridge.ts +191 -0
- package/dist/extensions/pi-subagents/src/intercom/native-supervisor-channel.ts +812 -0
- package/dist/extensions/pi-subagents/src/intercom/result-intercom.ts +423 -0
- package/dist/extensions/pi-subagents/src/missions/actions.ts +433 -0
- package/dist/extensions/pi-subagents/src/missions/goal-driver.ts +164 -0
- package/dist/extensions/pi-subagents/src/missions/lifecycle.ts +367 -0
- package/dist/extensions/pi-subagents/src/missions/store.ts +584 -0
- package/dist/extensions/pi-subagents/src/missions/types.ts +190 -0
- package/dist/extensions/pi-subagents/src/missions/workflow-state.ts +260 -0
- package/dist/extensions/pi-subagents/src/policy/authority.ts +46 -0
- package/dist/extensions/pi-subagents/src/profiles/profiles.ts +662 -0
- package/dist/extensions/pi-subagents/src/runs/background/active-async-capacity.ts +516 -0
- package/dist/extensions/pi-subagents/src/runs/background/active-run-index.ts +139 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-execution.ts +2080 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-job-tracker.ts +781 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-resume.ts +631 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-retention.ts +903 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status-snapshot.ts +48 -0
- package/dist/extensions/pi-subagents/src/runs/background/async-status.ts +761 -0
- package/dist/extensions/pi-subagents/src/runs/background/auto-drain.ts +68 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-append.ts +321 -0
- package/dist/extensions/pi-subagents/src/runs/background/chain-root-attachment.ts +270 -0
- package/dist/extensions/pi-subagents/src/runs/background/completion-batcher.ts +168 -0
- package/dist/extensions/pi-subagents/src/runs/background/completion-dedupe.ts +58 -0
- package/dist/extensions/pi-subagents/src/runs/background/completion-replay.ts +287 -0
- package/dist/extensions/pi-subagents/src/runs/background/control-channel.ts +768 -0
- package/dist/extensions/pi-subagents/src/runs/background/fleet-view.ts +620 -0
- package/dist/extensions/pi-subagents/src/runs/background/index-segment.ts +59 -0
- package/dist/extensions/pi-subagents/src/runs/background/inspect-rpc.ts +443 -0
- package/dist/extensions/pi-subagents/src/runs/background/notify.ts +645 -0
- package/dist/extensions/pi-subagents/src/runs/background/owned-process-tree.ts +104 -0
- package/dist/extensions/pi-subagents/src/runs/background/parallel-groups.ts +45 -0
- package/dist/extensions/pi-subagents/src/runs/background/process-terminal.ts +310 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-delivery-ownership.ts +45 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-files.ts +519 -0
- package/dist/extensions/pi-subagents/src/runs/background/result-watcher.ts +792 -0
- package/dist/extensions/pi-subagents/src/runs/background/resume-guidance.ts +56 -0
- package/dist/extensions/pi-subagents/src/runs/background/retained-children.ts +135 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-id-query.ts +7 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-id-resolver.ts +175 -0
- package/dist/extensions/pi-subagents/src/runs/background/run-status.ts +714 -0
- package/dist/extensions/pi-subagents/src/runs/background/scheduled-runs.ts +965 -0
- package/dist/extensions/pi-subagents/src/runs/background/stale-run-reconciler.ts +410 -0
- package/dist/extensions/pi-subagents/src/runs/background/steering.ts +242 -0
- package/dist/extensions/pi-subagents/src/runs/background/subagent-runner.ts +5683 -0
- package/dist/extensions/pi-subagents/src/runs/background/subagent-wait.ts +725 -0
- package/dist/extensions/pi-subagents/src/runs/background/terminal-run-index.ts +138 -0
- package/dist/extensions/pi-subagents/src/runs/background/top-level-async.ts +14 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-completions.ts +209 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-config.ts +50 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-subscriptions.ts +348 -0
- package/dist/extensions/pi-subagents/src/runs/background/wait-tool.ts +51 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-dismiss-action.ts +86 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-steering-action.ts +262 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/async-stop-action.ts +86 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/execution.ts +2443 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-control.ts +153 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/foreground-history.ts +160 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/prompt-audit.ts +172 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/subagent-executor.ts +6971 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-detach-reconcile.ts +299 -0
- package/dist/extensions/pi-subagents/src/runs/foreground/workflow-foreground-steering.ts +188 -0
- package/dist/extensions/pi-subagents/src/runs/shared/abort-recovery.ts +119 -0
- package/dist/extensions/pi-subagents/src/runs/shared/acceptance.ts +1525 -0
- package/dist/extensions/pi-subagents/src/runs/shared/agent-contract.ts +38 -0
- package/dist/extensions/pi-subagents/src/runs/shared/async-status-projection.ts +565 -0
- package/dist/extensions/pi-subagents/src/runs/shared/background-process-options.ts +9 -0
- package/dist/extensions/pi-subagents/src/runs/shared/capability-ceiling.ts +210 -0
- package/dist/extensions/pi-subagents/src/runs/shared/chain-outputs.ts +116 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-identity.ts +51 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-launch-plan.ts +151 -0
- package/dist/extensions/pi-subagents/src/runs/shared/child-protocol.ts +415 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-evidence.ts +89 -0
- package/dist/extensions/pi-subagents/src/runs/shared/completion-guard.ts +252 -0
- package/dist/extensions/pi-subagents/src/runs/shared/context-mode.ts +44 -0
- package/dist/extensions/pi-subagents/src/runs/shared/dynamic-fanout.ts +297 -0
- package/dist/extensions/pi-subagents/src/runs/shared/extension-bindings.ts +78 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-contract.ts +138 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-preflight.ts +122 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-cli-runner.ts +429 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-job-bridge.ts +460 -0
- package/dist/extensions/pi-subagents/src/runs/shared/external-job-runner.ts +389 -0
- package/dist/extensions/pi-subagents/src/runs/shared/fast-mode-extension.ts +10 -0
- package/dist/extensions/pi-subagents/src/runs/shared/host-step-status.ts +231 -0
- package/dist/extensions/pi-subagents/src/runs/shared/lane-metadata.ts +126 -0
- package/dist/extensions/pi-subagents/src/runs/shared/launch-cwd.ts +16 -0
- package/dist/extensions/pi-subagents/src/runs/shared/llm-intent-arbiter.ts +302 -0
- package/dist/extensions/pi-subagents/src/runs/shared/long-running-guard.ts +221 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-config-sources.ts +422 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +483 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mcp-direct-tool-grant.ts +194 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-exclusions.ts +305 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-fallback.ts +578 -0
- package/dist/extensions/pi-subagents/src/runs/shared/model-scope.ts +205 -0
- package/dist/extensions/pi-subagents/src/runs/shared/mutation-evidence.ts +199 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-events.ts +1086 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-path.ts +52 -0
- package/dist/extensions/pi-subagents/src/runs/shared/nested-render.ts +127 -0
- package/dist/extensions/pi-subagents/src/runs/shared/orca-progress-tabs.ts +499 -0
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-handoff.ts +696 -0
- package/dist/extensions/pi-subagents/src/runs/shared/parallel-utils.ts +275 -0
- package/dist/extensions/pi-subagents/src/runs/shared/permissions.ts +100 -0
- package/dist/extensions/pi-subagents/src/runs/shared/pi-args.ts +1059 -0
- package/dist/extensions/pi-subagents/src/runs/shared/pi-spawn.ts +199 -0
- package/dist/extensions/pi-subagents/src/runs/shared/process-signal.ts +32 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-fanout-budget.ts +280 -0
- package/dist/extensions/pi-subagents/src/runs/shared/run-history.ts +201 -0
- package/dist/extensions/pi-subagents/src/runs/shared/runtime-acknowledged-extensions.ts +71 -0
- package/dist/extensions/pi-subagents/src/runs/shared/session-lease.ts +293 -0
- package/dist/extensions/pi-subagents/src/runs/shared/single-output.ts +304 -0
- package/dist/extensions/pi-subagents/src/runs/shared/spawn-budget.ts +128 -0
- package/dist/extensions/pi-subagents/src/runs/shared/structured-output.ts +223 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-control.ts +292 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.ts +825 -0
- package/dist/extensions/pi-subagents/src/runs/shared/subagent-startup-retry.ts +116 -0
- package/dist/extensions/pi-subagents/src/runs/shared/task-intent.ts +211 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-availability.ts +81 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-budget.ts +80 -0
- package/dist/extensions/pi-subagents/src/runs/shared/tool-timeout.ts +93 -0
- package/dist/extensions/pi-subagents/src/runs/shared/usage-budget.ts +65 -0
- package/dist/extensions/pi-subagents/src/runs/shared/workflow-graph.ts +225 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree-cleanup-plan.ts +847 -0
- package/dist/extensions/pi-subagents/src/runs/shared/worktree.ts +1206 -0
- package/dist/extensions/pi-subagents/src/shared/accessible-dir.ts +47 -0
- package/dist/extensions/pi-subagents/src/shared/agent-stream-options.ts +5 -0
- package/dist/extensions/pi-subagents/src/shared/artifacts.ts +281 -0
- package/dist/extensions/pi-subagents/src/shared/atomic-json.ts +83 -0
- package/dist/extensions/pi-subagents/src/shared/capacity-resilient-json.ts +102 -0
- package/dist/extensions/pi-subagents/src/shared/child-session-name.ts +46 -0
- package/dist/extensions/pi-subagents/src/shared/child-transcript.ts +264 -0
- package/dist/extensions/pi-subagents/src/shared/completion-owner.ts +14 -0
- package/dist/extensions/pi-subagents/src/shared/display-text.ts +150 -0
- package/dist/extensions/pi-subagents/src/shared/extension-context.ts +24 -0
- package/dist/extensions/pi-subagents/src/shared/file-coalescer.ts +49 -0
- package/dist/extensions/pi-subagents/src/shared/file-system-retry.ts +95 -0
- package/dist/extensions/pi-subagents/src/shared/fork-context.ts +293 -0
- package/dist/extensions/pi-subagents/src/shared/fork-session-cwd.ts +27 -0
- package/dist/extensions/pi-subagents/src/shared/formatters.ts +146 -0
- package/dist/extensions/pi-subagents/src/shared/jsonl-writer.ts +81 -0
- package/dist/extensions/pi-subagents/src/shared/launch-contract.ts +138 -0
- package/dist/extensions/pi-subagents/src/shared/model-info.ts +101 -0
- package/dist/extensions/pi-subagents/src/shared/node-executable.ts +21 -0
- package/dist/extensions/pi-subagents/src/shared/post-exit-stdio-guard.ts +85 -0
- package/dist/extensions/pi-subagents/src/shared/prompt-resources.ts +11 -0
- package/dist/extensions/pi-subagents/src/shared/pruned-fork.ts +450 -0
- package/dist/extensions/pi-subagents/src/shared/session-file-trust.ts +19 -0
- package/dist/extensions/pi-subagents/src/shared/session-identity.ts +10 -0
- package/dist/extensions/pi-subagents/src/shared/session-tokens.ts +55 -0
- package/dist/extensions/pi-subagents/src/shared/settings.ts +409 -0
- package/dist/extensions/pi-subagents/src/shared/shortcuts.ts +17 -0
- package/dist/extensions/pi-subagents/src/shared/status-format.ts +55 -0
- package/dist/extensions/pi-subagents/src/shared/thinking-ceiling.ts +52 -0
- package/dist/extensions/pi-subagents/src/shared/types.ts +2872 -0
- package/dist/extensions/pi-subagents/src/shared/utf8.ts +11 -0
- package/dist/extensions/pi-subagents/src/shared/utils.ts +601 -0
- package/dist/extensions/pi-subagents/src/shared/watch-strategy.ts +10 -0
- package/dist/extensions/pi-subagents/src/shared/workflow-child-permit.ts +207 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-adapters.ts +426 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-json.ts +108 -0
- package/dist/extensions/pi-subagents/src/slash/delegation-request.ts +162 -0
- package/dist/extensions/pi-subagents/src/slash/prompt-template-bridge.ts +419 -0
- package/dist/extensions/pi-subagents/src/slash/prompt-workflows.ts +287 -0
- package/dist/extensions/pi-subagents/src/slash/selector.ts +147 -0
- package/dist/extensions/pi-subagents/src/slash/slash-bridge.ts +192 -0
- package/dist/extensions/pi-subagents/src/slash/slash-commands.ts +1345 -0
- package/dist/extensions/pi-subagents/src/slash/slash-live-state.ts +310 -0
- package/dist/extensions/pi-subagents/src/slash/subagents-admin.ts +449 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-status.ts +964 -0
- package/dist/extensions/pi-subagents/src/tui/fleet-transcript.ts +536 -0
- package/dist/extensions/pi-subagents/src/tui/fleet.ts +1441 -0
- package/dist/extensions/pi-subagents/src/tui/render-helpers.ts +111 -0
- package/dist/extensions/pi-subagents/src/tui/render.ts +3359 -0
- package/dist/extensions/pi-subagents/src/types/pi-runtime-compat.d.ts +8 -0
- package/dist/extensions/pi-subagents/src/watchdog/change-signature.ts +260 -0
- package/dist/extensions/pi-subagents/src/watchdog/child-status.ts +227 -0
- package/dist/extensions/pi-subagents/src/watchdog/diff-tool.ts +77 -0
- package/dist/extensions/pi-subagents/src/watchdog/emission-guard.ts +125 -0
- package/dist/extensions/pi-subagents/src/watchdog/guidance.ts +20 -0
- package/dist/extensions/pi-subagents/src/watchdog/lsp-diagnostics.ts +538 -0
- package/dist/extensions/pi-subagents/src/watchdog/model-selection.ts +167 -0
- package/dist/extensions/pi-subagents/src/watchdog/permission-arbiter.ts +154 -0
- package/dist/extensions/pi-subagents/src/watchdog/register-child.ts +120 -0
- package/dist/extensions/pi-subagents/src/watchdog/register-main.ts +441 -0
- package/dist/extensions/pi-subagents/src/watchdog/render.ts +53 -0
- package/dist/extensions/pi-subagents/src/watchdog/review.ts +314 -0
- package/dist/extensions/pi-subagents/src/watchdog/rules.ts +70 -0
- package/dist/extensions/pi-subagents/src/watchdog/runtime.ts +851 -0
- package/dist/extensions/pi-subagents/src/watchdog/scope.ts +63 -0
- package/dist/extensions/pi-subagents/src/watchdog/settings.ts +512 -0
- package/dist/extensions/pi-subagents/src/watchdog/tool-actions.ts +155 -0
- package/dist/extensions/pi-subagents/src/watchdog/turn-delta.ts +161 -0
- package/dist/extensions/pi-subagents/src/watchdog/types.ts +184 -0
- package/dist/extensions/pi-subagents/src/watchdog/warning-format.ts +72 -0
- package/dist/extensions/pi-subagents/src/workflows/chat-progress.ts +152 -0
- package/dist/extensions/pi-subagents/src/workflows/host-command.ts +235 -0
- package/dist/extensions/pi-subagents/src/workflows/scripted-workflow.ts +2183 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-checklist.ts +439 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-child-summary.ts +121 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-preflight.ts +297 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-receipt.ts +330 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-resources.ts +150 -0
- package/dist/extensions/pi-subagents/src/workflows/workflow-settlement.ts +246 -0
- package/dist/extensions/pi-subagents/test/e2e/real-session-subagent.test.ts +224 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/register-bedrock.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/bun/restore-sandbox-env.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/args.d.ts +57 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/config-selector.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/file-processor.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/initial-message.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/list-models.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/project-trust.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/session-picker.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli/startup-ui.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/cli.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/config.d.ts +96 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-runtime.d.ts +119 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session-services.d.ts +85 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/agent-session.d.ts +620 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-guidance.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/auth-storage.d.ts +56 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/bash-executor.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/cache-stats.d.ts +49 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/branch-summarization.d.ts +93 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/compaction.d.ts +128 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/index.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/compaction/utils.d.ts +38 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/defaults.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/diagnostics.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/event-bus.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/exec.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/experimental.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/ansi-to-html.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/index.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/export-html/tool-renderer.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/index.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/loader.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/runner.d.ts +171 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/types.d.ts +1261 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/extensions/wrapper.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/footer-data-provider.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/http-dispatcher.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/index.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/keybindings.d.ts +358 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/messages.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-config.d.ts +512 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-registry.d.ts +43 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-resolver.d.ts +121 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/model-runtime.d.ts +82 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/models-store.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/output-guard.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/package-manager.d.ts +210 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/project-trust.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/prompt-templates.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-attribution.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/provider-composer.d.ts +55 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/radius.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/remote-catalog-provider.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resolve-config-value.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/resource-loader.d.ts +206 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/runtime-credentials.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/sdk.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-cwd.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/session-manager.d.ts +356 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/settings-manager.d.ts +297 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/skills.d.ts +60 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/slash-commands.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/source-info.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/system-prompt.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/telemetry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/timings.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/bash.d.ts +68 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit-diff.d.ts +106 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/edit.d.ts +51 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/file-mutation-queue.d.ts +6 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/find.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/grep.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/index.d.ts +40 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/ls.d.ts +37 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/output-accumulator.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/path-utils.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/read.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/render-utils.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/tool-definition-wrapper.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/truncate.d.ts +70 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/tools/write.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/trust-manager.d.ts +36 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/core/usage-totals.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/client.d.ts +61 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/huggingface.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/index.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/provider.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/extensions/llama/ui.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/index.d.ts +35 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/main.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/migrations.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/index.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/armin.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/assistant-message.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bash-execution.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/bordered-loader.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/branch-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/compaction-summary-message.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/config-selector.d.ts +102 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/countdown-timer.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-editor.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-entry.d.ts +19 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/custom-message.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/daxnuts.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/diff.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/dynamic-border.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/earendil-announcement.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-editor.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-input.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/extension-selector.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/first-time-setup.d.ts +25 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/footer.d.ts +32 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/index.d.ts +34 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/keybinding-hints.d.ts +13 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/login-dialog.d.ts +52 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/model-selector.d.ts +54 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/oauth-selector.d.ts +33 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/scoped-models-selector.d.ts +42 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector-search.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/session-selector.d.ts +95 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/settings-selector.d.ts +77 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/show-images-selector.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/skill-invocation-message.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/status-indicator.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/theme-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/thinking-selector.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tool-execution.d.ts +63 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/tree-selector.d.ts +94 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/trust-selector.d.ts +23 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message-selector.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/user-message.d.ts +14 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/components/visual-truncate.d.ts +24 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/interactive-mode.d.ts +394 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/model-search.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme-controller.d.ts +29 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/interactive/theme/theme.d.ts +120 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/print-mode.d.ts +28 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/jsonl.d.ts +17 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-client.d.ts +246 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-mode.d.ts +20 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/modes/rpc/rpc-types.d.ts +457 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/package-manager-cli.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/rpc-entry.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/ansi.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/changelog.d.ts +22 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/child-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-image.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard-native.d.ts +11 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/clipboard.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/deprecation.d.ts +4 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/exif-orientation.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/frontmatter.d.ts +8 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/fs-watch.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/git.d.ts +26 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/html.d.ts +7 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-convert.d.ts +10 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-process.d.ts +18 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-core.d.ts +30 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize-worker.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/image-resize.d.ts +16 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/json.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/mime.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/open-browser.d.ts +9 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/paths.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/photon.d.ts +21 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/pi-user-agent.d.ts +2 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/shell.d.ts +31 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/sleep.d.ts +5 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/syntax-highlight.d.ts +12 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/tools-manager.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/version-check.d.ts +15 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/dist/utils/windows-self-update.d.ts +3 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/index.mjs +84 -0
- package/dist/extensions/pi-subagents/test/fixtures/pi-coding-agent-shim/package.json +14 -0
- package/dist/extensions/pi-subagents/test/integration/acceptance-file-report.test.ts +472 -0
- package/dist/extensions/pi-subagents/test/integration/async-execution.test.ts +6986 -0
- package/dist/extensions/pi-subagents/test/integration/async-job-tracker.test.ts +2000 -0
- package/dist/extensions/pi-subagents/test/integration/async-status.test.ts +1300 -0
- package/dist/extensions/pi-subagents/test/integration/detect-error.test.ts +249 -0
- package/dist/extensions/pi-subagents/test/integration/doctor-executor.test.ts +128 -0
- package/dist/extensions/pi-subagents/test/integration/error-handling.test.ts +281 -0
- package/dist/extensions/pi-subagents/test/integration/external-cli-runner.test.ts +167 -0
- package/dist/extensions/pi-subagents/test/integration/foreground-result-size.test.ts +188 -0
- package/dist/extensions/pi-subagents/test/integration/fork-context-execution.test.ts +1356 -0
- package/dist/extensions/pi-subagents/test/integration/intercom-result-delivery.test.ts +1946 -0
- package/dist/extensions/pi-subagents/test/integration/orca-progress-tabs.test.ts +214 -0
- package/dist/extensions/pi-subagents/test/integration/render-fork-badge.test.ts +1408 -0
- package/dist/extensions/pi-subagents/test/integration/render-widget.test.ts +2094 -0
- package/dist/extensions/pi-subagents/test/integration/result-watcher.test.ts +2442 -0
- package/dist/extensions/pi-subagents/test/integration/session-tokens.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/integration/single-execution.test.ts +9292 -0
- package/dist/extensions/pi-subagents/test/integration/slash-commands.test.ts +1517 -0
- package/dist/extensions/pi-subagents/test/integration/slash-live-state.test.ts +166 -0
- package/dist/extensions/pi-subagents/test/integration/template-resolution.test.ts +344 -0
- package/dist/extensions/pi-subagents/test/integration/top-level-async.test.ts +43 -0
- package/dist/extensions/pi-subagents/test/support/cursor-smoke-inputs.ts +51 -0
- package/dist/extensions/pi-subagents/test/support/helpers.ts +250 -0
- package/dist/extensions/pi-subagents/test/support/isolated-temp-root.mjs +20 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi-script.mjs +447 -0
- package/dist/extensions/pi-subagents/test/support/mock-pi.ts +159 -0
- package/dist/extensions/pi-subagents/test/support/node-command.ts +15 -0
- package/dist/extensions/pi-subagents/test/support/real-session-child-cli.mjs +185 -0
- package/dist/extensions/pi-subagents/test/support/real-session-runner.ts +311 -0
- package/dist/extensions/pi-subagents/test/support/register-loader.mjs +16 -0
- package/dist/extensions/pi-subagents/test/support/session-lease-child.mjs +42 -0
- package/dist/extensions/pi-subagents/test/support/ts-loader.mjs +100 -0
- package/dist/extensions/pi-subagents/test/unit/abort-recovery.test.ts +152 -0
- package/dist/extensions/pi-subagents/test/unit/acceptance.test.ts +1556 -0
- package/dist/extensions/pi-subagents/test/unit/accessible-dir.test.ts +82 -0
- package/dist/extensions/pi-subagents/test/unit/active-async-capacity.test.ts +463 -0
- package/dist/extensions/pi-subagents/test/unit/agent-contract.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/agent-disabled.test.ts +213 -0
- package/dist/extensions/pi-subagents/test/unit/agent-discovery-cache.test.ts +232 -0
- package/dist/extensions/pi-subagents/test/unit/agent-eject-disable.test.ts +343 -0
- package/dist/extensions/pi-subagents/test/unit/agent-frontmatter.test.ts +2324 -0
- package/dist/extensions/pi-subagents/test/unit/agent-management.test.ts +1408 -0
- package/dist/extensions/pi-subagents/test/unit/agent-memory.test.ts +420 -0
- package/dist/extensions/pi-subagents/test/unit/agent-overrides.test.ts +1174 -0
- package/dist/extensions/pi-subagents/test/unit/agent-refinements.test.ts +178 -0
- package/dist/extensions/pi-subagents/test/unit/agent-scan-dirs.test.ts +133 -0
- package/dist/extensions/pi-subagents/test/unit/agent-scope.test.ts +20 -0
- package/dist/extensions/pi-subagents/test/unit/agent-selection.test.ts +88 -0
- package/dist/extensions/pi-subagents/test/unit/agent-stream-options.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/anti-slop-oxlint.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/artifacts.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/async-execution.test.ts +280 -0
- package/dist/extensions/pi-subagents/test/unit/async-interrupt-action.test.ts +1022 -0
- package/dist/extensions/pi-subagents/test/unit/async-permission-session.test.ts +100 -0
- package/dist/extensions/pi-subagents/test/unit/async-recovery-descriptor.test.ts +188 -0
- package/dist/extensions/pi-subagents/test/unit/async-resume.test.ts +978 -0
- package/dist/extensions/pi-subagents/test/unit/async-retention.test.ts +635 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-projection.test.ts +260 -0
- package/dist/extensions/pi-subagents/test/unit/async-status-snapshot.test.ts +204 -0
- package/dist/extensions/pi-subagents/test/unit/atomic-json.test.ts +192 -0
- package/dist/extensions/pi-subagents/test/unit/authority-policy.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/auto-drain.test.ts +83 -0
- package/dist/extensions/pi-subagents/test/unit/background-process-options.test.ts +17 -0
- package/dist/extensions/pi-subagents/test/unit/background-work.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-agent-allowlist.test.ts +102 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling-pi-args.test.ts +84 -0
- package/dist/extensions/pi-subagents/test/unit/capability-ceiling.test.ts +68 -0
- package/dist/extensions/pi-subagents/test/unit/capacity-resilient-json.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/chain-append.test.ts +283 -0
- package/dist/extensions/pi-subagents/test/unit/chain-root-attachment.test.ts +236 -0
- package/dist/extensions/pi-subagents/test/unit/chain-serializer.test.ts +229 -0
- package/dist/extensions/pi-subagents/test/unit/child-launch-plan.test.ts +94 -0
- package/dist/extensions/pi-subagents/test/unit/child-protocol.test.ts +202 -0
- package/dist/extensions/pi-subagents/test/unit/child-session-name.test.ts +50 -0
- package/dist/extensions/pi-subagents/test/unit/child-transcript.test.ts +267 -0
- package/dist/extensions/pi-subagents/test/unit/close-grace-timer.test.ts +101 -0
- package/dist/extensions/pi-subagents/test/unit/compaction-resume.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/completion-batcher.test.ts +230 -0
- package/dist/extensions/pi-subagents/test/unit/completion-dedupe.test.ts +35 -0
- package/dist/extensions/pi-subagents/test/unit/completion-evidence.test.ts +150 -0
- package/dist/extensions/pi-subagents/test/unit/completion-guard.test.ts +753 -0
- package/dist/extensions/pi-subagents/test/unit/completion-replay.test.ts +305 -0
- package/dist/extensions/pi-subagents/test/unit/config-dir-runtime.test.ts +107 -0
- package/dist/extensions/pi-subagents/test/unit/control-channel.test.ts +630 -0
- package/dist/extensions/pi-subagents/test/unit/control-notices.test.ts +110 -0
- package/dist/extensions/pi-subagents/test/unit/cursor-smoke-inputs.test.ts +77 -0
- package/dist/extensions/pi-subagents/test/unit/default-extensions.test.ts +219 -0
- package/dist/extensions/pi-subagents/test/unit/delegation-api.test.ts +588 -0
- package/dist/extensions/pi-subagents/test/unit/doctor.test.ts +201 -0
- package/dist/extensions/pi-subagents/test/unit/dynamic-fanout.test.ts +219 -0
- package/dist/extensions/pi-subagents/test/unit/ensure-accessible-dir.test.ts +125 -0
- package/dist/extensions/pi-subagents/test/unit/extension-bindings.test.ts +79 -0
- package/dist/extensions/pi-subagents/test/unit/extension-context.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/external-cli-runner.test.ts +339 -0
- package/dist/extensions/pi-subagents/test/unit/external-job-runner.test.ts +961 -0
- package/dist/extensions/pi-subagents/test/unit/external-runs.test.ts +261 -0
- package/dist/extensions/pi-subagents/test/unit/extra-agent-dirs.test.ts +88 -0
- package/dist/extensions/pi-subagents/test/unit/fast-mode-extension.test.ts +27 -0
- package/dist/extensions/pi-subagents/test/unit/file-coalescer.test.ts +83 -0
- package/dist/extensions/pi-subagents/test/unit/file-system-retry.test.ts +64 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-status.test.ts +1377 -0
- package/dist/extensions/pi-subagents/test/unit/fleet-transcript.test.ts +435 -0
- package/dist/extensions/pi-subagents/test/unit/fleet.test.ts +1786 -0
- package/dist/extensions/pi-subagents/test/unit/foreground-control.test.ts +125 -0
- package/dist/extensions/pi-subagents/test/unit/foreground-tool-call-compaction.test.ts +115 -0
- package/dist/extensions/pi-subagents/test/unit/fork-cache-key.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/fork-context.test.ts +588 -0
- package/dist/extensions/pi-subagents/test/unit/formatters.test.ts +14 -0
- package/dist/extensions/pi-subagents/test/unit/get-final-output.test.ts +175 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector-bootstrap.test.ts +101 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-inspector.test.ts +479 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-session-roots-codec.test.ts +63 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-shell-command.test.ts +59 -0
- package/dist/extensions/pi-subagents/test/unit/herdr-status-bridge.test.ts +716 -0
- package/dist/extensions/pi-subagents/test/unit/host-command.test.ts +157 -0
- package/dist/extensions/pi-subagents/test/unit/host-peer-runtime-imports.test.ts +157 -0
- package/dist/extensions/pi-subagents/test/unit/host-step-status.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/index-child-registration.test.ts +1307 -0
- package/dist/extensions/pi-subagents/test/unit/index-segment.test.ts +96 -0
- package/dist/extensions/pi-subagents/test/unit/inspect-rpc.test.ts +617 -0
- package/dist/extensions/pi-subagents/test/unit/intercom-bridge.test.ts +220 -0
- package/dist/extensions/pi-subagents/test/unit/jsonl-writer.test.ts +119 -0
- package/dist/extensions/pi-subagents/test/unit/llm-intent-arbiter.test.ts +226 -0
- package/dist/extensions/pi-subagents/test/unit/mcp-direct-tool-grant.test.ts +155 -0
- package/dist/extensions/pi-subagents/test/unit/mission-goal-driver.test.ts +180 -0
- package/dist/extensions/pi-subagents/test/unit/mission-lifecycle.test.ts +300 -0
- package/dist/extensions/pi-subagents/test/unit/mission-store.test.ts +470 -0
- package/dist/extensions/pi-subagents/test/unit/mock-pi.test.ts +22 -0
- package/dist/extensions/pi-subagents/test/unit/model-exclusions.test.ts +258 -0
- package/dist/extensions/pi-subagents/test/unit/model-fallback.test.ts +903 -0
- package/dist/extensions/pi-subagents/test/unit/model-info.test.ts +162 -0
- package/dist/extensions/pi-subagents/test/unit/model-scope-settings.test.ts +101 -0
- package/dist/extensions/pi-subagents/test/unit/model-scope.test.ts +198 -0
- package/dist/extensions/pi-subagents/test/unit/mutation-evidence.test.ts +177 -0
- package/dist/extensions/pi-subagents/test/unit/native-supervisor-channel.test.ts +796 -0
- package/dist/extensions/pi-subagents/test/unit/nested-control.test.ts +655 -0
- package/dist/extensions/pi-subagents/test/unit/nested-events.test.ts +492 -0
- package/dist/extensions/pi-subagents/test/unit/node-executable.test.ts +26 -0
- package/dist/extensions/pi-subagents/test/unit/notify.test.ts +816 -0
- package/dist/extensions/pi-subagents/test/unit/orca-progress-tabs.test.ts +545 -0
- package/dist/extensions/pi-subagents/test/unit/owned-process-tree.test.ts +69 -0
- package/dist/extensions/pi-subagents/test/unit/package-manifest.test.ts +241 -0
- package/dist/extensions/pi-subagents/test/unit/parallel-handoff.test.ts +563 -0
- package/dist/extensions/pi-subagents/test/unit/parallel-utils.test.ts +269 -0
- package/dist/extensions/pi-subagents/test/unit/path-handling.test.ts +108 -0
- package/dist/extensions/pi-subagents/test/unit/path-resolution.test.ts +103 -0
- package/dist/extensions/pi-subagents/test/unit/permissions.test.ts +46 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args-permission-system.test.ts +437 -0
- package/dist/extensions/pi-subagents/test/unit/pi-args.test.ts +2347 -0
- package/dist/extensions/pi-subagents/test/unit/pi-coding-agent-dir.test.ts +461 -0
- package/dist/extensions/pi-subagents/test/unit/pi-spawn.test.ts +493 -0
- package/dist/extensions/pi-subagents/test/unit/preflight.test.ts +978 -0
- package/dist/extensions/pi-subagents/test/unit/proactive-skills.test.ts +118 -0
- package/dist/extensions/pi-subagents/test/unit/process-terminal.test.ts +279 -0
- package/dist/extensions/pi-subagents/test/unit/profiles.test.ts +373 -0
- package/dist/extensions/pi-subagents/test/unit/project-panes-public-api.test.ts +293 -0
- package/dist/extensions/pi-subagents/test/unit/prompt-template-bridge.test.ts +244 -0
- package/dist/extensions/pi-subagents/test/unit/prompt-workflows.test.ts +167 -0
- package/dist/extensions/pi-subagents/test/unit/pruned-fork.test.ts +214 -0
- package/dist/extensions/pi-subagents/test/unit/public-execution.test.ts +182 -0
- package/dist/extensions/pi-subagents/test/unit/reads-resolution.test.ts +66 -0
- package/dist/extensions/pi-subagents/test/unit/recursion-guard.test.ts +265 -0
- package/dist/extensions/pi-subagents/test/unit/render-helpers.test.ts +639 -0
- package/dist/extensions/pi-subagents/test/unit/result-delivery-ownership.test.ts +34 -0
- package/dist/extensions/pi-subagents/test/unit/result-files.test.ts +501 -0
- package/dist/extensions/pi-subagents/test/unit/result-intercom.test.ts +258 -0
- package/dist/extensions/pi-subagents/test/unit/retained-children.test.ts +191 -0
- package/dist/extensions/pi-subagents/test/unit/rpc.test.ts +1124 -0
- package/dist/extensions/pi-subagents/test/unit/run-fanout-budget.test.ts +191 -0
- package/dist/extensions/pi-subagents/test/unit/run-id-resolver.test.ts +247 -0
- package/dist/extensions/pi-subagents/test/unit/run-status.test.ts +1545 -0
- package/dist/extensions/pi-subagents/test/unit/runtime-acknowledged-extensions.test.ts +52 -0
- package/dist/extensions/pi-subagents/test/unit/runtime-agent-registration.test.ts +349 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-runs.test.ts +904 -0
- package/dist/extensions/pi-subagents/test/unit/scheduled-store-root.test.ts +67 -0
- package/dist/extensions/pi-subagents/test/unit/schemas.test.ts +657 -0
- package/dist/extensions/pi-subagents/test/unit/scripted-workflow.test.ts +2501 -0
- package/dist/extensions/pi-subagents/test/unit/selector.test.ts +57 -0
- package/dist/extensions/pi-subagents/test/unit/session-lease.test.ts +339 -0
- package/dist/extensions/pi-subagents/test/unit/single-output.test.ts +361 -0
- package/dist/extensions/pi-subagents/test/unit/skills-fallback.test.ts +709 -0
- package/dist/extensions/pi-subagents/test/unit/slash-bridge.test.ts +115 -0
- package/dist/extensions/pi-subagents/test/unit/spawn-budget.test.ts +124 -0
- package/dist/extensions/pi-subagents/test/unit/stale-run-reconciler.test.ts +440 -0
- package/dist/extensions/pi-subagents/test/unit/status-format.test.ts +26 -0
- package/dist/extensions/pi-subagents/test/unit/steering-action.test.ts +435 -0
- package/dist/extensions/pi-subagents/test/unit/steering-notices.test.ts +58 -0
- package/dist/extensions/pi-subagents/test/unit/steering.test.ts +217 -0
- package/dist/extensions/pi-subagents/test/unit/streamed-progress-bounds.test.ts +78 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-action-recovery.test.ts +85 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-control.test.ts +342 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-guide.test.ts +37 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-prompt-runtime.test.ts +1593 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-startup-retry.test.ts +104 -0
- package/dist/extensions/pi-subagents/test/unit/subagent-wait.test.ts +1367 -0
- package/dist/extensions/pi-subagents/test/unit/task-intent.test.ts +153 -0
- package/dist/extensions/pi-subagents/test/unit/temp-paths.test.ts +147 -0
- package/dist/extensions/pi-subagents/test/unit/thinking-ceiling.test.ts +73 -0
- package/dist/extensions/pi-subagents/test/unit/timeout-defaults.test.ts +138 -0
- package/dist/extensions/pi-subagents/test/unit/tool-budget.test.ts +67 -0
- package/dist/extensions/pi-subagents/test/unit/tool-description.test.ts +308 -0
- package/dist/extensions/pi-subagents/test/unit/tool-timeout.test.ts +108 -0
- package/dist/extensions/pi-subagents/test/unit/total-cost.test.ts +61 -0
- package/dist/extensions/pi-subagents/test/unit/ts-loader.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/types-fork-preamble.test.ts +23 -0
- package/dist/extensions/pi-subagents/test/unit/wait-completions.test.ts +110 -0
- package/dist/extensions/pi-subagents/test/unit/wait-subscriptions.test.ts +663 -0
- package/dist/extensions/pi-subagents/test/unit/watch-strategy.test.ts +24 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-change-signature.test.ts +434 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-child-status.test.ts +170 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-diff-tool.test.ts +79 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-emission-guard.test.ts +62 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-lsp-diagnostics.test.ts +144 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-model-selection.test.ts +121 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-permission-arbiter.test.ts +113 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-render.test.ts +75 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-review.test.ts +372 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-rules.test.ts +37 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-runtime.test.ts +990 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-scope.test.ts +33 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-settings.test.ts +345 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-tool-actions.test.ts +91 -0
- package/dist/extensions/pi-subagents/test/unit/watchdog-turn-delta.test.ts +130 -0
- package/dist/extensions/pi-subagents/test/unit/widget-nested-render.test.ts +171 -0
- package/dist/extensions/pi-subagents/test/unit/windows-hide-spawn.test.ts +49 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-chat-progress.test.ts +570 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-checklist.test.ts +223 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-detach-reconcile.test.ts +777 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-graph.test.ts +134 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-launch-params.test.ts +407 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-preflight.test.ts +177 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-receipt.test.ts +461 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-resources.test.ts +98 -0
- package/dist/extensions/pi-subagents/test/unit/workflow-resume-hint.test.ts +365 -0
- package/dist/extensions/pi-subagents/test/unit/worktree-cleanup-plan.test.ts +349 -0
- package/dist/extensions/pi-subagents/test/unit/worktree.test.ts +827 -0
- package/dist/extensions/pi-subagents/test/unit/writer-budget-guidance.test.ts +25 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/effect/index.ts +13 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/effect/rules/no-service-constructor-imports.ts +52 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/index.ts +41 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-chained-type-assertions.ts +77 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-conditional-empty-object-spread.ts +49 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-known-value-widening.ts +247 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-module-mocking.ts +91 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-object-parameters.ts +126 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-reflect-apply.ts +28 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-reflect-get.ts +28 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-runtime-typeof.ts +67 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-shape-in-symbol-names.ts +39 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-parameters.ts +83 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-returns.ts +115 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unknown-type-aliases.ts +72 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-unsafe-dictionary-type.ts +134 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/no-widen-then-assert.ts +366 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/rules/require-safety-comment-for-type-assertion.ts +62 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/dictionary-types.ts +502 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/lexical-type-parameters.ts +60 -0
- package/dist/extensions/pi-subagents/tools/oxlint/anti-slop/shared/reflect-method.ts +35 -0
- package/dist/extensions/pi-subagents/tsconfig.json +15 -0
- package/dist/extensions/pi-tool-display/CHANGELOG.md +329 -0
- package/dist/extensions/pi-tool-display/LICENSE +21 -0
- package/dist/extensions/pi-tool-display/README.md +417 -0
- package/dist/extensions/pi-tool-display/config/config.example.json +40 -0
- package/dist/extensions/pi-tool-display/index.ts +3 -0
- package/dist/extensions/pi-tool-display/package-lock.json +2555 -0
- package/dist/extensions/pi-tool-display/package.json +86 -0
- package/dist/extensions/pi-tool-display/src/agent-dir.ts +35 -0
- package/dist/extensions/pi-tool-display/src/ansi-utils.ts +116 -0
- package/dist/extensions/pi-tool-display/src/bash-display.ts +213 -0
- package/dist/extensions/pi-tool-display/src/capabilities.ts +88 -0
- package/dist/extensions/pi-tool-display/src/config-modal.ts +541 -0
- package/dist/extensions/pi-tool-display/src/config-store.ts +304 -0
- package/dist/extensions/pi-tool-display/src/debug-logger.ts +150 -0
- package/dist/extensions/pi-tool-display/src/diff-presentation.ts +72 -0
- package/dist/extensions/pi-tool-display/src/diff-renderer.ts +2517 -0
- package/dist/extensions/pi-tool-display/src/disposable.ts +34 -0
- package/dist/extensions/pi-tool-display/src/extension-lifecycle.ts +14 -0
- package/dist/extensions/pi-tool-display/src/index.ts +109 -0
- package/dist/extensions/pi-tool-display/src/line-width-safety.ts +93 -0
- package/dist/extensions/pi-tool-display/src/modal-icons.ts +57 -0
- package/dist/extensions/pi-tool-display/src/pending-diff-preview.ts +370 -0
- package/dist/extensions/pi-tool-display/src/presets.ts +117 -0
- package/dist/extensions/pi-tool-display/src/render-utils.ts +186 -0
- package/dist/extensions/pi-tool-display/src/settings-inspector-modal.ts +475 -0
- package/dist/extensions/pi-tool-display/src/thinking-label.ts +343 -0
- package/dist/extensions/pi-tool-display/src/tool-call-box.ts +181 -0
- package/dist/extensions/pi-tool-display/src/tool-metadata.ts +139 -0
- package/dist/extensions/pi-tool-display/src/tool-overrides.ts +2168 -0
- package/dist/extensions/pi-tool-display/src/types.ts +109 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-markdown.ts +64 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-native.ts +66 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-patch.ts +72 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-renderer.ts +419 -0
- package/dist/extensions/pi-tool-display/src/user-message-box-utils.ts +106 -0
- package/dist/extensions/pi-tool-display/src/write-display-utils.ts +31 -0
- package/dist/extensions/pi-tool-display/src/zellij-modal.ts +1027 -0
- package/dist/extensions/pi-tool-display/tests/active-backlog-red.test.ts +65 -0
- package/dist/extensions/pi-tool-display/tests/ansi-utils.test.ts +345 -0
- package/dist/extensions/pi-tool-display/tests/bash-display.test.ts +442 -0
- package/dist/extensions/pi-tool-display/tests/capabilities-edge.test.ts +360 -0
- package/dist/extensions/pi-tool-display/tests/capabilities.test.ts +54 -0
- package/dist/extensions/pi-tool-display/tests/config-modal.test.ts +360 -0
- package/dist/extensions/pi-tool-display/tests/config-store.test.ts +87 -0
- package/dist/extensions/pi-tool-display/tests/custom-tool-overrides.test.ts +415 -0
- package/dist/extensions/pi-tool-display/tests/debug-logger-edge.test.ts +630 -0
- package/dist/extensions/pi-tool-display/tests/debug-logger.test.ts +62 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-ansi.test.ts +55 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-edge.test.ts +886 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-numbering.test.ts +135 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-width.test.ts +454 -0
- package/dist/extensions/pi-tool-display/tests/diff-renderer-wrap.test.ts +169 -0
- package/dist/extensions/pi-tool-display/tests/index-integration.test.ts +354 -0
- package/dist/extensions/pi-tool-display/tests/pending-diff-preview.test.ts +79 -0
- package/dist/extensions/pi-tool-display/tests/presets-edge.test.ts +229 -0
- package/dist/extensions/pi-tool-display/tests/presets.test.ts +26 -0
- package/dist/extensions/pi-tool-display/tests/reload-behavior.test.ts +1241 -0
- package/dist/extensions/pi-tool-display/tests/render-utils.test.ts +710 -0
- package/dist/extensions/pi-tool-display/tests/settings-inspector.test.ts +450 -0
- package/dist/extensions/pi-tool-display/tests/thinking-label-edge.test.ts +904 -0
- package/dist/extensions/pi-tool-display/tests/thinking-label.test.ts +72 -0
- package/dist/extensions/pi-tool-display/tests/tool-call-box.test.ts +105 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-config.test.ts +613 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-mcp.test.ts +499 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-registration.test.ts +315 -0
- package/dist/extensions/pi-tool-display/tests/tool-overrides-write-meta.test.ts +68 -0
- package/dist/extensions/pi-tool-display/tests/tool-ui-utils.test.ts +413 -0
- package/dist/extensions/pi-tool-display/tests/user-message-box-performance-red.test.ts +176 -0
- package/dist/extensions/pi-tool-display/tests/user-message-box.test.ts +908 -0
- package/dist/extensions/pi-tool-display/tests/zellij-modal.test.ts +848 -0
- package/dist/extensions/pi-tool-display/tool-display-api-consumer.d.ts +30 -0
- package/dist/extensions/pi-tool-display/tool-display-api-consumer.js +40 -0
- package/dist/extensions/pi-web-agent/CHANGELOG.md +410 -0
- package/dist/extensions/pi-web-agent/README.md +131 -0
- package/dist/extensions/pi-web-agent/package.json +33 -0
- package/dist/extensions/pi-web-agent/src/backends/config.ts +264 -0
- package/dist/extensions/pi-web-agent/src/backends/doctor.ts +272 -0
- package/dist/extensions/pi-web-agent/src/backends/factory.ts +253 -0
- package/dist/extensions/pi-web-agent/src/backends/settings-reader.ts +46 -0
- package/dist/extensions/pi-web-agent/src/cache/ttl-cache.ts +28 -0
- package/dist/extensions/pi-web-agent/src/changelog-notice.ts +136 -0
- package/dist/extensions/pi-web-agent/src/commands/web-agent-config.ts +1082 -0
- package/dist/extensions/pi-web-agent/src/extension.ts +163 -0
- package/dist/extensions/pi-web-agent/src/extract/readability.ts +126 -0
- package/dist/extensions/pi-web-agent/src/fetch/browser-resolution.ts +199 -0
- package/dist/extensions/pi-web-agent/src/fetch/firecrawl-fetch.ts +100 -0
- package/dist/extensions/pi-web-agent/src/fetch/headless-fetch.ts +117 -0
- package/dist/extensions/pi-web-agent/src/fetch/http-fetch.ts +67 -0
- package/dist/extensions/pi-web-agent/src/orchestration/answer-synthesizer.ts +60 -0
- package/dist/extensions/pi-web-agent/src/orchestration/candidate-selector.ts +51 -0
- package/dist/extensions/pi-web-agent/src/orchestration/direct-url.ts +29 -0
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-quality.ts +108 -0
- package/dist/extensions/pi-web-agent/src/orchestration/evidence-ranker.ts +47 -0
- package/dist/extensions/pi-web-agent/src/orchestration/index.ts +28 -0
- package/dist/extensions/pi-web-agent/src/orchestration/query-planner.ts +47 -0
- package/dist/extensions/pi-web-agent/src/orchestration/research-orchestrator.ts +441 -0
- package/dist/extensions/pi-web-agent/src/orchestration/research-types.ts +71 -0
- package/dist/extensions/pi-web-agent/src/orchestration/research-worker.ts +206 -0
- package/dist/extensions/pi-web-agent/src/orchestration/source-profile.ts +105 -0
- package/dist/extensions/pi-web-agent/src/orchestration/stop-decider.ts +81 -0
- package/dist/extensions/pi-web-agent/src/orchestration/url.ts +35 -0
- package/dist/extensions/pi-web-agent/src/presentation/config-store.ts +210 -0
- package/dist/extensions/pi-web-agent/src/presentation/config.ts +75 -0
- package/dist/extensions/pi-web-agent/src/presentation/explore-presentation.ts +73 -0
- package/dist/extensions/pi-web-agent/src/presentation/fetch-presentation.ts +54 -0
- package/dist/extensions/pi-web-agent/src/presentation/search-presentation.ts +53 -0
- package/dist/extensions/pi-web-agent/src/presentation/select-view.ts +20 -0
- package/dist/extensions/pi-web-agent/src/presentation/types.ts +63 -0
- package/dist/extensions/pi-web-agent/src/readers/github-reader.ts +150 -0
- package/dist/extensions/pi-web-agent/src/readers/limits.ts +3 -0
- package/dist/extensions/pi-web-agent/src/readers/pdf-reader.ts +87 -0
- package/dist/extensions/pi-web-agent/src/readers/resolver.ts +25 -0
- package/dist/extensions/pi-web-agent/src/readers/types.ts +11 -0
- package/dist/extensions/pi-web-agent/src/readers/youtube-reader.ts +79 -0
- package/dist/extensions/pi-web-agent/src/search/brave.ts +114 -0
- package/dist/extensions/pi-web-agent/src/search/duckduckgo.ts +99 -0
- package/dist/extensions/pi-web-agent/src/search/exa.ts +109 -0
- package/dist/extensions/pi-web-agent/src/search/fanout.ts +154 -0
- package/dist/extensions/pi-web-agent/src/search/searxng.ts +96 -0
- package/dist/extensions/pi-web-agent/src/search/tavily.ts +113 -0
- package/dist/extensions/pi-web-agent/src/search/tokenin.ts +130 -0
- package/dist/extensions/pi-web-agent/src/search/youcom.ts +109 -0
- package/dist/extensions/pi-web-agent/src/tools/web-explore.ts +71 -0
- package/dist/extensions/pi-web-agent/src/tools/web-fetch-headless.ts +31 -0
- package/dist/extensions/pi-web-agent/src/tools/web-fetch.ts +31 -0
- package/dist/extensions/pi-web-agent/src/tools/web-search.ts +170 -0
- package/dist/extensions/pi-web-agent/src/types.ts +103 -0
- package/dist/extensions/pi-zentui/.editorconfig +12 -0
- package/dist/extensions/pi-zentui/.github/CODEOWNERS +1 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/bug_report.yml +110 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/config.yml +8 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/config_question.yml +56 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/feature_request.yml +63 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/rendering_issue.yml +106 -0
- package/dist/extensions/pi-zentui/.github/ISSUE_TEMPLATE/runtime_detection.yml +103 -0
- package/dist/extensions/pi-zentui/.github/dependabot.yml +47 -0
- package/dist/extensions/pi-zentui/.github/pull_request_template.md +34 -0
- package/dist/extensions/pi-zentui/.github/release.yml +18 -0
- package/dist/extensions/pi-zentui/.github/workflows/ci.yml +79 -0
- package/dist/extensions/pi-zentui/.github/workflows/publish.yml +63 -0
- package/dist/extensions/pi-zentui/AGENTS.md +107 -0
- package/dist/extensions/pi-zentui/CONTRIBUTING.md +68 -0
- package/dist/extensions/pi-zentui/LICENSE +21 -0
- package/dist/extensions/pi-zentui/README.md +202 -0
- package/dist/extensions/pi-zentui/SECURITY.md +18 -0
- package/dist/extensions/pi-zentui/assets/main-cover.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/editor-accent-rail.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/editor-minimalist.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/editor-opencode-copy-friendly.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/editor-opencode.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/user-message-compact.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/user-message-framed-copy-friendly.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/user-message-framed.png +0 -0
- package/dist/extensions/pi-zentui/assets/screenshots/user-message-labeled.png +0 -0
- package/dist/extensions/pi-zentui/assets/zentui.png +0 -0
- package/dist/extensions/pi-zentui/biome.json +31 -0
- package/dist/extensions/pi-zentui/docs/configuration.md +537 -0
- package/dist/extensions/pi-zentui/docs/footer-format.md +162 -0
- package/dist/extensions/pi-zentui/extensions/zentui/accent-rail-editor.ts +99 -0
- package/dist/extensions/pi-zentui/extensions/zentui/accent-rail-layout-patch.ts +457 -0
- package/dist/extensions/pi-zentui/extensions/zentui/completion-menu.ts +157 -0
- package/dist/extensions/pi-zentui/extensions/zentui/config.ts +2129 -0
- package/dist/extensions/pi-zentui/extensions/zentui/editor-metadata-format.ts +321 -0
- package/dist/extensions/pi-zentui/extensions/zentui/editor-transfer.ts +73 -0
- package/dist/extensions/pi-zentui/extensions/zentui/extension-status.ts +89 -0
- package/dist/extensions/pi-zentui/extensions/zentui/footer-format.ts +364 -0
- package/dist/extensions/pi-zentui/extensions/zentui/footer-layout.ts +122 -0
- package/dist/extensions/pi-zentui/extensions/zentui/footer.ts +812 -0
- package/dist/extensions/pi-zentui/extensions/zentui/format.ts +620 -0
- package/dist/extensions/pi-zentui/extensions/zentui/git.ts +384 -0
- package/dist/extensions/pi-zentui/extensions/zentui/icons.ts +252 -0
- package/dist/extensions/pi-zentui/extensions/zentui/index.ts +1445 -0
- package/dist/extensions/pi-zentui/extensions/zentui/interaction-summary.ts +1049 -0
- package/dist/extensions/pi-zentui/extensions/zentui/live-context.ts +75 -0
- package/dist/extensions/pi-zentui/extensions/zentui/minimalist-editor.ts +463 -0
- package/dist/extensions/pi-zentui/extensions/zentui/package-version.ts +651 -0
- package/dist/extensions/pi-zentui/extensions/zentui/project-refresh.ts +120 -0
- package/dist/extensions/pi-zentui/extensions/zentui/project-state.ts +59 -0
- package/dist/extensions/pi-zentui/extensions/zentui/prototype-patch-registry.ts +210 -0
- package/dist/extensions/pi-zentui/extensions/zentui/repository-root.ts +98 -0
- package/dist/extensions/pi-zentui/extensions/zentui/runtime.ts +841 -0
- package/dist/extensions/pi-zentui/extensions/zentui/selector-border.ts +93 -0
- package/dist/extensions/pi-zentui/extensions/zentui/session-lifecycle.ts +60 -0
- package/dist/extensions/pi-zentui/extensions/zentui/settings-command.ts +1908 -0
- package/dist/extensions/pi-zentui/extensions/zentui/settings-previews.ts +245 -0
- package/dist/extensions/pi-zentui/extensions/zentui/state.ts +94 -0
- package/dist/extensions/pi-zentui/extensions/zentui/style.ts +424 -0
- package/dist/extensions/pi-zentui/extensions/zentui/telemetry.ts +82 -0
- package/dist/extensions/pi-zentui/extensions/zentui/thinking-experimental.ts +1768 -0
- package/dist/extensions/pi-zentui/extensions/zentui/thinking-status.ts +69 -0
- package/dist/extensions/pi-zentui/extensions/zentui/thinking-steps.ts +155 -0
- package/dist/extensions/pi-zentui/extensions/zentui/ui.ts +1291 -0
- package/dist/extensions/pi-zentui/extensions/zentui/user-message-osc.ts +262 -0
- package/dist/extensions/pi-zentui/extensions/zentui/user-message-styles.ts +215 -0
- package/dist/extensions/pi-zentui/extensions/zentui/user-message.ts +206 -0
- package/dist/extensions/pi-zentui/extensions/zentui/working-line-messages.ts +24 -0
- package/dist/extensions/pi-zentui/extensions/zentui/working-line-spinners.ts +54 -0
- package/dist/extensions/pi-zentui/extensions/zentui/working-line.ts +1433 -0
- package/dist/extensions/pi-zentui/package-lock.json +5311 -0
- package/dist/extensions/pi-zentui/package.json +60 -0
- package/dist/extensions/pi-zentui/test/accent-rail-editor.test.ts +232 -0
- package/dist/extensions/pi-zentui/test/accent-rail-layout-patch.test.ts +669 -0
- package/dist/extensions/pi-zentui/test/completion-menu.test.ts +265 -0
- package/dist/extensions/pi-zentui/test/config-load-lifecycle.test.ts +124 -0
- package/dist/extensions/pi-zentui/test/config.test.ts +3199 -0
- package/dist/extensions/pi-zentui/test/editor-metadata-format.test.ts +405 -0
- package/dist/extensions/pi-zentui/test/editor-transfer.test.ts +260 -0
- package/dist/extensions/pi-zentui/test/editor-viewport-indicators.test.ts +1301 -0
- package/dist/extensions/pi-zentui/test/extension-compliance.test.ts +7245 -0
- package/dist/extensions/pi-zentui/test/extension-status.test.ts +182 -0
- package/dist/extensions/pi-zentui/test/fixtures/starship-nerd-font-symbols.toml +172 -0
- package/dist/extensions/pi-zentui/test/footer-format.test.ts +431 -0
- package/dist/extensions/pi-zentui/test/footer-layout.test.ts +113 -0
- package/dist/extensions/pi-zentui/test/footer-repository-path.test.ts +123 -0
- package/dist/extensions/pi-zentui/test/format.test.ts +927 -0
- package/dist/extensions/pi-zentui/test/git.test.ts +212 -0
- package/dist/extensions/pi-zentui/test/icons.test.ts +69 -0
- package/dist/extensions/pi-zentui/test/interaction-summary.test.ts +1402 -0
- package/dist/extensions/pi-zentui/test/live-context-integration.test.ts +378 -0
- package/dist/extensions/pi-zentui/test/live-context.test.ts +139 -0
- package/dist/extensions/pi-zentui/test/minimalist-editor.test.ts +811 -0
- package/dist/extensions/pi-zentui/test/package-contents.mjs +33 -0
- package/dist/extensions/pi-zentui/test/package-version.test.ts +321 -0
- package/dist/extensions/pi-zentui/test/project-refresh.test.ts +250 -0
- package/dist/extensions/pi-zentui/test/project-state.test.ts +159 -0
- package/dist/extensions/pi-zentui/test/prototype-patch-registry.test.ts +131 -0
- package/dist/extensions/pi-zentui/test/repository-root.test.ts +108 -0
- package/dist/extensions/pi-zentui/test/responsive-dependencies.test.ts +825 -0
- package/dist/extensions/pi-zentui/test/runtime.test.ts +183 -0
- package/dist/extensions/pi-zentui/test/session-lifecycle.test.ts +40 -0
- package/dist/extensions/pi-zentui/test/settings-command.test.ts +1663 -0
- package/dist/extensions/pi-zentui/test/settings-previews.test.ts +453 -0
- package/dist/extensions/pi-zentui/test/state.test.ts +84 -0
- package/dist/extensions/pi-zentui/test/telemetry-lifecycle-integration.test.ts +276 -0
- package/dist/extensions/pi-zentui/test/telemetry.test.ts +105 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental-docs.test.ts +51 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental-loader-diagnostics.mjs +54 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental-missing-export.test.ts +44 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental-rows.test.ts +297 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental-tui.mjs +2329 -0
- package/dist/extensions/pi-zentui/test/thinking-experimental.test.ts +1668 -0
- package/dist/extensions/pi-zentui/test/thinking-status.test.ts +85 -0
- package/dist/extensions/pi-zentui/test/thinking-steps.test.ts +122 -0
- package/dist/extensions/pi-zentui/test/turn-summary-lifecycle.integration.test.ts +327 -0
- package/dist/extensions/pi-zentui/test/user-message-osc.test.ts +222 -0
- package/dist/extensions/pi-zentui/test/user-message-styles.test.ts +292 -0
- package/dist/extensions/pi-zentui/test/working-line-lifecycle.integration.test.ts +730 -0
- package/dist/extensions/pi-zentui/test/working-line-messages.test.ts +34 -0
- package/dist/extensions/pi-zentui/test/working-line.test.ts +1990 -0
- package/dist/extensions/pi-zentui/tsconfig.json +16 -0
- package/dist/extensions/ponytail/index.js +176 -0
- package/dist/extensions/ponytail/package.json +8 -0
- package/dist/extensions/ponytail/ponytail-config.cjs +151 -0
- package/dist/extensions/ponytail/ponytail-instructions.cjs +112 -0
- package/dist/extensions/ponytail/test/extension.test.js +299 -0
- package/dist/extensions/ponytail/test/helpers.test.js +312 -0
- package/dist/extensions/question/batch.ts +103 -0
- package/dist/extensions/question/constants.ts +31 -0
- package/dist/extensions/question/helpers.ts +58 -0
- package/dist/extensions/question/index.ts +688 -0
- package/dist/extensions/question/navigation.ts +14 -0
- package/dist/extensions/question/package.json +19 -0
- package/dist/extensions/question/question-list.ts +533 -0
- package/dist/extensions/question/row-layout.ts +165 -0
- package/dist/extensions/question/schemas.ts +43 -0
- package/dist/extensions/question/selection-mode.ts +47 -0
- package/dist/extensions/question/shortcuts.ts +44 -0
- package/dist/extensions/question/tests/batch.test.ts +113 -0
- package/dist/extensions/question/tests/exp.test.ts +70 -0
- package/dist/extensions/question/tests/exp2.test.ts +59 -0
- package/dist/extensions/question/tests/exp3.test.ts +47 -0
- package/dist/extensions/question/tests/helpers.test.ts +93 -0
- package/dist/extensions/question/tests/question-list.test.ts +694 -0
- package/dist/extensions/question/tests/row-layout.test.ts +215 -0
- package/dist/extensions/question/tests/schemas.test.ts +53 -0
- package/dist/extensions/question/tests/selection-mode.test.ts +54 -0
- package/dist/extensions/question/tests/shortcuts.test.ts +107 -0
- package/dist/extensions/question/tests/wizard.test.ts +839 -0
- package/dist/extensions/question/tests/zz-ig3.test.ts +20 -0
- package/dist/extensions/question/tests/zz-probe.test.ts +29 -0
- package/dist/extensions/question/types.ts +132 -0
- package/dist/extensions/rtk.test.ts +320 -0
- package/dist/extensions/rtk.ts +123 -0
- package/dist/extensions/test-resolve-hook-impl.mjs +7 -0
- package/dist/extensions/test-resolve-hook.mjs +7 -0
- package/dist/extensions/tokenin-onboarding.ts +883 -0
- package/dist/extensions/tps.test.ts +38 -0
- package/dist/extensions/tps.ts +349 -0
- package/dist/extensions/undo.test.ts +720 -0
- package/dist/extensions/undo.ts +298 -0
- package/dist/extensions/web-agent-onboarding.test.ts +415 -0
- package/dist/extensions/web-agent-onboarding.ts +222 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +48 -0
- package/dist/main.d.ts +11 -0
- package/dist/main.js +768 -0
- package/dist/migrations.d.ts +32 -0
- package/dist/migrations.js +280 -0
- package/dist/modes/index.d.ts +8 -0
- package/dist/modes/index.js +7 -0
- package/dist/modes/interactive/assets/clankolas.png +0 -0
- package/dist/modes/interactive/components/armin.d.ts +33 -0
- package/dist/modes/interactive/components/armin.js +332 -0
- package/dist/modes/interactive/components/assistant-message.d.ts +21 -0
- package/dist/modes/interactive/components/assistant-message.js +142 -0
- package/dist/modes/interactive/components/bash-execution.d.ts +33 -0
- package/dist/modes/interactive/components/bash-execution.js +174 -0
- package/dist/modes/interactive/components/bordered-loader.d.ts +15 -0
- package/dist/modes/interactive/components/bordered-loader.js +53 -0
- package/dist/modes/interactive/components/branch-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/branch-summary-message.js +43 -0
- package/dist/modes/interactive/components/compaction-summary-message.d.ts +15 -0
- package/dist/modes/interactive/components/compaction-summary-message.js +44 -0
- package/dist/modes/interactive/components/config-selector.d.ts +101 -0
- package/dist/modes/interactive/components/config-selector.js +760 -0
- package/dist/modes/interactive/components/countdown-timer.d.ts +13 -0
- package/dist/modes/interactive/components/countdown-timer.js +32 -0
- package/dist/modes/interactive/components/custom-editor.d.ts +20 -0
- package/dist/modes/interactive/components/custom-editor.js +69 -0
- package/dist/modes/interactive/components/custom-entry.d.ts +18 -0
- package/dist/modes/interactive/components/custom-entry.js +51 -0
- package/dist/modes/interactive/components/custom-message.d.ts +21 -0
- package/dist/modes/interactive/components/custom-message.js +86 -0
- package/dist/modes/interactive/components/daxnuts.d.ts +22 -0
- package/dist/modes/interactive/components/daxnuts.js +139 -0
- package/dist/modes/interactive/components/diff.d.ts +11 -0
- package/dist/modes/interactive/components/diff.js +132 -0
- package/dist/modes/interactive/components/dynamic-border.d.ts +14 -0
- package/dist/modes/interactive/components/dynamic-border.js +20 -0
- package/dist/modes/interactive/components/earendil-announcement.d.ts +4 -0
- package/dist/modes/interactive/components/earendil-announcement.js +39 -0
- package/dist/modes/interactive/components/extension-editor.d.ts +20 -0
- package/dist/modes/interactive/components/extension-editor.js +97 -0
- package/dist/modes/interactive/components/extension-input.d.ts +22 -0
- package/dist/modes/interactive/components/extension-input.js +60 -0
- package/dist/modes/interactive/components/extension-selector.d.ts +25 -0
- package/dist/modes/interactive/components/extension-selector.js +82 -0
- package/dist/modes/interactive/components/first-time-setup.d.ts +24 -0
- package/dist/modes/interactive/components/first-time-setup.js +116 -0
- package/dist/modes/interactive/components/footer.d.ts +31 -0
- package/dist/modes/interactive/components/footer.js +221 -0
- package/dist/modes/interactive/components/index.d.ts +33 -0
- package/dist/modes/interactive/components/index.js +34 -0
- package/dist/modes/interactive/components/keybinding-hints.d.ts +12 -0
- package/dist/modes/interactive/components/keybinding-hints.js +35 -0
- package/dist/modes/interactive/components/login-dialog.d.ts +51 -0
- package/dist/modes/interactive/components/login-dialog.js +187 -0
- package/dist/modes/interactive/components/model-selector.d.ts +63 -0
- package/dist/modes/interactive/components/model-selector.js +321 -0
- package/dist/modes/interactive/components/oauth-selector.d.ts +32 -0
- package/dist/modes/interactive/components/oauth-selector.js +162 -0
- package/dist/modes/interactive/components/scoped-models-selector.d.ts +41 -0
- package/dist/modes/interactive/components/scoped-models-selector.js +301 -0
- package/dist/modes/interactive/components/session-selector-search.d.ts +22 -0
- package/dist/modes/interactive/components/session-selector-search.js +154 -0
- package/dist/modes/interactive/components/session-selector.d.ts +94 -0
- package/dist/modes/interactive/components/session-selector.js +866 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +103 -0
- package/dist/modes/interactive/components/settings-selector.js +726 -0
- package/dist/modes/interactive/components/show-images-selector.d.ts +9 -0
- package/dist/modes/interactive/components/show-images-selector.js +38 -0
- package/dist/modes/interactive/components/skill-invocation-message.d.ts +16 -0
- package/dist/modes/interactive/components/skill-invocation-message.js +46 -0
- package/dist/modes/interactive/components/startup-box.d.ts +38 -0
- package/dist/modes/interactive/components/startup-box.js +90 -0
- package/dist/modes/interactive/components/status-indicator.d.ts +30 -0
- package/dist/modes/interactive/components/status-indicator.js +64 -0
- package/dist/modes/interactive/components/theme-selector.d.ts +10 -0
- package/dist/modes/interactive/components/theme-selector.js +49 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +10 -0
- package/dist/modes/interactive/components/thinking-selector.js +51 -0
- package/dist/modes/interactive/components/tool-execution.d.ts +62 -0
- package/dist/modes/interactive/components/tool-execution.js +325 -0
- package/dist/modes/interactive/components/tree-selector.d.ts +93 -0
- package/dist/modes/interactive/components/tree-selector.js +1244 -0
- package/dist/modes/interactive/components/trust-selector.d.ts +22 -0
- package/dist/modes/interactive/components/trust-selector.js +90 -0
- package/dist/modes/interactive/components/user-message-selector.d.ts +29 -0
- package/dist/modes/interactive/components/user-message-selector.js +113 -0
- package/dist/modes/interactive/components/user-message.d.ts +13 -0
- package/dist/modes/interactive/components/user-message.js +41 -0
- package/dist/modes/interactive/components/visual-truncate.d.ts +23 -0
- package/dist/modes/interactive/components/visual-truncate.js +32 -0
- package/dist/modes/interactive/external-editor.d.ts +11 -0
- package/dist/modes/interactive/external-editor.js +36 -0
- package/dist/modes/interactive/interactive-mode.d.ts +447 -0
- package/dist/modes/interactive/interactive-mode.js +5489 -0
- package/dist/modes/interactive/model-catalog-refresh.d.ts +6 -0
- package/dist/modes/interactive/model-catalog-refresh.js +33 -0
- package/dist/modes/interactive/model-search.d.ts +11 -0
- package/dist/modes/interactive/model-search.js +14 -0
- package/dist/modes/interactive/theme/dark.json +90 -0
- package/dist/modes/interactive/theme/light.json +89 -0
- package/dist/modes/interactive/theme/theme-controller.d.ts +39 -0
- package/dist/modes/interactive/theme/theme-controller.js +124 -0
- package/dist/modes/interactive/theme/theme-schema.json +348 -0
- package/dist/modes/interactive/theme/theme.d.ts +121 -0
- package/dist/modes/interactive/theme/theme.js +1090 -0
- package/dist/modes/print-mode.d.ts +27 -0
- package/dist/modes/print-mode.js +141 -0
- package/dist/modes/rpc/jsonl.d.ts +16 -0
- package/dist/modes/rpc/jsonl.js +48 -0
- package/dist/modes/rpc/rpc-client.d.ts +438 -0
- package/dist/modes/rpc/rpc-client.js +712 -0
- package/dist/modes/rpc/rpc-mode.d.ts +19 -0
- package/dist/modes/rpc/rpc-mode.js +1459 -0
- package/dist/modes/rpc/rpc-types.d.ts +902 -0
- package/dist/modes/rpc/rpc-types.js +7 -0
- package/dist/package-manager-cli.d.ts +7 -0
- package/dist/package-manager-cli.js +789 -0
- package/dist/rpc-entry.d.ts +2 -0
- package/dist/rpc-entry.js +9 -0
- package/dist/skills/agent-browser/SKILL.md +53 -0
- package/dist/skills/batch-grill-me/SKILL.md +20 -0
- package/dist/skills/brandkit/SKILL.md +798 -0
- package/dist/skills/brutalist/SKILL.md +92 -0
- package/dist/skills/design-references/SKILL.md +32 -0
- package/dist/skills/design-references/references/clickhouse/DESIGN.md +544 -0
- package/dist/skills/gpt-taste/SKILL.md +74 -0
- package/dist/skills/grill-me/SKILL.md +11 -0
- package/dist/skills/handoff/SKILL.md +17 -0
- package/dist/skills/handoff-text/SKILL.md +15 -0
- package/dist/skills/image-to-code/SKILL.md +1228 -0
- package/dist/skills/imagegen-frontend-mobile/SKILL.md +1465 -0
- package/dist/skills/imagegen-frontend-web/SKILL.md +987 -0
- package/dist/skills/implanger/SKILL.md +70 -0
- package/dist/skills/improve-codebase/REFERENCE.md +78 -0
- package/dist/skills/improve-codebase/SKILL.md +180 -0
- package/dist/skills/minimalist/SKILL.md +85 -0
- package/dist/skills/output/SKILL.md +49 -0
- package/dist/skills/pi-subagents/SKILL.md +50 -0
- package/dist/skills/pi-subagents/references/constraints-and-recipes.md +274 -0
- package/dist/skills/pi-subagents/references/execution-controls.md +463 -0
- package/dist/skills/pi-subagents/references/management-authoring-rpc.md +161 -0
- package/dist/skills/pi-subagents/references/multi-lane-orchestration.md +39 -0
- package/dist/skills/pi-subagents/references/prompting-and-roles.md +267 -0
- package/dist/skills/planger/SKILL.md +167 -0
- package/dist/skills/ponytail/SKILL.md +121 -0
- package/dist/skills/ponytail-audit/SKILL.md +42 -0
- package/dist/skills/ponytail-debt/SKILL.md +45 -0
- package/dist/skills/ponytail-gain/SKILL.md +51 -0
- package/dist/skills/ponytail-help/SKILL.md +72 -0
- package/dist/skills/ponytail-review/SKILL.md +58 -0
- package/dist/skills/redesign/SKILL.md +178 -0
- package/dist/skills/selesai-handoff/SKILL.md +21 -0
- package/dist/skills/soft/SKILL.md +98 -0
- package/dist/skills/stitch/DESIGN.md +121 -0
- package/dist/skills/stitch/SKILL.md +184 -0
- package/dist/skills/taste/SKILL.md +1206 -0
- package/dist/skills/taste-v1/SKILL.md +226 -0
- package/dist/skills/unlazy/CHANGELOG.md +109 -0
- package/dist/skills/unlazy/CONTRIBUTING.md +63 -0
- package/dist/skills/unlazy/LICENSE +21 -0
- package/dist/skills/unlazy/README.md +228 -0
- package/dist/skills/unlazy/SECURITY.md +60 -0
- package/dist/skills/unlazy/SKILL.md +93 -0
- package/dist/skills/unlazy/package.json +13 -0
- package/dist/skills/unlazy/references/dispatch.md +79 -0
- package/dist/skills/unlazy/references/gates.md +132 -0
- package/dist/skills/unlazy/references/method.md +49 -0
- package/dist/skills/unlazy/references/orchestration.md +98 -0
- package/dist/skills/unlazy/references/parallel.md +111 -0
- package/dist/skills/unlazy/references/token-economy.md +39 -0
- package/dist/skills/unlazy/research/validation-protocol.md +81 -0
- package/dist/skills/unlazy/scripts/dispatch-check.mjs +108 -0
- package/dist/skills/unlazy/scripts/gate-check.mjs +879 -0
- package/dist/skills/unlazy/scripts/gate-lint.mjs +178 -0
- package/dist/skills/unlazy/scripts/lib/check-supervisor.mjs +46 -0
- package/dist/skills/unlazy/scripts/lib/dispatch.mjs +283 -0
- package/dist/skills/unlazy/scripts/lib/gates.mjs +625 -0
- package/dist/skills/unlazy/scripts/lib/process-tree.mjs +161 -0
- package/dist/skills/unlazy/scripts/lib/regex-worker.mjs +9 -0
- package/dist/skills/unlazy/templates/PLAN.md +65 -0
- package/dist/skills/unlazy/templates/gates-leaf.md +51 -0
- package/dist/skills/unlazy/templates/gates-node.md +50 -0
- package/dist/skills/unlazy/tests/contract-tests.mjs +127 -0
- package/dist/skills/unlazy/tests/dispatch-tests.mjs +296 -0
- package/dist/skills/unlazy/tests/hardening-tests.mjs +900 -0
- package/dist/skills/unlazy/tests/lint-tests.mjs +242 -0
- package/dist/skills/unlazy/tests/run-tests.mjs +360 -0
- package/dist/skills/unlazy/tests/self-check.mjs +152 -0
- package/dist/skills/unlazy/tests/stress-tests.mjs +165 -0
- package/dist/skills/web-design-guidelines/SKILL.md +41 -0
- package/dist/skills/workflow/SKILL.md +95 -0
- package/dist/themes/adventure.json +84 -0
- package/dist/themes/adwaita-dark.json +84 -0
- package/dist/themes/arcoiris.json +84 -0
- package/dist/themes/arthur.json +84 -0
- package/dist/themes/atom.json +84 -0
- package/dist/themes/aura.json +84 -0
- package/dist/themes/black-metal-bathory.json +84 -0
- package/dist/themes/black-metal-burzum.json +84 -0
- package/dist/themes/black-metal-khold.json +84 -0
- package/dist/themes/box.json +84 -0
- package/dist/themes/brogrammer.json +84 -0
- package/dist/themes/carbonfox.json +84 -0
- package/dist/themes/catppuccin-mocha.json +84 -0
- package/dist/themes/citruszest.json +84 -0
- package/dist/themes/cursor-dark.json +84 -0
- package/dist/themes/cutie-pro.json +84 -0
- package/dist/themes/dark-modern.json +84 -0
- package/dist/themes/dark-pastel.json +84 -0
- package/dist/themes/dimmed-monokai.json +84 -0
- package/dist/themes/doom-peacock.json +84 -0
- package/dist/themes/dracula-plus.json +84 -0
- package/dist/themes/dracula.json +80 -0
- package/dist/themes/earthsong.json +84 -0
- package/dist/themes/everforest-dark-hard.json +84 -0
- package/dist/themes/everforest-dark.json +80 -0
- package/dist/themes/fahrenheit.json +84 -0
- package/dist/themes/flatland.json +84 -0
- package/dist/themes/flexoki-dark.json +84 -0
- package/dist/themes/front-end-delight.json +84 -0
- package/dist/themes/fun-forrest.json +84 -0
- package/dist/themes/galizur.json +84 -0
- package/dist/themes/github-dark-colorblind.json +84 -0
- package/dist/themes/github-dark-high-contrast.json +84 -0
- package/dist/themes/glacier.json +84 -0
- package/dist/themes/gruber-darker.json +84 -0
- package/dist/themes/gruvbox-dark-hard.json +84 -0
- package/dist/themes/gruvbox-dark.json +84 -0
- package/dist/themes/gruvbox-material.json +84 -0
- package/dist/themes/guezwhoz.json +84 -0
- package/dist/themes/hacktober.json +84 -0
- package/dist/themes/hardcore.json +84 -0
- package/dist/themes/havn-skumring.json +84 -0
- package/dist/themes/ic-orange-ppl.json +84 -0
- package/dist/themes/iterm2-smoooooth.json +84 -0
- package/dist/themes/iterm2-tango-dark.json +84 -0
- package/dist/themes/japanesque.json +84 -0
- package/dist/themes/jellybeans.json +84 -0
- package/dist/themes/kanagawa-wave.json +84 -0
- package/dist/themes/kurokula.json +84 -0
- package/dist/themes/later-this-evening.json +84 -0
- package/dist/themes/lovelace.json +84 -0
- package/dist/themes/material-darker.json +84 -0
- package/dist/themes/matte-black.json +84 -0
- package/dist/themes/mellow.json +84 -0
- package/dist/themes/miasma.json +84 -0
- package/dist/themes/nord.json +80 -0
- package/dist/themes/nvim-dark.json +84 -0
- package/dist/themes/one-dark.json +80 -0
- package/dist/themes/popping-and-locking.json +84 -0
- package/dist/themes/rose-pine.json +80 -0
- package/dist/themes/sea-shells.json +84 -0
- package/dist/themes/sleepy-hollow.json +84 -0
- package/dist/themes/smyck.json +84 -0
- package/dist/themes/solarized-dark.json +80 -0
- package/dist/themes/tokyo-night.json +80 -0
- package/dist/themes/tomorrow-night-bright.json +84 -0
- package/dist/themes/tomorrow-night-burns.json +84 -0
- package/dist/themes/tomorrow-night.json +84 -0
- package/dist/themes/twilight.json +84 -0
- package/dist/themes/vague.json +84 -0
- package/dist/themes/vesper.json +84 -0
- package/dist/themes/xcode-dark-hc.json +84 -0
- package/dist/utils/abort.d.ts +4 -0
- package/dist/utils/abort.js +47 -0
- package/dist/utils/ansi.d.ts +1 -0
- package/dist/utils/ansi.js +51 -0
- package/dist/utils/changelog.d.ts +21 -0
- package/dist/utils/changelog.js +164 -0
- package/dist/utils/child-process.d.ts +17 -0
- package/dist/utils/child-process.js +105 -0
- package/dist/utils/clipboard-image.d.ts +10 -0
- package/dist/utils/clipboard-image.js +250 -0
- package/dist/utils/clipboard-native.d.ts +10 -0
- package/dist/utils/clipboard-native.js +19 -0
- package/dist/utils/clipboard.d.ts +3 -0
- package/dist/utils/clipboard.js +140 -0
- package/dist/utils/deprecation.d.ts +3 -0
- package/dist/utils/deprecation.js +12 -0
- package/dist/utils/exif-orientation.d.ts +4 -0
- package/dist/utils/exif-orientation.js +157 -0
- package/dist/utils/frontmatter.d.ts +7 -0
- package/dist/utils/frontmatter.js +25 -0
- package/dist/utils/fs-watch.d.ts +4 -0
- package/dist/utils/fs-watch.js +24 -0
- package/dist/utils/git.d.ts +25 -0
- package/dist/utils/git.js +194 -0
- package/dist/utils/html.d.ts +6 -0
- package/dist/utils/html.js +39 -0
- package/dist/utils/image-convert.d.ts +9 -0
- package/dist/utils/image-convert.js +44 -0
- package/dist/utils/image-process.d.ts +17 -0
- package/dist/utils/image-process.js +82 -0
- package/dist/utils/image-resize-core.d.ts +29 -0
- package/dist/utils/image-resize-core.js +123 -0
- package/dist/utils/image-resize-worker.d.ts +1 -0
- package/dist/utils/image-resize-worker.js +30 -0
- package/dist/utils/image-resize.d.ts +15 -0
- package/dist/utils/image-resize.js +96 -0
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +6 -0
- package/dist/utils/mime.d.ts +2 -0
- package/dist/utils/mime.js +132 -0
- package/dist/utils/open-browser.d.ts +8 -0
- package/dist/utils/open-browser.js +21 -0
- package/dist/utils/paths.d.ts +30 -0
- package/dist/utils/paths.js +91 -0
- package/dist/utils/photon.d.ts +20 -0
- package/dist/utils/photon.js +120 -0
- package/dist/utils/pi-user-agent.d.ts +1 -0
- package/dist/utils/pi-user-agent.js +4 -0
- package/dist/utils/shell.d.ts +33 -0
- package/dist/utils/shell.js +215 -0
- package/dist/utils/sleep.d.ts +4 -0
- package/dist/utils/sleep.js +16 -0
- package/dist/utils/syntax-highlight.d.ts +11 -0
- package/dist/utils/syntax-highlight.js +117 -0
- package/dist/utils/thinking-tags.d.ts +6 -0
- package/dist/utils/thinking-tags.js +62 -0
- package/dist/utils/tools-manager.d.ts +7 -0
- package/dist/utils/tools-manager.js +402 -0
- package/dist/utils/version-check.d.ts +19 -0
- package/dist/utils/version-check.js +72 -0
- package/dist/utils/windows-self-update.d.ts +2 -0
- package/dist/utils/windows-self-update.js +76 -0
- package/package.json +1 -1
|
@@ -0,0 +1,2232 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { homedir } 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, isAbsolute, 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 { CONFIG_DIR_NAME, getBundledExtensionsDir } from "../config.js";
|
|
29
|
+
import { spawnProcess, spawnProcessSync } from "../utils/child-process.js";
|
|
30
|
+
import { parseGitUrl } from "../utils/git.js";
|
|
31
|
+
import { canonicalizePath, isLocalPath, markPathIgnoredByCloudSync, resolvePath } from "../utils/paths.js";
|
|
32
|
+
import { isStdoutTakenOver } from "./output-guard.js";
|
|
33
|
+
const NETWORK_TIMEOUT_MS = 10000;
|
|
34
|
+
const UPDATE_CHECK_CONCURRENCY = 4;
|
|
35
|
+
const GIT_UPDATE_CONCURRENCY = 4;
|
|
36
|
+
function isOfflineModeEnabled() {
|
|
37
|
+
const value = process.env.PI_OFFLINE;
|
|
38
|
+
if (!value)
|
|
39
|
+
return false;
|
|
40
|
+
return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
|
|
41
|
+
}
|
|
42
|
+
function isExactNpmVersion(version) {
|
|
43
|
+
return valid(version ?? "") !== null;
|
|
44
|
+
}
|
|
45
|
+
function getNpmVersionRange(version) {
|
|
46
|
+
return version ? (validRange(version) ?? undefined) : undefined;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Compute a numeric precedence rank for a resource based on its metadata.
|
|
50
|
+
* Lower rank = higher precedence. Used to sort resolved resources so that
|
|
51
|
+
* name-collision resolution ("first wins") produces the correct outcome.
|
|
52
|
+
*
|
|
53
|
+
* Precedence (highest to lowest):
|
|
54
|
+
* 0 project + settings entry (source: "local", scope: "project")
|
|
55
|
+
* 1 project + auto-discovered (source: "auto", scope: "project")
|
|
56
|
+
* 2 user + settings entry (source: "local", scope: "user")
|
|
57
|
+
* 3 user + auto-discovered (source: "auto", scope: "user")
|
|
58
|
+
* 4 package resource (origin: "package")
|
|
59
|
+
*/
|
|
60
|
+
function resourcePrecedenceRank(m) {
|
|
61
|
+
if (m.origin === "package")
|
|
62
|
+
return 4;
|
|
63
|
+
const scopeBase = m.scope === "project" ? 0 : 2;
|
|
64
|
+
return scopeBase + (m.source === "local" ? 0 : 1);
|
|
65
|
+
}
|
|
66
|
+
const RESOURCE_TYPES = ["extensions", "skills", "prompts", "themes", "agents"];
|
|
67
|
+
const FILE_PATTERNS = {
|
|
68
|
+
extensions: /\.(ts|js)$/,
|
|
69
|
+
skills: /\.md$/,
|
|
70
|
+
prompts: /\.md$/,
|
|
71
|
+
themes: /\.json$/,
|
|
72
|
+
agents: /\.md$/,
|
|
73
|
+
};
|
|
74
|
+
const IGNORE_FILE_NAMES = [".gitignore", ".ignore", ".fdignore"];
|
|
75
|
+
function toPosixPath(p) {
|
|
76
|
+
return p.split(sep).join("/");
|
|
77
|
+
}
|
|
78
|
+
function getHomeDir() {
|
|
79
|
+
return process.env.HOME || homedir();
|
|
80
|
+
}
|
|
81
|
+
export function getExtensionTempFolder(agentDir) {
|
|
82
|
+
const tempFolder = join(agentDir, "tmp", "extensions");
|
|
83
|
+
mkdirSync(tempFolder, { recursive: true, mode: 0o700 });
|
|
84
|
+
chmodSync(tempFolder, 0o700);
|
|
85
|
+
return tempFolder;
|
|
86
|
+
}
|
|
87
|
+
function prefixIgnorePattern(line, prefix) {
|
|
88
|
+
const trimmed = line.trim();
|
|
89
|
+
if (!trimmed)
|
|
90
|
+
return null;
|
|
91
|
+
if (trimmed.startsWith("#") && !trimmed.startsWith("\\#"))
|
|
92
|
+
return null;
|
|
93
|
+
let pattern = line;
|
|
94
|
+
let negated = false;
|
|
95
|
+
if (pattern.startsWith("!")) {
|
|
96
|
+
negated = true;
|
|
97
|
+
pattern = pattern.slice(1);
|
|
98
|
+
}
|
|
99
|
+
else if (pattern.startsWith("\\!")) {
|
|
100
|
+
pattern = pattern.slice(1);
|
|
101
|
+
}
|
|
102
|
+
if (pattern.startsWith("/")) {
|
|
103
|
+
pattern = pattern.slice(1);
|
|
104
|
+
}
|
|
105
|
+
const prefixed = prefix ? `${prefix}${pattern}` : pattern;
|
|
106
|
+
return negated ? `!${prefixed}` : prefixed;
|
|
107
|
+
}
|
|
108
|
+
function addIgnoreRules(ig, dir, rootDir) {
|
|
109
|
+
const relativeDir = relative(rootDir, dir);
|
|
110
|
+
const prefix = relativeDir ? `${toPosixPath(relativeDir)}/` : "";
|
|
111
|
+
for (const filename of IGNORE_FILE_NAMES) {
|
|
112
|
+
const ignorePath = join(dir, filename);
|
|
113
|
+
if (!existsSync(ignorePath))
|
|
114
|
+
continue;
|
|
115
|
+
try {
|
|
116
|
+
const content = readFileSync(ignorePath, "utf-8");
|
|
117
|
+
const patterns = content
|
|
118
|
+
.split(/\r?\n/)
|
|
119
|
+
.map((line) => prefixIgnorePattern(line, prefix))
|
|
120
|
+
.filter((line) => Boolean(line));
|
|
121
|
+
if (patterns.length > 0) {
|
|
122
|
+
ig.add(patterns);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch { }
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function isPattern(s) {
|
|
129
|
+
return s.startsWith("!") || s.startsWith("+") || s.startsWith("-") || s.includes("*") || s.includes("?");
|
|
130
|
+
}
|
|
131
|
+
function isOverridePattern(s) {
|
|
132
|
+
return s.startsWith("!") || s.startsWith("+") || s.startsWith("-");
|
|
133
|
+
}
|
|
134
|
+
function hasGlobPattern(s) {
|
|
135
|
+
return s.includes("*") || s.includes("?");
|
|
136
|
+
}
|
|
137
|
+
function splitPatterns(entries) {
|
|
138
|
+
const plain = [];
|
|
139
|
+
const patterns = [];
|
|
140
|
+
for (const entry of entries) {
|
|
141
|
+
if (isPattern(entry)) {
|
|
142
|
+
patterns.push(entry);
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
plain.push(entry);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { plain, patterns };
|
|
149
|
+
}
|
|
150
|
+
function collectFiles(dir, filePattern, skipNodeModules = true, ignoreMatcher, rootDir) {
|
|
151
|
+
const files = [];
|
|
152
|
+
if (!existsSync(dir))
|
|
153
|
+
return files;
|
|
154
|
+
const root = rootDir ?? dir;
|
|
155
|
+
const ig = ignoreMatcher ?? ignore();
|
|
156
|
+
addIgnoreRules(ig, dir, root);
|
|
157
|
+
try {
|
|
158
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
159
|
+
for (const entry of entries) {
|
|
160
|
+
if (entry.name.startsWith("."))
|
|
161
|
+
continue;
|
|
162
|
+
if (skipNodeModules && entry.name === "node_modules")
|
|
163
|
+
continue;
|
|
164
|
+
const fullPath = join(dir, entry.name);
|
|
165
|
+
let isDir = entry.isDirectory();
|
|
166
|
+
let isFile = entry.isFile();
|
|
167
|
+
if (entry.isSymbolicLink()) {
|
|
168
|
+
try {
|
|
169
|
+
const stats = statSync(fullPath);
|
|
170
|
+
isDir = stats.isDirectory();
|
|
171
|
+
isFile = stats.isFile();
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
const relPath = toPosixPath(relative(root, fullPath));
|
|
178
|
+
const ignorePath = isDir ? `${relPath}/` : relPath;
|
|
179
|
+
if (ig.ignores(ignorePath))
|
|
180
|
+
continue;
|
|
181
|
+
if (isDir) {
|
|
182
|
+
files.push(...collectFiles(fullPath, filePattern, skipNodeModules, ig, root));
|
|
183
|
+
}
|
|
184
|
+
else if (isFile && filePattern.test(entry.name)) {
|
|
185
|
+
files.push(fullPath);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
// Ignore errors
|
|
191
|
+
}
|
|
192
|
+
return files;
|
|
193
|
+
}
|
|
194
|
+
function collectSkillEntries(dir, mode, ignoreMatcher, rootDir) {
|
|
195
|
+
const entries = [];
|
|
196
|
+
if (!existsSync(dir))
|
|
197
|
+
return entries;
|
|
198
|
+
const root = rootDir ?? dir;
|
|
199
|
+
const ig = ignoreMatcher ?? ignore();
|
|
200
|
+
addIgnoreRules(ig, dir, root);
|
|
201
|
+
try {
|
|
202
|
+
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
203
|
+
for (const entry of dirEntries) {
|
|
204
|
+
if (entry.name !== "SKILL.md") {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const fullPath = join(dir, entry.name);
|
|
208
|
+
let isFile = entry.isFile();
|
|
209
|
+
if (entry.isSymbolicLink()) {
|
|
210
|
+
try {
|
|
211
|
+
isFile = statSync(fullPath).isFile();
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
const relPath = toPosixPath(relative(root, fullPath));
|
|
218
|
+
if (isFile && !ig.ignores(relPath)) {
|
|
219
|
+
entries.push(fullPath);
|
|
220
|
+
return entries;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
for (const entry of dirEntries) {
|
|
224
|
+
if (entry.name.startsWith("."))
|
|
225
|
+
continue;
|
|
226
|
+
if (entry.name === "node_modules")
|
|
227
|
+
continue;
|
|
228
|
+
const fullPath = join(dir, entry.name);
|
|
229
|
+
let isDir = entry.isDirectory();
|
|
230
|
+
let isFile = entry.isFile();
|
|
231
|
+
if (entry.isSymbolicLink()) {
|
|
232
|
+
try {
|
|
233
|
+
const stats = statSync(fullPath);
|
|
234
|
+
isDir = stats.isDirectory();
|
|
235
|
+
isFile = stats.isFile();
|
|
236
|
+
}
|
|
237
|
+
catch {
|
|
238
|
+
continue;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const relPath = toPosixPath(relative(root, fullPath));
|
|
242
|
+
if (mode === "pi" && dir === root && isFile && entry.name.endsWith(".md") && !ig.ignores(relPath)) {
|
|
243
|
+
entries.push(fullPath);
|
|
244
|
+
continue;
|
|
245
|
+
}
|
|
246
|
+
if (!isDir)
|
|
247
|
+
continue;
|
|
248
|
+
if (ig.ignores(`${relPath}/`))
|
|
249
|
+
continue;
|
|
250
|
+
entries.push(...collectSkillEntries(fullPath, mode, ig, root));
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
catch {
|
|
254
|
+
// Ignore errors
|
|
255
|
+
}
|
|
256
|
+
return entries;
|
|
257
|
+
}
|
|
258
|
+
function collectAutoSkillEntries(dir, mode) {
|
|
259
|
+
return collectSkillEntries(dir, mode);
|
|
260
|
+
}
|
|
261
|
+
function findGitRepoRoot(startDir) {
|
|
262
|
+
let dir = resolve(startDir);
|
|
263
|
+
while (true) {
|
|
264
|
+
if (existsSync(join(dir, ".git"))) {
|
|
265
|
+
return dir;
|
|
266
|
+
}
|
|
267
|
+
const parent = dirname(dir);
|
|
268
|
+
if (parent === dir) {
|
|
269
|
+
return null;
|
|
270
|
+
}
|
|
271
|
+
dir = parent;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function collectAncestorAgentsSkillDirs(startDir) {
|
|
275
|
+
const skillDirs = [];
|
|
276
|
+
const resolvedStartDir = resolve(startDir);
|
|
277
|
+
const gitRepoRoot = findGitRepoRoot(resolvedStartDir);
|
|
278
|
+
let dir = resolvedStartDir;
|
|
279
|
+
while (true) {
|
|
280
|
+
skillDirs.push(join(dir, ".agents", "skills"));
|
|
281
|
+
if (gitRepoRoot && dir === gitRepoRoot) {
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
const parent = dirname(dir);
|
|
285
|
+
if (parent === dir) {
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
dir = parent;
|
|
289
|
+
}
|
|
290
|
+
return skillDirs;
|
|
291
|
+
}
|
|
292
|
+
function collectAutoPromptEntries(dir) {
|
|
293
|
+
const entries = [];
|
|
294
|
+
if (!existsSync(dir))
|
|
295
|
+
return entries;
|
|
296
|
+
const ig = ignore();
|
|
297
|
+
addIgnoreRules(ig, dir, dir);
|
|
298
|
+
try {
|
|
299
|
+
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
300
|
+
for (const entry of dirEntries) {
|
|
301
|
+
if (entry.name.startsWith("."))
|
|
302
|
+
continue;
|
|
303
|
+
if (entry.name === "node_modules")
|
|
304
|
+
continue;
|
|
305
|
+
const fullPath = join(dir, entry.name);
|
|
306
|
+
let isFile = entry.isFile();
|
|
307
|
+
if (entry.isSymbolicLink()) {
|
|
308
|
+
try {
|
|
309
|
+
isFile = statSync(fullPath).isFile();
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
const relPath = toPosixPath(relative(dir, fullPath));
|
|
316
|
+
if (ig.ignores(relPath))
|
|
317
|
+
continue;
|
|
318
|
+
if (isFile && entry.name.endsWith(".md")) {
|
|
319
|
+
entries.push(fullPath);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
catch {
|
|
324
|
+
// Ignore errors
|
|
325
|
+
}
|
|
326
|
+
return entries;
|
|
327
|
+
}
|
|
328
|
+
function collectAutoThemeEntries(dir) {
|
|
329
|
+
const entries = [];
|
|
330
|
+
if (!existsSync(dir))
|
|
331
|
+
return entries;
|
|
332
|
+
const ig = ignore();
|
|
333
|
+
addIgnoreRules(ig, dir, dir);
|
|
334
|
+
try {
|
|
335
|
+
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
336
|
+
for (const entry of dirEntries) {
|
|
337
|
+
if (entry.name.startsWith("."))
|
|
338
|
+
continue;
|
|
339
|
+
if (entry.name === "node_modules")
|
|
340
|
+
continue;
|
|
341
|
+
const fullPath = join(dir, entry.name);
|
|
342
|
+
let isFile = entry.isFile();
|
|
343
|
+
if (entry.isSymbolicLink()) {
|
|
344
|
+
try {
|
|
345
|
+
isFile = statSync(fullPath).isFile();
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
const relPath = toPosixPath(relative(dir, fullPath));
|
|
352
|
+
if (ig.ignores(relPath))
|
|
353
|
+
continue;
|
|
354
|
+
if (isFile && entry.name.endsWith(".json")) {
|
|
355
|
+
entries.push(fullPath);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
catch {
|
|
360
|
+
// Ignore errors
|
|
361
|
+
}
|
|
362
|
+
return entries;
|
|
363
|
+
}
|
|
364
|
+
function readPiManifestFile(packageJsonPath) {
|
|
365
|
+
try {
|
|
366
|
+
const content = readFileSync(packageJsonPath, "utf-8");
|
|
367
|
+
const pkg = JSON.parse(content);
|
|
368
|
+
return pkg.pi ?? null;
|
|
369
|
+
}
|
|
370
|
+
catch {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
function resolveExtensionEntries(dir) {
|
|
375
|
+
const packageJsonPath = join(dir, "package.json");
|
|
376
|
+
if (existsSync(packageJsonPath)) {
|
|
377
|
+
const manifest = readPiManifestFile(packageJsonPath);
|
|
378
|
+
if (manifest?.extensions?.length) {
|
|
379
|
+
const entries = [];
|
|
380
|
+
for (const extPath of manifest.extensions) {
|
|
381
|
+
const resolvedExtPath = resolve(dir, extPath);
|
|
382
|
+
if (existsSync(resolvedExtPath)) {
|
|
383
|
+
entries.push(resolvedExtPath);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
if (entries.length > 0) {
|
|
387
|
+
return entries;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
const indexTs = join(dir, "index.ts");
|
|
392
|
+
const indexJs = join(dir, "index.js");
|
|
393
|
+
if (existsSync(indexTs)) {
|
|
394
|
+
return [indexTs];
|
|
395
|
+
}
|
|
396
|
+
if (existsSync(indexJs)) {
|
|
397
|
+
return [indexJs];
|
|
398
|
+
}
|
|
399
|
+
return null;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Derive the top-level extension entry name for a resolved extension path,
|
|
403
|
+
* relative to its extensions root dir. Loose files map to their extension id
|
|
404
|
+
* without script suffix (e.g. "copy-turn.ts" -> "copy-turn"); package/dir extensions map to their containing
|
|
405
|
+
* entry dir (e.g. "pi-subagents"). Returns undefined if the path is not
|
|
406
|
+
* under the given root (e.g. a settings-listed absolute path elsewhere).
|
|
407
|
+
*/
|
|
408
|
+
export function extensionEntryName(extPath, extensionsRoot) {
|
|
409
|
+
const rel = relative(resolve(extensionsRoot), resolve(extPath));
|
|
410
|
+
if (rel.startsWith("..") || isAbsolute(rel))
|
|
411
|
+
return undefined;
|
|
412
|
+
const first = rel.split(sep)[0];
|
|
413
|
+
if (!first)
|
|
414
|
+
return undefined;
|
|
415
|
+
return first.endsWith(".ts") || first.endsWith(".js") ? first.slice(0, -3) : first;
|
|
416
|
+
}
|
|
417
|
+
function collectAutoExtensionEntries(dir) {
|
|
418
|
+
const entries = [];
|
|
419
|
+
if (!existsSync(dir))
|
|
420
|
+
return entries;
|
|
421
|
+
// First check if this directory itself has explicit extension entries (package.json or index)
|
|
422
|
+
const rootEntries = resolveExtensionEntries(dir);
|
|
423
|
+
if (rootEntries) {
|
|
424
|
+
return rootEntries;
|
|
425
|
+
}
|
|
426
|
+
// Otherwise, discover extensions from directory contents
|
|
427
|
+
const ig = ignore();
|
|
428
|
+
addIgnoreRules(ig, dir, dir);
|
|
429
|
+
try {
|
|
430
|
+
const dirEntries = readdirSync(dir, { withFileTypes: true });
|
|
431
|
+
for (const entry of dirEntries) {
|
|
432
|
+
if (entry.name.startsWith("."))
|
|
433
|
+
continue;
|
|
434
|
+
if (entry.name === "node_modules")
|
|
435
|
+
continue;
|
|
436
|
+
const fullPath = join(dir, entry.name);
|
|
437
|
+
let isDir = entry.isDirectory();
|
|
438
|
+
let isFile = entry.isFile();
|
|
439
|
+
if (entry.isSymbolicLink()) {
|
|
440
|
+
try {
|
|
441
|
+
const stats = statSync(fullPath);
|
|
442
|
+
isDir = stats.isDirectory();
|
|
443
|
+
isFile = stats.isFile();
|
|
444
|
+
}
|
|
445
|
+
catch {
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
const relPath = toPosixPath(relative(dir, fullPath));
|
|
450
|
+
const ignorePath = isDir ? `${relPath}/` : relPath;
|
|
451
|
+
if (ig.ignores(ignorePath))
|
|
452
|
+
continue;
|
|
453
|
+
if (isFile && (entry.name.endsWith(".ts") || entry.name.endsWith(".js"))) {
|
|
454
|
+
entries.push(fullPath);
|
|
455
|
+
}
|
|
456
|
+
else if (isDir) {
|
|
457
|
+
const resolvedEntries = resolveExtensionEntries(fullPath);
|
|
458
|
+
if (resolvedEntries) {
|
|
459
|
+
entries.push(...resolvedEntries);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
catch {
|
|
465
|
+
// Ignore errors
|
|
466
|
+
}
|
|
467
|
+
return entries;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Collect resource files from a directory based on resource type.
|
|
471
|
+
* Extensions use smart discovery (index.ts in subdirs), others use recursive collection.
|
|
472
|
+
*/
|
|
473
|
+
function collectResourceFiles(dir, resourceType) {
|
|
474
|
+
if (resourceType === "skills") {
|
|
475
|
+
return collectSkillEntries(dir, "pi");
|
|
476
|
+
}
|
|
477
|
+
if (resourceType === "extensions") {
|
|
478
|
+
return collectAutoExtensionEntries(dir);
|
|
479
|
+
}
|
|
480
|
+
return collectFiles(dir, FILE_PATTERNS[resourceType]);
|
|
481
|
+
}
|
|
482
|
+
function matchesAnyPattern(filePath, patterns, baseDir) {
|
|
483
|
+
const rel = toPosixPath(relative(baseDir, filePath));
|
|
484
|
+
const name = basename(filePath);
|
|
485
|
+
const filePathPosix = toPosixPath(filePath);
|
|
486
|
+
const isSkillFile = name === "SKILL.md";
|
|
487
|
+
const parentDir = isSkillFile ? dirname(filePath) : undefined;
|
|
488
|
+
const parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir)) : undefined;
|
|
489
|
+
const parentName = isSkillFile ? basename(parentDir) : undefined;
|
|
490
|
+
const parentDirPosix = isSkillFile ? toPosixPath(parentDir) : undefined;
|
|
491
|
+
return patterns.some((pattern) => {
|
|
492
|
+
const normalizedPattern = toPosixPath(pattern);
|
|
493
|
+
if (minimatch(rel, normalizedPattern) ||
|
|
494
|
+
minimatch(name, normalizedPattern) ||
|
|
495
|
+
minimatch(filePathPosix, normalizedPattern)) {
|
|
496
|
+
return true;
|
|
497
|
+
}
|
|
498
|
+
if (!isSkillFile)
|
|
499
|
+
return false;
|
|
500
|
+
return (minimatch(parentRel, normalizedPattern) ||
|
|
501
|
+
minimatch(parentName, normalizedPattern) ||
|
|
502
|
+
minimatch(parentDirPosix, normalizedPattern));
|
|
503
|
+
});
|
|
504
|
+
}
|
|
505
|
+
function normalizeExactPattern(pattern) {
|
|
506
|
+
const normalized = pattern.startsWith("./") || pattern.startsWith(".\\") ? pattern.slice(2) : pattern;
|
|
507
|
+
return toPosixPath(normalized);
|
|
508
|
+
}
|
|
509
|
+
function matchesAnyExactPattern(filePath, patterns, baseDir) {
|
|
510
|
+
if (patterns.length === 0)
|
|
511
|
+
return false;
|
|
512
|
+
const rel = toPosixPath(relative(baseDir, filePath));
|
|
513
|
+
const name = basename(filePath);
|
|
514
|
+
const filePathPosix = toPosixPath(filePath);
|
|
515
|
+
const isSkillFile = name === "SKILL.md";
|
|
516
|
+
const parentDir = isSkillFile ? dirname(filePath) : undefined;
|
|
517
|
+
const parentRel = isSkillFile ? toPosixPath(relative(baseDir, parentDir)) : undefined;
|
|
518
|
+
const parentDirPosix = isSkillFile ? toPosixPath(parentDir) : undefined;
|
|
519
|
+
return patterns.some((pattern) => {
|
|
520
|
+
const normalized = normalizeExactPattern(pattern);
|
|
521
|
+
if (normalized === rel || normalized === filePathPosix) {
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
if (!isSkillFile)
|
|
525
|
+
return false;
|
|
526
|
+
return normalized === parentRel || normalized === parentDirPosix;
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
function getOverridePatterns(entries) {
|
|
530
|
+
return entries.filter((pattern) => pattern.startsWith("!") || pattern.startsWith("+") || pattern.startsWith("-"));
|
|
531
|
+
}
|
|
532
|
+
export function isEnabledByOverrides(filePath, patterns, baseDir, defaultEnabled = true) {
|
|
533
|
+
const overrides = getOverridePatterns(patterns);
|
|
534
|
+
const excludes = overrides.filter((pattern) => pattern.startsWith("!")).map((pattern) => pattern.slice(1));
|
|
535
|
+
const forceIncludes = overrides.filter((pattern) => pattern.startsWith("+")).map((pattern) => pattern.slice(1));
|
|
536
|
+
const forceExcludes = overrides.filter((pattern) => pattern.startsWith("-")).map((pattern) => pattern.slice(1));
|
|
537
|
+
let enabled = defaultEnabled;
|
|
538
|
+
if (excludes.length > 0 && matchesAnyPattern(filePath, excludes, baseDir)) {
|
|
539
|
+
enabled = false;
|
|
540
|
+
}
|
|
541
|
+
if (forceIncludes.length > 0 && matchesAnyExactPattern(filePath, forceIncludes, baseDir)) {
|
|
542
|
+
enabled = true;
|
|
543
|
+
}
|
|
544
|
+
if (forceExcludes.length > 0 && matchesAnyExactPattern(filePath, forceExcludes, baseDir)) {
|
|
545
|
+
enabled = false;
|
|
546
|
+
}
|
|
547
|
+
return enabled;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Apply patterns to paths and return a Set of enabled paths.
|
|
551
|
+
* Pattern types:
|
|
552
|
+
* - Plain patterns: include matching paths
|
|
553
|
+
* - `!pattern`: exclude matching paths
|
|
554
|
+
* - `+path`: force-include exact path (overrides exclusions)
|
|
555
|
+
* - `-path`: force-exclude exact path (overrides force-includes)
|
|
556
|
+
*/
|
|
557
|
+
function applyPatterns(allPaths, patterns, baseDir) {
|
|
558
|
+
const includes = [];
|
|
559
|
+
const excludes = [];
|
|
560
|
+
const forceIncludes = [];
|
|
561
|
+
const forceExcludes = [];
|
|
562
|
+
for (const p of patterns) {
|
|
563
|
+
if (p.startsWith("+")) {
|
|
564
|
+
forceIncludes.push(p.slice(1));
|
|
565
|
+
}
|
|
566
|
+
else if (p.startsWith("-")) {
|
|
567
|
+
forceExcludes.push(p.slice(1));
|
|
568
|
+
}
|
|
569
|
+
else if (p.startsWith("!")) {
|
|
570
|
+
excludes.push(p.slice(1));
|
|
571
|
+
}
|
|
572
|
+
else {
|
|
573
|
+
includes.push(p);
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
// Step 1: Apply includes (or all if no includes)
|
|
577
|
+
let result;
|
|
578
|
+
if (includes.length === 0) {
|
|
579
|
+
result = [...allPaths];
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
result = allPaths.filter((filePath) => matchesAnyPattern(filePath, includes, baseDir));
|
|
583
|
+
}
|
|
584
|
+
// Step 2: Apply excludes
|
|
585
|
+
if (excludes.length > 0) {
|
|
586
|
+
result = result.filter((filePath) => !matchesAnyPattern(filePath, excludes, baseDir));
|
|
587
|
+
}
|
|
588
|
+
// Step 3: Force-include (add back from allPaths, overriding exclusions)
|
|
589
|
+
if (forceIncludes.length > 0) {
|
|
590
|
+
for (const filePath of allPaths) {
|
|
591
|
+
if (!result.includes(filePath) && matchesAnyExactPattern(filePath, forceIncludes, baseDir)) {
|
|
592
|
+
result.push(filePath);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
// Step 4: Force-exclude (remove even if included or force-included)
|
|
597
|
+
if (forceExcludes.length > 0) {
|
|
598
|
+
result = result.filter((filePath) => !matchesAnyExactPattern(filePath, forceExcludes, baseDir));
|
|
599
|
+
}
|
|
600
|
+
return new Set(result);
|
|
601
|
+
}
|
|
602
|
+
function applyAutoloadDisabledPatterns(allPaths, patterns, baseDir) {
|
|
603
|
+
const result = new Map();
|
|
604
|
+
for (const pattern of patterns) {
|
|
605
|
+
const target = pattern.slice(pattern.startsWith("+") || pattern.startsWith("-") || pattern.startsWith("!") ? 1 : 0);
|
|
606
|
+
const enabled = !pattern.startsWith("-") && !pattern.startsWith("!");
|
|
607
|
+
const exact = pattern.startsWith("+") || pattern.startsWith("-");
|
|
608
|
+
for (const filePath of allPaths) {
|
|
609
|
+
if (exact ? matchesAnyExactPattern(filePath, [target], baseDir) : matchesAnyPattern(filePath, [target], baseDir)) {
|
|
610
|
+
result.set(filePath, enabled);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return result;
|
|
615
|
+
}
|
|
616
|
+
export class DefaultPackageManager {
|
|
617
|
+
cwd;
|
|
618
|
+
agentDir;
|
|
619
|
+
settingsManager;
|
|
620
|
+
globalNpmRoot;
|
|
621
|
+
globalNpmRootCommandKey;
|
|
622
|
+
progressCallback;
|
|
623
|
+
constructor(options) {
|
|
624
|
+
this.cwd = resolvePath(options.cwd);
|
|
625
|
+
this.agentDir = resolvePath(options.agentDir);
|
|
626
|
+
this.settingsManager = options.settingsManager;
|
|
627
|
+
}
|
|
628
|
+
setProgressCallback(callback) {
|
|
629
|
+
this.progressCallback = callback;
|
|
630
|
+
}
|
|
631
|
+
addSourceToSettings(source, options) {
|
|
632
|
+
const scope = options?.local ? "project" : "user";
|
|
633
|
+
const currentSettings = scope === "project" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();
|
|
634
|
+
const currentPackages = currentSettings.packages ?? [];
|
|
635
|
+
const normalizedSource = this.normalizePackageSourceForSettings(source, scope);
|
|
636
|
+
const matchIndex = currentPackages.findIndex((existing) => this.packageSourcesMatch(existing, source, scope));
|
|
637
|
+
if (matchIndex !== -1) {
|
|
638
|
+
const existing = currentPackages[matchIndex];
|
|
639
|
+
if (this.getPackageSourceString(existing) === normalizedSource) {
|
|
640
|
+
return false;
|
|
641
|
+
}
|
|
642
|
+
const nextPackages = [...currentPackages];
|
|
643
|
+
nextPackages[matchIndex] =
|
|
644
|
+
typeof existing === "string" ? normalizedSource : { ...existing, source: normalizedSource };
|
|
645
|
+
if (scope === "project") {
|
|
646
|
+
this.settingsManager.setProjectPackages(nextPackages);
|
|
647
|
+
}
|
|
648
|
+
else {
|
|
649
|
+
this.settingsManager.setPackages(nextPackages);
|
|
650
|
+
}
|
|
651
|
+
return true;
|
|
652
|
+
}
|
|
653
|
+
const nextPackages = [...currentPackages, normalizedSource];
|
|
654
|
+
if (scope === "project") {
|
|
655
|
+
this.settingsManager.setProjectPackages(nextPackages);
|
|
656
|
+
}
|
|
657
|
+
else {
|
|
658
|
+
this.settingsManager.setPackages(nextPackages);
|
|
659
|
+
}
|
|
660
|
+
return true;
|
|
661
|
+
}
|
|
662
|
+
removeSourceFromSettings(source, options) {
|
|
663
|
+
const scope = options?.local ? "project" : "user";
|
|
664
|
+
const currentSettings = scope === "project" ? this.settingsManager.getProjectSettings() : this.settingsManager.getGlobalSettings();
|
|
665
|
+
const currentPackages = currentSettings.packages ?? [];
|
|
666
|
+
const nextPackages = currentPackages.filter((existing) => !this.packageSourcesMatch(existing, source, scope));
|
|
667
|
+
const changed = nextPackages.length !== currentPackages.length;
|
|
668
|
+
if (!changed) {
|
|
669
|
+
return false;
|
|
670
|
+
}
|
|
671
|
+
if (scope === "project") {
|
|
672
|
+
this.settingsManager.setProjectPackages(nextPackages);
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
this.settingsManager.setPackages(nextPackages);
|
|
676
|
+
}
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
679
|
+
getInstalledPath(source, scope) {
|
|
680
|
+
const parsed = this.parseSource(source);
|
|
681
|
+
if (parsed.type === "npm") {
|
|
682
|
+
const path = this.getNpmInstallPath(parsed, scope);
|
|
683
|
+
return existsSync(path) ? path : undefined;
|
|
684
|
+
}
|
|
685
|
+
if (parsed.type === "git") {
|
|
686
|
+
const path = this.getGitInstallPath(parsed, scope);
|
|
687
|
+
return existsSync(path) ? path : undefined;
|
|
688
|
+
}
|
|
689
|
+
if (parsed.type === "local") {
|
|
690
|
+
const baseDir = this.getBaseDirForScope(scope);
|
|
691
|
+
const path = this.resolvePathFromBase(parsed.path, baseDir);
|
|
692
|
+
return existsSync(path) ? path : undefined;
|
|
693
|
+
}
|
|
694
|
+
return undefined;
|
|
695
|
+
}
|
|
696
|
+
emitProgress(event) {
|
|
697
|
+
this.progressCallback?.(event);
|
|
698
|
+
}
|
|
699
|
+
async withProgress(action, source, message, operation) {
|
|
700
|
+
this.emitProgress({ type: "start", action, source, message });
|
|
701
|
+
try {
|
|
702
|
+
await operation();
|
|
703
|
+
this.emitProgress({ type: "complete", action, source });
|
|
704
|
+
}
|
|
705
|
+
catch (error) {
|
|
706
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
707
|
+
this.emitProgress({ type: "error", action, source, message: errorMessage });
|
|
708
|
+
throw error;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
async resolve(onMissing) {
|
|
712
|
+
const accumulator = this.createAccumulator();
|
|
713
|
+
const globalSettings = this.settingsManager.getGlobalSettings();
|
|
714
|
+
const projectSettings = this.settingsManager.getProjectSettings();
|
|
715
|
+
// Collect all packages with scope (project first so cwd resources win collisions)
|
|
716
|
+
const allPackages = [];
|
|
717
|
+
for (const pkg of projectSettings.packages ?? []) {
|
|
718
|
+
allPackages.push({ pkg, scope: "project" });
|
|
719
|
+
}
|
|
720
|
+
for (const pkg of globalSettings.packages ?? []) {
|
|
721
|
+
allPackages.push({ pkg, scope: "user" });
|
|
722
|
+
}
|
|
723
|
+
// Dedupe: project scope wins over global for same package identity
|
|
724
|
+
const packageSources = this.dedupePackages(allPackages);
|
|
725
|
+
await this.resolvePackageSources(packageSources, accumulator, onMissing);
|
|
726
|
+
const globalBaseDir = this.agentDir;
|
|
727
|
+
const projectBaseDir = join(this.cwd, CONFIG_DIR_NAME);
|
|
728
|
+
for (const resourceType of RESOURCE_TYPES) {
|
|
729
|
+
const target = this.getTargetMap(accumulator, resourceType);
|
|
730
|
+
const globalEntries = (globalSettings[resourceType] ?? []);
|
|
731
|
+
const projectEntries = (projectSettings[resourceType] ?? []);
|
|
732
|
+
this.resolveLocalEntries(projectEntries, resourceType, target, {
|
|
733
|
+
source: "local",
|
|
734
|
+
scope: "project",
|
|
735
|
+
origin: "top-level",
|
|
736
|
+
}, projectBaseDir);
|
|
737
|
+
this.resolveLocalEntries(globalEntries, resourceType, target, {
|
|
738
|
+
source: "local",
|
|
739
|
+
scope: "user",
|
|
740
|
+
origin: "top-level",
|
|
741
|
+
}, globalBaseDir);
|
|
742
|
+
}
|
|
743
|
+
const collisions = this.addAutoDiscoveredResources(accumulator, globalSettings, projectSettings, globalBaseDir, projectBaseDir);
|
|
744
|
+
return this.toResolvedPaths(accumulator, collisions);
|
|
745
|
+
}
|
|
746
|
+
async resolveExtensionSources(sources, options) {
|
|
747
|
+
const accumulator = this.createAccumulator();
|
|
748
|
+
const scope = options?.temporary ? "temporary" : options?.local ? "project" : "user";
|
|
749
|
+
const packageSources = sources.map((source) => ({ pkg: source, scope }));
|
|
750
|
+
await this.resolvePackageSources(packageSources, accumulator);
|
|
751
|
+
return this.toResolvedPaths(accumulator, []);
|
|
752
|
+
}
|
|
753
|
+
listConfiguredPackages() {
|
|
754
|
+
const globalSettings = this.settingsManager.getGlobalSettings();
|
|
755
|
+
const projectSettings = this.settingsManager.getProjectSettings();
|
|
756
|
+
const configuredPackages = [];
|
|
757
|
+
for (const pkg of globalSettings.packages ?? []) {
|
|
758
|
+
const source = typeof pkg === "string" ? pkg : pkg.source;
|
|
759
|
+
configuredPackages.push({
|
|
760
|
+
source,
|
|
761
|
+
scope: "user",
|
|
762
|
+
filtered: typeof pkg === "object",
|
|
763
|
+
installedPath: this.getInstalledPath(source, "user"),
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
for (const pkg of projectSettings.packages ?? []) {
|
|
767
|
+
const source = typeof pkg === "string" ? pkg : pkg.source;
|
|
768
|
+
configuredPackages.push({
|
|
769
|
+
source,
|
|
770
|
+
scope: "project",
|
|
771
|
+
filtered: typeof pkg === "object",
|
|
772
|
+
installedPath: this.getInstalledPath(source, "project"),
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
return configuredPackages;
|
|
776
|
+
}
|
|
777
|
+
async install(source, options) {
|
|
778
|
+
const parsed = this.parseSource(source);
|
|
779
|
+
const scope = options?.local ? "project" : "user";
|
|
780
|
+
this.assertProjectTrustedForScope(scope);
|
|
781
|
+
await this.withProgress("install", source, `Installing ${source}...`, async () => {
|
|
782
|
+
if (parsed.type === "npm") {
|
|
783
|
+
await this.installNpm(parsed, scope, false);
|
|
784
|
+
return;
|
|
785
|
+
}
|
|
786
|
+
if (parsed.type === "git") {
|
|
787
|
+
await this.installGit(parsed, scope);
|
|
788
|
+
return;
|
|
789
|
+
}
|
|
790
|
+
if (parsed.type === "local") {
|
|
791
|
+
const resolved = this.resolvePath(parsed.path);
|
|
792
|
+
if (!existsSync(resolved)) {
|
|
793
|
+
throw new Error(`Path does not exist: ${resolved}`);
|
|
794
|
+
}
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
throw new Error(`Unsupported install source: ${source}`);
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
async installAndPersist(source, options) {
|
|
801
|
+
await this.install(source, options);
|
|
802
|
+
this.addSourceToSettings(source, options);
|
|
803
|
+
}
|
|
804
|
+
async remove(source, options) {
|
|
805
|
+
const parsed = this.parseSource(source);
|
|
806
|
+
const scope = options?.local ? "project" : "user";
|
|
807
|
+
this.assertProjectTrustedForScope(scope);
|
|
808
|
+
await this.withProgress("remove", source, `Removing ${source}...`, async () => {
|
|
809
|
+
if (parsed.type === "npm") {
|
|
810
|
+
await this.uninstallNpm(parsed, scope);
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
if (parsed.type === "git") {
|
|
814
|
+
await this.removeGit(parsed, scope);
|
|
815
|
+
return;
|
|
816
|
+
}
|
|
817
|
+
if (parsed.type === "local") {
|
|
818
|
+
return;
|
|
819
|
+
}
|
|
820
|
+
throw new Error(`Unsupported remove source: ${source}`);
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
async removeAndPersist(source, options) {
|
|
824
|
+
await this.remove(source, options);
|
|
825
|
+
return this.removeSourceFromSettings(source, options);
|
|
826
|
+
}
|
|
827
|
+
async update(source) {
|
|
828
|
+
const globalSettings = this.settingsManager.getGlobalSettings();
|
|
829
|
+
const projectSettings = this.settingsManager.getProjectSettings();
|
|
830
|
+
const identity = source ? this.getPackageIdentity(source) : undefined;
|
|
831
|
+
let matched = false;
|
|
832
|
+
const updateSources = [];
|
|
833
|
+
for (const pkg of globalSettings.packages ?? []) {
|
|
834
|
+
const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
|
|
835
|
+
if (identity && this.getPackageIdentity(sourceStr, "user") !== identity)
|
|
836
|
+
continue;
|
|
837
|
+
matched = true;
|
|
838
|
+
updateSources.push({ source: sourceStr, scope: "user" });
|
|
839
|
+
}
|
|
840
|
+
for (const pkg of projectSettings.packages ?? []) {
|
|
841
|
+
const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
|
|
842
|
+
if (identity && this.getPackageIdentity(sourceStr, "project") !== identity)
|
|
843
|
+
continue;
|
|
844
|
+
matched = true;
|
|
845
|
+
updateSources.push({ source: sourceStr, scope: "project" });
|
|
846
|
+
}
|
|
847
|
+
if (source && !matched) {
|
|
848
|
+
throw new Error(this.buildNoMatchingPackageMessage(source, [
|
|
849
|
+
...(globalSettings.packages ?? []),
|
|
850
|
+
...(projectSettings.packages ?? []),
|
|
851
|
+
]));
|
|
852
|
+
}
|
|
853
|
+
await this.updateConfiguredSources(updateSources);
|
|
854
|
+
}
|
|
855
|
+
async updateConfiguredSources(sources) {
|
|
856
|
+
if (isOfflineModeEnabled() || sources.length === 0) {
|
|
857
|
+
return;
|
|
858
|
+
}
|
|
859
|
+
const npmCandidates = [];
|
|
860
|
+
const gitCandidates = [];
|
|
861
|
+
for (const entry of sources) {
|
|
862
|
+
const parsed = this.parseSource(entry.source);
|
|
863
|
+
// Pinned npm versions are fixed. Pinned git refs are configured checkout targets,
|
|
864
|
+
// so include them to reconcile an existing clone when the configured ref changes.
|
|
865
|
+
if (parsed.type === "npm") {
|
|
866
|
+
if (!parsed.pinned) {
|
|
867
|
+
npmCandidates.push({ ...entry, parsed });
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
else if (parsed.type === "git") {
|
|
871
|
+
gitCandidates.push({ ...entry, parsed });
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
const npmCheckTasks = npmCandidates.map((entry) => async () => ({
|
|
875
|
+
entry,
|
|
876
|
+
shouldUpdate: await this.shouldUpdateNpmSource(entry.parsed, entry.scope),
|
|
877
|
+
}));
|
|
878
|
+
const npmCheckResults = await this.runWithConcurrency(npmCheckTasks, UPDATE_CHECK_CONCURRENCY);
|
|
879
|
+
const userNpmUpdates = [];
|
|
880
|
+
const projectNpmUpdates = [];
|
|
881
|
+
for (const result of npmCheckResults) {
|
|
882
|
+
if (!result.shouldUpdate) {
|
|
883
|
+
continue;
|
|
884
|
+
}
|
|
885
|
+
if (result.entry.scope === "user") {
|
|
886
|
+
userNpmUpdates.push(result.entry);
|
|
887
|
+
}
|
|
888
|
+
else {
|
|
889
|
+
projectNpmUpdates.push(result.entry);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
const tasks = [];
|
|
893
|
+
if (userNpmUpdates.length > 0) {
|
|
894
|
+
tasks.push(this.updateNpmBatch(userNpmUpdates, "user"));
|
|
895
|
+
}
|
|
896
|
+
if (projectNpmUpdates.length > 0) {
|
|
897
|
+
tasks.push(this.updateNpmBatch(projectNpmUpdates, "project"));
|
|
898
|
+
}
|
|
899
|
+
if (gitCandidates.length > 0) {
|
|
900
|
+
const gitTasks = gitCandidates.map((entry) => async () => this.withProgress("update", entry.source, `Updating ${entry.source}...`, async () => {
|
|
901
|
+
await this.updateGit(entry.parsed, entry.scope);
|
|
902
|
+
}));
|
|
903
|
+
tasks.push(this.runWithConcurrency(gitTasks, GIT_UPDATE_CONCURRENCY).then(() => { }));
|
|
904
|
+
}
|
|
905
|
+
await Promise.all(tasks);
|
|
906
|
+
}
|
|
907
|
+
async shouldUpdateNpmSource(source, scope) {
|
|
908
|
+
const installedPath = this.getManagedNpmInstallPath(source, scope);
|
|
909
|
+
const installedVersion = existsSync(installedPath) ? this.getInstalledNpmVersion(installedPath) : undefined;
|
|
910
|
+
if (!installedVersion) {
|
|
911
|
+
return true;
|
|
912
|
+
}
|
|
913
|
+
try {
|
|
914
|
+
const targetVersion = await this.getLatestNpmVersion(source.version ? source.spec : source.name, source.range);
|
|
915
|
+
return targetVersion !== installedVersion;
|
|
916
|
+
}
|
|
917
|
+
catch {
|
|
918
|
+
// Preserve existing update behavior when version lookup fails.
|
|
919
|
+
return true;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
async updateNpmBatch(sources, scope) {
|
|
923
|
+
if (sources.length === 0) {
|
|
924
|
+
return;
|
|
925
|
+
}
|
|
926
|
+
const sourceLabel = sources.length === 1 ? sources[0].source : `${scope} npm packages`;
|
|
927
|
+
const message = sources.length === 1 ? `Updating ${sources[0].source}...` : `Updating ${scope} npm packages...`;
|
|
928
|
+
const specs = sources.map((entry) => (entry.parsed.version ? entry.parsed.spec : `${entry.parsed.name}@latest`));
|
|
929
|
+
await this.withProgress("update", sourceLabel, message, async () => {
|
|
930
|
+
await this.installNpmBatch(specs, scope);
|
|
931
|
+
});
|
|
932
|
+
}
|
|
933
|
+
async installNpmBatch(specs, scope) {
|
|
934
|
+
const installRoot = this.getNpmInstallRoot(scope, false);
|
|
935
|
+
this.ensureNpmProject(installRoot);
|
|
936
|
+
await this.runNpmCommand(this.getNpmInstallArgs(specs, installRoot));
|
|
937
|
+
}
|
|
938
|
+
async checkForAvailableUpdates() {
|
|
939
|
+
if (isOfflineModeEnabled()) {
|
|
940
|
+
return [];
|
|
941
|
+
}
|
|
942
|
+
const globalSettings = this.settingsManager.getGlobalSettings();
|
|
943
|
+
const projectSettings = this.settingsManager.getProjectSettings();
|
|
944
|
+
const allPackages = [];
|
|
945
|
+
for (const pkg of projectSettings.packages ?? []) {
|
|
946
|
+
allPackages.push({ pkg, scope: "project" });
|
|
947
|
+
}
|
|
948
|
+
for (const pkg of globalSettings.packages ?? []) {
|
|
949
|
+
allPackages.push({ pkg, scope: "user" });
|
|
950
|
+
}
|
|
951
|
+
const packageSources = this.dedupePackages(allPackages);
|
|
952
|
+
const checks = packageSources
|
|
953
|
+
.filter((entry) => entry.scope !== "temporary")
|
|
954
|
+
.map((entry) => async () => {
|
|
955
|
+
const source = typeof entry.pkg === "string" ? entry.pkg : entry.pkg.source;
|
|
956
|
+
const parsed = this.parseSource(source);
|
|
957
|
+
if (parsed.type === "local" || parsed.pinned) {
|
|
958
|
+
return undefined;
|
|
959
|
+
}
|
|
960
|
+
if (parsed.type === "npm") {
|
|
961
|
+
const installedPath = this.getNpmInstallPath(parsed, entry.scope);
|
|
962
|
+
if (!existsSync(installedPath)) {
|
|
963
|
+
return undefined;
|
|
964
|
+
}
|
|
965
|
+
const hasUpdate = await this.npmHasAvailableUpdate(parsed, installedPath);
|
|
966
|
+
if (!hasUpdate) {
|
|
967
|
+
return undefined;
|
|
968
|
+
}
|
|
969
|
+
return {
|
|
970
|
+
source,
|
|
971
|
+
displayName: parsed.name,
|
|
972
|
+
type: "npm",
|
|
973
|
+
scope: entry.scope,
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
const installedPath = this.getGitInstallPath(parsed, entry.scope);
|
|
977
|
+
if (!existsSync(installedPath)) {
|
|
978
|
+
return undefined;
|
|
979
|
+
}
|
|
980
|
+
const hasUpdate = await this.gitHasAvailableUpdate(installedPath);
|
|
981
|
+
if (!hasUpdate) {
|
|
982
|
+
return undefined;
|
|
983
|
+
}
|
|
984
|
+
return {
|
|
985
|
+
source,
|
|
986
|
+
displayName: `${parsed.host}/${parsed.path}`,
|
|
987
|
+
type: "git",
|
|
988
|
+
scope: entry.scope,
|
|
989
|
+
};
|
|
990
|
+
});
|
|
991
|
+
const results = await this.runWithConcurrency(checks, UPDATE_CHECK_CONCURRENCY);
|
|
992
|
+
return results.filter((result) => result !== undefined);
|
|
993
|
+
}
|
|
994
|
+
async resolvePackageSources(sources, accumulator, onMissing) {
|
|
995
|
+
for (const { pkg, scope } of sources) {
|
|
996
|
+
const sourceStr = typeof pkg === "string" ? pkg : pkg.source;
|
|
997
|
+
const filter = typeof pkg === "object" ? pkg : undefined;
|
|
998
|
+
const deltaBase = this.findAutoloadDeltaBase(pkg, scope, sources);
|
|
999
|
+
const resolvedSource = deltaBase?.source ?? sourceStr;
|
|
1000
|
+
const resolvedScope = deltaBase?.scope ?? scope;
|
|
1001
|
+
const parsed = this.parseSource(resolvedSource);
|
|
1002
|
+
const metadata = { source: sourceStr, scope, origin: "package" };
|
|
1003
|
+
if (parsed.type === "local") {
|
|
1004
|
+
const baseDir = this.getBaseDirForScope(resolvedScope);
|
|
1005
|
+
this.resolveLocalExtensionSource(parsed, accumulator, filter, metadata, baseDir);
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
const installMissing = async () => {
|
|
1009
|
+
if (isOfflineModeEnabled())
|
|
1010
|
+
return false;
|
|
1011
|
+
if (!onMissing) {
|
|
1012
|
+
await this.installParsedSource(parsed, resolvedScope);
|
|
1013
|
+
return true;
|
|
1014
|
+
}
|
|
1015
|
+
const action = await onMissing(resolvedSource);
|
|
1016
|
+
if (action === "skip")
|
|
1017
|
+
return false;
|
|
1018
|
+
if (action === "error")
|
|
1019
|
+
throw new Error(`Missing source: ${resolvedSource}`);
|
|
1020
|
+
await this.installParsedSource(parsed, resolvedScope);
|
|
1021
|
+
return true;
|
|
1022
|
+
};
|
|
1023
|
+
if (parsed.type === "npm") {
|
|
1024
|
+
let installedPath = this.getNpmInstallPath(parsed, resolvedScope);
|
|
1025
|
+
const needsInstall = !existsSync(installedPath) || !(await this.installedNpmMatchesConfiguredVersion(parsed, installedPath));
|
|
1026
|
+
if (needsInstall) {
|
|
1027
|
+
const installed = await installMissing();
|
|
1028
|
+
if (!installed)
|
|
1029
|
+
continue;
|
|
1030
|
+
installedPath = this.getNpmInstallPath(parsed, resolvedScope);
|
|
1031
|
+
}
|
|
1032
|
+
metadata.baseDir = installedPath;
|
|
1033
|
+
this.collectPackageResources(installedPath, accumulator, filter, metadata);
|
|
1034
|
+
continue;
|
|
1035
|
+
}
|
|
1036
|
+
if (parsed.type === "git") {
|
|
1037
|
+
const installedPath = this.getGitInstallPath(parsed, resolvedScope);
|
|
1038
|
+
if (!existsSync(installedPath)) {
|
|
1039
|
+
const installed = await installMissing();
|
|
1040
|
+
if (!installed)
|
|
1041
|
+
continue;
|
|
1042
|
+
}
|
|
1043
|
+
else if (resolvedScope === "temporary" && !parsed.pinned && !isOfflineModeEnabled()) {
|
|
1044
|
+
await this.refreshTemporaryGitSource(parsed, resolvedSource);
|
|
1045
|
+
}
|
|
1046
|
+
metadata.baseDir = installedPath;
|
|
1047
|
+
this.collectPackageResources(installedPath, accumulator, filter, metadata);
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
}
|
|
1051
|
+
findAutoloadDeltaBase(pkg, scope, sources) {
|
|
1052
|
+
if (scope !== "project" || typeof pkg !== "object" || pkg.autoload !== false)
|
|
1053
|
+
return undefined;
|
|
1054
|
+
const identity = this.getPackageIdentity(pkg.source, scope);
|
|
1055
|
+
const userEntry = sources.find((entry) => entry.scope === "user" &&
|
|
1056
|
+
this.getPackageIdentity(this.getPackageSourceString(entry.pkg), "user") === identity);
|
|
1057
|
+
return userEntry ? { source: this.getPackageSourceString(userEntry.pkg), scope: "user" } : undefined;
|
|
1058
|
+
}
|
|
1059
|
+
resolveLocalExtensionSource(source, accumulator, filter, metadata, baseDir) {
|
|
1060
|
+
const resolved = this.resolvePathFromBase(source.path, baseDir);
|
|
1061
|
+
if (!existsSync(resolved)) {
|
|
1062
|
+
return;
|
|
1063
|
+
}
|
|
1064
|
+
try {
|
|
1065
|
+
const stats = statSync(resolved);
|
|
1066
|
+
if (stats.isFile()) {
|
|
1067
|
+
metadata.baseDir = dirname(resolved);
|
|
1068
|
+
this.addResource(accumulator.extensions, resolved, metadata, true);
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
if (stats.isDirectory()) {
|
|
1072
|
+
metadata.baseDir = resolved;
|
|
1073
|
+
const resources = this.collectPackageResources(resolved, accumulator, filter, metadata);
|
|
1074
|
+
if (!resources) {
|
|
1075
|
+
this.addResource(accumulator.extensions, resolved, metadata, true);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
}
|
|
1079
|
+
catch {
|
|
1080
|
+
return;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
async installParsedSource(parsed, scope) {
|
|
1084
|
+
if (parsed.type === "npm") {
|
|
1085
|
+
await this.installNpm(parsed, scope, scope === "temporary");
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
if (parsed.type === "git") {
|
|
1089
|
+
await this.installGit(parsed, scope);
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
getPackageSourceString(pkg) {
|
|
1094
|
+
return typeof pkg === "string" ? pkg : pkg.source;
|
|
1095
|
+
}
|
|
1096
|
+
getSourceMatchKeyForInput(source) {
|
|
1097
|
+
const parsed = this.parseSource(source);
|
|
1098
|
+
if (parsed.type === "npm") {
|
|
1099
|
+
return `npm:${parsed.name}`;
|
|
1100
|
+
}
|
|
1101
|
+
if (parsed.type === "git") {
|
|
1102
|
+
return `git:${parsed.host}/${parsed.path}`;
|
|
1103
|
+
}
|
|
1104
|
+
return `local:${this.resolvePath(parsed.path)}`;
|
|
1105
|
+
}
|
|
1106
|
+
getSourceMatchKeyForSettings(source, scope) {
|
|
1107
|
+
const parsed = this.parseSource(source);
|
|
1108
|
+
if (parsed.type === "npm") {
|
|
1109
|
+
return `npm:${parsed.name}`;
|
|
1110
|
+
}
|
|
1111
|
+
if (parsed.type === "git") {
|
|
1112
|
+
return `git:${parsed.host}/${parsed.path}`;
|
|
1113
|
+
}
|
|
1114
|
+
const baseDir = this.getBaseDirForScope(scope);
|
|
1115
|
+
return `local:${this.resolvePathFromBase(parsed.path, baseDir)}`;
|
|
1116
|
+
}
|
|
1117
|
+
buildNoMatchingPackageMessage(source, configuredPackages) {
|
|
1118
|
+
const suggestion = this.findSuggestedConfiguredSource(source, configuredPackages);
|
|
1119
|
+
if (!suggestion) {
|
|
1120
|
+
return `No matching package found for ${source}`;
|
|
1121
|
+
}
|
|
1122
|
+
return `No matching package found for ${source}. Did you mean ${suggestion}?`;
|
|
1123
|
+
}
|
|
1124
|
+
findSuggestedConfiguredSource(source, configuredPackages) {
|
|
1125
|
+
const trimmedSource = source.trim();
|
|
1126
|
+
const suggestions = new Set();
|
|
1127
|
+
for (const pkg of configuredPackages) {
|
|
1128
|
+
const sourceStr = this.getPackageSourceString(pkg);
|
|
1129
|
+
const parsed = this.parseSource(sourceStr);
|
|
1130
|
+
if (parsed.type === "npm") {
|
|
1131
|
+
if (trimmedSource === parsed.name || trimmedSource === parsed.spec) {
|
|
1132
|
+
suggestions.add(sourceStr);
|
|
1133
|
+
}
|
|
1134
|
+
continue;
|
|
1135
|
+
}
|
|
1136
|
+
if (parsed.type === "git") {
|
|
1137
|
+
const shorthand = `${parsed.host}/${parsed.path}`;
|
|
1138
|
+
const shorthandWithRef = parsed.ref ? `${shorthand}@${parsed.ref}` : undefined;
|
|
1139
|
+
if (trimmedSource === shorthand || (shorthandWithRef && trimmedSource === shorthandWithRef)) {
|
|
1140
|
+
suggestions.add(sourceStr);
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
return suggestions.values().next().value;
|
|
1145
|
+
}
|
|
1146
|
+
packageSourcesMatch(existing, inputSource, scope) {
|
|
1147
|
+
const left = this.getSourceMatchKeyForSettings(this.getPackageSourceString(existing), scope);
|
|
1148
|
+
const right = this.getSourceMatchKeyForInput(inputSource);
|
|
1149
|
+
return left === right;
|
|
1150
|
+
}
|
|
1151
|
+
normalizePackageSourceForSettings(source, scope) {
|
|
1152
|
+
const parsed = this.parseSource(source);
|
|
1153
|
+
if (parsed.type !== "local") {
|
|
1154
|
+
return source;
|
|
1155
|
+
}
|
|
1156
|
+
const baseDir = this.getBaseDirForScope(scope);
|
|
1157
|
+
const resolved = this.resolvePath(parsed.path);
|
|
1158
|
+
const rel = relative(baseDir, resolved);
|
|
1159
|
+
return rel || ".";
|
|
1160
|
+
}
|
|
1161
|
+
parseSource(source) {
|
|
1162
|
+
if (source.startsWith("npm:")) {
|
|
1163
|
+
const spec = source.slice("npm:".length).trim();
|
|
1164
|
+
const { name, version } = this.parseNpmSpec(spec);
|
|
1165
|
+
return {
|
|
1166
|
+
type: "npm",
|
|
1167
|
+
spec,
|
|
1168
|
+
name,
|
|
1169
|
+
version,
|
|
1170
|
+
range: getNpmVersionRange(version),
|
|
1171
|
+
pinned: isExactNpmVersion(version),
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
if (isLocalPath(source)) {
|
|
1175
|
+
return { type: "local", path: source };
|
|
1176
|
+
}
|
|
1177
|
+
// Try parsing as git URL
|
|
1178
|
+
const gitParsed = parseGitUrl(source);
|
|
1179
|
+
if (gitParsed) {
|
|
1180
|
+
return gitParsed;
|
|
1181
|
+
}
|
|
1182
|
+
return { type: "local", path: source };
|
|
1183
|
+
}
|
|
1184
|
+
async installedNpmMatchesConfiguredVersion(source, installedPath) {
|
|
1185
|
+
const installedVersion = this.getInstalledNpmVersion(installedPath);
|
|
1186
|
+
if (!installedVersion) {
|
|
1187
|
+
return false;
|
|
1188
|
+
}
|
|
1189
|
+
return source.range ? satisfies(installedVersion, source.range) : true;
|
|
1190
|
+
}
|
|
1191
|
+
async npmHasAvailableUpdate(source, installedPath) {
|
|
1192
|
+
if (isOfflineModeEnabled()) {
|
|
1193
|
+
return false;
|
|
1194
|
+
}
|
|
1195
|
+
const installedVersion = this.getInstalledNpmVersion(installedPath);
|
|
1196
|
+
if (!installedVersion) {
|
|
1197
|
+
return false;
|
|
1198
|
+
}
|
|
1199
|
+
try {
|
|
1200
|
+
const targetVersion = await this.getLatestNpmVersion(source.version ? source.spec : source.name, source.range);
|
|
1201
|
+
return targetVersion !== installedVersion;
|
|
1202
|
+
}
|
|
1203
|
+
catch {
|
|
1204
|
+
return false;
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
getInstalledNpmVersion(installedPath) {
|
|
1208
|
+
const packageJsonPath = join(installedPath, "package.json");
|
|
1209
|
+
if (!existsSync(packageJsonPath))
|
|
1210
|
+
return undefined;
|
|
1211
|
+
try {
|
|
1212
|
+
const content = readFileSync(packageJsonPath, "utf-8");
|
|
1213
|
+
const pkg = JSON.parse(content);
|
|
1214
|
+
return pkg.version;
|
|
1215
|
+
}
|
|
1216
|
+
catch {
|
|
1217
|
+
return undefined;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
async getLatestNpmVersion(packageSpec, range) {
|
|
1221
|
+
const npmCommand = this.getNpmCommand();
|
|
1222
|
+
const stdout = await this.runCommandCapture(npmCommand.command, [...npmCommand.args, "view", packageSpec, "version", "--json"], { cwd: this.cwd, timeoutMs: NETWORK_TIMEOUT_MS });
|
|
1223
|
+
const raw = stdout.trim();
|
|
1224
|
+
if (!raw)
|
|
1225
|
+
throw new Error("Empty response from npm view");
|
|
1226
|
+
const parsed = JSON.parse(raw);
|
|
1227
|
+
if (typeof parsed === "string") {
|
|
1228
|
+
return parsed;
|
|
1229
|
+
}
|
|
1230
|
+
if (Array.isArray(parsed)) {
|
|
1231
|
+
const versions = parsed.filter((value) => typeof value === "string" && value.length > 0);
|
|
1232
|
+
const latest = range ? maxSatisfying(versions, range) : [...versions].sort(rcompare)[0];
|
|
1233
|
+
if (latest)
|
|
1234
|
+
return latest;
|
|
1235
|
+
}
|
|
1236
|
+
throw new Error("Unexpected response from npm view");
|
|
1237
|
+
}
|
|
1238
|
+
async gitHasAvailableUpdate(installedPath) {
|
|
1239
|
+
if (isOfflineModeEnabled()) {
|
|
1240
|
+
return false;
|
|
1241
|
+
}
|
|
1242
|
+
try {
|
|
1243
|
+
const localHead = await this.runCommandCapture("git", ["rev-parse", "HEAD"], {
|
|
1244
|
+
cwd: installedPath,
|
|
1245
|
+
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1246
|
+
});
|
|
1247
|
+
const remoteHead = await this.getRemoteGitHead(installedPath);
|
|
1248
|
+
return localHead.trim() !== remoteHead.trim();
|
|
1249
|
+
}
|
|
1250
|
+
catch {
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
async getRemoteGitHead(installedPath) {
|
|
1255
|
+
const upstreamRef = await this.getGitUpstreamRef(installedPath);
|
|
1256
|
+
if (upstreamRef) {
|
|
1257
|
+
const remoteHead = await this.runGitRemoteCommand(installedPath, ["ls-remote", "origin", upstreamRef]);
|
|
1258
|
+
const match = remoteHead.match(/^([0-9a-f]{40})\s+/m);
|
|
1259
|
+
if (match?.[1]) {
|
|
1260
|
+
return match[1];
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1263
|
+
const remoteHead = await this.runGitRemoteCommand(installedPath, ["ls-remote", "origin", "HEAD"]);
|
|
1264
|
+
const match = remoteHead.match(/^([0-9a-f]{40})\s+HEAD$/m);
|
|
1265
|
+
if (!match?.[1]) {
|
|
1266
|
+
throw new Error("Failed to determine remote HEAD");
|
|
1267
|
+
}
|
|
1268
|
+
return match[1];
|
|
1269
|
+
}
|
|
1270
|
+
async getLocalGitUpdateTarget(installedPath) {
|
|
1271
|
+
try {
|
|
1272
|
+
const upstream = await this.runCommandCapture("git", ["rev-parse", "--abbrev-ref", "@{upstream}"], {
|
|
1273
|
+
cwd: installedPath,
|
|
1274
|
+
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1275
|
+
});
|
|
1276
|
+
const trimmedUpstream = upstream.trim();
|
|
1277
|
+
if (!trimmedUpstream.startsWith("origin/")) {
|
|
1278
|
+
throw new Error(`Unsupported upstream remote: ${trimmedUpstream}`);
|
|
1279
|
+
}
|
|
1280
|
+
const branch = trimmedUpstream.slice("origin/".length);
|
|
1281
|
+
if (!branch) {
|
|
1282
|
+
throw new Error("Missing upstream branch name");
|
|
1283
|
+
}
|
|
1284
|
+
const head = await this.runCommandCapture("git", ["rev-parse", "@{upstream}"], {
|
|
1285
|
+
cwd: installedPath,
|
|
1286
|
+
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1287
|
+
});
|
|
1288
|
+
return {
|
|
1289
|
+
ref: "@{upstream}",
|
|
1290
|
+
head,
|
|
1291
|
+
fetchArgs: [
|
|
1292
|
+
"fetch",
|
|
1293
|
+
"--prune",
|
|
1294
|
+
"--no-tags",
|
|
1295
|
+
"origin",
|
|
1296
|
+
`+refs/heads/${branch}:refs/remotes/origin/${branch}`,
|
|
1297
|
+
],
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
catch {
|
|
1301
|
+
await this.runCommand("git", ["remote", "set-head", "origin", "-a"], { cwd: installedPath }).catch(() => { });
|
|
1302
|
+
const head = await this.runCommandCapture("git", ["rev-parse", "origin/HEAD"], {
|
|
1303
|
+
cwd: installedPath,
|
|
1304
|
+
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1305
|
+
});
|
|
1306
|
+
const originHeadRef = await this.runCommandCapture("git", ["symbolic-ref", "refs/remotes/origin/HEAD"], {
|
|
1307
|
+
cwd: installedPath,
|
|
1308
|
+
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1309
|
+
}).catch(() => "");
|
|
1310
|
+
const branch = originHeadRef.trim().replace(/^refs\/remotes\/origin\//, "");
|
|
1311
|
+
if (branch) {
|
|
1312
|
+
return {
|
|
1313
|
+
ref: "origin/HEAD",
|
|
1314
|
+
head,
|
|
1315
|
+
fetchArgs: [
|
|
1316
|
+
"fetch",
|
|
1317
|
+
"--prune",
|
|
1318
|
+
"--no-tags",
|
|
1319
|
+
"origin",
|
|
1320
|
+
`+refs/heads/${branch}:refs/remotes/origin/${branch}`,
|
|
1321
|
+
],
|
|
1322
|
+
};
|
|
1323
|
+
}
|
|
1324
|
+
return {
|
|
1325
|
+
ref: "origin/HEAD",
|
|
1326
|
+
head,
|
|
1327
|
+
fetchArgs: ["fetch", "--prune", "--no-tags", "origin", "+HEAD:refs/remotes/origin/HEAD"],
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
async getGitUpstreamRef(installedPath) {
|
|
1332
|
+
try {
|
|
1333
|
+
const upstream = await this.runCommandCapture("git", ["rev-parse", "--abbrev-ref", "@{upstream}"], {
|
|
1334
|
+
cwd: installedPath,
|
|
1335
|
+
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1336
|
+
});
|
|
1337
|
+
const trimmed = upstream.trim();
|
|
1338
|
+
if (!trimmed.startsWith("origin/")) {
|
|
1339
|
+
return undefined;
|
|
1340
|
+
}
|
|
1341
|
+
const branch = trimmed.slice("origin/".length);
|
|
1342
|
+
return branch ? `refs/heads/${branch}` : undefined;
|
|
1343
|
+
}
|
|
1344
|
+
catch {
|
|
1345
|
+
return undefined;
|
|
1346
|
+
}
|
|
1347
|
+
}
|
|
1348
|
+
runGitRemoteCommand(installedPath, args) {
|
|
1349
|
+
return this.runCommandCapture("git", args, {
|
|
1350
|
+
cwd: installedPath,
|
|
1351
|
+
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1352
|
+
env: {
|
|
1353
|
+
GIT_TERMINAL_PROMPT: "0",
|
|
1354
|
+
},
|
|
1355
|
+
});
|
|
1356
|
+
}
|
|
1357
|
+
async runWithConcurrency(tasks, limit) {
|
|
1358
|
+
if (tasks.length === 0) {
|
|
1359
|
+
return [];
|
|
1360
|
+
}
|
|
1361
|
+
const results = new Array(tasks.length);
|
|
1362
|
+
let nextIndex = 0;
|
|
1363
|
+
const workerCount = Math.max(1, Math.min(limit, tasks.length));
|
|
1364
|
+
const worker = async () => {
|
|
1365
|
+
while (true) {
|
|
1366
|
+
const index = nextIndex;
|
|
1367
|
+
nextIndex += 1;
|
|
1368
|
+
if (index >= tasks.length) {
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
results[index] = await tasks[index]();
|
|
1372
|
+
}
|
|
1373
|
+
};
|
|
1374
|
+
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
1375
|
+
return results;
|
|
1376
|
+
}
|
|
1377
|
+
/**
|
|
1378
|
+
* Get a unique identity for a package, ignoring version/ref.
|
|
1379
|
+
* Used to detect when the same package is in both global and project settings.
|
|
1380
|
+
* For git packages, uses normalized host/path to ensure SSH and HTTPS URLs
|
|
1381
|
+
* for the same repository are treated as identical.
|
|
1382
|
+
*/
|
|
1383
|
+
getPackageIdentity(source, scope) {
|
|
1384
|
+
const parsed = this.parseSource(source);
|
|
1385
|
+
if (parsed.type === "npm") {
|
|
1386
|
+
return `npm:${parsed.name}`;
|
|
1387
|
+
}
|
|
1388
|
+
if (parsed.type === "git") {
|
|
1389
|
+
// Use host/path for identity to normalize SSH and HTTPS
|
|
1390
|
+
return `git:${parsed.host}/${parsed.path}`;
|
|
1391
|
+
}
|
|
1392
|
+
if (scope) {
|
|
1393
|
+
const baseDir = this.getBaseDirForScope(scope);
|
|
1394
|
+
return `local:${this.resolvePathFromBase(parsed.path, baseDir)}`;
|
|
1395
|
+
}
|
|
1396
|
+
return `local:${this.resolvePath(parsed.path)}`;
|
|
1397
|
+
}
|
|
1398
|
+
/**
|
|
1399
|
+
* Dedupe packages: if same package identity appears in both global and project,
|
|
1400
|
+
* keep only the project one (project wins). A project entry with autoload=false
|
|
1401
|
+
* is a delta over the global entry, so both are kept (delta first).
|
|
1402
|
+
*/
|
|
1403
|
+
dedupePackages(packages) {
|
|
1404
|
+
const result = [];
|
|
1405
|
+
const seen = new Map();
|
|
1406
|
+
for (const entry of packages) {
|
|
1407
|
+
const identity = this.getPackageIdentity(this.getPackageSourceString(entry.pkg), entry.scope);
|
|
1408
|
+
const index = seen.get(identity);
|
|
1409
|
+
if (index === undefined) {
|
|
1410
|
+
seen.set(identity, result.length);
|
|
1411
|
+
result.push(entry);
|
|
1412
|
+
continue;
|
|
1413
|
+
}
|
|
1414
|
+
const existing = result[index];
|
|
1415
|
+
if (existing?.scope === "project" && entry.scope === "user") {
|
|
1416
|
+
if (typeof existing.pkg === "object" && existing.pkg.autoload === false)
|
|
1417
|
+
result.push(entry);
|
|
1418
|
+
}
|
|
1419
|
+
else if (entry.scope === "project") {
|
|
1420
|
+
result[index] = entry;
|
|
1421
|
+
}
|
|
1422
|
+
}
|
|
1423
|
+
return result;
|
|
1424
|
+
}
|
|
1425
|
+
parseNpmSpec(spec) {
|
|
1426
|
+
const match = spec.match(/^(@?[^@]+(?:\/[^@]+)?)(?:@(.+))?$/);
|
|
1427
|
+
if (!match) {
|
|
1428
|
+
return { name: spec };
|
|
1429
|
+
}
|
|
1430
|
+
const name = match[1] ?? spec;
|
|
1431
|
+
const version = match[2];
|
|
1432
|
+
return { name, version };
|
|
1433
|
+
}
|
|
1434
|
+
assertProjectTrustedForScope(scope) {
|
|
1435
|
+
if (scope === "project" && !this.settingsManager.isProjectTrusted()) {
|
|
1436
|
+
throw new Error("Project is not trusted; refusing to access project package storage");
|
|
1437
|
+
}
|
|
1438
|
+
}
|
|
1439
|
+
getNpmCommand() {
|
|
1440
|
+
const configuredCommand = this.settingsManager.getNpmCommand();
|
|
1441
|
+
if (!configuredCommand || configuredCommand.length === 0) {
|
|
1442
|
+
return { command: "npm", args: [] };
|
|
1443
|
+
}
|
|
1444
|
+
const [command, ...args] = configuredCommand;
|
|
1445
|
+
if (!command) {
|
|
1446
|
+
throw new Error("Invalid npmCommand: first array entry must be a non-empty command");
|
|
1447
|
+
}
|
|
1448
|
+
return { command, args };
|
|
1449
|
+
}
|
|
1450
|
+
getPackageManagerName() {
|
|
1451
|
+
const npmCommand = this.getNpmCommand();
|
|
1452
|
+
const commandParts = [npmCommand.command, ...npmCommand.args];
|
|
1453
|
+
const separatorIndex = commandParts.lastIndexOf("--");
|
|
1454
|
+
const packageManagerCommand = separatorIndex >= 0 ? commandParts[separatorIndex + 1] : npmCommand.command;
|
|
1455
|
+
return packageManagerCommand ? basename(packageManagerCommand).replace(/\.(cmd|exe)$/i, "") : "";
|
|
1456
|
+
}
|
|
1457
|
+
async runNpmCommand(args, options) {
|
|
1458
|
+
const npmCommand = this.getNpmCommand();
|
|
1459
|
+
await this.runCommand(npmCommand.command, [...npmCommand.args, ...args], options);
|
|
1460
|
+
}
|
|
1461
|
+
getGitDependencyInstallArgs() {
|
|
1462
|
+
const configuredCommand = this.settingsManager.getNpmCommand();
|
|
1463
|
+
if (configuredCommand && configuredCommand.length > 0) {
|
|
1464
|
+
return ["install", "--ignore-scripts"];
|
|
1465
|
+
}
|
|
1466
|
+
return ["install", "--omit=dev", "--ignore-scripts"];
|
|
1467
|
+
}
|
|
1468
|
+
runNpmCommandSync(args) {
|
|
1469
|
+
const npmCommand = this.getNpmCommand();
|
|
1470
|
+
return this.runCommandSync(npmCommand.command, [...npmCommand.args, ...args]);
|
|
1471
|
+
}
|
|
1472
|
+
getNpmInstallArgs(specs, installRoot) {
|
|
1473
|
+
const packageManagerName = this.getPackageManagerName();
|
|
1474
|
+
// Extension packages run inside pi and resolve pi APIs through loader aliases/virtual modules.
|
|
1475
|
+
// Disable peer dependency resolution for managed installs (npm's --legacy-peer-deps, and
|
|
1476
|
+
// equivalent bun/pnpm settings) so package managers do not install or solve host-provided
|
|
1477
|
+
// @earendil-works/pi-* peers. Stale auto-installed pi peers can otherwise block updates.
|
|
1478
|
+
if (packageManagerName === "bun") {
|
|
1479
|
+
return ["install", ...specs, "--cwd", installRoot, "--omit=peer", "--ignore-scripts"];
|
|
1480
|
+
}
|
|
1481
|
+
if (packageManagerName === "pnpm") {
|
|
1482
|
+
return [
|
|
1483
|
+
"install",
|
|
1484
|
+
...specs,
|
|
1485
|
+
"--prefix",
|
|
1486
|
+
installRoot,
|
|
1487
|
+
"--config.auto-install-peers=false",
|
|
1488
|
+
"--config.strict-peer-dependencies=false",
|
|
1489
|
+
"--config.strict-dep-builds=false",
|
|
1490
|
+
"--ignore-scripts",
|
|
1491
|
+
];
|
|
1492
|
+
}
|
|
1493
|
+
return ["install", ...specs, "--prefix", installRoot, "--legacy-peer-deps", "--ignore-scripts"];
|
|
1494
|
+
}
|
|
1495
|
+
async installNpm(source, scope, temporary) {
|
|
1496
|
+
const installRoot = this.getNpmInstallRoot(scope, temporary);
|
|
1497
|
+
this.ensureNpmProject(installRoot);
|
|
1498
|
+
await this.runNpmCommand(this.getNpmInstallArgs([source.spec], installRoot));
|
|
1499
|
+
}
|
|
1500
|
+
async uninstallNpm(source, scope) {
|
|
1501
|
+
const installRoot = this.getNpmInstallRoot(scope, false);
|
|
1502
|
+
if (!existsSync(installRoot)) {
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
const packageManagerName = this.getPackageManagerName();
|
|
1506
|
+
if (packageManagerName === "bun") {
|
|
1507
|
+
await this.runNpmCommand(["uninstall", source.name, "--cwd", installRoot]);
|
|
1508
|
+
return;
|
|
1509
|
+
}
|
|
1510
|
+
const args = ["uninstall", source.name, "--prefix", installRoot];
|
|
1511
|
+
if (packageManagerName !== "pnpm") {
|
|
1512
|
+
args.push("--legacy-peer-deps");
|
|
1513
|
+
}
|
|
1514
|
+
await this.runNpmCommand(args);
|
|
1515
|
+
}
|
|
1516
|
+
async installGit(source, scope) {
|
|
1517
|
+
const targetDir = this.getGitInstallPath(source, scope);
|
|
1518
|
+
if (existsSync(targetDir)) {
|
|
1519
|
+
if (source.ref) {
|
|
1520
|
+
await this.ensureGitRef(targetDir, ["fetch", "origin", source.ref], "FETCH_HEAD");
|
|
1521
|
+
return;
|
|
1522
|
+
}
|
|
1523
|
+
const target = await this.getLocalGitUpdateTarget(targetDir);
|
|
1524
|
+
await this.ensureGitRef(targetDir, target.fetchArgs, target.ref);
|
|
1525
|
+
return;
|
|
1526
|
+
}
|
|
1527
|
+
const gitRoot = this.getGitInstallRoot(scope);
|
|
1528
|
+
if (gitRoot) {
|
|
1529
|
+
this.ensureGitIgnore(gitRoot);
|
|
1530
|
+
}
|
|
1531
|
+
mkdirSync(dirname(targetDir), { recursive: true });
|
|
1532
|
+
try {
|
|
1533
|
+
await this.runCommand("git", ["clone", source.repo, targetDir]);
|
|
1534
|
+
if (source.ref) {
|
|
1535
|
+
await this.runCommand("git", ["checkout", source.ref], { cwd: targetDir });
|
|
1536
|
+
}
|
|
1537
|
+
const packageJsonPath = join(targetDir, "package.json");
|
|
1538
|
+
if (existsSync(packageJsonPath)) {
|
|
1539
|
+
await this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
catch (error) {
|
|
1543
|
+
rmSync(targetDir, { recursive: true, force: true });
|
|
1544
|
+
this.pruneEmptyGitParents(targetDir, gitRoot);
|
|
1545
|
+
throw error;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
async updateGit(source, scope) {
|
|
1549
|
+
const targetDir = this.getGitInstallPath(source, scope);
|
|
1550
|
+
if (!existsSync(targetDir)) {
|
|
1551
|
+
await this.installGit(source, scope);
|
|
1552
|
+
return;
|
|
1553
|
+
}
|
|
1554
|
+
if (source.ref) {
|
|
1555
|
+
await this.ensureGitRef(targetDir, ["fetch", "origin", source.ref], "FETCH_HEAD");
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
const target = await this.getLocalGitUpdateTarget(targetDir);
|
|
1559
|
+
await this.ensureGitRef(targetDir, target.fetchArgs, target.ref);
|
|
1560
|
+
}
|
|
1561
|
+
async ensureGitRef(targetDir, fetchArgs, ref) {
|
|
1562
|
+
// Fetch only the ref we will reset to, avoiding unrelated branch/tag noise.
|
|
1563
|
+
await this.runCommand("git", fetchArgs, { cwd: targetDir });
|
|
1564
|
+
const localHead = await this.runCommandCapture("git", ["rev-parse", "HEAD"], {
|
|
1565
|
+
cwd: targetDir,
|
|
1566
|
+
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1567
|
+
});
|
|
1568
|
+
const commitRef = `${ref}^{commit}`;
|
|
1569
|
+
const targetHead = await this.runCommandCapture("git", ["rev-parse", commitRef], {
|
|
1570
|
+
cwd: targetDir,
|
|
1571
|
+
timeoutMs: NETWORK_TIMEOUT_MS,
|
|
1572
|
+
});
|
|
1573
|
+
if (localHead.trim() === targetHead.trim()) {
|
|
1574
|
+
return;
|
|
1575
|
+
}
|
|
1576
|
+
await this.runCommand("git", ["reset", "--hard", commitRef], { cwd: targetDir });
|
|
1577
|
+
// Clean untracked files (extensions should be pristine)
|
|
1578
|
+
await this.runCommand("git", ["clean", "-fdx"], { cwd: targetDir });
|
|
1579
|
+
const packageJsonPath = join(targetDir, "package.json");
|
|
1580
|
+
if (existsSync(packageJsonPath)) {
|
|
1581
|
+
await this.runNpmCommand(this.getGitDependencyInstallArgs(), { cwd: targetDir });
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
async refreshTemporaryGitSource(source, sourceStr) {
|
|
1585
|
+
if (isOfflineModeEnabled()) {
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1588
|
+
try {
|
|
1589
|
+
await this.withProgress("pull", sourceStr, `Refreshing ${sourceStr}...`, async () => {
|
|
1590
|
+
await this.updateGit(source, "temporary");
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
catch {
|
|
1594
|
+
// Keep cached temporary checkout if refresh fails.
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
async removeGit(source, scope) {
|
|
1598
|
+
const targetDir = this.getGitInstallPath(source, scope);
|
|
1599
|
+
if (!existsSync(targetDir))
|
|
1600
|
+
return;
|
|
1601
|
+
rmSync(targetDir, { recursive: true, force: true });
|
|
1602
|
+
this.pruneEmptyGitParents(targetDir, this.getGitInstallRoot(scope));
|
|
1603
|
+
}
|
|
1604
|
+
pruneEmptyGitParents(targetDir, installRoot) {
|
|
1605
|
+
if (!installRoot)
|
|
1606
|
+
return;
|
|
1607
|
+
const resolvedRoot = resolve(installRoot);
|
|
1608
|
+
let current = dirname(targetDir);
|
|
1609
|
+
while (current.startsWith(resolvedRoot) && current !== resolvedRoot) {
|
|
1610
|
+
if (!existsSync(current)) {
|
|
1611
|
+
current = dirname(current);
|
|
1612
|
+
continue;
|
|
1613
|
+
}
|
|
1614
|
+
const entries = readdirSync(current);
|
|
1615
|
+
if (entries.length > 0) {
|
|
1616
|
+
break;
|
|
1617
|
+
}
|
|
1618
|
+
try {
|
|
1619
|
+
rmSync(current, { recursive: true, force: true });
|
|
1620
|
+
}
|
|
1621
|
+
catch {
|
|
1622
|
+
break;
|
|
1623
|
+
}
|
|
1624
|
+
current = dirname(current);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
ensureNpmProject(installRoot) {
|
|
1628
|
+
if (!existsSync(installRoot)) {
|
|
1629
|
+
mkdirSync(installRoot, { recursive: true });
|
|
1630
|
+
}
|
|
1631
|
+
markPathIgnoredByCloudSync(installRoot);
|
|
1632
|
+
this.ensureGitIgnore(installRoot);
|
|
1633
|
+
const packageJsonPath = join(installRoot, "package.json");
|
|
1634
|
+
if (!existsSync(packageJsonPath)) {
|
|
1635
|
+
const pkgJson = { name: "pi-extensions", private: true };
|
|
1636
|
+
writeFileSync(packageJsonPath, JSON.stringify(pkgJson, null, 2), "utf-8");
|
|
1637
|
+
}
|
|
1638
|
+
}
|
|
1639
|
+
ensureGitIgnore(dir) {
|
|
1640
|
+
if (!existsSync(dir)) {
|
|
1641
|
+
mkdirSync(dir, { recursive: true });
|
|
1642
|
+
}
|
|
1643
|
+
const ignorePath = join(dir, ".gitignore");
|
|
1644
|
+
if (!existsSync(ignorePath)) {
|
|
1645
|
+
writeFileSync(ignorePath, "*\n!.gitignore\n", "utf-8");
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
getNpmInstallRoot(scope, temporary) {
|
|
1649
|
+
if (temporary) {
|
|
1650
|
+
return this.getTemporaryDir("npm");
|
|
1651
|
+
}
|
|
1652
|
+
if (scope === "project") {
|
|
1653
|
+
this.assertProjectTrustedForScope(scope);
|
|
1654
|
+
return join(this.cwd, CONFIG_DIR_NAME, "npm");
|
|
1655
|
+
}
|
|
1656
|
+
return join(this.agentDir, "npm");
|
|
1657
|
+
}
|
|
1658
|
+
getGlobalNpmRoot() {
|
|
1659
|
+
const npmCommand = this.getNpmCommand();
|
|
1660
|
+
const commandKey = [npmCommand.command, ...npmCommand.args].join("\0");
|
|
1661
|
+
if (this.globalNpmRoot && this.globalNpmRootCommandKey === commandKey) {
|
|
1662
|
+
return this.globalNpmRoot;
|
|
1663
|
+
}
|
|
1664
|
+
if (this.getPackageManagerName() === "bun") {
|
|
1665
|
+
const binDir = this.runNpmCommandSync(["pm", "bin", "-g"]).trim();
|
|
1666
|
+
this.globalNpmRoot = join(dirname(binDir), "install", "global", "node_modules");
|
|
1667
|
+
}
|
|
1668
|
+
else {
|
|
1669
|
+
this.globalNpmRoot = this.runNpmCommandSync(["root", "-g"]).trim();
|
|
1670
|
+
}
|
|
1671
|
+
this.globalNpmRootCommandKey = commandKey;
|
|
1672
|
+
return this.globalNpmRoot;
|
|
1673
|
+
}
|
|
1674
|
+
getPnpmGlobalPackagePath(packageName) {
|
|
1675
|
+
if (this.getPackageManagerName() !== "pnpm") {
|
|
1676
|
+
return undefined;
|
|
1677
|
+
}
|
|
1678
|
+
const output = this.runNpmCommandSync(["list", "-g", "--depth", "0", "--json"]);
|
|
1679
|
+
const entries = JSON.parse(output);
|
|
1680
|
+
for (const entry of entries) {
|
|
1681
|
+
const path = entry.dependencies?.[packageName]?.path;
|
|
1682
|
+
if (path)
|
|
1683
|
+
return path;
|
|
1684
|
+
}
|
|
1685
|
+
return undefined;
|
|
1686
|
+
}
|
|
1687
|
+
getManagedNpmInstallPath(source, scope) {
|
|
1688
|
+
if (scope === "temporary") {
|
|
1689
|
+
return join(this.getTemporaryDir("npm"), "node_modules", source.name);
|
|
1690
|
+
}
|
|
1691
|
+
if (scope === "project") {
|
|
1692
|
+
this.assertProjectTrustedForScope(scope);
|
|
1693
|
+
return join(this.cwd, CONFIG_DIR_NAME, "npm", "node_modules", source.name);
|
|
1694
|
+
}
|
|
1695
|
+
return join(this.agentDir, "npm", "node_modules", source.name);
|
|
1696
|
+
}
|
|
1697
|
+
getLegacyGlobalNpmInstallPath(source) {
|
|
1698
|
+
try {
|
|
1699
|
+
return this.getPnpmGlobalPackagePath(source.name) ?? join(this.getGlobalNpmRoot(), source.name);
|
|
1700
|
+
}
|
|
1701
|
+
catch {
|
|
1702
|
+
return undefined;
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
getNpmInstallPath(source, scope) {
|
|
1706
|
+
const managedPath = this.getManagedNpmInstallPath(source, scope);
|
|
1707
|
+
if (scope !== "user" || existsSync(managedPath)) {
|
|
1708
|
+
return managedPath;
|
|
1709
|
+
}
|
|
1710
|
+
const legacyPath = this.getLegacyGlobalNpmInstallPath(source);
|
|
1711
|
+
return legacyPath && existsSync(legacyPath) ? legacyPath : managedPath;
|
|
1712
|
+
}
|
|
1713
|
+
getGitInstallPath(source, scope) {
|
|
1714
|
+
if (scope === "temporary") {
|
|
1715
|
+
return this.getTemporaryDir(`git-${source.host}`, source.path);
|
|
1716
|
+
}
|
|
1717
|
+
const installRoot = this.getGitInstallRoot(scope);
|
|
1718
|
+
if (!installRoot) {
|
|
1719
|
+
throw new Error("Missing git install root");
|
|
1720
|
+
}
|
|
1721
|
+
return this.resolveManagedPath(installRoot, source.host, source.path);
|
|
1722
|
+
}
|
|
1723
|
+
getGitInstallRoot(scope) {
|
|
1724
|
+
if (scope === "temporary") {
|
|
1725
|
+
return undefined;
|
|
1726
|
+
}
|
|
1727
|
+
if (scope === "project") {
|
|
1728
|
+
this.assertProjectTrustedForScope(scope);
|
|
1729
|
+
return join(this.cwd, CONFIG_DIR_NAME, "git");
|
|
1730
|
+
}
|
|
1731
|
+
return join(this.agentDir, "git");
|
|
1732
|
+
}
|
|
1733
|
+
getTemporaryDir(prefix, suffix) {
|
|
1734
|
+
const root = this.resolveManagedPath(getExtensionTempFolder(this.agentDir), prefix);
|
|
1735
|
+
const hash = createHash("sha256")
|
|
1736
|
+
.update(`${prefix}-${suffix ?? ""}`)
|
|
1737
|
+
.digest("hex")
|
|
1738
|
+
.slice(0, 8);
|
|
1739
|
+
return this.resolveManagedPath(root, hash, suffix ?? "");
|
|
1740
|
+
}
|
|
1741
|
+
resolveManagedPath(root, ...parts) {
|
|
1742
|
+
const resolvedRoot = resolve(root);
|
|
1743
|
+
const resolvedPath = resolve(resolvedRoot, ...parts);
|
|
1744
|
+
if (resolvedPath !== resolvedRoot && !resolvedPath.startsWith(`${resolvedRoot}${sep}`)) {
|
|
1745
|
+
throw new Error(`Refusing to use path outside package install root: ${resolvedPath}`);
|
|
1746
|
+
}
|
|
1747
|
+
return resolvedPath;
|
|
1748
|
+
}
|
|
1749
|
+
getBaseDirForScope(scope) {
|
|
1750
|
+
if (scope === "project") {
|
|
1751
|
+
this.assertProjectTrustedForScope(scope);
|
|
1752
|
+
return join(this.cwd, CONFIG_DIR_NAME);
|
|
1753
|
+
}
|
|
1754
|
+
if (scope === "user") {
|
|
1755
|
+
return this.agentDir;
|
|
1756
|
+
}
|
|
1757
|
+
return this.cwd;
|
|
1758
|
+
}
|
|
1759
|
+
resolvePath(input) {
|
|
1760
|
+
return resolvePath(input, this.cwd, { homeDir: getHomeDir(), trim: true });
|
|
1761
|
+
}
|
|
1762
|
+
resolvePathFromBase(input, baseDir) {
|
|
1763
|
+
return resolvePath(input, baseDir, { homeDir: getHomeDir(), trim: true });
|
|
1764
|
+
}
|
|
1765
|
+
collectPackageResources(packageRoot, accumulator, filter, metadata) {
|
|
1766
|
+
if (filter) {
|
|
1767
|
+
for (const resourceType of RESOURCE_TYPES) {
|
|
1768
|
+
const patterns = filter[resourceType];
|
|
1769
|
+
const target = this.getTargetMap(accumulator, resourceType);
|
|
1770
|
+
if (filter.autoload === false) {
|
|
1771
|
+
this.applyPackageDeltaFilter(packageRoot, patterns ?? [], resourceType, target, metadata);
|
|
1772
|
+
}
|
|
1773
|
+
else if (patterns !== undefined) {
|
|
1774
|
+
this.applyPackageFilter(packageRoot, patterns, resourceType, target, metadata);
|
|
1775
|
+
}
|
|
1776
|
+
else {
|
|
1777
|
+
this.collectDefaultResources(packageRoot, resourceType, target, metadata);
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
return true;
|
|
1781
|
+
}
|
|
1782
|
+
const manifest = this.readPiManifest(packageRoot);
|
|
1783
|
+
if (manifest) {
|
|
1784
|
+
for (const resourceType of RESOURCE_TYPES) {
|
|
1785
|
+
const entries = manifest[resourceType];
|
|
1786
|
+
this.addManifestEntries(entries, packageRoot, resourceType, this.getTargetMap(accumulator, resourceType), metadata);
|
|
1787
|
+
}
|
|
1788
|
+
return true;
|
|
1789
|
+
}
|
|
1790
|
+
let hasAnyDir = false;
|
|
1791
|
+
for (const resourceType of RESOURCE_TYPES) {
|
|
1792
|
+
const dir = join(packageRoot, resourceType);
|
|
1793
|
+
if (existsSync(dir)) {
|
|
1794
|
+
// Collect all files from the directory (all enabled by default)
|
|
1795
|
+
const files = collectResourceFiles(dir, resourceType);
|
|
1796
|
+
for (const f of files) {
|
|
1797
|
+
this.addResource(this.getTargetMap(accumulator, resourceType), f, metadata, true);
|
|
1798
|
+
}
|
|
1799
|
+
hasAnyDir = true;
|
|
1800
|
+
}
|
|
1801
|
+
}
|
|
1802
|
+
return hasAnyDir;
|
|
1803
|
+
}
|
|
1804
|
+
collectDefaultResources(packageRoot, resourceType, target, metadata) {
|
|
1805
|
+
const manifest = this.readPiManifest(packageRoot);
|
|
1806
|
+
const entries = manifest?.[resourceType];
|
|
1807
|
+
if (entries) {
|
|
1808
|
+
this.addManifestEntries(entries, packageRoot, resourceType, target, metadata);
|
|
1809
|
+
return;
|
|
1810
|
+
}
|
|
1811
|
+
const dir = join(packageRoot, resourceType);
|
|
1812
|
+
if (existsSync(dir)) {
|
|
1813
|
+
// Collect all files from the directory (all enabled by default)
|
|
1814
|
+
const files = collectResourceFiles(dir, resourceType);
|
|
1815
|
+
for (const f of files) {
|
|
1816
|
+
this.addResource(target, f, metadata, true);
|
|
1817
|
+
}
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1820
|
+
applyPackageFilter(packageRoot, userPatterns, resourceType, target, metadata) {
|
|
1821
|
+
const { allFiles } = this.collectManifestFiles(packageRoot, resourceType);
|
|
1822
|
+
if (userPatterns.length === 0) {
|
|
1823
|
+
// Empty array explicitly disables all resources of this type
|
|
1824
|
+
for (const f of allFiles) {
|
|
1825
|
+
this.addResource(target, f, metadata, false);
|
|
1826
|
+
}
|
|
1827
|
+
return;
|
|
1828
|
+
}
|
|
1829
|
+
// Apply user patterns
|
|
1830
|
+
const enabledByUser = applyPatterns(allFiles, userPatterns, packageRoot);
|
|
1831
|
+
for (const f of allFiles) {
|
|
1832
|
+
const enabled = enabledByUser.has(f);
|
|
1833
|
+
this.addResource(target, f, metadata, enabled);
|
|
1834
|
+
}
|
|
1835
|
+
}
|
|
1836
|
+
applyPackageDeltaFilter(packageRoot, userPatterns, resourceType, target, metadata) {
|
|
1837
|
+
if (userPatterns.length === 0) {
|
|
1838
|
+
return;
|
|
1839
|
+
}
|
|
1840
|
+
const { allFiles } = this.collectManifestFiles(packageRoot, resourceType);
|
|
1841
|
+
const enabledByUser = applyAutoloadDisabledPatterns(allFiles, userPatterns, packageRoot);
|
|
1842
|
+
for (const [filePath, enabled] of enabledByUser) {
|
|
1843
|
+
this.addResource(target, filePath, metadata, enabled);
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Collect all files from a package for a resource type, applying manifest patterns.
|
|
1848
|
+
* Returns { allFiles, enabledByManifest } where enabledByManifest is the set of files
|
|
1849
|
+
* that pass the manifest's own patterns.
|
|
1850
|
+
*/
|
|
1851
|
+
collectManifestFiles(packageRoot, resourceType) {
|
|
1852
|
+
const manifest = this.readPiManifest(packageRoot);
|
|
1853
|
+
const entries = manifest?.[resourceType];
|
|
1854
|
+
if (entries && entries.length > 0) {
|
|
1855
|
+
const allFiles = this.collectFilesFromManifestEntries(entries, packageRoot, resourceType);
|
|
1856
|
+
const manifestPatterns = entries.filter(isOverridePattern);
|
|
1857
|
+
const enabledByManifest = manifestPatterns.length > 0 ? applyPatterns(allFiles, manifestPatterns, packageRoot) : new Set(allFiles);
|
|
1858
|
+
return { allFiles: Array.from(enabledByManifest), enabledByManifest };
|
|
1859
|
+
}
|
|
1860
|
+
const conventionDir = join(packageRoot, resourceType);
|
|
1861
|
+
if (!existsSync(conventionDir)) {
|
|
1862
|
+
return { allFiles: [], enabledByManifest: new Set() };
|
|
1863
|
+
}
|
|
1864
|
+
const allFiles = collectResourceFiles(conventionDir, resourceType);
|
|
1865
|
+
return { allFiles, enabledByManifest: new Set(allFiles) };
|
|
1866
|
+
}
|
|
1867
|
+
readPiManifest(packageRoot) {
|
|
1868
|
+
const packageJsonPath = join(packageRoot, "package.json");
|
|
1869
|
+
if (!existsSync(packageJsonPath)) {
|
|
1870
|
+
return null;
|
|
1871
|
+
}
|
|
1872
|
+
try {
|
|
1873
|
+
const content = readFileSync(packageJsonPath, "utf-8");
|
|
1874
|
+
const pkg = JSON.parse(content);
|
|
1875
|
+
return pkg.pi ?? null;
|
|
1876
|
+
}
|
|
1877
|
+
catch {
|
|
1878
|
+
return null;
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
addManifestEntries(entries, root, resourceType, target, metadata) {
|
|
1882
|
+
if (!entries)
|
|
1883
|
+
return;
|
|
1884
|
+
const allFiles = this.collectFilesFromManifestEntries(entries, root, resourceType);
|
|
1885
|
+
const patterns = entries.filter(isOverridePattern);
|
|
1886
|
+
const enabledPaths = applyPatterns(allFiles, patterns, root);
|
|
1887
|
+
for (const f of allFiles) {
|
|
1888
|
+
if (enabledPaths.has(f)) {
|
|
1889
|
+
this.addResource(target, f, metadata, true);
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
collectFilesFromManifestEntries(entries, root, resourceType) {
|
|
1894
|
+
const sourceEntries = entries.filter((entry) => !isOverridePattern(entry));
|
|
1895
|
+
const resolved = sourceEntries.flatMap((entry) => {
|
|
1896
|
+
if (!hasGlobPattern(entry)) {
|
|
1897
|
+
return [resolve(root, entry)];
|
|
1898
|
+
}
|
|
1899
|
+
return globSync(entry, {
|
|
1900
|
+
cwd: root,
|
|
1901
|
+
absolute: true,
|
|
1902
|
+
dot: false,
|
|
1903
|
+
nodir: false,
|
|
1904
|
+
}).map((match) => resolve(match));
|
|
1905
|
+
});
|
|
1906
|
+
return this.collectFilesFromPaths(resolved, resourceType);
|
|
1907
|
+
}
|
|
1908
|
+
resolveLocalEntries(entries, resourceType, target, metadata, baseDir) {
|
|
1909
|
+
if (entries.length === 0)
|
|
1910
|
+
return;
|
|
1911
|
+
// Collect all files from plain entries (non-pattern entries)
|
|
1912
|
+
const { plain, patterns } = splitPatterns(entries);
|
|
1913
|
+
const resolvedPlain = plain.map((p) => this.resolvePathFromBase(p, baseDir));
|
|
1914
|
+
const allFiles = this.collectFilesFromPaths(resolvedPlain, resourceType);
|
|
1915
|
+
// Determine which files are enabled based on patterns
|
|
1916
|
+
const enabledPaths = applyPatterns(allFiles, patterns, baseDir);
|
|
1917
|
+
// Add all files with their enabled state
|
|
1918
|
+
for (const f of allFiles) {
|
|
1919
|
+
this.addResource(target, f, metadata, enabledPaths.has(f));
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
addAutoDiscoveredResources(accumulator, globalSettings, projectSettings, globalBaseDir, projectBaseDir) {
|
|
1923
|
+
const collisions = [];
|
|
1924
|
+
const userMetadata = {
|
|
1925
|
+
source: "auto",
|
|
1926
|
+
scope: "user",
|
|
1927
|
+
origin: "top-level",
|
|
1928
|
+
baseDir: globalBaseDir,
|
|
1929
|
+
};
|
|
1930
|
+
const projectMetadata = {
|
|
1931
|
+
source: "auto",
|
|
1932
|
+
scope: "project",
|
|
1933
|
+
origin: "top-level",
|
|
1934
|
+
baseDir: projectBaseDir,
|
|
1935
|
+
};
|
|
1936
|
+
const userOverrides = {
|
|
1937
|
+
extensions: (globalSettings.extensions ?? []),
|
|
1938
|
+
skills: (globalSettings.skills ?? []),
|
|
1939
|
+
prompts: (globalSettings.prompts ?? []),
|
|
1940
|
+
themes: (globalSettings.themes ?? []),
|
|
1941
|
+
};
|
|
1942
|
+
const projectOverrides = {
|
|
1943
|
+
extensions: (projectSettings.extensions ?? []),
|
|
1944
|
+
skills: (projectSettings.skills ?? []),
|
|
1945
|
+
prompts: (projectSettings.prompts ?? []),
|
|
1946
|
+
themes: (projectSettings.themes ?? []),
|
|
1947
|
+
};
|
|
1948
|
+
const userDirs = {
|
|
1949
|
+
extensions: join(globalBaseDir, "extensions"),
|
|
1950
|
+
skills: join(globalBaseDir, "skills"),
|
|
1951
|
+
prompts: join(globalBaseDir, "prompts"),
|
|
1952
|
+
themes: join(globalBaseDir, "themes"),
|
|
1953
|
+
};
|
|
1954
|
+
const projectDirs = {
|
|
1955
|
+
extensions: join(projectBaseDir, "extensions"),
|
|
1956
|
+
skills: join(projectBaseDir, "skills"),
|
|
1957
|
+
prompts: join(projectBaseDir, "prompts"),
|
|
1958
|
+
themes: join(projectBaseDir, "themes"),
|
|
1959
|
+
};
|
|
1960
|
+
const userAgentsSkillsDir = join(getHomeDir(), ".agents", "skills");
|
|
1961
|
+
const projectTrusted = this.settingsManager.isProjectTrusted();
|
|
1962
|
+
const projectAgentsSkillDirs = projectTrusted
|
|
1963
|
+
? collectAncestorAgentsSkillDirs(this.cwd).filter((dir) => resolve(dir) !== resolve(userAgentsSkillsDir))
|
|
1964
|
+
: [];
|
|
1965
|
+
const addResources = (resourceType, paths, metadata, overrides, baseDir, defaultEnabled = true) => {
|
|
1966
|
+
const target = this.getTargetMap(accumulator, resourceType);
|
|
1967
|
+
for (const path of paths) {
|
|
1968
|
+
const enabled = isEnabledByOverrides(path, overrides, baseDir, defaultEnabled);
|
|
1969
|
+
this.addResource(target, path, metadata, enabled);
|
|
1970
|
+
}
|
|
1971
|
+
};
|
|
1972
|
+
if (projectTrusted) {
|
|
1973
|
+
// Project extensions from .pi/
|
|
1974
|
+
addResources("extensions", collectAutoExtensionEntries(projectDirs.extensions), projectMetadata, projectOverrides.extensions, projectBaseDir);
|
|
1975
|
+
// Project skills from .pi/
|
|
1976
|
+
addResources("skills", collectAutoSkillEntries(projectDirs.skills, "pi"), projectMetadata, projectOverrides.skills, projectBaseDir);
|
|
1977
|
+
}
|
|
1978
|
+
// Project skills from .agents/ (each with its own baseDir)
|
|
1979
|
+
for (const agentsSkillsDir of projectAgentsSkillDirs) {
|
|
1980
|
+
const agentsBaseDir = dirname(agentsSkillsDir); // the .agents directory
|
|
1981
|
+
const agentsMetadata = {
|
|
1982
|
+
...projectMetadata,
|
|
1983
|
+
baseDir: agentsBaseDir,
|
|
1984
|
+
};
|
|
1985
|
+
addResources("skills", collectAutoSkillEntries(agentsSkillsDir, "agents"), agentsMetadata, projectOverrides.skills, agentsBaseDir);
|
|
1986
|
+
}
|
|
1987
|
+
if (projectTrusted) {
|
|
1988
|
+
addResources("prompts", collectAutoPromptEntries(projectDirs.prompts), projectMetadata, projectOverrides.prompts, projectBaseDir);
|
|
1989
|
+
addResources("themes", collectAutoThemeEntries(projectDirs.themes), projectMetadata, projectOverrides.themes, projectBaseDir);
|
|
1990
|
+
}
|
|
1991
|
+
// User extensions from ~/.selesai/agent/
|
|
1992
|
+
addResources("extensions", collectAutoExtensionEntries(userDirs.extensions), userMetadata, userOverrides.extensions, globalBaseDir);
|
|
1993
|
+
// ponytail: also load user extensions from the host pi dir (~/.pi/agent/extensions)
|
|
1994
|
+
// so selesai reuses pi-installed extensions without sharing auth/models/sessions.
|
|
1995
|
+
// Coupling: hardcodes ".pi" — if pi renames its config dir this silently stops loading.
|
|
1996
|
+
// Upgrade path: read from a resolver if selesai ever needs to locate the host dynamically.
|
|
1997
|
+
const piHostExtDir = join(getHomeDir(), ".pi", "agent", "extensions");
|
|
1998
|
+
const piHostBaseDir = join(getHomeDir(), ".pi", "agent");
|
|
1999
|
+
const selesaiExtSource = "~/.selesai/agent/extensions";
|
|
2000
|
+
const piExtSource = "~/.pi/agent/extensions";
|
|
2001
|
+
// On name collisions between ~/.selesai/agent/extensions and ~/.pi/agent/extensions,
|
|
2002
|
+
// drop the loser entirely (avoids double-load split-brain in stateful extensions
|
|
2003
|
+
// like pi-subagents) and record a collision so the user is told. Winner is settable
|
|
2004
|
+
// per extension via `extensionHost` in settings.json; default is selesai.
|
|
2005
|
+
const extensionHost = globalSettings.extensionHost ?? {};
|
|
2006
|
+
const selesaiPathsByName = new Map();
|
|
2007
|
+
for (const extPath of accumulator.extensions.keys()) {
|
|
2008
|
+
const name = extensionEntryName(extPath, userDirs.extensions);
|
|
2009
|
+
if (name)
|
|
2010
|
+
selesaiPathsByName.set(name, extPath);
|
|
2011
|
+
}
|
|
2012
|
+
// ponytail: bundled built-in extensions (src/extensions, shipped with selesai)
|
|
2013
|
+
// are the selesai side too: a pi-host copy of the same name must be dropped here
|
|
2014
|
+
// or detectExtensionConflicts() throws a fatal tool conflict at load time
|
|
2015
|
+
// (e.g. selesai's bundled question vs ~/.pi/agent/extensions/question.ts).
|
|
2016
|
+
// Bundled always wins — extensionHost can't override it (it loads via
|
|
2017
|
+
// additionalExtensionPaths at boot, not the accumulator, so delete() is a no-op
|
|
2018
|
+
// and a pi-winner override would leave both loaded = fatal conflict).
|
|
2019
|
+
const bundledExtDir = getBundledExtensionsDir();
|
|
2020
|
+
const bundledExtNames = new Set();
|
|
2021
|
+
for (const extPath of collectAutoExtensionEntries(bundledExtDir)) {
|
|
2022
|
+
const name = extensionEntryName(extPath, bundledExtDir);
|
|
2023
|
+
if (name) {
|
|
2024
|
+
bundledExtNames.add(name);
|
|
2025
|
+
if (!selesaiPathsByName.has(name))
|
|
2026
|
+
selesaiPathsByName.set(name, extPath);
|
|
2027
|
+
}
|
|
2028
|
+
}
|
|
2029
|
+
const piHostEntries = collectAutoExtensionEntries(piHostExtDir);
|
|
2030
|
+
const piHostKept = [];
|
|
2031
|
+
for (const extPath of piHostEntries) {
|
|
2032
|
+
const name = extensionEntryName(extPath, piHostExtDir);
|
|
2033
|
+
if (!name || !selesaiPathsByName.has(name)) {
|
|
2034
|
+
piHostKept.push(extPath);
|
|
2035
|
+
continue;
|
|
2036
|
+
}
|
|
2037
|
+
// Collision: pick winner per settings; default selesai.
|
|
2038
|
+
// Bundled always wins — ignore a "pi" override for bundled extensions.
|
|
2039
|
+
const isBundled = bundledExtNames.has(name);
|
|
2040
|
+
const winner = isBundled ? "selesai" : (extensionHost[name] ?? "selesai");
|
|
2041
|
+
const selesaiWins = winner === "selesai";
|
|
2042
|
+
const selesaiPath = selesaiPathsByName.get(name);
|
|
2043
|
+
if (!selesaiWins) {
|
|
2044
|
+
// Drop the selesai copy so pi's wins; register pi's path.
|
|
2045
|
+
accumulator.extensions.delete(selesaiPath);
|
|
2046
|
+
piHostKept.push(extPath);
|
|
2047
|
+
}
|
|
2048
|
+
collisions.push({
|
|
2049
|
+
resourceType: "extension",
|
|
2050
|
+
name,
|
|
2051
|
+
winnerPath: selesaiWins ? selesaiPath : extPath,
|
|
2052
|
+
loserPath: selesaiWins ? extPath : selesaiPath,
|
|
2053
|
+
winnerSource: selesaiWins ? selesaiExtSource : piExtSource,
|
|
2054
|
+
loserSource: selesaiWins ? piExtSource : selesaiExtSource,
|
|
2055
|
+
winner,
|
|
2056
|
+
});
|
|
2057
|
+
}
|
|
2058
|
+
addResources("extensions", piHostKept, { ...userMetadata, baseDir: piHostBaseDir }, userOverrides.extensions, piHostBaseDir);
|
|
2059
|
+
// User skills from ~/.selesai/agent/
|
|
2060
|
+
addResources("skills", collectAutoSkillEntries(userDirs.skills, "pi"), userMetadata, userOverrides.skills, globalBaseDir);
|
|
2061
|
+
// User skills from ~/.agents/ (with its own baseDir)
|
|
2062
|
+
const userAgentsBaseDir = dirname(userAgentsSkillsDir);
|
|
2063
|
+
const userAgentsMetadata = {
|
|
2064
|
+
...userMetadata,
|
|
2065
|
+
baseDir: userAgentsBaseDir,
|
|
2066
|
+
};
|
|
2067
|
+
addResources("skills", collectAutoSkillEntries(userAgentsSkillsDir, "agents"), userAgentsMetadata, userOverrides.skills, userAgentsBaseDir);
|
|
2068
|
+
addResources("prompts", collectAutoPromptEntries(userDirs.prompts), userMetadata, userOverrides.prompts, globalBaseDir);
|
|
2069
|
+
addResources("themes", collectAutoThemeEntries(userDirs.themes), userMetadata, userOverrides.themes, globalBaseDir);
|
|
2070
|
+
return collisions;
|
|
2071
|
+
}
|
|
2072
|
+
collectFilesFromPaths(paths, resourceType) {
|
|
2073
|
+
const files = [];
|
|
2074
|
+
for (const p of paths) {
|
|
2075
|
+
if (!existsSync(p))
|
|
2076
|
+
continue;
|
|
2077
|
+
try {
|
|
2078
|
+
const stats = statSync(p);
|
|
2079
|
+
if (stats.isFile()) {
|
|
2080
|
+
files.push(p);
|
|
2081
|
+
}
|
|
2082
|
+
else if (stats.isDirectory()) {
|
|
2083
|
+
files.push(...collectResourceFiles(p, resourceType));
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
catch {
|
|
2087
|
+
// Ignore errors
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
return files;
|
|
2091
|
+
}
|
|
2092
|
+
getTargetMap(accumulator, resourceType) {
|
|
2093
|
+
switch (resourceType) {
|
|
2094
|
+
case "extensions":
|
|
2095
|
+
return accumulator.extensions;
|
|
2096
|
+
case "skills":
|
|
2097
|
+
return accumulator.skills;
|
|
2098
|
+
case "prompts":
|
|
2099
|
+
return accumulator.prompts;
|
|
2100
|
+
case "themes":
|
|
2101
|
+
return accumulator.themes;
|
|
2102
|
+
case "agents":
|
|
2103
|
+
return accumulator.agents;
|
|
2104
|
+
default:
|
|
2105
|
+
throw new Error(`Unknown resource type: ${resourceType}`);
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
addResource(map, path, metadata, enabled) {
|
|
2109
|
+
if (!path)
|
|
2110
|
+
return;
|
|
2111
|
+
if (!map.has(path)) {
|
|
2112
|
+
map.set(path, { metadata, enabled });
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2115
|
+
createAccumulator() {
|
|
2116
|
+
return {
|
|
2117
|
+
extensions: new Map(),
|
|
2118
|
+
skills: new Map(),
|
|
2119
|
+
prompts: new Map(),
|
|
2120
|
+
themes: new Map(),
|
|
2121
|
+
agents: new Map(),
|
|
2122
|
+
};
|
|
2123
|
+
}
|
|
2124
|
+
toResolvedPaths(accumulator, collisions) {
|
|
2125
|
+
const mapToResolved = (entries) => {
|
|
2126
|
+
const resolved = Array.from(entries.entries()).map(([path, { metadata, enabled }]) => ({
|
|
2127
|
+
path,
|
|
2128
|
+
enabled,
|
|
2129
|
+
metadata,
|
|
2130
|
+
}));
|
|
2131
|
+
resolved.sort((a, b) => resourcePrecedenceRank(a.metadata) - resourcePrecedenceRank(b.metadata));
|
|
2132
|
+
const seen = new Set();
|
|
2133
|
+
return resolved.filter((entry) => {
|
|
2134
|
+
const canonicalPath = canonicalizePath(entry.path);
|
|
2135
|
+
if (seen.has(canonicalPath))
|
|
2136
|
+
return false;
|
|
2137
|
+
seen.add(canonicalPath);
|
|
2138
|
+
return true;
|
|
2139
|
+
});
|
|
2140
|
+
};
|
|
2141
|
+
return {
|
|
2142
|
+
extensions: mapToResolved(accumulator.extensions),
|
|
2143
|
+
skills: mapToResolved(accumulator.skills),
|
|
2144
|
+
prompts: mapToResolved(accumulator.prompts),
|
|
2145
|
+
themes: mapToResolved(accumulator.themes),
|
|
2146
|
+
agents: mapToResolved(accumulator.agents),
|
|
2147
|
+
extensionCollisions: collisions,
|
|
2148
|
+
};
|
|
2149
|
+
}
|
|
2150
|
+
spawnCommand(command, args, options) {
|
|
2151
|
+
const env = getEnv();
|
|
2152
|
+
return spawnProcess(command, args, {
|
|
2153
|
+
cwd: options?.cwd,
|
|
2154
|
+
stdio: isStdoutTakenOver() ? ["ignore", 2, 2] : "inherit",
|
|
2155
|
+
env,
|
|
2156
|
+
});
|
|
2157
|
+
}
|
|
2158
|
+
spawnCaptureCommand(command, args, options) {
|
|
2159
|
+
const baseEnv = getEnv();
|
|
2160
|
+
const env = options?.env ? { ...baseEnv, ...options.env } : baseEnv;
|
|
2161
|
+
return spawnProcess(command, args, {
|
|
2162
|
+
cwd: options?.cwd,
|
|
2163
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
2164
|
+
env,
|
|
2165
|
+
});
|
|
2166
|
+
}
|
|
2167
|
+
runCommandCapture(command, args, options) {
|
|
2168
|
+
return new Promise((resolvePromise, reject) => {
|
|
2169
|
+
const child = this.spawnCaptureCommand(command, args, options);
|
|
2170
|
+
let stdout = "";
|
|
2171
|
+
let stderr = "";
|
|
2172
|
+
let timedOut = false;
|
|
2173
|
+
const timeout = typeof options?.timeoutMs === "number"
|
|
2174
|
+
? setTimeout(() => {
|
|
2175
|
+
timedOut = true;
|
|
2176
|
+
child.kill();
|
|
2177
|
+
}, options.timeoutMs)
|
|
2178
|
+
: undefined;
|
|
2179
|
+
child.stdout?.on("data", (data) => {
|
|
2180
|
+
stdout += data.toString();
|
|
2181
|
+
});
|
|
2182
|
+
child.stderr?.on("data", (data) => {
|
|
2183
|
+
stderr += data.toString();
|
|
2184
|
+
});
|
|
2185
|
+
child.once("error", (error) => {
|
|
2186
|
+
if (timeout)
|
|
2187
|
+
clearTimeout(timeout);
|
|
2188
|
+
reject(error);
|
|
2189
|
+
});
|
|
2190
|
+
child.once("close", (code, signal) => {
|
|
2191
|
+
if (timeout)
|
|
2192
|
+
clearTimeout(timeout);
|
|
2193
|
+
if (timedOut) {
|
|
2194
|
+
reject(new Error(`${command} ${args.join(" ")} timed out after ${options?.timeoutMs}ms`));
|
|
2195
|
+
return;
|
|
2196
|
+
}
|
|
2197
|
+
if (code === 0) {
|
|
2198
|
+
resolvePromise(stdout.trim());
|
|
2199
|
+
return;
|
|
2200
|
+
}
|
|
2201
|
+
const exitStatus = code === null ? `signal ${signal ?? "unknown"}` : `code ${code}`;
|
|
2202
|
+
reject(new Error(`${command} ${args.join(" ")} failed with ${exitStatus}: ${stderr || stdout}`));
|
|
2203
|
+
});
|
|
2204
|
+
});
|
|
2205
|
+
}
|
|
2206
|
+
runCommand(command, args, options) {
|
|
2207
|
+
return new Promise((resolvePromise, reject) => {
|
|
2208
|
+
const child = this.spawnCommand(command, args, options);
|
|
2209
|
+
child.on("error", reject);
|
|
2210
|
+
child.on("exit", (code) => {
|
|
2211
|
+
if (code === 0) {
|
|
2212
|
+
resolvePromise();
|
|
2213
|
+
}
|
|
2214
|
+
else {
|
|
2215
|
+
reject(new Error(`${command} ${args.join(" ")} failed with code ${code}`));
|
|
2216
|
+
}
|
|
2217
|
+
});
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
runCommandSync(command, args) {
|
|
2221
|
+
const env = getEnv();
|
|
2222
|
+
const result = spawnProcessSync(command, args, {
|
|
2223
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
2224
|
+
encoding: "utf-8",
|
|
2225
|
+
env,
|
|
2226
|
+
});
|
|
2227
|
+
if (result.error || result.status !== 0) {
|
|
2228
|
+
throw new Error(`Failed to run ${command} ${args.join(" ")}: ${result.error?.message || result.stderr || result.stdout}`);
|
|
2229
|
+
}
|
|
2230
|
+
return (result.stdout || result.stderr || "").trim();
|
|
2231
|
+
}
|
|
2232
|
+
}
|