@hoilab/ada-cli 0.84.21 → 0.84.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.es.md +163 -0
- package/README.md +99 -652
- package/dist/cli/args.d.ts +3 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +11 -0
- package/dist/cli/args.js.map +1 -1
- package/dist/cli/file-processor.d.ts.map +1 -1
- package/dist/cli/file-processor.js +2 -1
- package/dist/cli/file-processor.js.map +1 -1
- package/dist/cli/home-screen.d.ts.map +1 -1
- package/dist/cli/home-screen.js +2 -2
- package/dist/cli/home-screen.js.map +1 -1
- package/dist/cli/startup-ui.d.ts.map +1 -1
- package/dist/cli/startup-ui.js +9 -3
- package/dist/cli/startup-ui.js.map +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -1
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +57 -7
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +449 -73
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/auth-storage.d.ts.map +1 -1
- package/dist/core/auth-storage.js +4 -3
- package/dist/core/auth-storage.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +3 -0
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts +4 -3
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +41 -32
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/defaults.d.ts +1 -0
- package/dist/core/defaults.d.ts.map +1 -1
- package/dist/core/defaults.js +9 -0
- package/dist/core/defaults.js.map +1 -1
- package/dist/core/engine-personality.d.ts +12 -0
- package/dist/core/engine-personality.d.ts.map +1 -0
- package/dist/core/engine-personality.js +53 -0
- package/dist/core/engine-personality.js.map +1 -0
- package/dist/core/extensions/index.d.ts +1 -1
- package/dist/core/extensions/index.d.ts.map +1 -1
- package/dist/core/extensions/index.js.map +1 -1
- package/dist/core/extensions/loader.d.ts.map +1 -1
- package/dist/core/extensions/loader.js +10 -5
- package/dist/core/extensions/loader.js.map +1 -1
- package/dist/core/extensions/types.d.ts +23 -4
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +2 -1
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/memory-engine/audit-export.d.ts +54 -0
- package/dist/core/memory-engine/audit-export.d.ts.map +1 -0
- package/dist/core/memory-engine/audit-export.js +85 -0
- package/dist/core/memory-engine/audit-export.js.map +1 -0
- package/dist/core/memory-engine/audit.d.ts.map +1 -1
- package/dist/core/memory-engine/audit.js +7 -8
- package/dist/core/memory-engine/audit.js.map +1 -1
- package/dist/core/memory-engine/engine.d.ts +2 -3
- package/dist/core/memory-engine/engine.d.ts.map +1 -1
- package/dist/core/memory-engine/engine.js +148 -50
- package/dist/core/memory-engine/engine.js.map +1 -1
- package/dist/core/memory-engine/inverted-index.d.ts.map +1 -1
- package/dist/core/memory-engine/inverted-index.js +67 -10
- package/dist/core/memory-engine/inverted-index.js.map +1 -1
- package/dist/core/memory-engine/keychain.d.ts.map +1 -1
- package/dist/core/memory-engine/keychain.js +1 -6
- package/dist/core/memory-engine/keychain.js.map +1 -1
- package/dist/core/memory-engine/observation-store.d.ts +1 -0
- package/dist/core/memory-engine/observation-store.d.ts.map +1 -1
- package/dist/core/memory-engine/observation-store.js +37 -8
- package/dist/core/memory-engine/observation-store.js.map +1 -1
- package/dist/core/memory-engine/scanner.d.ts.map +1 -1
- package/dist/core/memory-engine/scanner.js +25 -5
- package/dist/core/memory-engine/scanner.js.map +1 -1
- package/dist/core/memory-engine/security.d.ts.map +1 -1
- package/dist/core/memory-engine/security.js +131 -23
- package/dist/core/memory-engine/security.js.map +1 -1
- package/dist/core/memory-engine/session-indexer.d.ts.map +1 -1
- package/dist/core/memory-engine/session-indexer.js +8 -2
- package/dist/core/memory-engine/session-indexer.js.map +1 -1
- package/dist/core/memory-engine/tools.d.ts +2 -2
- package/dist/core/memory-engine/tools.d.ts.map +1 -1
- package/dist/core/memory-engine/tools.js +14 -7
- package/dist/core/memory-engine/tools.js.map +1 -1
- package/dist/core/memory-engine/vault.d.ts.map +1 -1
- package/dist/core/memory-engine/vault.js +2 -2
- package/dist/core/memory-engine/vault.js.map +1 -1
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +2 -1
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/model-resolver.d.ts +1 -0
- package/dist/core/model-resolver.d.ts.map +1 -1
- package/dist/core/model-resolver.js +12 -6
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/models-store.d.ts.map +1 -1
- package/dist/core/models-store.js +2 -1
- package/dist/core/models-store.js.map +1 -1
- package/dist/core/package-manager.d.ts.map +1 -1
- package/dist/core/package-manager.js +11 -6
- package/dist/core/package-manager.js.map +1 -1
- package/dist/core/pi-manifest.d.ts.map +1 -1
- package/dist/core/pi-manifest.js +2 -1
- package/dist/core/pi-manifest.js.map +1 -1
- package/dist/core/prompt-optimizer.d.ts +53 -0
- package/dist/core/prompt-optimizer.d.ts.map +1 -0
- package/dist/core/prompt-optimizer.js +138 -0
- package/dist/core/prompt-optimizer.js.map +1 -0
- package/dist/core/provider-attribution.d.ts.map +1 -1
- package/dist/core/provider-attribution.js +1 -1
- package/dist/core/provider-attribution.js.map +1 -1
- package/dist/core/remote-catalog-provider.d.ts.map +1 -1
- package/dist/core/remote-catalog-provider.js +2 -1
- package/dist/core/remote-catalog-provider.js.map +1 -1
- package/dist/core/resource-loader.d.ts +50 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +233 -7
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +8 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +11 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +2 -1
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/settings-diagnostics.d.ts +9 -0
- package/dist/core/settings-diagnostics.d.ts.map +1 -0
- package/dist/core/settings-diagnostics.js +21 -0
- package/dist/core/settings-diagnostics.js.map +1 -0
- package/dist/core/settings-manager.d.ts +52 -0
- package/dist/core/settings-manager.d.ts.map +1 -1
- package/dist/core/settings-manager.js +204 -10
- package/dist/core/settings-manager.js.map +1 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +51 -33
- package/dist/core/skills.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +2 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/core/tools/edit-diff.d.ts +0 -5
- package/dist/core/tools/edit-diff.d.ts.map +1 -1
- package/dist/core/tools/edit-diff.js +2 -5
- package/dist/core/tools/edit-diff.js.map +1 -1
- package/dist/core/tools/edit.d.ts.map +1 -1
- package/dist/core/tools/edit.js +20 -4
- package/dist/core/tools/edit.js.map +1 -1
- package/dist/core/tools/index.d.ts.map +1 -1
- package/dist/core/tools/index.js +2 -2
- package/dist/core/tools/index.js.map +1 -1
- package/dist/core/tools/project-memory-tool.d.ts.map +1 -1
- package/dist/core/tools/project-memory-tool.js +4 -1
- package/dist/core/tools/project-memory-tool.js.map +1 -1
- package/dist/core/trust-manager.d.ts.map +1 -1
- package/dist/core/trust-manager.js +2 -1
- package/dist/core/trust-manager.js.map +1 -1
- package/dist/core/workflows/agent-runner.d.ts +86 -0
- package/dist/core/workflows/agent-runner.d.ts.map +1 -0
- package/dist/core/workflows/agent-runner.js +225 -0
- package/dist/core/workflows/agent-runner.js.map +1 -0
- package/dist/core/workflows/builtins.d.ts +41 -0
- package/dist/core/workflows/builtins.d.ts.map +1 -0
- package/dist/core/workflows/builtins.js +282 -0
- package/dist/core/workflows/builtins.js.map +1 -0
- package/dist/core/workflows/goal-engine/engine.d.ts +134 -0
- package/dist/core/workflows/goal-engine/engine.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/engine.js +462 -0
- package/dist/core/workflows/goal-engine/engine.js.map +1 -0
- package/dist/core/workflows/goal-engine/errors.d.ts +7 -0
- package/dist/core/workflows/goal-engine/errors.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/errors.js +9 -0
- package/dist/core/workflows/goal-engine/errors.js.map +1 -0
- package/dist/core/workflows/goal-engine/index.d.ts +13 -0
- package/dist/core/workflows/goal-engine/index.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/index.js +8 -0
- package/dist/core/workflows/goal-engine/index.js.map +1 -0
- package/dist/core/workflows/goal-engine/persistence.d.ts +31 -0
- package/dist/core/workflows/goal-engine/persistence.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/persistence.js +145 -0
- package/dist/core/workflows/goal-engine/persistence.js.map +1 -0
- package/dist/core/workflows/goal-engine/prompts.d.ts +37 -0
- package/dist/core/workflows/goal-engine/prompts.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/prompts.js +131 -0
- package/dist/core/workflows/goal-engine/prompts.js.map +1 -0
- package/dist/core/workflows/goal-engine/state.d.ts +41 -0
- package/dist/core/workflows/goal-engine/state.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/state.js +397 -0
- package/dist/core/workflows/goal-engine/state.js.map +1 -0
- package/dist/core/workflows/goal-engine/tools.d.ts +31 -0
- package/dist/core/workflows/goal-engine/tools.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/tools.js +211 -0
- package/dist/core/workflows/goal-engine/tools.js.map +1 -0
- package/dist/core/workflows/goal-engine/types.d.ts +286 -0
- package/dist/core/workflows/goal-engine/types.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/types.js +17 -0
- package/dist/core/workflows/goal-engine/types.js.map +1 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.d.ts +23 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.d.ts.map +1 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.js +72 -0
- package/dist/core/workflows/goal-engine/worktree-fingerprint.js.map +1 -0
- package/dist/core/workflows/graph-sync.d.ts +67 -0
- package/dist/core/workflows/graph-sync.d.ts.map +1 -0
- package/dist/core/workflows/graph-sync.js +188 -0
- package/dist/core/workflows/graph-sync.js.map +1 -0
- package/dist/core/workflows/graph.d.ts +143 -0
- package/dist/core/workflows/graph.d.ts.map +1 -0
- package/dist/core/workflows/graph.js +319 -0
- package/dist/core/workflows/graph.js.map +1 -0
- package/dist/core/workflows/index.d.ts +18 -0
- package/dist/core/workflows/index.d.ts.map +1 -0
- package/dist/core/workflows/index.js +14 -0
- package/dist/core/workflows/index.js.map +1 -0
- package/dist/core/workflows/journal.d.ts +68 -0
- package/dist/core/workflows/journal.d.ts.map +1 -0
- package/dist/core/workflows/journal.js +83 -0
- package/dist/core/workflows/journal.js.map +1 -0
- package/dist/core/workflows/manager.d.ts +112 -0
- package/dist/core/workflows/manager.d.ts.map +1 -0
- package/dist/core/workflows/manager.js +327 -0
- package/dist/core/workflows/manager.js.map +1 -0
- package/dist/core/workflows/resolve-script.d.ts +35 -0
- package/dist/core/workflows/resolve-script.d.ts.map +1 -0
- package/dist/core/workflows/resolve-script.js +66 -0
- package/dist/core/workflows/resolve-script.js.map +1 -0
- package/dist/core/workflows/runtime.d.ts +49 -0
- package/dist/core/workflows/runtime.d.ts.map +1 -0
- package/dist/core/workflows/runtime.js +301 -0
- package/dist/core/workflows/runtime.js.map +1 -0
- package/dist/core/workflows/shared-store.d.ts +31 -0
- package/dist/core/workflows/shared-store.d.ts.map +1 -0
- package/dist/core/workflows/shared-store.js +80 -0
- package/dist/core/workflows/shared-store.js.map +1 -0
- package/dist/core/workflows/subagent-host.d.ts +50 -0
- package/dist/core/workflows/subagent-host.d.ts.map +1 -0
- package/dist/core/workflows/subagent-host.js +225 -0
- package/dist/core/workflows/subagent-host.js.map +1 -0
- package/dist/core/workflows/tool-workflow.d.ts +22 -0
- package/dist/core/workflows/tool-workflow.d.ts.map +1 -0
- package/dist/core/workflows/tool-workflow.js +120 -0
- package/dist/core/workflows/tool-workflow.js.map +1 -0
- package/dist/core/workflows/types.d.ts +142 -0
- package/dist/core/workflows/types.d.ts.map +1 -0
- package/dist/core/workflows/types.js +26 -0
- package/dist/core/workflows/types.js.map +1 -0
- package/dist/core/workflows/worktree.d.ts +42 -0
- package/dist/core/workflows/worktree.d.ts.map +1 -0
- package/dist/core/workflows/worktree.js +107 -0
- package/dist/core/workflows/worktree.js.map +1 -0
- package/dist/extensions/llama/index.d.ts.map +1 -1
- package/dist/extensions/llama/index.js +2 -0
- package/dist/extensions/llama/index.js.map +1 -1
- package/dist/extensions/llama/provider.d.ts.map +1 -1
- package/dist/extensions/llama/provider.js +6 -2
- package/dist/extensions/llama/provider.js.map +1 -1
- package/dist/index.d.ts +16 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts +4 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -15
- package/dist/main.js.map +1 -1
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +4 -3
- package/dist/migrations.js.map +1 -1
- package/dist/modes/interactive/components/home-screen.d.ts.map +1 -1
- package/dist/modes/interactive/components/home-screen.js +2 -2
- package/dist/modes/interactive/components/home-screen.js.map +1 -1
- package/dist/modes/interactive/components/model-selector.d.ts +2 -3
- package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/model-selector.js +16 -6
- package/dist/modes/interactive/components/model-selector.js.map +1 -1
- package/dist/modes/interactive/components/prompt-optimization.d.ts +16 -0
- package/dist/modes/interactive/components/prompt-optimization.d.ts.map +1 -0
- package/dist/modes/interactive/components/prompt-optimization.js +46 -0
- package/dist/modes/interactive/components/prompt-optimization.js.map +1 -0
- package/dist/modes/interactive/components/settings-selector.d.ts +19 -1
- package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector.js +247 -46
- package/dist/modes/interactive/components/settings-selector.js.map +1 -1
- package/dist/modes/interactive/components/settings-submenu.d.ts +72 -0
- package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -0
- package/dist/modes/interactive/components/settings-submenu.js +165 -0
- package/dist/modes/interactive/components/settings-submenu.js.map +1 -0
- package/dist/modes/interactive/components/thinking-selector.d.ts +8 -3
- package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
- package/dist/modes/interactive/components/thinking-selector.js +29 -3
- package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
- package/dist/modes/interactive/external-editor.d.ts.map +1 -1
- package/dist/modes/interactive/external-editor.js +2 -1
- package/dist/modes/interactive/external-editor.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +24 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +677 -34
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +4 -3
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/modes/json-event.d.ts +16 -13
- package/dist/modes/json-event.d.ts.map +1 -1
- package/dist/modes/json-event.js +20 -6
- package/dist/modes/json-event.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +173 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +29 -0
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/dist/package-manager-cli.d.ts.map +1 -1
- package/dist/package-manager-cli.js +1 -1
- package/dist/package-manager-cli.js.map +1 -1
- package/dist/skills/ada-engine/SKILL.md +153 -0
- package/dist/utils/frontmatter.d.ts.map +1 -1
- package/dist/utils/frontmatter.js +2 -1
- package/dist/utils/frontmatter.js.map +1 -1
- package/dist/utils/management-http.d.ts +5 -3
- package/dist/utils/management-http.d.ts.map +1 -1
- package/dist/utils/management-http.js +14 -10
- package/dist/utils/management-http.js.map +1 -1
- package/dist/utils/text.d.ts +8 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +9 -0
- package/dist/utils/text.js.map +1 -0
- package/docs/compaction.md +15 -0
- package/docs/custom-provider.md +5 -2
- package/docs/extensions.md +11 -2
- package/docs/json.md +7 -2
- package/docs/llama-cpp.md +2 -0
- package/docs/models.md +8 -2
- package/docs/rpc.md +9 -3
- package/docs/settings.md +2 -2
- package/docs/skills.md +4 -3
- package/examples/extensions/border-status-editor.ts +1 -1
- package/examples/extensions/git-checkpoint.ts +2 -2
- package/examples/extensions/notify.ts +3 -1
- package/examples/extensions/subagent/README.md +1 -1
- package/examples/extensions/subagent/index.ts +6 -1
- package/examples/extensions/titlebar-spinner.ts +1 -1
- package/examples/rpc-extension-ui.ts +1 -1
- package/examples/sdk/06-extensions.ts +1 -1
- package/examples/sdk/README.md +1 -1
- package/npm-shrinkwrap.json +2 -12
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager-cli.d.ts","sourceRoot":"","sources":["../src/package-manager-cli.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAclE,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAyftE,MAAM,WAAW,4BAA4B;IAC5C,kBAAkB,CAAC,EAAE,eAAe,EAAE,CAAC;CACvC;AAiED,wBAAsB,mBAAmB,CACxC,IAAI,EAAE,MAAM,EAAE,EACd,cAAc,GAAE,4BAAiC,GAC/C,OAAO,CAAC,OAAO,CAAC,CAoElB;AAED,wBAAsB,oBAAoB,CACzC,IAAI,EAAE,MAAM,EAAE,EACd,cAAc,GAAE,4BAAiC,GAC/C,OAAO,CAAC,OAAO,CAAC,CAgNlB","sourcesContent":["import { join } from \"node:path\";\nimport { Markdown, type MarkdownTheme } from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { selectConfig } from \"./cli/config-selector.ts\";\nimport { createProjectTrustContext } from \"./cli/project-trust.ts\";\nimport {\n\tAPP_NAME,\n\tCONFIG_DIR_NAME,\n\tdetectInstallMethod,\n\tgetAgentDir,\n\tgetPackageDir,\n\tgetSelfUpdateCommand,\n\tgetSelfUpdateUnavailableInstruction,\n\tPACKAGE_NAME,\n\ttype SelfUpdateCommand,\n\ttype SelfUpdatePackageTarget,\n\tVERSION,\n} from \"./config.ts\";\nimport type { InlineExtension } from \"./core/extensions/types.ts\";\nimport { ModelRuntime } from \"./core/model-runtime.ts\";\nimport { DefaultPackageManager } from \"./core/package-manager.ts\";\nimport { type AppMode, resolveProjectTrusted } from \"./core/project-trust.ts\";\nimport { DefaultResourceLoader } from \"./core/resource-loader.ts\";\nimport { SettingsManager } from \"./core/settings-manager.ts\";\nimport { hasTrustRequiringProjectResources, ProjectTrustStore } from \"./core/trust-manager.ts\";\nimport { spawnProcess } from \"./utils/child-process.ts\";\nimport { formatVersionCheckError, getLatestPiRelease, isNewerPackageVersion } from \"./utils/version-check.ts\";\nimport {\n\tcleanupWindowsSelfUpdateQuarantine,\n\tquarantineWindowsNativeDependencies,\n} from \"./utils/windows-self-update.ts\";\n\nexport type PackageCommand = \"install\" | \"remove\" | \"update\" | \"list\";\n\ntype UpdateTarget = { type: \"all\" } | { type: \"self\" } | { type: \"extensions\"; source?: string } | { type: \"models\" };\n\nconst SELF_UPDATE_NOTE_MARKDOWN_THEME: MarkdownTheme = {\n\theading: (text) => chalk.bold(chalk.yellow(text)),\n\tlink: (text) => chalk.cyan(text),\n\tlinkUrl: (text) => chalk.dim(text),\n\tcode: (text) => chalk.yellow(text),\n\tcodeBlock: (text) => chalk.dim(text),\n\tcodeBlockBorder: (text) => chalk.dim(text),\n\tquote: (text) => chalk.dim(text),\n\tquoteBorder: (text) => chalk.dim(text),\n\thr: (text) => chalk.dim(text),\n\tlistBullet: (text) => chalk.yellow(text),\n\tbold: (text) => chalk.bold(text),\n\titalic: (text) => chalk.italic(text),\n\tstrikethrough: (text) => chalk.strikethrough(text),\n\tunderline: (text) => chalk.underline(text),\n};\n\ninterface PackageCommandOptions {\n\tcommand: PackageCommand;\n\tsource?: string;\n\tupdateTarget?: UpdateTarget;\n\tshowExtensionsSkippedNote: boolean;\n\tlocal: boolean;\n\tforce: boolean;\n\tprojectTrustOverride?: boolean;\n\thelp: boolean;\n\tinvalidOption?: string;\n\tinvalidArgument?: string;\n\tmissingOptionValue?: string;\n\tconflictingOptions?: string;\n}\n\nfunction reportSettingsErrors(settingsManager: SettingsManager, context: string): void {\n\tconst errors = settingsManager.drainErrors();\n\tfor (const { scope, error } of errors) {\n\t\tconsole.error(chalk.yellow(`Warning (${context}, ${scope} settings): ${error.message}`));\n\t\tif (error.stack) {\n\t\t\tconsole.error(chalk.dim(error.stack));\n\t\t}\n\t}\n}\n\nfunction getPackageCommandUsage(command: PackageCommand): string {\n\tswitch (command) {\n\t\tcase \"install\":\n\t\t\treturn `${APP_NAME} install <source> [-l] [--approve|--no-approve]`;\n\t\tcase \"remove\":\n\t\t\treturn `${APP_NAME} remove <source> [-l] [--approve|--no-approve]`;\n\t\tcase \"update\":\n\t\t\treturn `${APP_NAME} update [source|self|ada-cli] [--self|--extensions|--models|--all] [--extension <source>] [--approve|--no-approve] [--force]`;\n\t\tcase \"list\":\n\t\t\treturn `${APP_NAME} list [--approve|--no-approve]`;\n\t}\n}\n\nconst CONFIG_COMMAND_USAGE = `${APP_NAME} config [-l] [--approve|--no-approve]`;\n\nfunction printConfigCommandHelp(): void {\n\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${CONFIG_COMMAND_USAGE}\n\nOpen the resource configuration TUI to enable or disable package resources.\nWithout -l, starts in global settings (~/${CONFIG_DIR_NAME}/agent/settings.json).\nPress Tab in the TUI to switch between global and project-local modes.\n\nOptions:\n -l, --local Edit project overrides (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command with -l\n -na, --no-approve Ignore project-local files for this command with -l\n`);\n}\n\nfunction printPackageCommandHelp(command: PackageCommand): void {\n\tswitch (command) {\n\t\tcase \"install\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"install\")}\n\nInstall a package and add it to settings.\n\nOptions:\n -l, --local Install project-locally (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n\nExamples:\n ${APP_NAME} install npm:@foo/bar\n ${APP_NAME} install git:github.com/user/repo\n ${APP_NAME} install git:git@github.com:user/repo\n ${APP_NAME} install https://github.com/user/repo\n ${APP_NAME} install ssh://git@github.com/user/repo\n ${APP_NAME} install ./local/path\n`);\n\t\t\treturn;\n\n\t\tcase \"remove\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"remove\")}\n\nRemove a package and its source from settings.\nAlias: ${APP_NAME} uninstall <source> [-l]\n\nOptions:\n -l, --local Remove from project settings (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n\nExamples:\n ${APP_NAME} remove npm:@foo/bar\n ${APP_NAME} uninstall npm:@foo/bar\n`);\n\t\t\treturn;\n\n\t\tcase \"update\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"update\")}\n\nUpdate ada-cli, installed packages, or model catalogs.\n\nOptions:\n --self Update ada-cli only (default when no target is given)\n --extensions Update installed packages only\n --models Refresh model catalogs only\n --all Update pi and installed packages\n --extension <source> Update one package only\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n --force Reinstall pi even if the current version is latest\n\nShort forms:\n ${APP_NAME} update Update pi only\n ${APP_NAME} update --all Update pi and all extensions\n ${APP_NAME} update --models Refresh model catalogs only\n ${APP_NAME} update <source> Update one package\n ${APP_NAME} update ada-cli Update ada-cli only (self works as alias to ada-cli)\n`);\n\t\t\treturn;\n\n\t\tcase \"list\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"list\")}\n\nList installed packages from user and project settings.\n\nOptions:\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n`);\n\t\t\treturn;\n\t}\n}\n\nfunction parsePackageCommand(args: string[]): PackageCommandOptions | undefined {\n\tconst [rawCommand, ...rest] = args;\n\tlet command: PackageCommand | undefined;\n\tif (rawCommand === \"uninstall\") {\n\t\tcommand = \"remove\";\n\t} else if (rawCommand === \"install\" || rawCommand === \"remove\" || rawCommand === \"update\" || rawCommand === \"list\") {\n\t\tcommand = rawCommand;\n\t}\n\tif (!command) {\n\t\treturn undefined;\n\t}\n\n\tlet local = false;\n\tlet force = false;\n\tlet projectTrustOverride: boolean | undefined;\n\tlet help = false;\n\tlet invalidOption: string | undefined;\n\tlet invalidArgument: string | undefined;\n\tlet missingOptionValue: string | undefined;\n\tlet conflictingOptions: string | undefined;\n\tlet source: string | undefined;\n\tlet selfFlag = false;\n\tlet extensionsFlag = false;\n\tlet modelsFlag = false;\n\tlet allFlag = false;\n\tlet extensionFlagSource: string | undefined;\n\n\tfor (let index = 0; index < rest.length; index++) {\n\t\tconst arg = rest[index];\n\t\tif (arg === \"-h\" || arg === \"--help\") {\n\t\t\thelp = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"-l\" || arg === \"--local\") {\n\t\t\tif (command === \"install\" || command === \"remove\") {\n\t\t\t\tlocal = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--self\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tselfFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--extensions\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\textensionsFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--models\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tmodelsFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--all\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tallFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--approve\" || arg === \"-a\") {\n\t\t\tprojectTrustOverride = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--no-approve\" || arg === \"-na\") {\n\t\t\tprojectTrustOverride = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--force\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tforce = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--extension\") {\n\t\t\tif (command !== \"update\") {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst value = rest[index + 1];\n\t\t\tif (!value || value.startsWith(\"-\")) {\n\t\t\t\tmissingOptionValue = missingOptionValue ?? arg;\n\t\t\t} else if (extensionFlagSource) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--extension can only be provided once\";\n\t\t\t\tindex++;\n\t\t\t} else {\n\t\t\t\textensionFlagSource = value;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg.startsWith(\"-\")) {\n\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!source) {\n\t\t\tsource = arg;\n\t\t} else {\n\t\t\tinvalidArgument = invalidArgument ?? arg;\n\t\t}\n\t}\n\n\tlet updateTarget: UpdateTarget | undefined;\n\tlet showExtensionsSkippedNote = false;\n\tif (command === \"update\") {\n\t\tif (allFlag && (selfFlag || extensionsFlag || modelsFlag || extensionFlagSource)) {\n\t\t\tconflictingOptions =\n\t\t\t\tconflictingOptions ?? \"--all cannot be combined with --self, --extensions, --models, or --extension\";\n\t\t}\n\t\tif (allFlag && source) {\n\t\t\tconflictingOptions = conflictingOptions ?? \"--all cannot be combined with a positional source\";\n\t\t}\n\n\t\tif (modelsFlag) {\n\t\t\tif (selfFlag || extensionsFlag || allFlag || extensionFlagSource) {\n\t\t\t\tconflictingOptions =\n\t\t\t\t\tconflictingOptions ?? \"--models cannot be combined with --self, --extensions, --all, or --extension\";\n\t\t\t}\n\t\t\tif (source) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--models cannot be combined with a positional source\";\n\t\t\t}\n\t\t\tupdateTarget = { type: \"models\" };\n\t\t} else if (extensionFlagSource) {\n\t\t\tif (selfFlag || extensionsFlag || allFlag) {\n\t\t\t\tconflictingOptions =\n\t\t\t\t\tconflictingOptions ?? \"--extension cannot be combined with --self, --extensions, or --all\";\n\t\t\t}\n\t\t\tif (source) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--extension cannot be combined with a positional source\";\n\t\t\t}\n\t\t\tupdateTarget = { type: \"extensions\", source: extensionFlagSource };\n\t\t} else if (source) {\n\t\t\tconst sourceIsSelf = source === \"self\" || source === \"ada-cli\" || source === \"pi\";\n\t\t\tif (sourceIsSelf) {\n\t\t\t\tupdateTarget = extensionsFlag ? { type: \"all\" } : { type: \"self\" };\n\t\t\t} else {\n\t\t\t\tif (extensionsFlag || selfFlag || allFlag) {\n\t\t\t\t\tconflictingOptions =\n\t\t\t\t\t\tconflictingOptions ??\n\t\t\t\t\t\t\"positional update targets cannot be combined with --self, --extensions, or --all\";\n\t\t\t\t}\n\t\t\t\tupdateTarget = { type: \"extensions\", source };\n\t\t\t}\n\t\t} else if (allFlag) {\n\t\t\tupdateTarget = { type: \"all\" };\n\t\t} else if (selfFlag && extensionsFlag) {\n\t\t\tupdateTarget = { type: \"all\" };\n\t\t} else if (selfFlag) {\n\t\t\tupdateTarget = { type: \"self\" };\n\t\t} else if (extensionsFlag) {\n\t\t\tupdateTarget = { type: \"extensions\" };\n\t\t} else {\n\t\t\tupdateTarget = { type: \"self\" };\n\t\t\tshowExtensionsSkippedNote = true;\n\t\t}\n\t}\n\n\treturn {\n\t\tcommand,\n\t\tsource,\n\t\tupdateTarget,\n\t\tshowExtensionsSkippedNote,\n\t\tlocal,\n\t\tforce,\n\t\tprojectTrustOverride,\n\t\thelp,\n\t\tinvalidOption,\n\t\tinvalidArgument,\n\t\tmissingOptionValue,\n\t\tconflictingOptions,\n\t};\n}\n\nfunction updateTargetIncludesSelf(target: UpdateTarget): boolean {\n\treturn target.type === \"all\" || target.type === \"self\";\n}\n\nfunction updateTargetIncludesExtensions(target: UpdateTarget): boolean {\n\treturn target.type === \"all\" || target.type === \"extensions\";\n}\n\nasync function refreshModelCatalogs(agentDir: string): Promise<void> {\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), 15_000);\n\ttry {\n\t\tconst modelRuntime = await ModelRuntime.create({\n\t\t\tauthPath: join(agentDir, \"auth.json\"),\n\t\t\tmodelsPath: join(agentDir, \"models.json\"),\n\t\t\tallowModelNetwork: false,\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\tconst result = await modelRuntime.refresh({\n\t\t\tallowNetwork: true,\n\t\t\tforce: true,\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\tif (result.aborted) {\n\t\t\tthrow new Error(\"Model catalog refresh timed out.\");\n\t\t}\n\t\tif (result.errors.size > 0) {\n\t\t\tconst details = Array.from(result.errors, ([provider, error]) => `${provider}: ${error.message}`).join(\"; \");\n\t\t\tthrow new Error(`Could not refresh model catalogs: ${details}`);\n\t\t}\n\t} finally {\n\t\tclearTimeout(timeout);\n\t}\n\tconsole.log(chalk.green(\"Model catalogs refreshed\"));\n}\n\nfunction printSelfUpdateUnavailable(\n\tnpmCommand?: string[],\n\tupdatePackageTarget: SelfUpdatePackageTarget = PACKAGE_NAME,\n): void {\n\tconsole.error(`error: ${APP_NAME} cannot self-update this installation.`);\n\tconsole.error(getSelfUpdateUnavailableInstruction(PACKAGE_NAME, npmCommand, updatePackageTarget));\n\n\tconst entrypoint = process.argv[1];\n\tif (entrypoint) {\n\t\tconsole.error(\"\");\n\t\tconsole.error(`Location of ${APP_NAME} executable: ${entrypoint}`);\n\t}\n}\n\nfunction printSelfUpdateFallback(command: SelfUpdateCommand): void {\n\tconsole.error(chalk.dim(`If this keeps failing, run this command yourself: ${command.display}`));\n}\n\nfunction printPnpmSelfUpdateMetadataHint(): void {\n\tconsole.error(chalk.yellow(\"If pnpm reports missing package versions, its cached registry metadata may be stale.\"));\n\tconsole.error(chalk.yellow(`Run \\`pnpm store prune\\` and retry \\`${APP_NAME} update --self\\`.`));\n}\n\nfunction printSelfUpdateNote(note: string): void {\n\tconst trimmedNote = note.trim();\n\tif (!trimmedNote) {\n\t\treturn;\n\t}\n\n\tconsole.log();\n\tconsole.log(chalk.bold(chalk.yellow(\"Update note\")));\n\ttry {\n\t\tconst width = Math.max(20, process.stdout.columns ?? 80);\n\t\tconst renderedLines = new Markdown(trimmedNote, 0, 0, SELF_UPDATE_NOTE_MARKDOWN_THEME)\n\t\t\t.render(width)\n\t\t\t.map((line) => line.trimEnd());\n\t\tconsole.log(renderedLines.join(\"\\n\"));\n\t} catch {\n\t\tconsole.log(trimmedNote);\n\t}\n\tconsole.log();\n}\n\ninterface SelfUpdatePlan {\n\tpackageName: string;\n\tinstallSpec: string;\n\tversion: string;\n\tshouldRun: boolean;\n\tnote?: string;\n}\n\nasync function getSelfUpdatePlan(force: boolean): Promise<SelfUpdatePlan> {\n\tlet latestRelease: Awaited<ReturnType<typeof getLatestPiRelease>>;\n\ttry {\n\t\tlatestRelease = await getLatestPiRelease(VERSION, { retry: true });\n\t} catch (error: unknown) {\n\t\tthrow new Error(`Could not determine latest ${APP_NAME} version: ${formatVersionCheckError(error)}`, {\n\t\t\tcause: error,\n\t\t});\n\t}\n\tif (!latestRelease) {\n\t\tthrow new Error(`Could not determine latest ${APP_NAME} version.`);\n\t}\n\n\tconst packageName = PACKAGE_NAME;\n\tconst installSpec = `${packageName}@${latestRelease.version}`;\n\tif (force || isNewerPackageVersion(latestRelease.version, VERSION)) {\n\t\treturn {\n\t\t\tpackageName,\n\t\t\tinstallSpec,\n\t\t\tversion: latestRelease.version,\n\t\t\t...(latestRelease.note ? { note: latestRelease.note } : {}),\n\t\t\tshouldRun: true,\n\t\t};\n\t}\n\n\tconsole.log(chalk.green(`${APP_NAME} is already up to date (v${VERSION})`));\n\treturn { packageName, installSpec, version: latestRelease.version, shouldRun: false };\n}\n\nasync function runSelfUpdate(command: SelfUpdateCommand): Promise<void> {\n\tconsole.log(chalk.dim(`Updating ${APP_NAME} with ${command.display}...`));\n\tfor (const step of command.steps ?? [command]) {\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst child = spawnProcess(step.command, step.args, {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t});\n\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\treject(error);\n\t\t\t});\n\t\t\tchild.on(\"close\", (code, signal) => {\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else if (signal) {\n\t\t\t\t\treject(new Error(`${step.display} terminated by signal ${signal}`));\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error(`${step.display} exited with code ${code ?? \"unknown\"}`));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n}\n\nfunction prepareWindowsNpmSelfUpdate(): void {\n\tif (process.platform !== \"win32\") {\n\t\treturn;\n\t}\n\n\tconst packageDir = getPackageDir();\n\tcleanupWindowsSelfUpdateQuarantine(packageDir);\n\tquarantineWindowsNativeDependencies(packageDir);\n}\n\nexport interface PackageCommandRuntimeOptions {\n\textensionFactories?: InlineExtension[];\n}\n\ninterface CommandSettingsResult {\n\tsettingsManager: SettingsManager;\n\tprojectTrustWarnings: string[];\n}\n\nfunction getCommandAppMode(): AppMode {\n\treturn process.stdin.isTTY && process.stdout.isTTY ? \"interactive\" : \"print\";\n}\n\nfunction reportProjectTrustWarnings(warnings: readonly string[]): void {\n\tfor (const warning of warnings) {\n\t\tconsole.error(chalk.yellow(`Warning: ${warning}`));\n\t}\n}\n\nasync function createCommandSettingsManager(options: {\n\tcwd: string;\n\tagentDir: string;\n\tprojectTrustOverride?: boolean;\n\tuseSavedProjectTrustOnly?: boolean;\n\textensionFactories?: InlineExtension[];\n}): Promise<CommandSettingsResult> {\n\tconst settingsManager = SettingsManager.create(options.cwd, options.agentDir, { projectTrusted: false });\n\tconst projectTrustWarnings: string[] = [];\n\tconst trustStore = new ProjectTrustStore(options.agentDir);\n\tif (options.useSavedProjectTrustOnly) {\n\t\tconst savedProjectTrusted = trustStore.get(options.cwd) === true;\n\t\tsettingsManager.setProjectTrusted(options.projectTrustOverride ?? savedProjectTrusted);\n\t\treturn { settingsManager, projectTrustWarnings };\n\t}\n\n\tconst appMode = getCommandAppMode();\n\tconst extensionsResult =\n\t\toptions.projectTrustOverride === undefined && hasTrustRequiringProjectResources(options.cwd)\n\t\t\t? await new DefaultResourceLoader({\n\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\tagentDir: options.agentDir,\n\t\t\t\t\tsettingsManager,\n\t\t\t\t\textensionFactories: options.extensionFactories,\n\t\t\t\t}).loadProjectTrustExtensions()\n\t\t\t: undefined;\n\tfor (const error of extensionsResult?.errors ?? []) {\n\t\tprojectTrustWarnings.push(`Failed to load extension \"${error.path}\": ${error.error}`);\n\t}\n\n\tconst projectTrusted = await resolveProjectTrusted({\n\t\tcwd: options.cwd,\n\t\ttrustStore,\n\t\ttrustOverride: options.projectTrustOverride,\n\t\tdefaultProjectTrust: settingsManager.getDefaultProjectTrust(),\n\t\textensionsResult,\n\t\tprojectTrustContext: createProjectTrustContext({\n\t\t\tcwd: options.cwd,\n\t\t\tmode: appMode,\n\t\t\tsettingsManager,\n\t\t\thasUI: appMode === \"interactive\",\n\t\t}),\n\t\tonExtensionError: (message) => projectTrustWarnings.push(message),\n\t});\n\tsettingsManager.setProjectTrusted(projectTrusted);\n\treturn { settingsManager, projectTrustWarnings };\n}\n\nexport async function handleConfigCommand(\n\targs: string[],\n\truntimeOptions: PackageCommandRuntimeOptions = {},\n): Promise<boolean> {\n\tconst [command, ...rest] = args;\n\tif (command !== \"config\") {\n\t\treturn false;\n\t}\n\n\tif (rest.includes(\"-h\") || rest.includes(\"--help\")) {\n\t\tprintConfigCommandHelp();\n\t\treturn true;\n\t}\n\n\tlet local = false;\n\tlet projectTrustOverride: boolean | undefined;\n\tfor (const arg of rest) {\n\t\tif (arg === \"-l\" || arg === \"--local\") {\n\t\t\tlocal = true;\n\t\t} else if (arg === \"-a\" || arg === \"--approve\") {\n\t\t\tprojectTrustOverride = true;\n\t\t} else if (arg === \"-na\" || arg === \"--no-approve\") {\n\t\t\tprojectTrustOverride = false;\n\t\t} else if (arg.startsWith(\"-\")) {\n\t\t\tconsole.error(chalk.red(`Unknown option ${arg} for \"config\".`));\n\t\t\tconsole.error(chalk.dim(`Use \"${APP_NAME} --help\" or \"${CONFIG_COMMAND_USAGE}\".`));\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn true;\n\t\t} else {\n\t\t\tconsole.error(chalk.red(`Unexpected argument ${arg}.`));\n\t\t\tconsole.error(chalk.dim(`Usage: ${CONFIG_COMMAND_USAGE}`));\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst cwd = process.cwd();\n\tconst agentDir = getAgentDir();\n\tconst { settingsManager, projectTrustWarnings } = await createCommandSettingsManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tprojectTrustOverride,\n\t\textensionFactories: runtimeOptions.extensionFactories,\n\t});\n\treportProjectTrustWarnings(projectTrustWarnings);\n\tif (local && !settingsManager.isProjectTrusted()) {\n\t\tconsole.error(chalk.red(\"Project is not trusted. Use --approve to modify local resource config.\"));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\treportSettingsErrors(settingsManager, \"config command\");\n\tconst globalSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: false });\n\tconst globalResolvedPaths = await new DefaultPackageManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tsettingsManager: globalSettingsManager,\n\t}).resolve();\n\tconst projectResolvedPaths = settingsManager.isProjectTrusted()\n\t\t? await new DefaultPackageManager({ cwd, agentDir, settingsManager }).resolve()\n\t\t: globalResolvedPaths;\n\n\tawait selectConfig({\n\t\tresolvedPaths: { global: globalResolvedPaths, project: projectResolvedPaths },\n\t\tsettingsManager,\n\t\tcwd,\n\t\tagentDir,\n\t\twriteScope: local ? \"project\" : \"global\",\n\t\tprojectModeAvailable: settingsManager.isProjectTrusted(),\n\t});\n\n\tprocess.exit(0);\n}\n\nexport async function handlePackageCommand(\n\targs: string[],\n\truntimeOptions: PackageCommandRuntimeOptions = {},\n): Promise<boolean> {\n\tconst options = parsePackageCommand(args);\n\tif (!options) {\n\t\treturn false;\n\t}\n\n\tif (options.help) {\n\t\tprintPackageCommandHelp(options.command);\n\t\treturn true;\n\t}\n\n\tif (options.invalidOption) {\n\t\tconsole.error(chalk.red(`Unknown option ${options.invalidOption} for \"${options.command}\".`));\n\t\tconsole.error(chalk.dim(`Use \"${APP_NAME} --help\" or \"${getPackageCommandUsage(options.command)}\".`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.missingOptionValue) {\n\t\tconsole.error(chalk.red(`Missing value for ${options.missingOptionValue}.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.invalidArgument) {\n\t\tconsole.error(chalk.red(`Unexpected argument ${options.invalidArgument}.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.conflictingOptions) {\n\t\tconsole.error(chalk.red(options.conflictingOptions));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tconst source = options.source;\n\tif ((options.command === \"install\" || options.command === \"remove\") && !source) {\n\t\tconsole.error(chalk.red(`Missing ${options.command} source.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.command === \"update\" && options.updateTarget?.type === \"models\") {\n\t\ttry {\n\t\t\tawait refreshModelCatalogs(getAgentDir());\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error ? error.message : \"Unknown model catalog refresh error\";\n\t\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\t\treturn true;\n\t}\n\n\tconst cwd = process.cwd();\n\tconst agentDir = getAgentDir();\n\tconst writesProjectPackageConfig = (options.command === \"install\" || options.command === \"remove\") && options.local;\n\tconst { settingsManager, projectTrustWarnings } = await createCommandSettingsManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tprojectTrustOverride: options.projectTrustOverride,\n\t\tuseSavedProjectTrustOnly: options.command === \"update\",\n\t\textensionFactories: runtimeOptions.extensionFactories,\n\t});\n\treportProjectTrustWarnings(projectTrustWarnings);\n\tif (!settingsManager.isProjectTrusted() && writesProjectPackageConfig) {\n\t\tconsole.error(chalk.red(\"Project is not trusted. Use --approve to modify local package config.\"));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\treportSettingsErrors(settingsManager, \"package command\");\n\tconst selfUpdateNpmCommand = settingsManager.getGlobalSettings().npmCommand;\n\n\tconst packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });\n\n\tpackageManager.setProgressCallback((event) => {\n\t\tif (event.type === \"start\") {\n\t\t\tprocess.stdout.write(chalk.dim(`${event.message}\\n`));\n\t\t}\n\t});\n\n\ttry {\n\t\tswitch (options.command) {\n\t\t\tcase \"install\":\n\t\t\t\tawait packageManager.installAndPersist(source!, { local: options.local });\n\t\t\t\tconsole.log(chalk.green(`Installed ${source}`));\n\t\t\t\treturn true;\n\n\t\t\tcase \"remove\": {\n\t\t\t\tconst removed = await packageManager.removeAndPersist(source!, { local: options.local });\n\t\t\t\tif (!removed) {\n\t\t\t\t\tconsole.error(chalk.red(`No matching package found for ${source}`));\n\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconsole.log(chalk.green(`Removed ${source}`));\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tcase \"list\": {\n\t\t\t\tconst configuredPackages = packageManager.listConfiguredPackages();\n\t\t\t\tconst userPackages = configuredPackages.filter((pkg) => pkg.scope === \"user\");\n\t\t\t\tconst projectPackages = configuredPackages.filter((pkg) => pkg.scope === \"project\");\n\n\t\t\t\tif (configuredPackages.length === 0) {\n\t\t\t\t\tconsole.log(chalk.dim(\"No packages installed.\"));\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tconst formatPackage = (pkg: (typeof configuredPackages)[number]) => {\n\t\t\t\t\tconst display = pkg.filtered ? `${pkg.source} (filtered)` : pkg.source;\n\t\t\t\t\tconsole.log(` ${display}`);\n\t\t\t\t\tif (pkg.installedPath) {\n\t\t\t\t\t\tconsole.log(chalk.dim(` ${pkg.installedPath}`));\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tif (userPackages.length > 0) {\n\t\t\t\t\tconsole.log(chalk.bold(\"User packages:\"));\n\t\t\t\t\tfor (const pkg of userPackages) {\n\t\t\t\t\t\tformatPackage(pkg);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (projectPackages.length > 0) {\n\t\t\t\t\tif (userPackages.length > 0) console.log();\n\t\t\t\t\tconsole.log(chalk.bold(\"Project packages:\"));\n\t\t\t\t\tfor (const pkg of projectPackages) {\n\t\t\t\t\t\tformatPackage(pkg);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tcase \"update\": {\n\t\t\t\tconst target = options.updateTarget ?? { type: \"self\" };\n\t\t\t\tif (options.showExtensionsSkippedNote) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\tchalk.dim(`Extensions are skipped. Run ${APP_NAME} update --extensions to update extensions.`),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (updateTargetIncludesExtensions(target)) {\n\t\t\t\t\tconst updateSource = target.type === \"extensions\" ? target.source : undefined;\n\t\t\t\t\tawait packageManager.update(updateSource);\n\t\t\t\t\tif (updateSource) {\n\t\t\t\t\t\tconsole.log(chalk.green(`Updated ${updateSource}`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log(chalk.green(\"Updated packages\"));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (updateTargetIncludesSelf(target)) {\n\t\t\t\t\tconst selfUpdatePlan = await getSelfUpdatePlan(options.force);\n\t\t\t\t\tif (!selfUpdatePlan.shouldRun) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconst installMethod = detectInstallMethod();\n\t\t\t\t\tif (process.platform === \"win32\" && installMethod !== \"npm\" && installMethod !== \"pnpm\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tchalk.red(`${APP_NAME} self-update on Windows is only supported for npm and pnpm installs.`),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.error(chalk.dim(`Detected install method: ${installMethod}. Update ${APP_NAME} manually.`));\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconst selfUpdateTarget = {\n\t\t\t\t\t\tpackageName: selfUpdatePlan.packageName,\n\t\t\t\t\t\tinstallSpec: selfUpdatePlan.installSpec,\n\t\t\t\t\t};\n\t\t\t\t\tconst selfUpdateCommand = getSelfUpdateCommand(PACKAGE_NAME, selfUpdateNpmCommand, selfUpdateTarget);\n\t\t\t\t\tif (!selfUpdateCommand) {\n\t\t\t\t\t\tprintSelfUpdateUnavailable(selfUpdateNpmCommand, selfUpdateTarget);\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (selfUpdatePlan.note) {\n\t\t\t\t\t\tprintSelfUpdateNote(selfUpdatePlan.note);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (installMethod === \"npm\") {\n\t\t\t\t\t\t\tprepareWindowsNpmSelfUpdate();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait runSelfUpdate(selfUpdateCommand);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tconst message = error instanceof Error ? error.message : \"Unknown package command error\";\n\t\t\t\t\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\t\t\t\t\tif (installMethod === \"pnpm\") {\n\t\t\t\t\t\t\tprintPnpmSelfUpdateMetadataHint();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tprintSelfUpdateFallback(selfUpdateCommand);\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconsole.log(chalk.green(`Updated ${APP_NAME} from ${VERSION} to ${selfUpdatePlan.version}`));\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown package command error\";\n\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"package-manager-cli.d.ts","sourceRoot":"","sources":["../src/package-manager-cli.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAclE,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAyftE,MAAM,WAAW,4BAA4B;IAC5C,kBAAkB,CAAC,EAAE,eAAe,EAAE,CAAC;CACvC;AAiED,wBAAsB,mBAAmB,CACxC,IAAI,EAAE,MAAM,EAAE,EACd,cAAc,GAAE,4BAAiC,GAC/C,OAAO,CAAC,OAAO,CAAC,CAoElB;AAED,wBAAsB,oBAAoB,CACzC,IAAI,EAAE,MAAM,EAAE,EACd,cAAc,GAAE,4BAAiC,GAC/C,OAAO,CAAC,OAAO,CAAC,CAgNlB","sourcesContent":["import { join } from \"node:path\";\nimport { Markdown, type MarkdownTheme } from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { selectConfig } from \"./cli/config-selector.ts\";\nimport { createProjectTrustContext } from \"./cli/project-trust.ts\";\nimport {\n\tAPP_NAME,\n\tCONFIG_DIR_NAME,\n\tdetectInstallMethod,\n\tgetAgentDir,\n\tgetPackageDir,\n\tgetSelfUpdateCommand,\n\tgetSelfUpdateUnavailableInstruction,\n\tPACKAGE_NAME,\n\ttype SelfUpdateCommand,\n\ttype SelfUpdatePackageTarget,\n\tVERSION,\n} from \"./config.ts\";\nimport type { InlineExtension } from \"./core/extensions/types.ts\";\nimport { ModelRuntime } from \"./core/model-runtime.ts\";\nimport { DefaultPackageManager } from \"./core/package-manager.ts\";\nimport { type AppMode, resolveProjectTrusted } from \"./core/project-trust.ts\";\nimport { DefaultResourceLoader } from \"./core/resource-loader.ts\";\nimport { SettingsManager } from \"./core/settings-manager.ts\";\nimport { hasTrustRequiringProjectResources, ProjectTrustStore } from \"./core/trust-manager.ts\";\nimport { spawnProcess } from \"./utils/child-process.ts\";\nimport { formatVersionCheckError, getLatestPiRelease, isNewerPackageVersion } from \"./utils/version-check.ts\";\nimport {\n\tcleanupWindowsSelfUpdateQuarantine,\n\tquarantineWindowsNativeDependencies,\n} from \"./utils/windows-self-update.ts\";\n\nexport type PackageCommand = \"install\" | \"remove\" | \"update\" | \"list\";\n\ntype UpdateTarget = { type: \"all\" } | { type: \"self\" } | { type: \"extensions\"; source?: string } | { type: \"models\" };\n\nconst SELF_UPDATE_NOTE_MARKDOWN_THEME: MarkdownTheme = {\n\theading: (text) => chalk.bold(chalk.yellow(text)),\n\tlink: (text) => chalk.cyan(text),\n\tlinkUrl: (text) => chalk.dim(text),\n\tcode: (text) => chalk.yellow(text),\n\tcodeBlock: (text) => chalk.dim(text),\n\tcodeBlockBorder: (text) => chalk.dim(text),\n\tquote: (text) => chalk.dim(text),\n\tquoteBorder: (text) => chalk.dim(text),\n\thr: (text) => chalk.dim(text),\n\tlistBullet: (text) => chalk.yellow(text),\n\tbold: (text) => chalk.bold(text),\n\titalic: (text) => chalk.italic(text),\n\tstrikethrough: (text) => chalk.strikethrough(text),\n\tunderline: (text) => chalk.underline(text),\n};\n\ninterface PackageCommandOptions {\n\tcommand: PackageCommand;\n\tsource?: string;\n\tupdateTarget?: UpdateTarget;\n\tshowExtensionsSkippedNote: boolean;\n\tlocal: boolean;\n\tforce: boolean;\n\tprojectTrustOverride?: boolean;\n\thelp: boolean;\n\tinvalidOption?: string;\n\tinvalidArgument?: string;\n\tmissingOptionValue?: string;\n\tconflictingOptions?: string;\n}\n\nfunction reportSettingsErrors(settingsManager: SettingsManager, context: string): void {\n\tconst errors = settingsManager.drainErrors();\n\tfor (const { scope, error } of errors) {\n\t\tconsole.error(chalk.yellow(`Warning (${context}, ${scope} settings): ${error.message}`));\n\t\tif (error.stack) {\n\t\t\tconsole.error(chalk.dim(error.stack));\n\t\t}\n\t}\n}\n\nfunction getPackageCommandUsage(command: PackageCommand): string {\n\tswitch (command) {\n\t\tcase \"install\":\n\t\t\treturn `${APP_NAME} install <source> [-l] [--approve|--no-approve]`;\n\t\tcase \"remove\":\n\t\t\treturn `${APP_NAME} remove <source> [-l] [--approve|--no-approve]`;\n\t\tcase \"update\":\n\t\t\treturn `${APP_NAME} update [source|self|ada-cli] [--self|--extensions|--models|--all] [--extension <source>] [--approve|--no-approve] [--force]`;\n\t\tcase \"list\":\n\t\t\treturn `${APP_NAME} list [--approve|--no-approve]`;\n\t}\n}\n\nconst CONFIG_COMMAND_USAGE = `${APP_NAME} config [-l] [--approve|--no-approve]`;\n\nfunction printConfigCommandHelp(): void {\n\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${CONFIG_COMMAND_USAGE}\n\nOpen the resource configuration TUI to enable or disable package resources.\nWithout -l, starts in global settings (~/${CONFIG_DIR_NAME}/agent/settings.json).\nPress Tab in the TUI to switch between global and project-local modes.\n\nOptions:\n -l, --local Edit project overrides (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command with -l\n -na, --no-approve Ignore project-local files for this command with -l\n`);\n}\n\nfunction printPackageCommandHelp(command: PackageCommand): void {\n\tswitch (command) {\n\t\tcase \"install\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"install\")}\n\nInstall a package and add it to settings.\n\nOptions:\n -l, --local Install project-locally (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n\nExamples:\n ${APP_NAME} install npm:@foo/bar\n ${APP_NAME} install git:github.com/user/repo\n ${APP_NAME} install git:git@github.com:user/repo\n ${APP_NAME} install https://github.com/user/repo\n ${APP_NAME} install ssh://git@github.com/user/repo\n ${APP_NAME} install ./local/path\n`);\n\t\t\treturn;\n\n\t\tcase \"remove\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"remove\")}\n\nRemove a package and its source from settings.\nAlias: ${APP_NAME} uninstall <source> [-l]\n\nOptions:\n -l, --local Remove from project settings (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n\nExamples:\n ${APP_NAME} remove npm:@foo/bar\n ${APP_NAME} uninstall npm:@foo/bar\n`);\n\t\t\treturn;\n\n\t\tcase \"update\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"update\")}\n\nUpdate ada-cli, installed packages, or model catalogs.\n\nOptions:\n --self Update ada-cli only (default when no target is given)\n --extensions Update installed packages only\n --models Refresh model catalogs only\n --all Update pi and installed packages\n --extension <source> Update one package only\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n --force Reinstall pi even if the current version is latest\n\nShort forms:\n ${APP_NAME} update Update pi only\n ${APP_NAME} update --all Update pi and all extensions\n ${APP_NAME} update --models Refresh model catalogs only\n ${APP_NAME} update <source> Update one package\n ${APP_NAME} update ada-cli Update ada-cli only (self works as alias to ada-cli)\n`);\n\t\t\treturn;\n\n\t\tcase \"list\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"list\")}\n\nList installed packages from user and project settings.\n\nOptions:\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n`);\n\t\t\treturn;\n\t}\n}\n\nfunction parsePackageCommand(args: string[]): PackageCommandOptions | undefined {\n\tconst [rawCommand, ...rest] = args;\n\tlet command: PackageCommand | undefined;\n\tif (rawCommand === \"uninstall\") {\n\t\tcommand = \"remove\";\n\t} else if (rawCommand === \"install\" || rawCommand === \"remove\" || rawCommand === \"update\" || rawCommand === \"list\") {\n\t\tcommand = rawCommand;\n\t}\n\tif (!command) {\n\t\treturn undefined;\n\t}\n\n\tlet local = false;\n\tlet force = false;\n\tlet projectTrustOverride: boolean | undefined;\n\tlet help = false;\n\tlet invalidOption: string | undefined;\n\tlet invalidArgument: string | undefined;\n\tlet missingOptionValue: string | undefined;\n\tlet conflictingOptions: string | undefined;\n\tlet source: string | undefined;\n\tlet selfFlag = false;\n\tlet extensionsFlag = false;\n\tlet modelsFlag = false;\n\tlet allFlag = false;\n\tlet extensionFlagSource: string | undefined;\n\n\tfor (let index = 0; index < rest.length; index++) {\n\t\tconst arg = rest[index];\n\t\tif (arg === \"-h\" || arg === \"--help\") {\n\t\t\thelp = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"-l\" || arg === \"--local\") {\n\t\t\tif (command === \"install\" || command === \"remove\") {\n\t\t\t\tlocal = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--self\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tselfFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--extensions\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\textensionsFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--models\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tmodelsFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--all\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tallFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--approve\" || arg === \"-a\") {\n\t\t\tprojectTrustOverride = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--no-approve\" || arg === \"-na\") {\n\t\t\tprojectTrustOverride = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--force\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tforce = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--extension\") {\n\t\t\tif (command !== \"update\") {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst value = rest[index + 1];\n\t\t\tif (!value || value.startsWith(\"-\")) {\n\t\t\t\tmissingOptionValue = missingOptionValue ?? arg;\n\t\t\t} else if (extensionFlagSource) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--extension can only be provided once\";\n\t\t\t\tindex++;\n\t\t\t} else {\n\t\t\t\textensionFlagSource = value;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg.startsWith(\"-\")) {\n\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!source) {\n\t\t\tsource = arg;\n\t\t} else {\n\t\t\tinvalidArgument = invalidArgument ?? arg;\n\t\t}\n\t}\n\n\tlet updateTarget: UpdateTarget | undefined;\n\tlet showExtensionsSkippedNote = false;\n\tif (command === \"update\") {\n\t\tif (allFlag && (selfFlag || extensionsFlag || modelsFlag || extensionFlagSource)) {\n\t\t\tconflictingOptions =\n\t\t\t\tconflictingOptions ?? \"--all cannot be combined with --self, --extensions, --models, or --extension\";\n\t\t}\n\t\tif (allFlag && source) {\n\t\t\tconflictingOptions = conflictingOptions ?? \"--all cannot be combined with a positional source\";\n\t\t}\n\n\t\tif (modelsFlag) {\n\t\t\tif (selfFlag || extensionsFlag || allFlag || extensionFlagSource) {\n\t\t\t\tconflictingOptions =\n\t\t\t\t\tconflictingOptions ?? \"--models cannot be combined with --self, --extensions, --all, or --extension\";\n\t\t\t}\n\t\t\tif (source) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--models cannot be combined with a positional source\";\n\t\t\t}\n\t\t\tupdateTarget = { type: \"models\" };\n\t\t} else if (extensionFlagSource) {\n\t\t\tif (selfFlag || extensionsFlag || allFlag) {\n\t\t\t\tconflictingOptions =\n\t\t\t\t\tconflictingOptions ?? \"--extension cannot be combined with --self, --extensions, or --all\";\n\t\t\t}\n\t\t\tif (source) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--extension cannot be combined with a positional source\";\n\t\t\t}\n\t\t\tupdateTarget = { type: \"extensions\", source: extensionFlagSource };\n\t\t} else if (source) {\n\t\t\tconst sourceIsSelf = source === \"self\" || source === \"ada-cli\" || source === \"pi\";\n\t\t\tif (sourceIsSelf) {\n\t\t\t\tupdateTarget = extensionsFlag ? { type: \"all\" } : { type: \"self\" };\n\t\t\t} else {\n\t\t\t\tif (extensionsFlag || selfFlag || allFlag) {\n\t\t\t\t\tconflictingOptions =\n\t\t\t\t\t\tconflictingOptions ??\n\t\t\t\t\t\t\"positional update targets cannot be combined with --self, --extensions, or --all\";\n\t\t\t\t}\n\t\t\t\tupdateTarget = { type: \"extensions\", source };\n\t\t\t}\n\t\t} else if (allFlag) {\n\t\t\tupdateTarget = { type: \"all\" };\n\t\t} else if (selfFlag && extensionsFlag) {\n\t\t\tupdateTarget = { type: \"all\" };\n\t\t} else if (selfFlag) {\n\t\t\tupdateTarget = { type: \"self\" };\n\t\t} else if (extensionsFlag) {\n\t\t\tupdateTarget = { type: \"extensions\" };\n\t\t} else {\n\t\t\tupdateTarget = { type: \"self\" };\n\t\t\tshowExtensionsSkippedNote = true;\n\t\t}\n\t}\n\n\treturn {\n\t\tcommand,\n\t\tsource,\n\t\tupdateTarget,\n\t\tshowExtensionsSkippedNote,\n\t\tlocal,\n\t\tforce,\n\t\tprojectTrustOverride,\n\t\thelp,\n\t\tinvalidOption,\n\t\tinvalidArgument,\n\t\tmissingOptionValue,\n\t\tconflictingOptions,\n\t};\n}\n\nfunction updateTargetIncludesSelf(target: UpdateTarget): boolean {\n\treturn target.type === \"all\" || target.type === \"self\";\n}\n\nfunction updateTargetIncludesExtensions(target: UpdateTarget): boolean {\n\treturn target.type === \"all\" || target.type === \"extensions\";\n}\n\nasync function refreshModelCatalogs(agentDir: string): Promise<void> {\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), 15_000);\n\ttry {\n\t\tconst modelRuntime = await ModelRuntime.create({\n\t\t\tauthPath: join(agentDir, \"auth.json\"),\n\t\t\tmodelsPath: join(agentDir, \"models.json\"),\n\t\t\tallowModelNetwork: false,\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\tconst result = await modelRuntime.refresh({\n\t\t\tallowNetwork: true,\n\t\t\tforce: true,\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\tif (result.aborted) {\n\t\t\tthrow new Error(\"Model catalog refresh timed out.\");\n\t\t}\n\t\tif (result.errors.size > 0) {\n\t\t\tconst details = Array.from(result.errors, ([provider, error]) => `${provider}: ${error.message}`).join(\"; \");\n\t\t\tthrow new Error(`Could not refresh model catalogs: ${details}`);\n\t\t}\n\t} finally {\n\t\tclearTimeout(timeout);\n\t}\n\tconsole.log(chalk.green(\"Model catalogs refreshed\"));\n}\n\nfunction printSelfUpdateUnavailable(\n\tnpmCommand?: string[],\n\tupdatePackageTarget: SelfUpdatePackageTarget = PACKAGE_NAME,\n): void {\n\tconsole.error(`error: ${APP_NAME} cannot self-update this installation.`);\n\tconsole.error(getSelfUpdateUnavailableInstruction(PACKAGE_NAME, npmCommand, updatePackageTarget));\n\n\tconst entrypoint = process.argv[1];\n\tif (entrypoint) {\n\t\tconsole.error(\"\");\n\t\tconsole.error(`Location of ${APP_NAME} executable: ${entrypoint}`);\n\t}\n}\n\nfunction printSelfUpdateFallback(command: SelfUpdateCommand): void {\n\tconsole.error(chalk.dim(`If this keeps failing, run this command yourself: ${command.display}`));\n}\n\nfunction printPnpmSelfUpdateMetadataHint(): void {\n\tconsole.error(chalk.yellow(\"If pnpm reports missing package versions, its cached registry metadata may be stale.\"));\n\tconsole.error(chalk.yellow(`Run \\`pnpm store prune\\` and retry \\`${APP_NAME} update --self\\`.`));\n}\n\nfunction printSelfUpdateNote(note: string): void {\n\tconst trimmedNote = note.trim();\n\tif (!trimmedNote) {\n\t\treturn;\n\t}\n\n\tconsole.log();\n\tconsole.log(chalk.bold(chalk.yellow(\"Update note\")));\n\ttry {\n\t\tconst width = Math.max(20, process.stdout.columns ?? 80);\n\t\tconst renderedLines = new Markdown(trimmedNote, 0, 0, SELF_UPDATE_NOTE_MARKDOWN_THEME)\n\t\t\t.render(width)\n\t\t\t.map((line) => line.trimEnd());\n\t\tconsole.log(renderedLines.join(\"\\n\"));\n\t} catch {\n\t\tconsole.log(trimmedNote);\n\t}\n\tconsole.log();\n}\n\ninterface SelfUpdatePlan {\n\tpackageName: string;\n\tinstallSpec: string;\n\tversion: string;\n\tshouldRun: boolean;\n\tnote?: string;\n}\n\nasync function getSelfUpdatePlan(force: boolean): Promise<SelfUpdatePlan> {\n\tlet latestRelease: Awaited<ReturnType<typeof getLatestPiRelease>>;\n\ttry {\n\t\tlatestRelease = await getLatestPiRelease(VERSION, { retry: true });\n\t} catch (error: unknown) {\n\t\tthrow new Error(`Could not determine latest ${APP_NAME} version: ${formatVersionCheckError(error)}`, {\n\t\t\tcause: error,\n\t\t});\n\t}\n\tif (!latestRelease) {\n\t\tthrow new Error(`Could not determine latest ${APP_NAME} version.`);\n\t}\n\n\tconst packageName = latestRelease.packageName ?? PACKAGE_NAME;\n\tconst installSpec = `${packageName}@${latestRelease.version}`;\n\tif (force || isNewerPackageVersion(latestRelease.version, VERSION)) {\n\t\treturn {\n\t\t\tpackageName,\n\t\t\tinstallSpec,\n\t\t\tversion: latestRelease.version,\n\t\t\t...(latestRelease.note ? { note: latestRelease.note } : {}),\n\t\t\tshouldRun: true,\n\t\t};\n\t}\n\n\tconsole.log(chalk.green(`${APP_NAME} is already up to date (v${VERSION})`));\n\treturn { packageName, installSpec, version: latestRelease.version, shouldRun: false };\n}\n\nasync function runSelfUpdate(command: SelfUpdateCommand): Promise<void> {\n\tconsole.log(chalk.dim(`Updating ${APP_NAME} with ${command.display}...`));\n\tfor (const step of command.steps ?? [command]) {\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst child = spawnProcess(step.command, step.args, {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t});\n\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\treject(error);\n\t\t\t});\n\t\t\tchild.on(\"close\", (code, signal) => {\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else if (signal) {\n\t\t\t\t\treject(new Error(`${step.display} terminated by signal ${signal}`));\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error(`${step.display} exited with code ${code ?? \"unknown\"}`));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n}\n\nfunction prepareWindowsNpmSelfUpdate(): void {\n\tif (process.platform !== \"win32\") {\n\t\treturn;\n\t}\n\n\tconst packageDir = getPackageDir();\n\tcleanupWindowsSelfUpdateQuarantine(packageDir);\n\tquarantineWindowsNativeDependencies(packageDir);\n}\n\nexport interface PackageCommandRuntimeOptions {\n\textensionFactories?: InlineExtension[];\n}\n\ninterface CommandSettingsResult {\n\tsettingsManager: SettingsManager;\n\tprojectTrustWarnings: string[];\n}\n\nfunction getCommandAppMode(): AppMode {\n\treturn process.stdin.isTTY && process.stdout.isTTY ? \"interactive\" : \"print\";\n}\n\nfunction reportProjectTrustWarnings(warnings: readonly string[]): void {\n\tfor (const warning of warnings) {\n\t\tconsole.error(chalk.yellow(`Warning: ${warning}`));\n\t}\n}\n\nasync function createCommandSettingsManager(options: {\n\tcwd: string;\n\tagentDir: string;\n\tprojectTrustOverride?: boolean;\n\tuseSavedProjectTrustOnly?: boolean;\n\textensionFactories?: InlineExtension[];\n}): Promise<CommandSettingsResult> {\n\tconst settingsManager = SettingsManager.create(options.cwd, options.agentDir, { projectTrusted: false });\n\tconst projectTrustWarnings: string[] = [];\n\tconst trustStore = new ProjectTrustStore(options.agentDir);\n\tif (options.useSavedProjectTrustOnly) {\n\t\tconst savedProjectTrusted = trustStore.get(options.cwd) === true;\n\t\tsettingsManager.setProjectTrusted(options.projectTrustOverride ?? savedProjectTrusted);\n\t\treturn { settingsManager, projectTrustWarnings };\n\t}\n\n\tconst appMode = getCommandAppMode();\n\tconst extensionsResult =\n\t\toptions.projectTrustOverride === undefined && hasTrustRequiringProjectResources(options.cwd)\n\t\t\t? await new DefaultResourceLoader({\n\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\tagentDir: options.agentDir,\n\t\t\t\t\tsettingsManager,\n\t\t\t\t\textensionFactories: options.extensionFactories,\n\t\t\t\t}).loadProjectTrustExtensions()\n\t\t\t: undefined;\n\tfor (const error of extensionsResult?.errors ?? []) {\n\t\tprojectTrustWarnings.push(`Failed to load extension \"${error.path}\": ${error.error}`);\n\t}\n\n\tconst projectTrusted = await resolveProjectTrusted({\n\t\tcwd: options.cwd,\n\t\ttrustStore,\n\t\ttrustOverride: options.projectTrustOverride,\n\t\tdefaultProjectTrust: settingsManager.getDefaultProjectTrust(),\n\t\textensionsResult,\n\t\tprojectTrustContext: createProjectTrustContext({\n\t\t\tcwd: options.cwd,\n\t\t\tmode: appMode,\n\t\t\tsettingsManager,\n\t\t\thasUI: appMode === \"interactive\",\n\t\t}),\n\t\tonExtensionError: (message) => projectTrustWarnings.push(message),\n\t});\n\tsettingsManager.setProjectTrusted(projectTrusted);\n\treturn { settingsManager, projectTrustWarnings };\n}\n\nexport async function handleConfigCommand(\n\targs: string[],\n\truntimeOptions: PackageCommandRuntimeOptions = {},\n): Promise<boolean> {\n\tconst [command, ...rest] = args;\n\tif (command !== \"config\") {\n\t\treturn false;\n\t}\n\n\tif (rest.includes(\"-h\") || rest.includes(\"--help\")) {\n\t\tprintConfigCommandHelp();\n\t\treturn true;\n\t}\n\n\tlet local = false;\n\tlet projectTrustOverride: boolean | undefined;\n\tfor (const arg of rest) {\n\t\tif (arg === \"-l\" || arg === \"--local\") {\n\t\t\tlocal = true;\n\t\t} else if (arg === \"-a\" || arg === \"--approve\") {\n\t\t\tprojectTrustOverride = true;\n\t\t} else if (arg === \"-na\" || arg === \"--no-approve\") {\n\t\t\tprojectTrustOverride = false;\n\t\t} else if (arg.startsWith(\"-\")) {\n\t\t\tconsole.error(chalk.red(`Unknown option ${arg} for \"config\".`));\n\t\t\tconsole.error(chalk.dim(`Use \"${APP_NAME} --help\" or \"${CONFIG_COMMAND_USAGE}\".`));\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn true;\n\t\t} else {\n\t\t\tconsole.error(chalk.red(`Unexpected argument ${arg}.`));\n\t\t\tconsole.error(chalk.dim(`Usage: ${CONFIG_COMMAND_USAGE}`));\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst cwd = process.cwd();\n\tconst agentDir = getAgentDir();\n\tconst { settingsManager, projectTrustWarnings } = await createCommandSettingsManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tprojectTrustOverride,\n\t\textensionFactories: runtimeOptions.extensionFactories,\n\t});\n\treportProjectTrustWarnings(projectTrustWarnings);\n\tif (local && !settingsManager.isProjectTrusted()) {\n\t\tconsole.error(chalk.red(\"Project is not trusted. Use --approve to modify local resource config.\"));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\treportSettingsErrors(settingsManager, \"config command\");\n\tconst globalSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: false });\n\tconst globalResolvedPaths = await new DefaultPackageManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tsettingsManager: globalSettingsManager,\n\t}).resolve();\n\tconst projectResolvedPaths = settingsManager.isProjectTrusted()\n\t\t? await new DefaultPackageManager({ cwd, agentDir, settingsManager }).resolve()\n\t\t: globalResolvedPaths;\n\n\tawait selectConfig({\n\t\tresolvedPaths: { global: globalResolvedPaths, project: projectResolvedPaths },\n\t\tsettingsManager,\n\t\tcwd,\n\t\tagentDir,\n\t\twriteScope: local ? \"project\" : \"global\",\n\t\tprojectModeAvailable: settingsManager.isProjectTrusted(),\n\t});\n\n\tprocess.exit(0);\n}\n\nexport async function handlePackageCommand(\n\targs: string[],\n\truntimeOptions: PackageCommandRuntimeOptions = {},\n): Promise<boolean> {\n\tconst options = parsePackageCommand(args);\n\tif (!options) {\n\t\treturn false;\n\t}\n\n\tif (options.help) {\n\t\tprintPackageCommandHelp(options.command);\n\t\treturn true;\n\t}\n\n\tif (options.invalidOption) {\n\t\tconsole.error(chalk.red(`Unknown option ${options.invalidOption} for \"${options.command}\".`));\n\t\tconsole.error(chalk.dim(`Use \"${APP_NAME} --help\" or \"${getPackageCommandUsage(options.command)}\".`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.missingOptionValue) {\n\t\tconsole.error(chalk.red(`Missing value for ${options.missingOptionValue}.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.invalidArgument) {\n\t\tconsole.error(chalk.red(`Unexpected argument ${options.invalidArgument}.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.conflictingOptions) {\n\t\tconsole.error(chalk.red(options.conflictingOptions));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tconst source = options.source;\n\tif ((options.command === \"install\" || options.command === \"remove\") && !source) {\n\t\tconsole.error(chalk.red(`Missing ${options.command} source.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.command === \"update\" && options.updateTarget?.type === \"models\") {\n\t\ttry {\n\t\t\tawait refreshModelCatalogs(getAgentDir());\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error ? error.message : \"Unknown model catalog refresh error\";\n\t\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\t\treturn true;\n\t}\n\n\tconst cwd = process.cwd();\n\tconst agentDir = getAgentDir();\n\tconst writesProjectPackageConfig = (options.command === \"install\" || options.command === \"remove\") && options.local;\n\tconst { settingsManager, projectTrustWarnings } = await createCommandSettingsManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tprojectTrustOverride: options.projectTrustOverride,\n\t\tuseSavedProjectTrustOnly: options.command === \"update\",\n\t\textensionFactories: runtimeOptions.extensionFactories,\n\t});\n\treportProjectTrustWarnings(projectTrustWarnings);\n\tif (!settingsManager.isProjectTrusted() && writesProjectPackageConfig) {\n\t\tconsole.error(chalk.red(\"Project is not trusted. Use --approve to modify local package config.\"));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\treportSettingsErrors(settingsManager, \"package command\");\n\tconst selfUpdateNpmCommand = settingsManager.getGlobalSettings().npmCommand;\n\n\tconst packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });\n\n\tpackageManager.setProgressCallback((event) => {\n\t\tif (event.type === \"start\") {\n\t\t\tprocess.stdout.write(chalk.dim(`${event.message}\\n`));\n\t\t}\n\t});\n\n\ttry {\n\t\tswitch (options.command) {\n\t\t\tcase \"install\":\n\t\t\t\tawait packageManager.installAndPersist(source!, { local: options.local });\n\t\t\t\tconsole.log(chalk.green(`Installed ${source}`));\n\t\t\t\treturn true;\n\n\t\t\tcase \"remove\": {\n\t\t\t\tconst removed = await packageManager.removeAndPersist(source!, { local: options.local });\n\t\t\t\tif (!removed) {\n\t\t\t\t\tconsole.error(chalk.red(`No matching package found for ${source}`));\n\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconsole.log(chalk.green(`Removed ${source}`));\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tcase \"list\": {\n\t\t\t\tconst configuredPackages = packageManager.listConfiguredPackages();\n\t\t\t\tconst userPackages = configuredPackages.filter((pkg) => pkg.scope === \"user\");\n\t\t\t\tconst projectPackages = configuredPackages.filter((pkg) => pkg.scope === \"project\");\n\n\t\t\t\tif (configuredPackages.length === 0) {\n\t\t\t\t\tconsole.log(chalk.dim(\"No packages installed.\"));\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tconst formatPackage = (pkg: (typeof configuredPackages)[number]) => {\n\t\t\t\t\tconst display = pkg.filtered ? `${pkg.source} (filtered)` : pkg.source;\n\t\t\t\t\tconsole.log(` ${display}`);\n\t\t\t\t\tif (pkg.installedPath) {\n\t\t\t\t\t\tconsole.log(chalk.dim(` ${pkg.installedPath}`));\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tif (userPackages.length > 0) {\n\t\t\t\t\tconsole.log(chalk.bold(\"User packages:\"));\n\t\t\t\t\tfor (const pkg of userPackages) {\n\t\t\t\t\t\tformatPackage(pkg);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (projectPackages.length > 0) {\n\t\t\t\t\tif (userPackages.length > 0) console.log();\n\t\t\t\t\tconsole.log(chalk.bold(\"Project packages:\"));\n\t\t\t\t\tfor (const pkg of projectPackages) {\n\t\t\t\t\t\tformatPackage(pkg);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tcase \"update\": {\n\t\t\t\tconst target = options.updateTarget ?? { type: \"self\" };\n\t\t\t\tif (options.showExtensionsSkippedNote) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\tchalk.dim(`Extensions are skipped. Run ${APP_NAME} update --extensions to update extensions.`),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (updateTargetIncludesExtensions(target)) {\n\t\t\t\t\tconst updateSource = target.type === \"extensions\" ? target.source : undefined;\n\t\t\t\t\tawait packageManager.update(updateSource);\n\t\t\t\t\tif (updateSource) {\n\t\t\t\t\t\tconsole.log(chalk.green(`Updated ${updateSource}`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log(chalk.green(\"Updated packages\"));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (updateTargetIncludesSelf(target)) {\n\t\t\t\t\tconst selfUpdatePlan = await getSelfUpdatePlan(options.force);\n\t\t\t\t\tif (!selfUpdatePlan.shouldRun) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconst installMethod = detectInstallMethod();\n\t\t\t\t\tif (process.platform === \"win32\" && installMethod !== \"npm\" && installMethod !== \"pnpm\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tchalk.red(`${APP_NAME} self-update on Windows is only supported for npm and pnpm installs.`),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.error(chalk.dim(`Detected install method: ${installMethod}. Update ${APP_NAME} manually.`));\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconst selfUpdateTarget = {\n\t\t\t\t\t\tpackageName: selfUpdatePlan.packageName,\n\t\t\t\t\t\tinstallSpec: selfUpdatePlan.installSpec,\n\t\t\t\t\t};\n\t\t\t\t\tconst selfUpdateCommand = getSelfUpdateCommand(PACKAGE_NAME, selfUpdateNpmCommand, selfUpdateTarget);\n\t\t\t\t\tif (!selfUpdateCommand) {\n\t\t\t\t\t\tprintSelfUpdateUnavailable(selfUpdateNpmCommand, selfUpdateTarget);\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (selfUpdatePlan.note) {\n\t\t\t\t\t\tprintSelfUpdateNote(selfUpdatePlan.note);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (installMethod === \"npm\") {\n\t\t\t\t\t\t\tprepareWindowsNpmSelfUpdate();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait runSelfUpdate(selfUpdateCommand);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tconst message = error instanceof Error ? error.message : \"Unknown package command error\";\n\t\t\t\t\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\t\t\t\t\tif (installMethod === \"pnpm\") {\n\t\t\t\t\t\t\tprintPnpmSelfUpdateMetadataHint();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tprintSelfUpdateFallback(selfUpdateCommand);\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconsole.log(chalk.green(`Updated ${APP_NAME} from ${VERSION} to ${selfUpdatePlan.version}`));\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown package command error\";\n\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n}\n"]}
|
|
@@ -423,7 +423,7 @@ async function getSelfUpdatePlan(force) {
|
|
|
423
423
|
if (!latestRelease) {
|
|
424
424
|
throw new Error(`Could not determine latest ${APP_NAME} version.`);
|
|
425
425
|
}
|
|
426
|
-
const packageName = PACKAGE_NAME;
|
|
426
|
+
const packageName = latestRelease.packageName ?? PACKAGE_NAME;
|
|
427
427
|
const installSpec = `${packageName}@${latestRelease.version}`;
|
|
428
428
|
if (force || isNewerPackageVersion(latestRelease.version, VERSION)) {
|
|
429
429
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-manager-cli.js","sourceRoot":"","sources":["../src/package-manager-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAsB,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,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Ac,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,+BAA+B,CAAC;QACzF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC,CAAC;QAC9C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACb,CAAC;AAAA,CACD","sourcesContent":["import { join } from \"node:path\";\nimport { Markdown, type MarkdownTheme } from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { selectConfig } from \"./cli/config-selector.ts\";\nimport { createProjectTrustContext } from \"./cli/project-trust.ts\";\nimport {\n\tAPP_NAME,\n\tCONFIG_DIR_NAME,\n\tdetectInstallMethod,\n\tgetAgentDir,\n\tgetPackageDir,\n\tgetSelfUpdateCommand,\n\tgetSelfUpdateUnavailableInstruction,\n\tPACKAGE_NAME,\n\ttype SelfUpdateCommand,\n\ttype SelfUpdatePackageTarget,\n\tVERSION,\n} from \"./config.ts\";\nimport type { InlineExtension } from \"./core/extensions/types.ts\";\nimport { ModelRuntime } from \"./core/model-runtime.ts\";\nimport { DefaultPackageManager } from \"./core/package-manager.ts\";\nimport { type AppMode, resolveProjectTrusted } from \"./core/project-trust.ts\";\nimport { DefaultResourceLoader } from \"./core/resource-loader.ts\";\nimport { SettingsManager } from \"./core/settings-manager.ts\";\nimport { hasTrustRequiringProjectResources, ProjectTrustStore } from \"./core/trust-manager.ts\";\nimport { spawnProcess } from \"./utils/child-process.ts\";\nimport { formatVersionCheckError, getLatestPiRelease, isNewerPackageVersion } from \"./utils/version-check.ts\";\nimport {\n\tcleanupWindowsSelfUpdateQuarantine,\n\tquarantineWindowsNativeDependencies,\n} from \"./utils/windows-self-update.ts\";\n\nexport type PackageCommand = \"install\" | \"remove\" | \"update\" | \"list\";\n\ntype UpdateTarget = { type: \"all\" } | { type: \"self\" } | { type: \"extensions\"; source?: string } | { type: \"models\" };\n\nconst SELF_UPDATE_NOTE_MARKDOWN_THEME: MarkdownTheme = {\n\theading: (text) => chalk.bold(chalk.yellow(text)),\n\tlink: (text) => chalk.cyan(text),\n\tlinkUrl: (text) => chalk.dim(text),\n\tcode: (text) => chalk.yellow(text),\n\tcodeBlock: (text) => chalk.dim(text),\n\tcodeBlockBorder: (text) => chalk.dim(text),\n\tquote: (text) => chalk.dim(text),\n\tquoteBorder: (text) => chalk.dim(text),\n\thr: (text) => chalk.dim(text),\n\tlistBullet: (text) => chalk.yellow(text),\n\tbold: (text) => chalk.bold(text),\n\titalic: (text) => chalk.italic(text),\n\tstrikethrough: (text) => chalk.strikethrough(text),\n\tunderline: (text) => chalk.underline(text),\n};\n\ninterface PackageCommandOptions {\n\tcommand: PackageCommand;\n\tsource?: string;\n\tupdateTarget?: UpdateTarget;\n\tshowExtensionsSkippedNote: boolean;\n\tlocal: boolean;\n\tforce: boolean;\n\tprojectTrustOverride?: boolean;\n\thelp: boolean;\n\tinvalidOption?: string;\n\tinvalidArgument?: string;\n\tmissingOptionValue?: string;\n\tconflictingOptions?: string;\n}\n\nfunction reportSettingsErrors(settingsManager: SettingsManager, context: string): void {\n\tconst errors = settingsManager.drainErrors();\n\tfor (const { scope, error } of errors) {\n\t\tconsole.error(chalk.yellow(`Warning (${context}, ${scope} settings): ${error.message}`));\n\t\tif (error.stack) {\n\t\t\tconsole.error(chalk.dim(error.stack));\n\t\t}\n\t}\n}\n\nfunction getPackageCommandUsage(command: PackageCommand): string {\n\tswitch (command) {\n\t\tcase \"install\":\n\t\t\treturn `${APP_NAME} install <source> [-l] [--approve|--no-approve]`;\n\t\tcase \"remove\":\n\t\t\treturn `${APP_NAME} remove <source> [-l] [--approve|--no-approve]`;\n\t\tcase \"update\":\n\t\t\treturn `${APP_NAME} update [source|self|ada-cli] [--self|--extensions|--models|--all] [--extension <source>] [--approve|--no-approve] [--force]`;\n\t\tcase \"list\":\n\t\t\treturn `${APP_NAME} list [--approve|--no-approve]`;\n\t}\n}\n\nconst CONFIG_COMMAND_USAGE = `${APP_NAME} config [-l] [--approve|--no-approve]`;\n\nfunction printConfigCommandHelp(): void {\n\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${CONFIG_COMMAND_USAGE}\n\nOpen the resource configuration TUI to enable or disable package resources.\nWithout -l, starts in global settings (~/${CONFIG_DIR_NAME}/agent/settings.json).\nPress Tab in the TUI to switch between global and project-local modes.\n\nOptions:\n -l, --local Edit project overrides (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command with -l\n -na, --no-approve Ignore project-local files for this command with -l\n`);\n}\n\nfunction printPackageCommandHelp(command: PackageCommand): void {\n\tswitch (command) {\n\t\tcase \"install\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"install\")}\n\nInstall a package and add it to settings.\n\nOptions:\n -l, --local Install project-locally (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n\nExamples:\n ${APP_NAME} install npm:@foo/bar\n ${APP_NAME} install git:github.com/user/repo\n ${APP_NAME} install git:git@github.com:user/repo\n ${APP_NAME} install https://github.com/user/repo\n ${APP_NAME} install ssh://git@github.com/user/repo\n ${APP_NAME} install ./local/path\n`);\n\t\t\treturn;\n\n\t\tcase \"remove\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"remove\")}\n\nRemove a package and its source from settings.\nAlias: ${APP_NAME} uninstall <source> [-l]\n\nOptions:\n -l, --local Remove from project settings (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n\nExamples:\n ${APP_NAME} remove npm:@foo/bar\n ${APP_NAME} uninstall npm:@foo/bar\n`);\n\t\t\treturn;\n\n\t\tcase \"update\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"update\")}\n\nUpdate ada-cli, installed packages, or model catalogs.\n\nOptions:\n --self Update ada-cli only (default when no target is given)\n --extensions Update installed packages only\n --models Refresh model catalogs only\n --all Update pi and installed packages\n --extension <source> Update one package only\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n --force Reinstall pi even if the current version is latest\n\nShort forms:\n ${APP_NAME} update Update pi only\n ${APP_NAME} update --all Update pi and all extensions\n ${APP_NAME} update --models Refresh model catalogs only\n ${APP_NAME} update <source> Update one package\n ${APP_NAME} update ada-cli Update ada-cli only (self works as alias to ada-cli)\n`);\n\t\t\treturn;\n\n\t\tcase \"list\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"list\")}\n\nList installed packages from user and project settings.\n\nOptions:\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n`);\n\t\t\treturn;\n\t}\n}\n\nfunction parsePackageCommand(args: string[]): PackageCommandOptions | undefined {\n\tconst [rawCommand, ...rest] = args;\n\tlet command: PackageCommand | undefined;\n\tif (rawCommand === \"uninstall\") {\n\t\tcommand = \"remove\";\n\t} else if (rawCommand === \"install\" || rawCommand === \"remove\" || rawCommand === \"update\" || rawCommand === \"list\") {\n\t\tcommand = rawCommand;\n\t}\n\tif (!command) {\n\t\treturn undefined;\n\t}\n\n\tlet local = false;\n\tlet force = false;\n\tlet projectTrustOverride: boolean | undefined;\n\tlet help = false;\n\tlet invalidOption: string | undefined;\n\tlet invalidArgument: string | undefined;\n\tlet missingOptionValue: string | undefined;\n\tlet conflictingOptions: string | undefined;\n\tlet source: string | undefined;\n\tlet selfFlag = false;\n\tlet extensionsFlag = false;\n\tlet modelsFlag = false;\n\tlet allFlag = false;\n\tlet extensionFlagSource: string | undefined;\n\n\tfor (let index = 0; index < rest.length; index++) {\n\t\tconst arg = rest[index];\n\t\tif (arg === \"-h\" || arg === \"--help\") {\n\t\t\thelp = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"-l\" || arg === \"--local\") {\n\t\t\tif (command === \"install\" || command === \"remove\") {\n\t\t\t\tlocal = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--self\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tselfFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--extensions\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\textensionsFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--models\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tmodelsFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--all\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tallFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--approve\" || arg === \"-a\") {\n\t\t\tprojectTrustOverride = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--no-approve\" || arg === \"-na\") {\n\t\t\tprojectTrustOverride = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--force\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tforce = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--extension\") {\n\t\t\tif (command !== \"update\") {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst value = rest[index + 1];\n\t\t\tif (!value || value.startsWith(\"-\")) {\n\t\t\t\tmissingOptionValue = missingOptionValue ?? arg;\n\t\t\t} else if (extensionFlagSource) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--extension can only be provided once\";\n\t\t\t\tindex++;\n\t\t\t} else {\n\t\t\t\textensionFlagSource = value;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg.startsWith(\"-\")) {\n\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!source) {\n\t\t\tsource = arg;\n\t\t} else {\n\t\t\tinvalidArgument = invalidArgument ?? arg;\n\t\t}\n\t}\n\n\tlet updateTarget: UpdateTarget | undefined;\n\tlet showExtensionsSkippedNote = false;\n\tif (command === \"update\") {\n\t\tif (allFlag && (selfFlag || extensionsFlag || modelsFlag || extensionFlagSource)) {\n\t\t\tconflictingOptions =\n\t\t\t\tconflictingOptions ?? \"--all cannot be combined with --self, --extensions, --models, or --extension\";\n\t\t}\n\t\tif (allFlag && source) {\n\t\t\tconflictingOptions = conflictingOptions ?? \"--all cannot be combined with a positional source\";\n\t\t}\n\n\t\tif (modelsFlag) {\n\t\t\tif (selfFlag || extensionsFlag || allFlag || extensionFlagSource) {\n\t\t\t\tconflictingOptions =\n\t\t\t\t\tconflictingOptions ?? \"--models cannot be combined with --self, --extensions, --all, or --extension\";\n\t\t\t}\n\t\t\tif (source) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--models cannot be combined with a positional source\";\n\t\t\t}\n\t\t\tupdateTarget = { type: \"models\" };\n\t\t} else if (extensionFlagSource) {\n\t\t\tif (selfFlag || extensionsFlag || allFlag) {\n\t\t\t\tconflictingOptions =\n\t\t\t\t\tconflictingOptions ?? \"--extension cannot be combined with --self, --extensions, or --all\";\n\t\t\t}\n\t\t\tif (source) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--extension cannot be combined with a positional source\";\n\t\t\t}\n\t\t\tupdateTarget = { type: \"extensions\", source: extensionFlagSource };\n\t\t} else if (source) {\n\t\t\tconst sourceIsSelf = source === \"self\" || source === \"ada-cli\" || source === \"pi\";\n\t\t\tif (sourceIsSelf) {\n\t\t\t\tupdateTarget = extensionsFlag ? { type: \"all\" } : { type: \"self\" };\n\t\t\t} else {\n\t\t\t\tif (extensionsFlag || selfFlag || allFlag) {\n\t\t\t\t\tconflictingOptions =\n\t\t\t\t\t\tconflictingOptions ??\n\t\t\t\t\t\t\"positional update targets cannot be combined with --self, --extensions, or --all\";\n\t\t\t\t}\n\t\t\t\tupdateTarget = { type: \"extensions\", source };\n\t\t\t}\n\t\t} else if (allFlag) {\n\t\t\tupdateTarget = { type: \"all\" };\n\t\t} else if (selfFlag && extensionsFlag) {\n\t\t\tupdateTarget = { type: \"all\" };\n\t\t} else if (selfFlag) {\n\t\t\tupdateTarget = { type: \"self\" };\n\t\t} else if (extensionsFlag) {\n\t\t\tupdateTarget = { type: \"extensions\" };\n\t\t} else {\n\t\t\tupdateTarget = { type: \"self\" };\n\t\t\tshowExtensionsSkippedNote = true;\n\t\t}\n\t}\n\n\treturn {\n\t\tcommand,\n\t\tsource,\n\t\tupdateTarget,\n\t\tshowExtensionsSkippedNote,\n\t\tlocal,\n\t\tforce,\n\t\tprojectTrustOverride,\n\t\thelp,\n\t\tinvalidOption,\n\t\tinvalidArgument,\n\t\tmissingOptionValue,\n\t\tconflictingOptions,\n\t};\n}\n\nfunction updateTargetIncludesSelf(target: UpdateTarget): boolean {\n\treturn target.type === \"all\" || target.type === \"self\";\n}\n\nfunction updateTargetIncludesExtensions(target: UpdateTarget): boolean {\n\treturn target.type === \"all\" || target.type === \"extensions\";\n}\n\nasync function refreshModelCatalogs(agentDir: string): Promise<void> {\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), 15_000);\n\ttry {\n\t\tconst modelRuntime = await ModelRuntime.create({\n\t\t\tauthPath: join(agentDir, \"auth.json\"),\n\t\t\tmodelsPath: join(agentDir, \"models.json\"),\n\t\t\tallowModelNetwork: false,\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\tconst result = await modelRuntime.refresh({\n\t\t\tallowNetwork: true,\n\t\t\tforce: true,\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\tif (result.aborted) {\n\t\t\tthrow new Error(\"Model catalog refresh timed out.\");\n\t\t}\n\t\tif (result.errors.size > 0) {\n\t\t\tconst details = Array.from(result.errors, ([provider, error]) => `${provider}: ${error.message}`).join(\"; \");\n\t\t\tthrow new Error(`Could not refresh model catalogs: ${details}`);\n\t\t}\n\t} finally {\n\t\tclearTimeout(timeout);\n\t}\n\tconsole.log(chalk.green(\"Model catalogs refreshed\"));\n}\n\nfunction printSelfUpdateUnavailable(\n\tnpmCommand?: string[],\n\tupdatePackageTarget: SelfUpdatePackageTarget = PACKAGE_NAME,\n): void {\n\tconsole.error(`error: ${APP_NAME} cannot self-update this installation.`);\n\tconsole.error(getSelfUpdateUnavailableInstruction(PACKAGE_NAME, npmCommand, updatePackageTarget));\n\n\tconst entrypoint = process.argv[1];\n\tif (entrypoint) {\n\t\tconsole.error(\"\");\n\t\tconsole.error(`Location of ${APP_NAME} executable: ${entrypoint}`);\n\t}\n}\n\nfunction printSelfUpdateFallback(command: SelfUpdateCommand): void {\n\tconsole.error(chalk.dim(`If this keeps failing, run this command yourself: ${command.display}`));\n}\n\nfunction printPnpmSelfUpdateMetadataHint(): void {\n\tconsole.error(chalk.yellow(\"If pnpm reports missing package versions, its cached registry metadata may be stale.\"));\n\tconsole.error(chalk.yellow(`Run \\`pnpm store prune\\` and retry \\`${APP_NAME} update --self\\`.`));\n}\n\nfunction printSelfUpdateNote(note: string): void {\n\tconst trimmedNote = note.trim();\n\tif (!trimmedNote) {\n\t\treturn;\n\t}\n\n\tconsole.log();\n\tconsole.log(chalk.bold(chalk.yellow(\"Update note\")));\n\ttry {\n\t\tconst width = Math.max(20, process.stdout.columns ?? 80);\n\t\tconst renderedLines = new Markdown(trimmedNote, 0, 0, SELF_UPDATE_NOTE_MARKDOWN_THEME)\n\t\t\t.render(width)\n\t\t\t.map((line) => line.trimEnd());\n\t\tconsole.log(renderedLines.join(\"\\n\"));\n\t} catch {\n\t\tconsole.log(trimmedNote);\n\t}\n\tconsole.log();\n}\n\ninterface SelfUpdatePlan {\n\tpackageName: string;\n\tinstallSpec: string;\n\tversion: string;\n\tshouldRun: boolean;\n\tnote?: string;\n}\n\nasync function getSelfUpdatePlan(force: boolean): Promise<SelfUpdatePlan> {\n\tlet latestRelease: Awaited<ReturnType<typeof getLatestPiRelease>>;\n\ttry {\n\t\tlatestRelease = await getLatestPiRelease(VERSION, { retry: true });\n\t} catch (error: unknown) {\n\t\tthrow new Error(`Could not determine latest ${APP_NAME} version: ${formatVersionCheckError(error)}`, {\n\t\t\tcause: error,\n\t\t});\n\t}\n\tif (!latestRelease) {\n\t\tthrow new Error(`Could not determine latest ${APP_NAME} version.`);\n\t}\n\n\tconst packageName = PACKAGE_NAME;\n\tconst installSpec = `${packageName}@${latestRelease.version}`;\n\tif (force || isNewerPackageVersion(latestRelease.version, VERSION)) {\n\t\treturn {\n\t\t\tpackageName,\n\t\t\tinstallSpec,\n\t\t\tversion: latestRelease.version,\n\t\t\t...(latestRelease.note ? { note: latestRelease.note } : {}),\n\t\t\tshouldRun: true,\n\t\t};\n\t}\n\n\tconsole.log(chalk.green(`${APP_NAME} is already up to date (v${VERSION})`));\n\treturn { packageName, installSpec, version: latestRelease.version, shouldRun: false };\n}\n\nasync function runSelfUpdate(command: SelfUpdateCommand): Promise<void> {\n\tconsole.log(chalk.dim(`Updating ${APP_NAME} with ${command.display}...`));\n\tfor (const step of command.steps ?? [command]) {\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst child = spawnProcess(step.command, step.args, {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t});\n\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\treject(error);\n\t\t\t});\n\t\t\tchild.on(\"close\", (code, signal) => {\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else if (signal) {\n\t\t\t\t\treject(new Error(`${step.display} terminated by signal ${signal}`));\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error(`${step.display} exited with code ${code ?? \"unknown\"}`));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n}\n\nfunction prepareWindowsNpmSelfUpdate(): void {\n\tif (process.platform !== \"win32\") {\n\t\treturn;\n\t}\n\n\tconst packageDir = getPackageDir();\n\tcleanupWindowsSelfUpdateQuarantine(packageDir);\n\tquarantineWindowsNativeDependencies(packageDir);\n}\n\nexport interface PackageCommandRuntimeOptions {\n\textensionFactories?: InlineExtension[];\n}\n\ninterface CommandSettingsResult {\n\tsettingsManager: SettingsManager;\n\tprojectTrustWarnings: string[];\n}\n\nfunction getCommandAppMode(): AppMode {\n\treturn process.stdin.isTTY && process.stdout.isTTY ? \"interactive\" : \"print\";\n}\n\nfunction reportProjectTrustWarnings(warnings: readonly string[]): void {\n\tfor (const warning of warnings) {\n\t\tconsole.error(chalk.yellow(`Warning: ${warning}`));\n\t}\n}\n\nasync function createCommandSettingsManager(options: {\n\tcwd: string;\n\tagentDir: string;\n\tprojectTrustOverride?: boolean;\n\tuseSavedProjectTrustOnly?: boolean;\n\textensionFactories?: InlineExtension[];\n}): Promise<CommandSettingsResult> {\n\tconst settingsManager = SettingsManager.create(options.cwd, options.agentDir, { projectTrusted: false });\n\tconst projectTrustWarnings: string[] = [];\n\tconst trustStore = new ProjectTrustStore(options.agentDir);\n\tif (options.useSavedProjectTrustOnly) {\n\t\tconst savedProjectTrusted = trustStore.get(options.cwd) === true;\n\t\tsettingsManager.setProjectTrusted(options.projectTrustOverride ?? savedProjectTrusted);\n\t\treturn { settingsManager, projectTrustWarnings };\n\t}\n\n\tconst appMode = getCommandAppMode();\n\tconst extensionsResult =\n\t\toptions.projectTrustOverride === undefined && hasTrustRequiringProjectResources(options.cwd)\n\t\t\t? await new DefaultResourceLoader({\n\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\tagentDir: options.agentDir,\n\t\t\t\t\tsettingsManager,\n\t\t\t\t\textensionFactories: options.extensionFactories,\n\t\t\t\t}).loadProjectTrustExtensions()\n\t\t\t: undefined;\n\tfor (const error of extensionsResult?.errors ?? []) {\n\t\tprojectTrustWarnings.push(`Failed to load extension \"${error.path}\": ${error.error}`);\n\t}\n\n\tconst projectTrusted = await resolveProjectTrusted({\n\t\tcwd: options.cwd,\n\t\ttrustStore,\n\t\ttrustOverride: options.projectTrustOverride,\n\t\tdefaultProjectTrust: settingsManager.getDefaultProjectTrust(),\n\t\textensionsResult,\n\t\tprojectTrustContext: createProjectTrustContext({\n\t\t\tcwd: options.cwd,\n\t\t\tmode: appMode,\n\t\t\tsettingsManager,\n\t\t\thasUI: appMode === \"interactive\",\n\t\t}),\n\t\tonExtensionError: (message) => projectTrustWarnings.push(message),\n\t});\n\tsettingsManager.setProjectTrusted(projectTrusted);\n\treturn { settingsManager, projectTrustWarnings };\n}\n\nexport async function handleConfigCommand(\n\targs: string[],\n\truntimeOptions: PackageCommandRuntimeOptions = {},\n): Promise<boolean> {\n\tconst [command, ...rest] = args;\n\tif (command !== \"config\") {\n\t\treturn false;\n\t}\n\n\tif (rest.includes(\"-h\") || rest.includes(\"--help\")) {\n\t\tprintConfigCommandHelp();\n\t\treturn true;\n\t}\n\n\tlet local = false;\n\tlet projectTrustOverride: boolean | undefined;\n\tfor (const arg of rest) {\n\t\tif (arg === \"-l\" || arg === \"--local\") {\n\t\t\tlocal = true;\n\t\t} else if (arg === \"-a\" || arg === \"--approve\") {\n\t\t\tprojectTrustOverride = true;\n\t\t} else if (arg === \"-na\" || arg === \"--no-approve\") {\n\t\t\tprojectTrustOverride = false;\n\t\t} else if (arg.startsWith(\"-\")) {\n\t\t\tconsole.error(chalk.red(`Unknown option ${arg} for \"config\".`));\n\t\t\tconsole.error(chalk.dim(`Use \"${APP_NAME} --help\" or \"${CONFIG_COMMAND_USAGE}\".`));\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn true;\n\t\t} else {\n\t\t\tconsole.error(chalk.red(`Unexpected argument ${arg}.`));\n\t\t\tconsole.error(chalk.dim(`Usage: ${CONFIG_COMMAND_USAGE}`));\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst cwd = process.cwd();\n\tconst agentDir = getAgentDir();\n\tconst { settingsManager, projectTrustWarnings } = await createCommandSettingsManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tprojectTrustOverride,\n\t\textensionFactories: runtimeOptions.extensionFactories,\n\t});\n\treportProjectTrustWarnings(projectTrustWarnings);\n\tif (local && !settingsManager.isProjectTrusted()) {\n\t\tconsole.error(chalk.red(\"Project is not trusted. Use --approve to modify local resource config.\"));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\treportSettingsErrors(settingsManager, \"config command\");\n\tconst globalSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: false });\n\tconst globalResolvedPaths = await new DefaultPackageManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tsettingsManager: globalSettingsManager,\n\t}).resolve();\n\tconst projectResolvedPaths = settingsManager.isProjectTrusted()\n\t\t? await new DefaultPackageManager({ cwd, agentDir, settingsManager }).resolve()\n\t\t: globalResolvedPaths;\n\n\tawait selectConfig({\n\t\tresolvedPaths: { global: globalResolvedPaths, project: projectResolvedPaths },\n\t\tsettingsManager,\n\t\tcwd,\n\t\tagentDir,\n\t\twriteScope: local ? \"project\" : \"global\",\n\t\tprojectModeAvailable: settingsManager.isProjectTrusted(),\n\t});\n\n\tprocess.exit(0);\n}\n\nexport async function handlePackageCommand(\n\targs: string[],\n\truntimeOptions: PackageCommandRuntimeOptions = {},\n): Promise<boolean> {\n\tconst options = parsePackageCommand(args);\n\tif (!options) {\n\t\treturn false;\n\t}\n\n\tif (options.help) {\n\t\tprintPackageCommandHelp(options.command);\n\t\treturn true;\n\t}\n\n\tif (options.invalidOption) {\n\t\tconsole.error(chalk.red(`Unknown option ${options.invalidOption} for \"${options.command}\".`));\n\t\tconsole.error(chalk.dim(`Use \"${APP_NAME} --help\" or \"${getPackageCommandUsage(options.command)}\".`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.missingOptionValue) {\n\t\tconsole.error(chalk.red(`Missing value for ${options.missingOptionValue}.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.invalidArgument) {\n\t\tconsole.error(chalk.red(`Unexpected argument ${options.invalidArgument}.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.conflictingOptions) {\n\t\tconsole.error(chalk.red(options.conflictingOptions));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tconst source = options.source;\n\tif ((options.command === \"install\" || options.command === \"remove\") && !source) {\n\t\tconsole.error(chalk.red(`Missing ${options.command} source.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.command === \"update\" && options.updateTarget?.type === \"models\") {\n\t\ttry {\n\t\t\tawait refreshModelCatalogs(getAgentDir());\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error ? error.message : \"Unknown model catalog refresh error\";\n\t\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\t\treturn true;\n\t}\n\n\tconst cwd = process.cwd();\n\tconst agentDir = getAgentDir();\n\tconst writesProjectPackageConfig = (options.command === \"install\" || options.command === \"remove\") && options.local;\n\tconst { settingsManager, projectTrustWarnings } = await createCommandSettingsManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tprojectTrustOverride: options.projectTrustOverride,\n\t\tuseSavedProjectTrustOnly: options.command === \"update\",\n\t\textensionFactories: runtimeOptions.extensionFactories,\n\t});\n\treportProjectTrustWarnings(projectTrustWarnings);\n\tif (!settingsManager.isProjectTrusted() && writesProjectPackageConfig) {\n\t\tconsole.error(chalk.red(\"Project is not trusted. Use --approve to modify local package config.\"));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\treportSettingsErrors(settingsManager, \"package command\");\n\tconst selfUpdateNpmCommand = settingsManager.getGlobalSettings().npmCommand;\n\n\tconst packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });\n\n\tpackageManager.setProgressCallback((event) => {\n\t\tif (event.type === \"start\") {\n\t\t\tprocess.stdout.write(chalk.dim(`${event.message}\\n`));\n\t\t}\n\t});\n\n\ttry {\n\t\tswitch (options.command) {\n\t\t\tcase \"install\":\n\t\t\t\tawait packageManager.installAndPersist(source!, { local: options.local });\n\t\t\t\tconsole.log(chalk.green(`Installed ${source}`));\n\t\t\t\treturn true;\n\n\t\t\tcase \"remove\": {\n\t\t\t\tconst removed = await packageManager.removeAndPersist(source!, { local: options.local });\n\t\t\t\tif (!removed) {\n\t\t\t\t\tconsole.error(chalk.red(`No matching package found for ${source}`));\n\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconsole.log(chalk.green(`Removed ${source}`));\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tcase \"list\": {\n\t\t\t\tconst configuredPackages = packageManager.listConfiguredPackages();\n\t\t\t\tconst userPackages = configuredPackages.filter((pkg) => pkg.scope === \"user\");\n\t\t\t\tconst projectPackages = configuredPackages.filter((pkg) => pkg.scope === \"project\");\n\n\t\t\t\tif (configuredPackages.length === 0) {\n\t\t\t\t\tconsole.log(chalk.dim(\"No packages installed.\"));\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tconst formatPackage = (pkg: (typeof configuredPackages)[number]) => {\n\t\t\t\t\tconst display = pkg.filtered ? `${pkg.source} (filtered)` : pkg.source;\n\t\t\t\t\tconsole.log(` ${display}`);\n\t\t\t\t\tif (pkg.installedPath) {\n\t\t\t\t\t\tconsole.log(chalk.dim(` ${pkg.installedPath}`));\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tif (userPackages.length > 0) {\n\t\t\t\t\tconsole.log(chalk.bold(\"User packages:\"));\n\t\t\t\t\tfor (const pkg of userPackages) {\n\t\t\t\t\t\tformatPackage(pkg);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (projectPackages.length > 0) {\n\t\t\t\t\tif (userPackages.length > 0) console.log();\n\t\t\t\t\tconsole.log(chalk.bold(\"Project packages:\"));\n\t\t\t\t\tfor (const pkg of projectPackages) {\n\t\t\t\t\t\tformatPackage(pkg);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tcase \"update\": {\n\t\t\t\tconst target = options.updateTarget ?? { type: \"self\" };\n\t\t\t\tif (options.showExtensionsSkippedNote) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\tchalk.dim(`Extensions are skipped. Run ${APP_NAME} update --extensions to update extensions.`),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (updateTargetIncludesExtensions(target)) {\n\t\t\t\t\tconst updateSource = target.type === \"extensions\" ? target.source : undefined;\n\t\t\t\t\tawait packageManager.update(updateSource);\n\t\t\t\t\tif (updateSource) {\n\t\t\t\t\t\tconsole.log(chalk.green(`Updated ${updateSource}`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log(chalk.green(\"Updated packages\"));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (updateTargetIncludesSelf(target)) {\n\t\t\t\t\tconst selfUpdatePlan = await getSelfUpdatePlan(options.force);\n\t\t\t\t\tif (!selfUpdatePlan.shouldRun) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconst installMethod = detectInstallMethod();\n\t\t\t\t\tif (process.platform === \"win32\" && installMethod !== \"npm\" && installMethod !== \"pnpm\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tchalk.red(`${APP_NAME} self-update on Windows is only supported for npm and pnpm installs.`),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.error(chalk.dim(`Detected install method: ${installMethod}. Update ${APP_NAME} manually.`));\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconst selfUpdateTarget = {\n\t\t\t\t\t\tpackageName: selfUpdatePlan.packageName,\n\t\t\t\t\t\tinstallSpec: selfUpdatePlan.installSpec,\n\t\t\t\t\t};\n\t\t\t\t\tconst selfUpdateCommand = getSelfUpdateCommand(PACKAGE_NAME, selfUpdateNpmCommand, selfUpdateTarget);\n\t\t\t\t\tif (!selfUpdateCommand) {\n\t\t\t\t\t\tprintSelfUpdateUnavailable(selfUpdateNpmCommand, selfUpdateTarget);\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (selfUpdatePlan.note) {\n\t\t\t\t\t\tprintSelfUpdateNote(selfUpdatePlan.note);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (installMethod === \"npm\") {\n\t\t\t\t\t\t\tprepareWindowsNpmSelfUpdate();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait runSelfUpdate(selfUpdateCommand);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tconst message = error instanceof Error ? error.message : \"Unknown package command error\";\n\t\t\t\t\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\t\t\t\t\tif (installMethod === \"pnpm\") {\n\t\t\t\t\t\t\tprintPnpmSelfUpdateMetadataHint();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tprintSelfUpdateFallback(selfUpdateCommand);\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconsole.log(chalk.green(`Updated ${APP_NAME} from ${VERSION} to ${selfUpdatePlan.version}`));\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown package command error\";\n\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"package-manager-cli.js","sourceRoot":"","sources":["../src/package-manager-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAsB,MAAM,wBAAwB,CAAC;AACtE,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,yBAAyB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,EACN,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,WAAW,EACX,aAAa,EACb,oBAAoB,EACpB,mCAAmC,EACnC,YAAY,EAGZ,OAAO,GACP,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAgB,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,iCAAiC,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,qB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C,OAAO,CAAC,CAAC,CAAC,+BAA+B,CAAC;wBACzF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC,CAAC;wBAC9C,IAAI,aAAa,KAAK,MAAM,EAAE,CAAC;4BAC9B,+BAA+B,EAAE,CAAC;wBACnC,CAAC;wBACD,uBAAuB,CAAC,iBAAiB,CAAC,CAAC;wBAC3C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;wBACrB,OAAO,IAAI,CAAC;oBACb,CAAC;oBACD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,QAAQ,SAAS,OAAO,OAAO,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;gBAC9F,CAAC;gBACD,OAAO,IAAI,CAAC;YACb,CAAC;QACF,CAAC;IACF,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACzB,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,+BAA+B,CAAC;QACzF,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC,CAAC;QAC9C,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACb,CAAC;AAAA,CACD","sourcesContent":["import { join } from \"node:path\";\nimport { Markdown, type MarkdownTheme } from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { selectConfig } from \"./cli/config-selector.ts\";\nimport { createProjectTrustContext } from \"./cli/project-trust.ts\";\nimport {\n\tAPP_NAME,\n\tCONFIG_DIR_NAME,\n\tdetectInstallMethod,\n\tgetAgentDir,\n\tgetPackageDir,\n\tgetSelfUpdateCommand,\n\tgetSelfUpdateUnavailableInstruction,\n\tPACKAGE_NAME,\n\ttype SelfUpdateCommand,\n\ttype SelfUpdatePackageTarget,\n\tVERSION,\n} from \"./config.ts\";\nimport type { InlineExtension } from \"./core/extensions/types.ts\";\nimport { ModelRuntime } from \"./core/model-runtime.ts\";\nimport { DefaultPackageManager } from \"./core/package-manager.ts\";\nimport { type AppMode, resolveProjectTrusted } from \"./core/project-trust.ts\";\nimport { DefaultResourceLoader } from \"./core/resource-loader.ts\";\nimport { SettingsManager } from \"./core/settings-manager.ts\";\nimport { hasTrustRequiringProjectResources, ProjectTrustStore } from \"./core/trust-manager.ts\";\nimport { spawnProcess } from \"./utils/child-process.ts\";\nimport { formatVersionCheckError, getLatestPiRelease, isNewerPackageVersion } from \"./utils/version-check.ts\";\nimport {\n\tcleanupWindowsSelfUpdateQuarantine,\n\tquarantineWindowsNativeDependencies,\n} from \"./utils/windows-self-update.ts\";\n\nexport type PackageCommand = \"install\" | \"remove\" | \"update\" | \"list\";\n\ntype UpdateTarget = { type: \"all\" } | { type: \"self\" } | { type: \"extensions\"; source?: string } | { type: \"models\" };\n\nconst SELF_UPDATE_NOTE_MARKDOWN_THEME: MarkdownTheme = {\n\theading: (text) => chalk.bold(chalk.yellow(text)),\n\tlink: (text) => chalk.cyan(text),\n\tlinkUrl: (text) => chalk.dim(text),\n\tcode: (text) => chalk.yellow(text),\n\tcodeBlock: (text) => chalk.dim(text),\n\tcodeBlockBorder: (text) => chalk.dim(text),\n\tquote: (text) => chalk.dim(text),\n\tquoteBorder: (text) => chalk.dim(text),\n\thr: (text) => chalk.dim(text),\n\tlistBullet: (text) => chalk.yellow(text),\n\tbold: (text) => chalk.bold(text),\n\titalic: (text) => chalk.italic(text),\n\tstrikethrough: (text) => chalk.strikethrough(text),\n\tunderline: (text) => chalk.underline(text),\n};\n\ninterface PackageCommandOptions {\n\tcommand: PackageCommand;\n\tsource?: string;\n\tupdateTarget?: UpdateTarget;\n\tshowExtensionsSkippedNote: boolean;\n\tlocal: boolean;\n\tforce: boolean;\n\tprojectTrustOverride?: boolean;\n\thelp: boolean;\n\tinvalidOption?: string;\n\tinvalidArgument?: string;\n\tmissingOptionValue?: string;\n\tconflictingOptions?: string;\n}\n\nfunction reportSettingsErrors(settingsManager: SettingsManager, context: string): void {\n\tconst errors = settingsManager.drainErrors();\n\tfor (const { scope, error } of errors) {\n\t\tconsole.error(chalk.yellow(`Warning (${context}, ${scope} settings): ${error.message}`));\n\t\tif (error.stack) {\n\t\t\tconsole.error(chalk.dim(error.stack));\n\t\t}\n\t}\n}\n\nfunction getPackageCommandUsage(command: PackageCommand): string {\n\tswitch (command) {\n\t\tcase \"install\":\n\t\t\treturn `${APP_NAME} install <source> [-l] [--approve|--no-approve]`;\n\t\tcase \"remove\":\n\t\t\treturn `${APP_NAME} remove <source> [-l] [--approve|--no-approve]`;\n\t\tcase \"update\":\n\t\t\treturn `${APP_NAME} update [source|self|ada-cli] [--self|--extensions|--models|--all] [--extension <source>] [--approve|--no-approve] [--force]`;\n\t\tcase \"list\":\n\t\t\treturn `${APP_NAME} list [--approve|--no-approve]`;\n\t}\n}\n\nconst CONFIG_COMMAND_USAGE = `${APP_NAME} config [-l] [--approve|--no-approve]`;\n\nfunction printConfigCommandHelp(): void {\n\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${CONFIG_COMMAND_USAGE}\n\nOpen the resource configuration TUI to enable or disable package resources.\nWithout -l, starts in global settings (~/${CONFIG_DIR_NAME}/agent/settings.json).\nPress Tab in the TUI to switch between global and project-local modes.\n\nOptions:\n -l, --local Edit project overrides (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command with -l\n -na, --no-approve Ignore project-local files for this command with -l\n`);\n}\n\nfunction printPackageCommandHelp(command: PackageCommand): void {\n\tswitch (command) {\n\t\tcase \"install\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"install\")}\n\nInstall a package and add it to settings.\n\nOptions:\n -l, --local Install project-locally (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n\nExamples:\n ${APP_NAME} install npm:@foo/bar\n ${APP_NAME} install git:github.com/user/repo\n ${APP_NAME} install git:git@github.com:user/repo\n ${APP_NAME} install https://github.com/user/repo\n ${APP_NAME} install ssh://git@github.com/user/repo\n ${APP_NAME} install ./local/path\n`);\n\t\t\treturn;\n\n\t\tcase \"remove\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"remove\")}\n\nRemove a package and its source from settings.\nAlias: ${APP_NAME} uninstall <source> [-l]\n\nOptions:\n -l, --local Remove from project settings (${CONFIG_DIR_NAME}/settings.json)\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n\nExamples:\n ${APP_NAME} remove npm:@foo/bar\n ${APP_NAME} uninstall npm:@foo/bar\n`);\n\t\t\treturn;\n\n\t\tcase \"update\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"update\")}\n\nUpdate ada-cli, installed packages, or model catalogs.\n\nOptions:\n --self Update ada-cli only (default when no target is given)\n --extensions Update installed packages only\n --models Refresh model catalogs only\n --all Update pi and installed packages\n --extension <source> Update one package only\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n --force Reinstall pi even if the current version is latest\n\nShort forms:\n ${APP_NAME} update Update pi only\n ${APP_NAME} update --all Update pi and all extensions\n ${APP_NAME} update --models Refresh model catalogs only\n ${APP_NAME} update <source> Update one package\n ${APP_NAME} update ada-cli Update ada-cli only (self works as alias to ada-cli)\n`);\n\t\t\treturn;\n\n\t\tcase \"list\":\n\t\t\tconsole.log(`${chalk.bold(\"Usage:\")}\n ${getPackageCommandUsage(\"list\")}\n\nList installed packages from user and project settings.\n\nOptions:\n -a, --approve Trust project-local files for this command\n -na, --no-approve Ignore project-local files for this command\n`);\n\t\t\treturn;\n\t}\n}\n\nfunction parsePackageCommand(args: string[]): PackageCommandOptions | undefined {\n\tconst [rawCommand, ...rest] = args;\n\tlet command: PackageCommand | undefined;\n\tif (rawCommand === \"uninstall\") {\n\t\tcommand = \"remove\";\n\t} else if (rawCommand === \"install\" || rawCommand === \"remove\" || rawCommand === \"update\" || rawCommand === \"list\") {\n\t\tcommand = rawCommand;\n\t}\n\tif (!command) {\n\t\treturn undefined;\n\t}\n\n\tlet local = false;\n\tlet force = false;\n\tlet projectTrustOverride: boolean | undefined;\n\tlet help = false;\n\tlet invalidOption: string | undefined;\n\tlet invalidArgument: string | undefined;\n\tlet missingOptionValue: string | undefined;\n\tlet conflictingOptions: string | undefined;\n\tlet source: string | undefined;\n\tlet selfFlag = false;\n\tlet extensionsFlag = false;\n\tlet modelsFlag = false;\n\tlet allFlag = false;\n\tlet extensionFlagSource: string | undefined;\n\n\tfor (let index = 0; index < rest.length; index++) {\n\t\tconst arg = rest[index];\n\t\tif (arg === \"-h\" || arg === \"--help\") {\n\t\t\thelp = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"-l\" || arg === \"--local\") {\n\t\t\tif (command === \"install\" || command === \"remove\") {\n\t\t\t\tlocal = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--self\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tselfFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--extensions\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\textensionsFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--models\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tmodelsFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--all\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tallFlag = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--approve\" || arg === \"-a\") {\n\t\t\tprojectTrustOverride = true;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--no-approve\" || arg === \"-na\") {\n\t\t\tprojectTrustOverride = false;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--force\") {\n\t\t\tif (command === \"update\") {\n\t\t\t\tforce = true;\n\t\t\t} else {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg === \"--extension\") {\n\t\t\tif (command !== \"update\") {\n\t\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst value = rest[index + 1];\n\t\t\tif (!value || value.startsWith(\"-\")) {\n\t\t\t\tmissingOptionValue = missingOptionValue ?? arg;\n\t\t\t} else if (extensionFlagSource) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--extension can only be provided once\";\n\t\t\t\tindex++;\n\t\t\t} else {\n\t\t\t\textensionFlagSource = value;\n\t\t\t\tindex++;\n\t\t\t}\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (arg.startsWith(\"-\")) {\n\t\t\tinvalidOption = invalidOption ?? arg;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!source) {\n\t\t\tsource = arg;\n\t\t} else {\n\t\t\tinvalidArgument = invalidArgument ?? arg;\n\t\t}\n\t}\n\n\tlet updateTarget: UpdateTarget | undefined;\n\tlet showExtensionsSkippedNote = false;\n\tif (command === \"update\") {\n\t\tif (allFlag && (selfFlag || extensionsFlag || modelsFlag || extensionFlagSource)) {\n\t\t\tconflictingOptions =\n\t\t\t\tconflictingOptions ?? \"--all cannot be combined with --self, --extensions, --models, or --extension\";\n\t\t}\n\t\tif (allFlag && source) {\n\t\t\tconflictingOptions = conflictingOptions ?? \"--all cannot be combined with a positional source\";\n\t\t}\n\n\t\tif (modelsFlag) {\n\t\t\tif (selfFlag || extensionsFlag || allFlag || extensionFlagSource) {\n\t\t\t\tconflictingOptions =\n\t\t\t\t\tconflictingOptions ?? \"--models cannot be combined with --self, --extensions, --all, or --extension\";\n\t\t\t}\n\t\t\tif (source) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--models cannot be combined with a positional source\";\n\t\t\t}\n\t\t\tupdateTarget = { type: \"models\" };\n\t\t} else if (extensionFlagSource) {\n\t\t\tif (selfFlag || extensionsFlag || allFlag) {\n\t\t\t\tconflictingOptions =\n\t\t\t\t\tconflictingOptions ?? \"--extension cannot be combined with --self, --extensions, or --all\";\n\t\t\t}\n\t\t\tif (source) {\n\t\t\t\tconflictingOptions = conflictingOptions ?? \"--extension cannot be combined with a positional source\";\n\t\t\t}\n\t\t\tupdateTarget = { type: \"extensions\", source: extensionFlagSource };\n\t\t} else if (source) {\n\t\t\tconst sourceIsSelf = source === \"self\" || source === \"ada-cli\" || source === \"pi\";\n\t\t\tif (sourceIsSelf) {\n\t\t\t\tupdateTarget = extensionsFlag ? { type: \"all\" } : { type: \"self\" };\n\t\t\t} else {\n\t\t\t\tif (extensionsFlag || selfFlag || allFlag) {\n\t\t\t\t\tconflictingOptions =\n\t\t\t\t\t\tconflictingOptions ??\n\t\t\t\t\t\t\"positional update targets cannot be combined with --self, --extensions, or --all\";\n\t\t\t\t}\n\t\t\t\tupdateTarget = { type: \"extensions\", source };\n\t\t\t}\n\t\t} else if (allFlag) {\n\t\t\tupdateTarget = { type: \"all\" };\n\t\t} else if (selfFlag && extensionsFlag) {\n\t\t\tupdateTarget = { type: \"all\" };\n\t\t} else if (selfFlag) {\n\t\t\tupdateTarget = { type: \"self\" };\n\t\t} else if (extensionsFlag) {\n\t\t\tupdateTarget = { type: \"extensions\" };\n\t\t} else {\n\t\t\tupdateTarget = { type: \"self\" };\n\t\t\tshowExtensionsSkippedNote = true;\n\t\t}\n\t}\n\n\treturn {\n\t\tcommand,\n\t\tsource,\n\t\tupdateTarget,\n\t\tshowExtensionsSkippedNote,\n\t\tlocal,\n\t\tforce,\n\t\tprojectTrustOverride,\n\t\thelp,\n\t\tinvalidOption,\n\t\tinvalidArgument,\n\t\tmissingOptionValue,\n\t\tconflictingOptions,\n\t};\n}\n\nfunction updateTargetIncludesSelf(target: UpdateTarget): boolean {\n\treturn target.type === \"all\" || target.type === \"self\";\n}\n\nfunction updateTargetIncludesExtensions(target: UpdateTarget): boolean {\n\treturn target.type === \"all\" || target.type === \"extensions\";\n}\n\nasync function refreshModelCatalogs(agentDir: string): Promise<void> {\n\tconst controller = new AbortController();\n\tconst timeout = setTimeout(() => controller.abort(), 15_000);\n\ttry {\n\t\tconst modelRuntime = await ModelRuntime.create({\n\t\t\tauthPath: join(agentDir, \"auth.json\"),\n\t\t\tmodelsPath: join(agentDir, \"models.json\"),\n\t\t\tallowModelNetwork: false,\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\tconst result = await modelRuntime.refresh({\n\t\t\tallowNetwork: true,\n\t\t\tforce: true,\n\t\t\tsignal: controller.signal,\n\t\t});\n\t\tif (result.aborted) {\n\t\t\tthrow new Error(\"Model catalog refresh timed out.\");\n\t\t}\n\t\tif (result.errors.size > 0) {\n\t\t\tconst details = Array.from(result.errors, ([provider, error]) => `${provider}: ${error.message}`).join(\"; \");\n\t\t\tthrow new Error(`Could not refresh model catalogs: ${details}`);\n\t\t}\n\t} finally {\n\t\tclearTimeout(timeout);\n\t}\n\tconsole.log(chalk.green(\"Model catalogs refreshed\"));\n}\n\nfunction printSelfUpdateUnavailable(\n\tnpmCommand?: string[],\n\tupdatePackageTarget: SelfUpdatePackageTarget = PACKAGE_NAME,\n): void {\n\tconsole.error(`error: ${APP_NAME} cannot self-update this installation.`);\n\tconsole.error(getSelfUpdateUnavailableInstruction(PACKAGE_NAME, npmCommand, updatePackageTarget));\n\n\tconst entrypoint = process.argv[1];\n\tif (entrypoint) {\n\t\tconsole.error(\"\");\n\t\tconsole.error(`Location of ${APP_NAME} executable: ${entrypoint}`);\n\t}\n}\n\nfunction printSelfUpdateFallback(command: SelfUpdateCommand): void {\n\tconsole.error(chalk.dim(`If this keeps failing, run this command yourself: ${command.display}`));\n}\n\nfunction printPnpmSelfUpdateMetadataHint(): void {\n\tconsole.error(chalk.yellow(\"If pnpm reports missing package versions, its cached registry metadata may be stale.\"));\n\tconsole.error(chalk.yellow(`Run \\`pnpm store prune\\` and retry \\`${APP_NAME} update --self\\`.`));\n}\n\nfunction printSelfUpdateNote(note: string): void {\n\tconst trimmedNote = note.trim();\n\tif (!trimmedNote) {\n\t\treturn;\n\t}\n\n\tconsole.log();\n\tconsole.log(chalk.bold(chalk.yellow(\"Update note\")));\n\ttry {\n\t\tconst width = Math.max(20, process.stdout.columns ?? 80);\n\t\tconst renderedLines = new Markdown(trimmedNote, 0, 0, SELF_UPDATE_NOTE_MARKDOWN_THEME)\n\t\t\t.render(width)\n\t\t\t.map((line) => line.trimEnd());\n\t\tconsole.log(renderedLines.join(\"\\n\"));\n\t} catch {\n\t\tconsole.log(trimmedNote);\n\t}\n\tconsole.log();\n}\n\ninterface SelfUpdatePlan {\n\tpackageName: string;\n\tinstallSpec: string;\n\tversion: string;\n\tshouldRun: boolean;\n\tnote?: string;\n}\n\nasync function getSelfUpdatePlan(force: boolean): Promise<SelfUpdatePlan> {\n\tlet latestRelease: Awaited<ReturnType<typeof getLatestPiRelease>>;\n\ttry {\n\t\tlatestRelease = await getLatestPiRelease(VERSION, { retry: true });\n\t} catch (error: unknown) {\n\t\tthrow new Error(`Could not determine latest ${APP_NAME} version: ${formatVersionCheckError(error)}`, {\n\t\t\tcause: error,\n\t\t});\n\t}\n\tif (!latestRelease) {\n\t\tthrow new Error(`Could not determine latest ${APP_NAME} version.`);\n\t}\n\n\tconst packageName = latestRelease.packageName ?? PACKAGE_NAME;\n\tconst installSpec = `${packageName}@${latestRelease.version}`;\n\tif (force || isNewerPackageVersion(latestRelease.version, VERSION)) {\n\t\treturn {\n\t\t\tpackageName,\n\t\t\tinstallSpec,\n\t\t\tversion: latestRelease.version,\n\t\t\t...(latestRelease.note ? { note: latestRelease.note } : {}),\n\t\t\tshouldRun: true,\n\t\t};\n\t}\n\n\tconsole.log(chalk.green(`${APP_NAME} is already up to date (v${VERSION})`));\n\treturn { packageName, installSpec, version: latestRelease.version, shouldRun: false };\n}\n\nasync function runSelfUpdate(command: SelfUpdateCommand): Promise<void> {\n\tconsole.log(chalk.dim(`Updating ${APP_NAME} with ${command.display}...`));\n\tfor (const step of command.steps ?? [command]) {\n\t\tawait new Promise<void>((resolve, reject) => {\n\t\t\tconst child = spawnProcess(step.command, step.args, {\n\t\t\t\tstdio: \"inherit\",\n\t\t\t});\n\t\t\tchild.on(\"error\", (error) => {\n\t\t\t\treject(error);\n\t\t\t});\n\t\t\tchild.on(\"close\", (code, signal) => {\n\t\t\t\tif (code === 0) {\n\t\t\t\t\tresolve();\n\t\t\t\t} else if (signal) {\n\t\t\t\t\treject(new Error(`${step.display} terminated by signal ${signal}`));\n\t\t\t\t} else {\n\t\t\t\t\treject(new Error(`${step.display} exited with code ${code ?? \"unknown\"}`));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n}\n\nfunction prepareWindowsNpmSelfUpdate(): void {\n\tif (process.platform !== \"win32\") {\n\t\treturn;\n\t}\n\n\tconst packageDir = getPackageDir();\n\tcleanupWindowsSelfUpdateQuarantine(packageDir);\n\tquarantineWindowsNativeDependencies(packageDir);\n}\n\nexport interface PackageCommandRuntimeOptions {\n\textensionFactories?: InlineExtension[];\n}\n\ninterface CommandSettingsResult {\n\tsettingsManager: SettingsManager;\n\tprojectTrustWarnings: string[];\n}\n\nfunction getCommandAppMode(): AppMode {\n\treturn process.stdin.isTTY && process.stdout.isTTY ? \"interactive\" : \"print\";\n}\n\nfunction reportProjectTrustWarnings(warnings: readonly string[]): void {\n\tfor (const warning of warnings) {\n\t\tconsole.error(chalk.yellow(`Warning: ${warning}`));\n\t}\n}\n\nasync function createCommandSettingsManager(options: {\n\tcwd: string;\n\tagentDir: string;\n\tprojectTrustOverride?: boolean;\n\tuseSavedProjectTrustOnly?: boolean;\n\textensionFactories?: InlineExtension[];\n}): Promise<CommandSettingsResult> {\n\tconst settingsManager = SettingsManager.create(options.cwd, options.agentDir, { projectTrusted: false });\n\tconst projectTrustWarnings: string[] = [];\n\tconst trustStore = new ProjectTrustStore(options.agentDir);\n\tif (options.useSavedProjectTrustOnly) {\n\t\tconst savedProjectTrusted = trustStore.get(options.cwd) === true;\n\t\tsettingsManager.setProjectTrusted(options.projectTrustOverride ?? savedProjectTrusted);\n\t\treturn { settingsManager, projectTrustWarnings };\n\t}\n\n\tconst appMode = getCommandAppMode();\n\tconst extensionsResult =\n\t\toptions.projectTrustOverride === undefined && hasTrustRequiringProjectResources(options.cwd)\n\t\t\t? await new DefaultResourceLoader({\n\t\t\t\t\tcwd: options.cwd,\n\t\t\t\t\tagentDir: options.agentDir,\n\t\t\t\t\tsettingsManager,\n\t\t\t\t\textensionFactories: options.extensionFactories,\n\t\t\t\t}).loadProjectTrustExtensions()\n\t\t\t: undefined;\n\tfor (const error of extensionsResult?.errors ?? []) {\n\t\tprojectTrustWarnings.push(`Failed to load extension \"${error.path}\": ${error.error}`);\n\t}\n\n\tconst projectTrusted = await resolveProjectTrusted({\n\t\tcwd: options.cwd,\n\t\ttrustStore,\n\t\ttrustOverride: options.projectTrustOverride,\n\t\tdefaultProjectTrust: settingsManager.getDefaultProjectTrust(),\n\t\textensionsResult,\n\t\tprojectTrustContext: createProjectTrustContext({\n\t\t\tcwd: options.cwd,\n\t\t\tmode: appMode,\n\t\t\tsettingsManager,\n\t\t\thasUI: appMode === \"interactive\",\n\t\t}),\n\t\tonExtensionError: (message) => projectTrustWarnings.push(message),\n\t});\n\tsettingsManager.setProjectTrusted(projectTrusted);\n\treturn { settingsManager, projectTrustWarnings };\n}\n\nexport async function handleConfigCommand(\n\targs: string[],\n\truntimeOptions: PackageCommandRuntimeOptions = {},\n): Promise<boolean> {\n\tconst [command, ...rest] = args;\n\tif (command !== \"config\") {\n\t\treturn false;\n\t}\n\n\tif (rest.includes(\"-h\") || rest.includes(\"--help\")) {\n\t\tprintConfigCommandHelp();\n\t\treturn true;\n\t}\n\n\tlet local = false;\n\tlet projectTrustOverride: boolean | undefined;\n\tfor (const arg of rest) {\n\t\tif (arg === \"-l\" || arg === \"--local\") {\n\t\t\tlocal = true;\n\t\t} else if (arg === \"-a\" || arg === \"--approve\") {\n\t\t\tprojectTrustOverride = true;\n\t\t} else if (arg === \"-na\" || arg === \"--no-approve\") {\n\t\t\tprojectTrustOverride = false;\n\t\t} else if (arg.startsWith(\"-\")) {\n\t\t\tconsole.error(chalk.red(`Unknown option ${arg} for \"config\".`));\n\t\t\tconsole.error(chalk.dim(`Use \"${APP_NAME} --help\" or \"${CONFIG_COMMAND_USAGE}\".`));\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn true;\n\t\t} else {\n\t\t\tconsole.error(chalk.red(`Unexpected argument ${arg}.`));\n\t\t\tconsole.error(chalk.dim(`Usage: ${CONFIG_COMMAND_USAGE}`));\n\t\t\tprocess.exitCode = 1;\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tconst cwd = process.cwd();\n\tconst agentDir = getAgentDir();\n\tconst { settingsManager, projectTrustWarnings } = await createCommandSettingsManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tprojectTrustOverride,\n\t\textensionFactories: runtimeOptions.extensionFactories,\n\t});\n\treportProjectTrustWarnings(projectTrustWarnings);\n\tif (local && !settingsManager.isProjectTrusted()) {\n\t\tconsole.error(chalk.red(\"Project is not trusted. Use --approve to modify local resource config.\"));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\treportSettingsErrors(settingsManager, \"config command\");\n\tconst globalSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: false });\n\tconst globalResolvedPaths = await new DefaultPackageManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tsettingsManager: globalSettingsManager,\n\t}).resolve();\n\tconst projectResolvedPaths = settingsManager.isProjectTrusted()\n\t\t? await new DefaultPackageManager({ cwd, agentDir, settingsManager }).resolve()\n\t\t: globalResolvedPaths;\n\n\tawait selectConfig({\n\t\tresolvedPaths: { global: globalResolvedPaths, project: projectResolvedPaths },\n\t\tsettingsManager,\n\t\tcwd,\n\t\tagentDir,\n\t\twriteScope: local ? \"project\" : \"global\",\n\t\tprojectModeAvailable: settingsManager.isProjectTrusted(),\n\t});\n\n\tprocess.exit(0);\n}\n\nexport async function handlePackageCommand(\n\targs: string[],\n\truntimeOptions: PackageCommandRuntimeOptions = {},\n): Promise<boolean> {\n\tconst options = parsePackageCommand(args);\n\tif (!options) {\n\t\treturn false;\n\t}\n\n\tif (options.help) {\n\t\tprintPackageCommandHelp(options.command);\n\t\treturn true;\n\t}\n\n\tif (options.invalidOption) {\n\t\tconsole.error(chalk.red(`Unknown option ${options.invalidOption} for \"${options.command}\".`));\n\t\tconsole.error(chalk.dim(`Use \"${APP_NAME} --help\" or \"${getPackageCommandUsage(options.command)}\".`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.missingOptionValue) {\n\t\tconsole.error(chalk.red(`Missing value for ${options.missingOptionValue}.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.invalidArgument) {\n\t\tconsole.error(chalk.red(`Unexpected argument ${options.invalidArgument}.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.conflictingOptions) {\n\t\tconsole.error(chalk.red(options.conflictingOptions));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tconst source = options.source;\n\tif ((options.command === \"install\" || options.command === \"remove\") && !source) {\n\t\tconsole.error(chalk.red(`Missing ${options.command} source.`));\n\t\tconsole.error(chalk.dim(`Usage: ${getPackageCommandUsage(options.command)}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\n\tif (options.command === \"update\" && options.updateTarget?.type === \"models\") {\n\t\ttry {\n\t\t\tawait refreshModelCatalogs(getAgentDir());\n\t\t} catch (error: unknown) {\n\t\t\tconst message = error instanceof Error ? error.message : \"Unknown model catalog refresh error\";\n\t\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\t\tprocess.exitCode = 1;\n\t\t}\n\t\treturn true;\n\t}\n\n\tconst cwd = process.cwd();\n\tconst agentDir = getAgentDir();\n\tconst writesProjectPackageConfig = (options.command === \"install\" || options.command === \"remove\") && options.local;\n\tconst { settingsManager, projectTrustWarnings } = await createCommandSettingsManager({\n\t\tcwd,\n\t\tagentDir,\n\t\tprojectTrustOverride: options.projectTrustOverride,\n\t\tuseSavedProjectTrustOnly: options.command === \"update\",\n\t\textensionFactories: runtimeOptions.extensionFactories,\n\t});\n\treportProjectTrustWarnings(projectTrustWarnings);\n\tif (!settingsManager.isProjectTrusted() && writesProjectPackageConfig) {\n\t\tconsole.error(chalk.red(\"Project is not trusted. Use --approve to modify local package config.\"));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n\treportSettingsErrors(settingsManager, \"package command\");\n\tconst selfUpdateNpmCommand = settingsManager.getGlobalSettings().npmCommand;\n\n\tconst packageManager = new DefaultPackageManager({ cwd, agentDir, settingsManager });\n\n\tpackageManager.setProgressCallback((event) => {\n\t\tif (event.type === \"start\") {\n\t\t\tprocess.stdout.write(chalk.dim(`${event.message}\\n`));\n\t\t}\n\t});\n\n\ttry {\n\t\tswitch (options.command) {\n\t\t\tcase \"install\":\n\t\t\t\tawait packageManager.installAndPersist(source!, { local: options.local });\n\t\t\t\tconsole.log(chalk.green(`Installed ${source}`));\n\t\t\t\treturn true;\n\n\t\t\tcase \"remove\": {\n\t\t\t\tconst removed = await packageManager.removeAndPersist(source!, { local: options.local });\n\t\t\t\tif (!removed) {\n\t\t\t\t\tconsole.error(chalk.red(`No matching package found for ${source}`));\n\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tconsole.log(chalk.green(`Removed ${source}`));\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tcase \"list\": {\n\t\t\t\tconst configuredPackages = packageManager.listConfiguredPackages();\n\t\t\t\tconst userPackages = configuredPackages.filter((pkg) => pkg.scope === \"user\");\n\t\t\t\tconst projectPackages = configuredPackages.filter((pkg) => pkg.scope === \"project\");\n\n\t\t\t\tif (configuredPackages.length === 0) {\n\t\t\t\t\tconsole.log(chalk.dim(\"No packages installed.\"));\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\tconst formatPackage = (pkg: (typeof configuredPackages)[number]) => {\n\t\t\t\t\tconst display = pkg.filtered ? `${pkg.source} (filtered)` : pkg.source;\n\t\t\t\t\tconsole.log(` ${display}`);\n\t\t\t\t\tif (pkg.installedPath) {\n\t\t\t\t\t\tconsole.log(chalk.dim(` ${pkg.installedPath}`));\n\t\t\t\t\t}\n\t\t\t\t};\n\n\t\t\t\tif (userPackages.length > 0) {\n\t\t\t\t\tconsole.log(chalk.bold(\"User packages:\"));\n\t\t\t\t\tfor (const pkg of userPackages) {\n\t\t\t\t\t\tformatPackage(pkg);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (projectPackages.length > 0) {\n\t\t\t\t\tif (userPackages.length > 0) console.log();\n\t\t\t\t\tconsole.log(chalk.bold(\"Project packages:\"));\n\t\t\t\t\tfor (const pkg of projectPackages) {\n\t\t\t\t\t\tformatPackage(pkg);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\tcase \"update\": {\n\t\t\t\tconst target = options.updateTarget ?? { type: \"self\" };\n\t\t\t\tif (options.showExtensionsSkippedNote) {\n\t\t\t\t\tconsole.log(\n\t\t\t\t\t\tchalk.dim(`Extensions are skipped. Run ${APP_NAME} update --extensions to update extensions.`),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif (updateTargetIncludesExtensions(target)) {\n\t\t\t\t\tconst updateSource = target.type === \"extensions\" ? target.source : undefined;\n\t\t\t\t\tawait packageManager.update(updateSource);\n\t\t\t\t\tif (updateSource) {\n\t\t\t\t\t\tconsole.log(chalk.green(`Updated ${updateSource}`));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconsole.log(chalk.green(\"Updated packages\"));\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (updateTargetIncludesSelf(target)) {\n\t\t\t\t\tconst selfUpdatePlan = await getSelfUpdatePlan(options.force);\n\t\t\t\t\tif (!selfUpdatePlan.shouldRun) {\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconst installMethod = detectInstallMethod();\n\t\t\t\t\tif (process.platform === \"win32\" && installMethod !== \"npm\" && installMethod !== \"pnpm\") {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\tchalk.red(`${APP_NAME} self-update on Windows is only supported for npm and pnpm installs.`),\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconsole.error(chalk.dim(`Detected install method: ${installMethod}. Update ${APP_NAME} manually.`));\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconst selfUpdateTarget = {\n\t\t\t\t\t\tpackageName: selfUpdatePlan.packageName,\n\t\t\t\t\t\tinstallSpec: selfUpdatePlan.installSpec,\n\t\t\t\t\t};\n\t\t\t\t\tconst selfUpdateCommand = getSelfUpdateCommand(PACKAGE_NAME, selfUpdateNpmCommand, selfUpdateTarget);\n\t\t\t\t\tif (!selfUpdateCommand) {\n\t\t\t\t\t\tprintSelfUpdateUnavailable(selfUpdateNpmCommand, selfUpdateTarget);\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tif (selfUpdatePlan.note) {\n\t\t\t\t\t\tprintSelfUpdateNote(selfUpdatePlan.note);\n\t\t\t\t\t}\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (installMethod === \"npm\") {\n\t\t\t\t\t\t\tprepareWindowsNpmSelfUpdate();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tawait runSelfUpdate(selfUpdateCommand);\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tconst message = error instanceof Error ? error.message : \"Unknown package command error\";\n\t\t\t\t\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\t\t\t\t\tif (installMethod === \"pnpm\") {\n\t\t\t\t\t\t\tprintPnpmSelfUpdateMetadataHint();\n\t\t\t\t\t\t}\n\t\t\t\t\t\tprintSelfUpdateFallback(selfUpdateCommand);\n\t\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t}\n\t\t\t\t\tconsole.log(chalk.green(`Updated ${APP_NAME} from ${VERSION} to ${selfUpdatePlan.version}`));\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t} catch (error: unknown) {\n\t\tconst message = error instanceof Error ? error.message : \"Unknown package command error\";\n\t\tconsole.error(chalk.red(`Error: ${message}`));\n\t\tprocess.exitCode = 1;\n\t\treturn true;\n\t}\n}\n"]}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ada-engine
|
|
3
|
+
description: >
|
|
4
|
+
Orquestación autónoma: goal engine (objetivo de largo plazo con fases TDD y
|
|
5
|
+
juez con evidencia), workflows (deep-research, code-review, product-build,
|
|
6
|
+
codebase-audit, multi-perspective, scripts custom), grafo de trabajo
|
|
7
|
+
AUTÓNOMO. Cárgala SIEMPRE que el usuario pida: un objetivo grande o "goal",
|
|
8
|
+
investigación web profunda, revisión de código sistemática, construir un
|
|
9
|
+
producto con criterios, auditoría del repo, o análisis desde N perspectivas.
|
|
10
|
+
Si la tarea es una sola pasada (un fix, un script, responder algo), NO la
|
|
11
|
+
cargues — usa las tools normales.
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Ada Intelligence Engine — Opera SIN pensar
|
|
15
|
+
|
|
16
|
+
Regla #1: **DECIDE tú, sin preguntar.** Si el usuario describe un objetivo,
|
|
17
|
+
tú eliges goal, workflow o tools normales según el árbol de abajo, y ejecutas
|
|
18
|
+
el procedimiento completo. Nunca respondas "¿quieres que lo haga con goal o
|
|
19
|
+
workflow?" — ya lo decides tú.
|
|
20
|
+
|
|
21
|
+
## Árbol de decisión (evalúa el pedido del usuario, elige el primero que aplique)
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
¿El usuario pide un OBJETIVO de largo plazo, iterativo, con criterios de éxito?
|
|
25
|
+
(ej: "arregla el login y verifícalo", "construye X", "mejora Y hasta que...")
|
|
26
|
+
→ GOAL ENGINE. Ve a la Sección A.
|
|
27
|
+
|
|
28
|
+
¿El usuario pide INVESTIGACIÓN / REVISIÓN / AUDITORÍA / ANÁLISIS MULTI-ÁNGULO?
|
|
29
|
+
(ej: "investiga Z", "revisa este código", "audita el repo", "compara A y B")
|
|
30
|
+
→ WORKFLOW. Ve a la Sección B.
|
|
31
|
+
|
|
32
|
+
¿El usuario pide UNA TAREA CONCRETA de una pasada?
|
|
33
|
+
(ej: "crea un script", "corrige este bug", "explica X", "escribe un test")
|
|
34
|
+
→ TOOLS NORMALES. No hagas nada especial del engine.
|
|
35
|
+
|
|
36
|
+
¿El usuario menciona "goal"/"workflow" EXPLÍCITAMENTE aunque la tarea parezca
|
|
37
|
+
simple? → Respeta su elección y ve a la sección correspondiente.
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Sección A — GOAL (objetivo de largo plazo)
|
|
41
|
+
|
|
42
|
+
### Procedimiento exacto (en este orden, sin saltarte pasos)
|
|
43
|
+
|
|
44
|
+
1. **Crea el contrato** con la tool `goal_new`:
|
|
45
|
+
- `goal`: el objetivo verbatim del usuario.
|
|
46
|
+
- `doneCriteria`: 2-5 criterios **medibles y observables** (nunca vagos).
|
|
47
|
+
Si el usuario no los dio, **inventalos tú** a partir de su pedido.
|
|
48
|
+
- `verifyCommand`: comando de verificación si aplica (si no, "").
|
|
49
|
+
2. **El goal queda en estado `setup`** — NO empieces a trabajar todavía.
|
|
50
|
+
3. **Responde al usuario EXACTAMENTE con este formato** (corto, una línea):
|
|
51
|
+
```
|
|
52
|
+
🎯 Goal creado: <id>
|
|
53
|
+
Criterios: <c1> · <c2> …
|
|
54
|
+
Apruebalo con: /goal approve <id>
|
|
55
|
+
```
|
|
56
|
+
O si el usuario puede aprobar desde el panel: "Pulsa Approve en el panel Engine".
|
|
57
|
+
4. **Cuando el goal esté aprobado** (estado `active`), el engine lanza un
|
|
58
|
+
**workflow dinámico por sub-tarea** (uno a la vez). El goal es el
|
|
59
|
+
CONTENEDOR — los pasos viven en los workflows. Tu trabajo:
|
|
60
|
+
- Si el plan (sub-tareas) está vacío: **divídelo tú** con la tool `todo`/
|
|
61
|
+
planificación — cada sub-tarea es UN paso concreto y verificable.
|
|
62
|
+
- El engine lanza el workflow de cada sub-tarea automáticamente; NO lo
|
|
63
|
+
lances tú a mano.
|
|
64
|
+
- Escribe código, corre tests, edita archivos. **El grafo se registra
|
|
65
|
+
SOLO** — no hagas nada para el grafo.
|
|
66
|
+
5. **Cuando todas las sub-tareas estén done**, el juez evalúa los criterios.
|
|
67
|
+
Solo si emite `done`, el goal se completa. Nunca completes sin evidencia
|
|
68
|
+
real (archivo:línea, URL o salida de comando).
|
|
69
|
+
|
|
70
|
+
### Cómo responder durante el goal (sin sobre-explicar)
|
|
71
|
+
|
|
72
|
+
- Al completar una sub-tarea: `✓ <sub-tarea> — <1 línea de qué se hizo>`
|
|
73
|
+
- Si algo bloquea: usa `goal_blocked` con el motivo y dile al usuario qué
|
|
74
|
+
necesitas.
|
|
75
|
+
- Si una decisión necesita al usuario: `ask_user_question` (no adivines
|
|
76
|
+
criterios irreversibles como borrar datos o gastar dinero).
|
|
77
|
+
|
|
78
|
+
## Sección B — WORKFLOW (investigación/revisión/auditoría)
|
|
79
|
+
|
|
80
|
+
### Elegir el workflow (sin preguntar, según el pedido)
|
|
81
|
+
|
|
82
|
+
| El usuario pide… | Lanzas… |
|
|
83
|
+
|---|---|
|
|
84
|
+
| Investigar algo con fuentes | `workflow run deep_research question="..."` |
|
|
85
|
+
| Revisar código | `workflow run code_review` |
|
|
86
|
+
| Construir un producto con criterios | `workflow run product_build brief="..."` |
|
|
87
|
+
| Auditar el repo | `workflow run codebase_audit` |
|
|
88
|
+
| Analizar desde N perspectivas | `workflow run multi_perspective problem="..."` |
|
|
89
|
+
| Un flujo custom tuyo/guardado | `workflow run <nombre_script>` |
|
|
90
|
+
|
|
91
|
+
### Procedimiento exacto
|
|
92
|
+
|
|
93
|
+
1. Llama la tool `workflow` con `command: "run"` y el `name` + args.
|
|
94
|
+
2. **La confirmación de coste es automática** (fail-closed 15s). No la
|
|
95
|
+
simules — el sistema la maneja. Si se confirma, el run arranca.
|
|
96
|
+
3. **Responde al usuario EXACTAMENTE**:
|
|
97
|
+
```
|
|
98
|
+
⚡ Workflow lanzado: <name> (<runId>)
|
|
99
|
+
Fases: <f1> → <f2> → …
|
|
100
|
+
Sigue el progreso en el panel Engine o con /workflow status <runId>
|
|
101
|
+
```
|
|
102
|
+
4. Durante el run no bloquees esperando — el run es en background. Si el
|
|
103
|
+
usuario pregunta, usa `workflow status <runId>` y reporta fase actual,
|
|
104
|
+
agentes, tokens y coste.
|
|
105
|
+
|
|
106
|
+
## Sección C — TOOLS NORMALES (una pasada)
|
|
107
|
+
|
|
108
|
+
No cargues nada del engine. Haz la tarea con las tools normales
|
|
109
|
+
(write/edit/bash/read). El grafo se registra solo si escribes archivos — no
|
|
110
|
+
hagas nada especial. Responde normal.
|
|
111
|
+
|
|
112
|
+
## Comportamiento global (aplica siempre)
|
|
113
|
+
|
|
114
|
+
1. **Decide y ejecuta** — nunca preguntes "¿goal o workflow?".
|
|
115
|
+
2. **Responde corto**: una línea de estado + el siguiente paso que el usuario
|
|
116
|
+
debe dar (si lo hay). No expliques el engine.
|
|
117
|
+
3. **No registres el grafo manualmente** — es automático (escribir archivo →
|
|
118
|
+
ARTIFACT + implemented_by; test que pasa → verified_by; goal → spine).
|
|
119
|
+
4. **Solo usa `graph_add_nodes`** cuando estés haciendo una auditoría y
|
|
120
|
+
quieras marcar `QA_FINDING`/`RISK`/`DECISION` concretos con su contexto.
|
|
121
|
+
5. **Respeta los frenos**: si el bucle del goal se repite (3 turnos iguales),
|
|
122
|
+
pausa con `goal_blocked`/`goal_wait` y pide claridad. No fuerces.
|
|
123
|
+
6. **Evidencia antes de done**: nunca declares un goal completado sin
|
|
124
|
+
`archivo:línea`/URL/comando que lo pruebe.
|
|
125
|
+
|
|
126
|
+
## Referencia rápida (no la repitas al usuario)
|
|
127
|
+
|
|
128
|
+
- **Modelo**: el goal es un CONTENEDOR; cada sub-tarea lanza un workflow
|
|
129
|
+
dinámico (goal_subtask). Cuando todas las sub-tareas done → juez → done.
|
|
130
|
+
- **Tools del goal**: `goal_new` (crear contrato), `goal_complete` (cerrar con
|
|
131
|
+
evidencia), `goal_blocked`, `goal_wait`, `todo` (ver/crear sub-tareas),
|
|
132
|
+
`ask_user_question`.
|
|
133
|
+
- **Tool `workflow`**: run/list/status/abort. Args: question=, brief=, problem=,
|
|
134
|
+
verifyCommand=, k=v custom.
|
|
135
|
+
- **Scripts custom**: `~/.ada/agent/workflows/<nombre>.js` — se lanzan con
|
|
136
|
+
`workflow run <nombre>`. Cualquier JS con la API agent/parallel/pipeline/
|
|
137
|
+
phase/store/checkpoint/args/cwd/runId/log.
|
|
138
|
+
- **Modelo**: los subagentes HEREDAN el modelo de la sesión principal por
|
|
139
|
+
defecto (misma auth → misma API key del chat). Los tiers cheap/main/judge
|
|
140
|
+
configuran overrides.
|
|
141
|
+
- **Grafo**: autónomo (GraphSync). Consultas: `/graph gaps|context|search|gate`.
|
|
142
|
+
- **Modelos**: tiers cheap/main/judge configurables; jueces intermedios baratos.
|
|
143
|
+
|
|
144
|
+
## Prohibido
|
|
145
|
+
|
|
146
|
+
- ✗ Responder "¿goal o workflow?" — decide tú.
|
|
147
|
+
- ✗ Completar un goal sin evidencia citada.
|
|
148
|
+
- ✗ Registrar el grafo manualmente (FILE/TASK) — automático.
|
|
149
|
+
- ✗ Lanzar un workflow sin confirmación de coste (el sistema la pide; no la
|
|
150
|
+
eludas inventando resultados).
|
|
151
|
+
- ✗ Crear goals o workflows desde un subagente — solo la sesión principal.
|
|
152
|
+
- ✗ Inventar fuentes en deep_research — cada claim necesita ≥2 fuentes reales.
|
|
153
|
+
- ✗ Consenso falso en multi_perspective — señala desacuerdos.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../src/utils/frontmatter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["../../src/utils/frontmatter.ts"],"names":[],"mappings":"AAGA,KAAK,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IAC3D,WAAW,EAAE,CAAC,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAsBF,eAAO,MAAM,gBAAgB,GAAI,CAAC,oGASjC,CAAC;AAEF,eAAO,MAAM,gBAAgB,6BAA8D,CAAC","sourcesContent":["import { parse } from \"yaml\";\nimport { stripBom } from \"./text.ts\";\n\ntype ParsedFrontmatter<T extends Record<string, unknown>> = {\n\tfrontmatter: T;\n\tbody: string;\n};\n\nconst normalizeNewlines = (value: string): string => value.replace(/\\r\\n/g, \"\\n\").replace(/\\r/g, \"\\n\");\n\nconst extractFrontmatter = (content: string): { yamlString: string | null; body: string } => {\n\tconst normalized = normalizeNewlines(stripBom(content));\n\n\tif (!normalized.startsWith(\"---\")) {\n\t\treturn { yamlString: null, body: normalized };\n\t}\n\n\tconst endIndex = normalized.indexOf(\"\\n---\", 3);\n\tif (endIndex === -1) {\n\t\treturn { yamlString: null, body: normalized };\n\t}\n\n\treturn {\n\t\tyamlString: normalized.slice(4, endIndex),\n\t\tbody: normalized.slice(endIndex + 4).trim(),\n\t};\n};\n\nexport const parseFrontmatter = <T extends Record<string, unknown> = Record<string, unknown>>(\n\tcontent: string,\n): ParsedFrontmatter<T> => {\n\tconst { yamlString, body } = extractFrontmatter(content);\n\tif (!yamlString) {\n\t\treturn { frontmatter: {} as T, body };\n\t}\n\tconst parsed = parse(yamlString);\n\treturn { frontmatter: (parsed ?? {}) as T, body };\n};\n\nexport const stripFrontmatter = (content: string): string => parseFrontmatter(content).body;\n"]}
|