pi-oxidized 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agent-tasks/pi-rust-rewrite/Cargo.lock +5022 -0
- package/.agent-tasks/pi-rust-rewrite/Cargo.toml +22 -0
- package/.agent-tasks/pi-rust-rewrite/GOALS.md +1 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/branch_summary.json +8 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/changelog.md +16 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/debug_dump.txt +11 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/events.jsonl +6 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/legacy_auth_migration.json +16 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/selector_snapshot.txt +9 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/session_stats.json +16 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/goldens/share_result.json +7 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/phase7/sessions/export-roundtrip.jsonl +6 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/provider-drain/isolation-expectations.json +21 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/rpc/commands.json +238 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/rpc/host-state.json +128 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/rpc/ts-goldens.json +1 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/rpc/ts-replay.ts +317 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v1/linear-with-compaction.expected.json +576 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v1/linear-with-compaction.jsonl +12 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v2/branched.expected.json +387 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v2/branched.jsonl +8 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/basic.expected.json +256 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/basic.jsonl +5 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/branched-labels.expected.json +474 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/branched-labels.jsonl +13 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/branched-session.expected.json +352 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/branched-session.jsonl +9 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/compacted-twice.expected.json +590 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/compacted-twice.jsonl +13 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/custom-messages.expected.json +400 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/custom-messages.jsonl +8 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/forked-header.expected.json +257 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/forked-header.jsonl +5 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/unknown-entries.expected.json +297 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/sessions/v3/unknown-entries.jsonl +6 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/bash.json +16 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/edit.json +34 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/find.json +20 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/grep.json +36 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/ls.json +13 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/read.json +20 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tool-schemas/write.json +17 -0
- package/.agent-tasks/pi-rust-rewrite/fixtures/tools/edit-cases.json +93 -0
- package/.agent-tasks/pi-rust-rewrite/helpers/reopen_session.ts +168 -0
- package/.agent-tasks/pi-rust-rewrite/src/lib.rs +13 -0
- package/.agent-tasks/pi-rust-rewrite/tests/phase7_fixtures.rs +742 -0
- package/.agent-tasks/pi-rust-rewrite/tests/pi_ai_contract.rs +101 -0
- package/.agent-tasks/pi-rust-rewrite/tests/provider_drain_isolation.rs +760 -0
- package/.agent-tasks/pi-rust-rewrite/tests/rpc_parity.rs +679 -0
- package/.agent-tasks/pi-rust-rewrite/tests/session_compat.rs +839 -0
- package/.agent-tasks/pi-rust-rewrite/tests/tool_parity.rs +761 -0
- package/.github/workflows/release-verification.yml +204 -0
- package/.gitmodules +5 -0
- package/.outline/audit/coverage.json +3262 -0
- package/.outline/audit/queue.json +4841 -0
- package/.outline/review-fix-grill/iterations/1.json +767 -0
- package/.outline/review-fix-grill/iterations/2.json +69 -0
- package/.outline/review-fix-grill/iterations/3.json +81 -0
- package/.outline/review-fix-grill/iterations/4.json +35 -0
- package/.outline/review-fix-grill/iterations/5.json +21 -0
- package/.outline/review-fix-grill/queue.json +6454 -0
- package/.references/pi/.gitattributes +23 -0
- package/.references/pi/.github/APPROVED_CONTRIBUTORS +281 -0
- package/.references/pi/.github/ISSUE_TEMPLATE/bug.yml +45 -0
- package/.references/pi/.github/ISSUE_TEMPLATE/config.yml +5 -0
- package/.references/pi/.github/ISSUE_TEMPLATE/contribution.yml +36 -0
- package/.references/pi/.github/ISSUE_TEMPLATE/package-report.yml +49 -0
- package/.references/pi/.github/workflows/approve-contributor.yml +179 -0
- package/.references/pi/.github/workflows/build-binaries.yml +294 -0
- package/.references/pi/.github/workflows/ci.yml +42 -0
- package/.references/pi/.github/workflows/issue-analysis.yml +634 -0
- package/.references/pi/.github/workflows/issue-gate.yml +129 -0
- package/.references/pi/.github/workflows/issue-triage-labels.yml +142 -0
- package/.references/pi/.github/workflows/npm-audit.yml +31 -0
- package/.references/pi/.github/workflows/pr-gate.yml +128 -0
- package/.references/pi/.github/workflows/publish-model-catalog.yml +112 -0
- package/.references/pi/.github/workflows/remove-inprogress-on-close.yml +31 -0
- package/.references/pi/.husky/pre-commit +45 -0
- package/.references/pi/.pi/extensions/import-repro.ts +351 -0
- package/.references/pi/.pi/extensions/prompt-url-widget.ts +270 -0
- package/.references/pi/.pi/extensions/redraws.ts +24 -0
- package/.references/pi/.pi/extensions/tps.ts +47 -0
- package/.references/pi/.pi/git/.gitignore +2 -0
- package/.references/pi/.pi/npm/.gitignore +2 -0
- package/.references/pi/.pi/prompts/cl.md +54 -0
- package/.references/pi/.pi/prompts/is.md +28 -0
- package/.references/pi/.pi/prompts/pr.md +37 -0
- package/.references/pi/.pi/prompts/sa.md +163 -0
- package/.references/pi/.pi/prompts/wr.md +40 -0
- package/.references/pi/.pi/skills/add-llm-provider.md +57 -0
- package/.references/pi/AGENTS.md +162 -0
- package/.references/pi/CONTRIBUTING.md +102 -0
- package/.references/pi/LICENSE +21 -0
- package/.references/pi/README.md +99 -0
- package/.references/pi/SECURITY.md +87 -0
- package/.references/pi/biome.json +39 -0
- package/.references/pi/bun.lock +961 -0
- package/.references/pi/package-lock.json +6172 -0
- package/.references/pi/package.json +66 -0
- package/.references/pi/packages/agent/CHANGELOG.md +594 -0
- package/.references/pi/packages/agent/README.md +488 -0
- package/.references/pi/packages/agent/docs/agent-harness.md +488 -0
- package/.references/pi/packages/agent/docs/durable-harness.md +212 -0
- package/.references/pi/packages/agent/docs/hooks.md +445 -0
- package/.references/pi/packages/agent/docs/models.md +964 -0
- package/.references/pi/packages/agent/docs/observability.md +376 -0
- package/.references/pi/packages/agent/package.json +60 -0
- package/.references/pi/packages/agent/src/agent-loop.ts +792 -0
- package/.references/pi/packages/agent/src/agent.ts +575 -0
- package/.references/pi/packages/agent/src/harness/agent-harness.ts +1029 -0
- package/.references/pi/packages/agent/src/harness/compaction/branch-summarization.ts +261 -0
- package/.references/pi/packages/agent/src/harness/compaction/compaction.ts +753 -0
- package/.references/pi/packages/agent/src/harness/compaction/utils.ts +144 -0
- package/.references/pi/packages/agent/src/harness/env/nodejs.ts +569 -0
- package/.references/pi/packages/agent/src/harness/messages.ts +164 -0
- package/.references/pi/packages/agent/src/harness/prompt-templates.ts +267 -0
- package/.references/pi/packages/agent/src/harness/session/jsonl-repo.ts +179 -0
- package/.references/pi/packages/agent/src/harness/session/jsonl-storage.ts +314 -0
- package/.references/pi/packages/agent/src/harness/session/memory-repo.ts +50 -0
- package/.references/pi/packages/agent/src/harness/session/memory-storage.ts +133 -0
- package/.references/pi/packages/agent/src/harness/session/repo-utils.ts +51 -0
- package/.references/pi/packages/agent/src/harness/session/session.ts +338 -0
- package/.references/pi/packages/agent/src/harness/session/uuid.ts +54 -0
- package/.references/pi/packages/agent/src/harness/skills.ts +375 -0
- package/.references/pi/packages/agent/src/harness/system-prompt.ts +34 -0
- package/.references/pi/packages/agent/src/harness/types.ts +838 -0
- package/.references/pi/packages/agent/src/harness/utils/shell-output.ts +135 -0
- package/.references/pi/packages/agent/src/harness/utils/truncate.ts +344 -0
- package/.references/pi/packages/agent/src/index.ts +46 -0
- package/.references/pi/packages/agent/src/node.ts +2 -0
- package/.references/pi/packages/agent/src/proxy.ts +367 -0
- package/.references/pi/packages/agent/src/types.ts +430 -0
- package/.references/pi/packages/agent/test/agent-loop.test.ts +1424 -0
- package/.references/pi/packages/agent/test/agent.test.ts +699 -0
- package/.references/pi/packages/agent/test/e2e.test.ts +404 -0
- package/.references/pi/packages/agent/test/harness/agent-harness-stream.test.ts +213 -0
- package/.references/pi/packages/agent/test/harness/agent-harness.test.ts +608 -0
- package/.references/pi/packages/agent/test/harness/compaction.test.ts +655 -0
- package/.references/pi/packages/agent/test/harness/nodejs-env.test.ts +321 -0
- package/.references/pi/packages/agent/test/harness/prompt-templates.test.ts +90 -0
- package/.references/pi/packages/agent/test/harness/repo.test.ts +92 -0
- package/.references/pi/packages/agent/test/harness/resource-formatting.test.ts +24 -0
- package/.references/pi/packages/agent/test/harness/session-test-utils.ts +55 -0
- package/.references/pi/packages/agent/test/harness/session-uuid.test.ts +50 -0
- package/.references/pi/packages/agent/test/harness/session.test.ts +203 -0
- package/.references/pi/packages/agent/test/harness/skills.test.ts +116 -0
- package/.references/pi/packages/agent/test/harness/storage.test.ts +341 -0
- package/.references/pi/packages/agent/test/harness/system-prompt.test.ts +66 -0
- package/.references/pi/packages/agent/test/harness/truncate.test.ts +169 -0
- package/.references/pi/packages/agent/test/scratch/simple.ts +72 -0
- package/.references/pi/packages/agent/test/utils/calculate.ts +32 -0
- package/.references/pi/packages/agent/test/utils/get-current-time.ts +46 -0
- package/.references/pi/packages/agent/tsconfig.build.json +13 -0
- package/.references/pi/packages/agent/vitest.config.ts +21 -0
- package/.references/pi/packages/agent/vitest.harness.config.ts +28 -0
- package/.references/pi/packages/ai/CHANGELOG.md +1739 -0
- package/.references/pi/packages/ai/README.md +1621 -0
- package/.references/pi/packages/ai/bedrock-provider.d.ts +1 -0
- package/.references/pi/packages/ai/bedrock-provider.js +1 -0
- package/.references/pi/packages/ai/package.json +97 -0
- package/.references/pi/packages/ai/scripts/generate-image-models.ts +131 -0
- package/.references/pi/packages/ai/scripts/generate-models.ts +2401 -0
- package/.references/pi/packages/ai/scripts/generate-test-image.ts +33 -0
- package/.references/pi/packages/ai/src/api/anthropic-messages.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/anthropic-messages.ts +1313 -0
- package/.references/pi/packages/ai/src/api/azure-openai-responses.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/azure-openai-responses.ts +298 -0
- package/.references/pi/packages/ai/src/api/bedrock-converse-stream.lazy.ts +30 -0
- package/.references/pi/packages/ai/src/api/bedrock-converse-stream.ts +1091 -0
- package/.references/pi/packages/ai/src/api/cloudflare.ts +15 -0
- package/.references/pi/packages/ai/src/api/github-copilot-headers.ts +37 -0
- package/.references/pi/packages/ai/src/api/google-generative-ai.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/google-generative-ai.ts +509 -0
- package/.references/pi/packages/ai/src/api/google-shared.ts +350 -0
- package/.references/pi/packages/ai/src/api/google-vertex.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/google-vertex.ts +584 -0
- package/.references/pi/packages/ai/src/api/lazy.ts +75 -0
- package/.references/pi/packages/ai/src/api/mistral-conversations.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/mistral-conversations.ts +664 -0
- package/.references/pi/packages/ai/src/api/openai-codex-responses.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/openai-codex-responses.ts +1573 -0
- package/.references/pi/packages/ai/src/api/openai-completions.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/openai-completions.ts +1355 -0
- package/.references/pi/packages/ai/src/api/openai-prompt-cache.ts +8 -0
- package/.references/pi/packages/ai/src/api/openai-responses-shared.ts +613 -0
- package/.references/pi/packages/ai/src/api/openai-responses.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/openai-responses.ts +318 -0
- package/.references/pi/packages/ai/src/api/openrouter-images.lazy.ts +10 -0
- package/.references/pi/packages/ai/src/api/openrouter-images.ts +185 -0
- package/.references/pi/packages/ai/src/api/pi-messages.lazy.ts +4 -0
- package/.references/pi/packages/ai/src/api/pi-messages.ts +436 -0
- package/.references/pi/packages/ai/src/api/simple-options.ts +77 -0
- package/.references/pi/packages/ai/src/api/transform-messages.ts +223 -0
- package/.references/pi/packages/ai/src/auth/context.ts +45 -0
- package/.references/pi/packages/ai/src/auth/credential-store.ts +51 -0
- package/.references/pi/packages/ai/src/auth/helpers.ts +47 -0
- package/.references/pi/packages/ai/src/auth/oauth/anthropic.ts +350 -0
- package/.references/pi/packages/ai/src/auth/oauth/device-code.ts +98 -0
- package/.references/pi/packages/ai/src/auth/oauth/github-copilot.ts +379 -0
- package/.references/pi/packages/ai/src/auth/oauth/load.ts +56 -0
- package/.references/pi/packages/ai/src/auth/oauth/oauth-page.ts +109 -0
- package/.references/pi/packages/ai/src/auth/oauth/openai-codex.ts +538 -0
- package/.references/pi/packages/ai/src/auth/oauth/pkce.ts +34 -0
- package/.references/pi/packages/ai/src/auth/oauth/radius.ts +410 -0
- package/.references/pi/packages/ai/src/auth/oauth/xai.ts +238 -0
- package/.references/pi/packages/ai/src/auth/resolve.ts +139 -0
- package/.references/pi/packages/ai/src/auth/types.ts +220 -0
- package/.references/pi/packages/ai/src/bedrock-provider.ts +6 -0
- package/.references/pi/packages/ai/src/bun-oauth.ts +17 -0
- package/.references/pi/packages/ai/src/cli.ts +118 -0
- package/.references/pi/packages/ai/src/compat/extension-oauth-types.ts +45 -0
- package/.references/pi/packages/ai/src/compat.ts +298 -0
- package/.references/pi/packages/ai/src/env-api-keys.ts +178 -0
- package/.references/pi/packages/ai/src/image-models.generated.ts +534 -0
- package/.references/pi/packages/ai/src/image-models.ts +42 -0
- package/.references/pi/packages/ai/src/images-api-registry.ts +53 -0
- package/.references/pi/packages/ai/src/images-models.ts +274 -0
- package/.references/pi/packages/ai/src/images.ts +21 -0
- package/.references/pi/packages/ai/src/index.ts +45 -0
- package/.references/pi/packages/ai/src/legacy-api-aliases.ts +108 -0
- package/.references/pi/packages/ai/src/models-store.ts +38 -0
- package/.references/pi/packages/ai/src/models.generated.ts +76 -0
- package/.references/pi/packages/ai/src/models.ts +705 -0
- package/.references/pi/packages/ai/src/oauth.ts +10 -0
- package/.references/pi/packages/ai/src/providers/all.ts +140 -0
- package/.references/pi/packages/ai/src/providers/amazon-bedrock.models.ts +1897 -0
- package/.references/pi/packages/ai/src/providers/amazon-bedrock.ts +80 -0
- package/.references/pi/packages/ai/src/providers/ant-ling.models.ts +62 -0
- package/.references/pi/packages/ai/src/providers/ant-ling.ts +15 -0
- package/.references/pi/packages/ai/src/providers/anthropic.models.ts +257 -0
- package/.references/pi/packages/ai/src/providers/anthropic.ts +20 -0
- package/.references/pi/packages/ai/src/providers/azure-openai-responses.models.ts +816 -0
- package/.references/pi/packages/ai/src/providers/azure-openai-responses.ts +14 -0
- package/.references/pi/packages/ai/src/providers/cerebras.models.ts +61 -0
- package/.references/pi/packages/ai/src/providers/cerebras.ts +15 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-ai-gateway.models.ts +760 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-ai-gateway.ts +23 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-auth.ts +96 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-stream.ts +28 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-workers-ai.models.ts +241 -0
- package/.references/pi/packages/ai/src/providers/cloudflare-workers-ai.ts +15 -0
- package/.references/pi/packages/ai/src/providers/deepseek.models.ts +45 -0
- package/.references/pi/packages/ai/src/providers/deepseek.ts +15 -0
- package/.references/pi/packages/ai/src/providers/faux.ts +538 -0
- package/.references/pi/packages/ai/src/providers/fireworks.models.ts +297 -0
- package/.references/pi/packages/ai/src/providers/fireworks.ts +19 -0
- package/.references/pi/packages/ai/src/providers/github-copilot.models.ts +543 -0
- package/.references/pi/packages/ai/src/providers/github-copilot.ts +34 -0
- package/.references/pi/packages/ai/src/providers/google-vertex.models.ts +184 -0
- package/.references/pi/packages/ai/src/providers/google-vertex.ts +93 -0
- package/.references/pi/packages/ai/src/providers/google.models.ts +290 -0
- package/.references/pi/packages/ai/src/providers/google.ts +15 -0
- package/.references/pi/packages/ai/src/providers/groq.models.ts +127 -0
- package/.references/pi/packages/ai/src/providers/groq.ts +15 -0
- package/.references/pi/packages/ai/src/providers/huggingface.models.ts +889 -0
- package/.references/pi/packages/ai/src/providers/huggingface.ts +15 -0
- package/.references/pi/packages/ai/src/providers/images/register-builtins.ts +50 -0
- package/.references/pi/packages/ai/src/providers/kimi-coding.models.ts +103 -0
- package/.references/pi/packages/ai/src/providers/kimi-coding.ts +15 -0
- package/.references/pi/packages/ai/src/providers/minimax-cn.models.ts +58 -0
- package/.references/pi/packages/ai/src/providers/minimax-cn.ts +15 -0
- package/.references/pi/packages/ai/src/providers/minimax.models.ts +58 -0
- package/.references/pi/packages/ai/src/providers/minimax.ts +15 -0
- package/.references/pi/packages/ai/src/providers/mistral.models.ts +517 -0
- package/.references/pi/packages/ai/src/providers/mistral.ts +15 -0
- package/.references/pi/packages/ai/src/providers/moonshotai-cn.models.ts +190 -0
- package/.references/pi/packages/ai/src/providers/moonshotai-cn.ts +15 -0
- package/.references/pi/packages/ai/src/providers/moonshotai.models.ts +190 -0
- package/.references/pi/packages/ai/src/providers/moonshotai.ts +15 -0
- package/.references/pi/packages/ai/src/providers/nvidia.models.ts +387 -0
- package/.references/pi/packages/ai/src/providers/nvidia.ts +15 -0
- package/.references/pi/packages/ai/src/providers/openai-codex.models.ts +144 -0
- package/.references/pi/packages/ai/src/providers/openai-codex.ts +18 -0
- package/.references/pi/packages/ai/src/providers/openai.models.ts +830 -0
- package/.references/pi/packages/ai/src/providers/openai.ts +15 -0
- package/.references/pi/packages/ai/src/providers/opencode-go.models.ts +278 -0
- package/.references/pi/packages/ai/src/providers/opencode-go.ts +18 -0
- package/.references/pi/packages/ai/src/providers/opencode.models.ts +1001 -0
- package/.references/pi/packages/ai/src/providers/opencode.ts +24 -0
- package/.references/pi/packages/ai/src/providers/openrouter-images.ts +14 -0
- package/.references/pi/packages/ai/src/providers/openrouter.models.ts +4915 -0
- package/.references/pi/packages/ai/src/providers/openrouter.ts +15 -0
- package/.references/pi/packages/ai/src/providers/radius-config.ts +95 -0
- package/.references/pi/packages/ai/src/providers/radius.ts +67 -0
- package/.references/pi/packages/ai/src/providers/together.models.ts +382 -0
- package/.references/pi/packages/ai/src/providers/together.ts +15 -0
- package/.references/pi/packages/ai/src/providers/vercel-ai-gateway.models.ts +3268 -0
- package/.references/pi/packages/ai/src/providers/vercel-ai-gateway.ts +15 -0
- package/.references/pi/packages/ai/src/providers/xai.models.ts +62 -0
- package/.references/pi/packages/ai/src/providers/xai.ts +27 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-ams.models.ts +61 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-ams.ts +15 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-cn.models.ts +61 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-cn.ts +15 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-sgp.models.ts +61 -0
- package/.references/pi/packages/ai/src/providers/xiaomi-token-plan-sgp.ts +15 -0
- package/.references/pi/packages/ai/src/providers/xiaomi.models.ts +115 -0
- package/.references/pi/packages/ai/src/providers/xiaomi.ts +15 -0
- package/.references/pi/packages/ai/src/providers/zai-coding-cn.models.ts +116 -0
- package/.references/pi/packages/ai/src/providers/zai-coding-cn.ts +15 -0
- package/.references/pi/packages/ai/src/providers/zai.models.ts +116 -0
- package/.references/pi/packages/ai/src/providers/zai.ts +15 -0
- package/.references/pi/packages/ai/src/session-resources.ts +24 -0
- package/.references/pi/packages/ai/src/types.ts +738 -0
- package/.references/pi/packages/ai/src/utils/abort-signals.ts +41 -0
- package/.references/pi/packages/ai/src/utils/deferred-tools.ts +39 -0
- package/.references/pi/packages/ai/src/utils/diagnostics.ts +45 -0
- package/.references/pi/packages/ai/src/utils/error-body.ts +127 -0
- package/.references/pi/packages/ai/src/utils/estimate.ts +143 -0
- package/.references/pi/packages/ai/src/utils/event-stream.ts +88 -0
- package/.references/pi/packages/ai/src/utils/hash.ts +13 -0
- package/.references/pi/packages/ai/src/utils/headers.ts +18 -0
- package/.references/pi/packages/ai/src/utils/json-parse.ts +124 -0
- package/.references/pi/packages/ai/src/utils/node-http-proxy.ts +112 -0
- package/.references/pi/packages/ai/src/utils/overflow.ts +165 -0
- package/.references/pi/packages/ai/src/utils/provider-env.ts +52 -0
- package/.references/pi/packages/ai/src/utils/retry.ts +101 -0
- package/.references/pi/packages/ai/src/utils/sanitize-unicode.ts +25 -0
- package/.references/pi/packages/ai/src/utils/typebox-helpers.ts +24 -0
- package/.references/pi/packages/ai/src/utils/validation.ts +310 -0
- package/.references/pi/packages/ai/test/abort.test.ts +303 -0
- package/.references/pi/packages/ai/test/anthropic-adaptive-thinking-models.test.ts +39 -0
- package/.references/pi/packages/ai/test/anthropic-cache-write-1h-cost.test.ts +86 -0
- package/.references/pi/packages/ai/test/anthropic-eager-tool-input-compat.test.ts +122 -0
- package/.references/pi/packages/ai/test/anthropic-eager-tool-input-e2e.test.ts +155 -0
- package/.references/pi/packages/ai/test/anthropic-empty-thinking-signature-compat.test.ts +108 -0
- package/.references/pi/packages/ai/test/anthropic-force-adaptive-thinking.test.ts +125 -0
- package/.references/pi/packages/ai/test/anthropic-long-cache-retention-e2e.test.ts +127 -0
- package/.references/pi/packages/ai/test/anthropic-oauth.test.ts +137 -0
- package/.references/pi/packages/ai/test/anthropic-opus-4-8-smoke.test.ts +71 -0
- package/.references/pi/packages/ai/test/anthropic-sse-parsing.test.ts +275 -0
- package/.references/pi/packages/ai/test/anthropic-temperature-compat.test.ts +103 -0
- package/.references/pi/packages/ai/test/anthropic-thinking-disable.test.ts +172 -0
- package/.references/pi/packages/ai/test/anthropic-tool-name-normalization.test.ts +204 -0
- package/.references/pi/packages/ai/test/azure-openai-base-url.test.ts +175 -0
- package/.references/pi/packages/ai/test/azure-openai-responses-reasoning-replay.test.ts +136 -0
- package/.references/pi/packages/ai/test/azure-utils.ts +28 -0
- package/.references/pi/packages/ai/test/bedrock-convert-messages.test.ts +245 -0
- package/.references/pi/packages/ai/test/bedrock-custom-headers.test.ts +202 -0
- package/.references/pi/packages/ai/test/bedrock-endpoint-resolution.test.ts +208 -0
- package/.references/pi/packages/ai/test/bedrock-models.test.ts +65 -0
- package/.references/pi/packages/ai/test/bedrock-thinking-payload.test.ts +246 -0
- package/.references/pi/packages/ai/test/bedrock-utils.ts +18 -0
- package/.references/pi/packages/ai/test/cache-retention.test.ts +498 -0
- package/.references/pi/packages/ai/test/cloudflare-stream.test.ts +65 -0
- package/.references/pi/packages/ai/test/cloudflare-utils.ts +9 -0
- package/.references/pi/packages/ai/test/codex-websocket-cached-probe.ts +299 -0
- package/.references/pi/packages/ai/test/compat-env.test.ts +74 -0
- package/.references/pi/packages/ai/test/context-estimate.test.ts +81 -0
- package/.references/pi/packages/ai/test/context-overflow.test.ts +734 -0
- package/.references/pi/packages/ai/test/cross-provider-handoff.test.ts +502 -0
- package/.references/pi/packages/ai/test/data/red-circle.png +0 -0
- package/.references/pi/packages/ai/test/deferred-tools.test.ts +481 -0
- package/.references/pi/packages/ai/test/empty.test.ts +741 -0
- package/.references/pi/packages/ai/test/env-api-keys.test.ts +60 -0
- package/.references/pi/packages/ai/test/error-body.test.ts +154 -0
- package/.references/pi/packages/ai/test/faux-provider.test.ts +597 -0
- package/.references/pi/packages/ai/test/fireworks-models.test.ts +269 -0
- package/.references/pi/packages/ai/test/github-copilot-anthropic.test.ts +120 -0
- package/.references/pi/packages/ai/test/github-copilot-oauth.test.ts +444 -0
- package/.references/pi/packages/ai/test/google-shared-convert-tools.test.ts +187 -0
- package/.references/pi/packages/ai/test/google-shared-gemini3-unsigned-tool-call.test.ts +116 -0
- package/.references/pi/packages/ai/test/google-shared-image-tool-result-routing.test.ts +102 -0
- package/.references/pi/packages/ai/test/google-thinking-disable.test.ts +160 -0
- package/.references/pi/packages/ai/test/google-thinking-signature.test.ts +38 -0
- package/.references/pi/packages/ai/test/google-vertex-api-key-resolution.test.ts +223 -0
- package/.references/pi/packages/ai/test/image-tool-result.test.ts +501 -0
- package/.references/pi/packages/ai/test/images-models.test.ts +209 -0
- package/.references/pi/packages/ai/test/images.test.ts +90 -0
- package/.references/pi/packages/ai/test/interleaved-thinking.test.ts +144 -0
- package/.references/pi/packages/ai/test/lax-message-content.test.ts +67 -0
- package/.references/pi/packages/ai/test/lazy-module-load.test.ts +119 -0
- package/.references/pi/packages/ai/test/max-thinking.test.ts +89 -0
- package/.references/pi/packages/ai/test/mistral-reasoning-mode.test.ts +97 -0
- package/.references/pi/packages/ai/test/mistral-tool-schema.test.ts +60 -0
- package/.references/pi/packages/ai/test/models-runtime.test.ts +689 -0
- package/.references/pi/packages/ai/test/node-http-proxy.test.ts +76 -0
- package/.references/pi/packages/ai/test/oauth-auth.test.ts +141 -0
- package/.references/pi/packages/ai/test/oauth-device-code.test.ts +139 -0
- package/.references/pi/packages/ai/test/oauth.ts +83 -0
- package/.references/pi/packages/ai/test/openai-codex-cache-affinity-e2e.test.ts +35 -0
- package/.references/pi/packages/ai/test/openai-codex-oauth.test.ts +479 -0
- package/.references/pi/packages/ai/test/openai-codex-stream.test.ts +2028 -0
- package/.references/pi/packages/ai/test/openai-completions-cache-control-format.test.ts +189 -0
- package/.references/pi/packages/ai/test/openai-completions-empty-tools.test.ts +304 -0
- package/.references/pi/packages/ai/test/openai-completions-prompt-cache.test.ts +264 -0
- package/.references/pi/packages/ai/test/openai-completions-reasoning-details.test.ts +118 -0
- package/.references/pi/packages/ai/test/openai-completions-response-model.test.ts +140 -0
- package/.references/pi/packages/ai/test/openai-completions-retry.test.ts +86 -0
- package/.references/pi/packages/ai/test/openai-completions-thinking-as-text.test.ts +218 -0
- package/.references/pi/packages/ai/test/openai-completions-tool-choice.test.ts +1716 -0
- package/.references/pi/packages/ai/test/openai-completions-tool-result-images.test.ts +152 -0
- package/.references/pi/packages/ai/test/openai-responses-cache-affinity-e2e.test.ts +31 -0
- package/.references/pi/packages/ai/test/openai-responses-compat.test.ts +472 -0
- package/.references/pi/packages/ai/test/openai-responses-empty-tool-result.test.ts +58 -0
- package/.references/pi/packages/ai/test/openai-responses-foreign-toolcall-id.test.ts +66 -0
- package/.references/pi/packages/ai/test/openai-responses-message-id.test.ts +48 -0
- package/.references/pi/packages/ai/test/openai-responses-partial-json-cleanup.test.ts +106 -0
- package/.references/pi/packages/ai/test/openai-responses-reasoning-replay-e2e.test.ts +291 -0
- package/.references/pi/packages/ai/test/openai-responses-terminal-event.test.ts +233 -0
- package/.references/pi/packages/ai/test/openai-responses-tool-result-images.test.ts +194 -0
- package/.references/pi/packages/ai/test/openrouter-cache-write-repro.test.ts +77 -0
- package/.references/pi/packages/ai/test/openrouter-images.test.ts +140 -0
- package/.references/pi/packages/ai/test/overflow.test.ts +139 -0
- package/.references/pi/packages/ai/test/pi-messages.test.ts +243 -0
- package/.references/pi/packages/ai/test/provider-error-body-passthrough.test.ts +78 -0
- package/.references/pi/packages/ai/test/provider-error-body-regression.test.ts +189 -0
- package/.references/pi/packages/ai/test/providers.test.ts +404 -0
- package/.references/pi/packages/ai/test/responseid.test.ts +120 -0
- package/.references/pi/packages/ai/test/retry.test.ts +59 -0
- package/.references/pi/packages/ai/test/scratch.ts +57 -0
- package/.references/pi/packages/ai/test/stream.test.ts +1632 -0
- package/.references/pi/packages/ai/test/supports-xhigh.test.ts +145 -0
- package/.references/pi/packages/ai/test/together-models.test.ts +78 -0
- package/.references/pi/packages/ai/test/tokens.test.ts +333 -0
- package/.references/pi/packages/ai/test/tool-call-id-normalization.test.ts +290 -0
- package/.references/pi/packages/ai/test/tool-call-without-result.test.ts +327 -0
- package/.references/pi/packages/ai/test/total-tokens.test.ts +789 -0
- package/.references/pi/packages/ai/test/transform-messages-copilot-openai-to-anthropic.test.ts +191 -0
- package/.references/pi/packages/ai/test/unicode-surrogate.test.ts +774 -0
- package/.references/pi/packages/ai/test/validation.test.ts +116 -0
- package/.references/pi/packages/ai/test/xai-oauth.test.ts +330 -0
- package/.references/pi/packages/ai/test/xai-responses.test.ts +117 -0
- package/.references/pi/packages/ai/test/xhigh.test.ts +70 -0
- package/.references/pi/packages/ai/test/xiaomi-models.test.ts +17 -0
- package/.references/pi/packages/ai/test/xiaomi-token-plan-ams-anthropic-empty-signature-smoke.test.ts +114 -0
- package/.references/pi/packages/ai/test/zen.test.ts +25 -0
- package/.references/pi/packages/ai/tsconfig.build.json +9 -0
- package/.references/pi/packages/ai/vitest.config.ts +11 -0
- package/.references/pi/packages/coding-agent/CHANGELOG.md +5038 -0
- package/.references/pi/packages/coding-agent/README.md +691 -0
- package/.references/pi/packages/coding-agent/docs/compaction.md +396 -0
- package/.references/pi/packages/coding-agent/docs/containerization.md +111 -0
- package/.references/pi/packages/coding-agent/docs/custom-provider.md +735 -0
- package/.references/pi/packages/coding-agent/docs/development.md +71 -0
- package/.references/pi/packages/coding-agent/docs/docs.json +156 -0
- package/.references/pi/packages/coding-agent/docs/extensions.md +2911 -0
- package/.references/pi/packages/coding-agent/docs/images/doom-extension.png +0 -0
- package/.references/pi/packages/coding-agent/docs/images/exy.png +0 -0
- package/.references/pi/packages/coding-agent/docs/images/interactive-mode.png +0 -0
- package/.references/pi/packages/coding-agent/docs/images/tree-view.png +0 -0
- package/.references/pi/packages/coding-agent/docs/index.md +82 -0
- package/.references/pi/packages/coding-agent/docs/json.md +82 -0
- package/.references/pi/packages/coding-agent/docs/keybindings.md +198 -0
- package/.references/pi/packages/coding-agent/docs/models.md +540 -0
- package/.references/pi/packages/coding-agent/docs/packages.md +228 -0
- package/.references/pi/packages/coding-agent/docs/prompt-templates.md +95 -0
- package/.references/pi/packages/coding-agent/docs/providers.md +290 -0
- package/.references/pi/packages/coding-agent/docs/quickstart.md +165 -0
- package/.references/pi/packages/coding-agent/docs/rpc.md +1480 -0
- package/.references/pi/packages/coding-agent/docs/sdk.md +1183 -0
- package/.references/pi/packages/coding-agent/docs/security.md +59 -0
- package/.references/pi/packages/coding-agent/docs/session-format.md +422 -0
- package/.references/pi/packages/coding-agent/docs/sessions.md +145 -0
- package/.references/pi/packages/coding-agent/docs/settings.md +319 -0
- package/.references/pi/packages/coding-agent/docs/shell-aliases.md +13 -0
- package/.references/pi/packages/coding-agent/docs/skills.md +231 -0
- package/.references/pi/packages/coding-agent/docs/terminal-setup.md +142 -0
- package/.references/pi/packages/coding-agent/docs/termux.md +127 -0
- package/.references/pi/packages/coding-agent/docs/themes.md +297 -0
- package/.references/pi/packages/coding-agent/docs/tmux.md +63 -0
- package/.references/pi/packages/coding-agent/docs/tui.md +927 -0
- package/.references/pi/packages/coding-agent/docs/usage.md +310 -0
- package/.references/pi/packages/coding-agent/docs/windows.md +17 -0
- package/.references/pi/packages/coding-agent/examples/README.md +25 -0
- package/.references/pi/packages/coding-agent/examples/extensions/README.md +213 -0
- package/.references/pi/packages/coding-agent/examples/extensions/auto-commit-on-exit.ts +49 -0
- package/.references/pi/packages/coding-agent/examples/extensions/bash-spawn-hook.ts +30 -0
- package/.references/pi/packages/coding-agent/examples/extensions/bookmark.ts +50 -0
- package/.references/pi/packages/coding-agent/examples/extensions/border-status-editor.ts +150 -0
- package/.references/pi/packages/coding-agent/examples/extensions/built-in-tool-renderer.ts +249 -0
- package/.references/pi/packages/coding-agent/examples/extensions/claude-rules.ts +86 -0
- package/.references/pi/packages/coding-agent/examples/extensions/commands.ts +72 -0
- package/.references/pi/packages/coding-agent/examples/extensions/confirm-destructive.ts +59 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-compaction.ts +128 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-footer.ts +64 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-header.ts +73 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-anthropic/index.ts +604 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-anthropic/package-lock.json +24 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-anthropic/package.json +19 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-gitlab-duo/index.ts +404 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-gitlab-duo/package.json +16 -0
- package/.references/pi/packages/coding-agent/examples/extensions/custom-provider-gitlab-duo/test.ts +82 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dirty-repo-guard.ts +56 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/README.md +46 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom/build/doom.js +21 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom/build.sh +152 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom/doomgeneric_pi.c +72 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom-component.ts +132 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom-engine.ts +173 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/doom-keys.ts +104 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/index.ts +74 -0
- package/.references/pi/packages/coding-agent/examples/extensions/doom-overlay/wad-finder.ts +51 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dynamic-resources/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dynamic-resources/dynamic.json +79 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dynamic-resources/dynamic.md +5 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dynamic-resources/index.ts +15 -0
- package/.references/pi/packages/coding-agent/examples/extensions/dynamic-tools.ts +74 -0
- package/.references/pi/packages/coding-agent/examples/extensions/entry-renderer.ts +41 -0
- package/.references/pi/packages/coding-agent/examples/extensions/event-bus.ts +43 -0
- package/.references/pi/packages/coding-agent/examples/extensions/file-trigger.ts +41 -0
- package/.references/pi/packages/coding-agent/examples/extensions/git-checkpoint.ts +53 -0
- package/.references/pi/packages/coding-agent/examples/extensions/git-merge-and-resolve.ts +115 -0
- package/.references/pi/packages/coding-agent/examples/extensions/github-issue-autocomplete.ts +185 -0
- package/.references/pi/packages/coding-agent/examples/extensions/gondolin/index.ts +531 -0
- package/.references/pi/packages/coding-agent/examples/extensions/gondolin/package-lock.json +185 -0
- package/.references/pi/packages/coding-agent/examples/extensions/gondolin/package.json +19 -0
- package/.references/pi/packages/coding-agent/examples/extensions/handoff.ts +191 -0
- package/.references/pi/packages/coding-agent/examples/extensions/hello.ts +26 -0
- package/.references/pi/packages/coding-agent/examples/extensions/hidden-thinking-label.ts +53 -0
- package/.references/pi/packages/coding-agent/examples/extensions/inline-bash.ts +94 -0
- package/.references/pi/packages/coding-agent/examples/extensions/input-transform-streaming.ts +39 -0
- package/.references/pi/packages/coding-agent/examples/extensions/input-transform.ts +43 -0
- package/.references/pi/packages/coding-agent/examples/extensions/interactive-shell.ts +196 -0
- package/.references/pi/packages/coding-agent/examples/extensions/kimi-deferred-tools.ts +61 -0
- package/.references/pi/packages/coding-agent/examples/extensions/mac-system-theme.ts +47 -0
- package/.references/pi/packages/coding-agent/examples/extensions/message-renderer.ts +59 -0
- package/.references/pi/packages/coding-agent/examples/extensions/minimal-mode.ts +426 -0
- package/.references/pi/packages/coding-agent/examples/extensions/modal-editor.ts +85 -0
- package/.references/pi/packages/coding-agent/examples/extensions/model-status.ts +31 -0
- package/.references/pi/packages/coding-agent/examples/extensions/notify.ts +55 -0
- package/.references/pi/packages/coding-agent/examples/extensions/overlay-qa-tests.ts +1450 -0
- package/.references/pi/packages/coding-agent/examples/extensions/overlay-test.ts +153 -0
- package/.references/pi/packages/coding-agent/examples/extensions/permission-gate.ts +34 -0
- package/.references/pi/packages/coding-agent/examples/extensions/pirate.ts +47 -0
- package/.references/pi/packages/coding-agent/examples/extensions/plan-mode/README.md +66 -0
- package/.references/pi/packages/coding-agent/examples/extensions/plan-mode/index.ts +390 -0
- package/.references/pi/packages/coding-agent/examples/extensions/plan-mode/utils.ts +168 -0
- package/.references/pi/packages/coding-agent/examples/extensions/preset.ts +436 -0
- package/.references/pi/packages/coding-agent/examples/extensions/project-trust.ts +64 -0
- package/.references/pi/packages/coding-agent/examples/extensions/prompt-customizer.ts +97 -0
- package/.references/pi/packages/coding-agent/examples/extensions/protected-paths.ts +30 -0
- package/.references/pi/packages/coding-agent/examples/extensions/provider-payload.ts +18 -0
- package/.references/pi/packages/coding-agent/examples/extensions/qna.ts +122 -0
- package/.references/pi/packages/coding-agent/examples/extensions/question.ts +286 -0
- package/.references/pi/packages/coding-agent/examples/extensions/questionnaire.ts +448 -0
- package/.references/pi/packages/coding-agent/examples/extensions/rainbow-editor.ts +88 -0
- package/.references/pi/packages/coding-agent/examples/extensions/reload-runtime.ts +37 -0
- package/.references/pi/packages/coding-agent/examples/extensions/rpc-demo.ts +118 -0
- package/.references/pi/packages/coding-agent/examples/extensions/sandbox/index.ts +321 -0
- package/.references/pi/packages/coding-agent/examples/extensions/sandbox/package-lock.json +92 -0
- package/.references/pi/packages/coding-agent/examples/extensions/sandbox/package.json +19 -0
- package/.references/pi/packages/coding-agent/examples/extensions/send-user-message.ts +97 -0
- package/.references/pi/packages/coding-agent/examples/extensions/session-name.ts +27 -0
- package/.references/pi/packages/coding-agent/examples/extensions/shutdown-command.ts +63 -0
- package/.references/pi/packages/coding-agent/examples/extensions/snake.ts +343 -0
- package/.references/pi/packages/coding-agent/examples/extensions/space-invaders.ts +560 -0
- package/.references/pi/packages/coding-agent/examples/extensions/ssh.ts +220 -0
- package/.references/pi/packages/coding-agent/examples/extensions/status-line.ts +32 -0
- package/.references/pi/packages/coding-agent/examples/extensions/structured-output.ts +65 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/README.md +175 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/agents/planner.md +37 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/agents/reviewer.md +35 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/agents/scout.md +50 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/agents/worker.md +24 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/agents.ts +126 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/index.ts +1015 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/prompts/implement-and-review.md +10 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/prompts/implement.md +10 -0
- package/.references/pi/packages/coding-agent/examples/extensions/subagent/prompts/scout-and-plan.md +9 -0
- package/.references/pi/packages/coding-agent/examples/extensions/summarize.ts +207 -0
- package/.references/pi/packages/coding-agent/examples/extensions/system-prompt-header.ts +17 -0
- package/.references/pi/packages/coding-agent/examples/extensions/tic-tac-toe.ts +1008 -0
- package/.references/pi/packages/coding-agent/examples/extensions/timed-confirm.ts +70 -0
- package/.references/pi/packages/coding-agent/examples/extensions/titlebar-spinner.ts +58 -0
- package/.references/pi/packages/coding-agent/examples/extensions/todo.ts +297 -0
- package/.references/pi/packages/coding-agent/examples/extensions/tool-override.ts +144 -0
- package/.references/pi/packages/coding-agent/examples/extensions/tools.ts +146 -0
- package/.references/pi/packages/coding-agent/examples/extensions/trigger-compact.ts +50 -0
- package/.references/pi/packages/coding-agent/examples/extensions/truncated-tool.ts +195 -0
- package/.references/pi/packages/coding-agent/examples/extensions/widget-placement.ts +9 -0
- package/.references/pi/packages/coding-agent/examples/extensions/with-deps/index.ts +32 -0
- package/.references/pi/packages/coding-agent/examples/extensions/with-deps/package-lock.json +31 -0
- package/.references/pi/packages/coding-agent/examples/extensions/with-deps/package.json +22 -0
- package/.references/pi/packages/coding-agent/examples/extensions/working-indicator.ts +123 -0
- package/.references/pi/packages/coding-agent/examples/extensions/working-message-test.ts +25 -0
- package/.references/pi/packages/coding-agent/examples/rpc-extension-ui.ts +632 -0
- package/.references/pi/packages/coding-agent/examples/sdk/01-minimal.ts +26 -0
- package/.references/pi/packages/coding-agent/examples/sdk/02-custom-model.ts +50 -0
- package/.references/pi/packages/coding-agent/examples/sdk/03-custom-prompt.ts +75 -0
- package/.references/pi/packages/coding-agent/examples/sdk/04-skills.ts +55 -0
- package/.references/pi/packages/coding-agent/examples/sdk/05-tools.ts +48 -0
- package/.references/pi/packages/coding-agent/examples/sdk/06-extensions.ts +99 -0
- package/.references/pi/packages/coding-agent/examples/sdk/07-context-files.ts +47 -0
- package/.references/pi/packages/coding-agent/examples/sdk/08-prompt-templates.ts +51 -0
- package/.references/pi/packages/coding-agent/examples/sdk/09-api-keys-and-oauth.ts +34 -0
- package/.references/pi/packages/coding-agent/examples/sdk/10-settings.ts +53 -0
- package/.references/pi/packages/coding-agent/examples/sdk/11-sessions.ts +52 -0
- package/.references/pi/packages/coding-agent/examples/sdk/12-full-control.ts +72 -0
- package/.references/pi/packages/coding-agent/examples/sdk/13-session-runtime.ts +67 -0
- package/.references/pi/packages/coding-agent/examples/sdk/README.md +140 -0
- package/.references/pi/packages/coding-agent/install-lock/package-lock.json +1849 -0
- package/.references/pi/packages/coding-agent/install-lock/package.json +18 -0
- package/.references/pi/packages/coding-agent/npm-shrinkwrap.json +1839 -0
- package/.references/pi/packages/coding-agent/package.json +100 -0
- package/.references/pi/packages/coding-agent/scripts/migrate-sessions.sh +93 -0
- package/.references/pi/packages/coding-agent/src/bun/cli.ts +15 -0
- package/.references/pi/packages/coding-agent/src/bun/register-bedrock.ts +4 -0
- package/.references/pi/packages/coding-agent/src/bun/restore-sandbox-env.ts +36 -0
- package/.references/pi/packages/coding-agent/src/cli/args.ts +390 -0
- package/.references/pi/packages/coding-agent/src/cli/config-selector.ts +56 -0
- package/.references/pi/packages/coding-agent/src/cli/file-processor.ts +87 -0
- package/.references/pi/packages/coding-agent/src/cli/initial-message.ts +43 -0
- package/.references/pi/packages/coding-agent/src/cli/list-models.ts +111 -0
- package/.references/pi/packages/coding-agent/src/cli/project-trust.ts +62 -0
- package/.references/pi/packages/coding-agent/src/cli/session-picker.ts +55 -0
- package/.references/pi/packages/coding-agent/src/cli/startup-ui.ts +239 -0
- package/.references/pi/packages/coding-agent/src/cli.ts +20 -0
- package/.references/pi/packages/coding-agent/src/config.ts +566 -0
- package/.references/pi/packages/coding-agent/src/core/agent-session-runtime.ts +438 -0
- package/.references/pi/packages/coding-agent/src/core/agent-session-services.ts +207 -0
- package/.references/pi/packages/coding-agent/src/core/agent-session.ts +3279 -0
- package/.references/pi/packages/coding-agent/src/core/auth-guidance.ts +25 -0
- package/.references/pi/packages/coding-agent/src/core/auth-storage.ts +271 -0
- package/.references/pi/packages/coding-agent/src/core/bash-executor.ts +156 -0
- package/.references/pi/packages/coding-agent/src/core/cache-stats.ts +164 -0
- package/.references/pi/packages/coding-agent/src/core/compaction/branch-summarization.ts +371 -0
- package/.references/pi/packages/coding-agent/src/core/compaction/compaction.ts +872 -0
- package/.references/pi/packages/coding-agent/src/core/compaction/index.ts +7 -0
- package/.references/pi/packages/coding-agent/src/core/compaction/utils.ts +170 -0
- package/.references/pi/packages/coding-agent/src/core/defaults.ts +3 -0
- package/.references/pi/packages/coding-agent/src/core/diagnostics.ts +15 -0
- package/.references/pi/packages/coding-agent/src/core/event-bus.ts +33 -0
- package/.references/pi/packages/coding-agent/src/core/exec.ts +107 -0
- package/.references/pi/packages/coding-agent/src/core/experimental.ts +3 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/ansi-to-html.ts +258 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/index.ts +316 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/template.css +1066 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/template.html +55 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/template.js +1864 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/tool-renderer.ts +172 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/vendor/highlight.min.js +1213 -0
- package/.references/pi/packages/coding-agent/src/core/export-html/vendor/marked.min.js +78 -0
- package/.references/pi/packages/coding-agent/src/core/extensions/index.ts +184 -0
- package/.references/pi/packages/coding-agent/src/core/extensions/loader.ts +708 -0
- package/.references/pi/packages/coding-agent/src/core/extensions/runner.ts +1189 -0
- package/.references/pi/packages/coding-agent/src/core/extensions/types.ts +1674 -0
- package/.references/pi/packages/coding-agent/src/core/extensions/wrapper.ts +45 -0
- package/.references/pi/packages/coding-agent/src/core/footer-data-provider.ts +388 -0
- package/.references/pi/packages/coding-agent/src/core/http-dispatcher.ts +106 -0
- package/.references/pi/packages/coding-agent/src/core/index.ts +80 -0
- package/.references/pi/packages/coding-agent/src/core/keybindings.ts +370 -0
- package/.references/pi/packages/coding-agent/src/core/messages.ts +195 -0
- package/.references/pi/packages/coding-agent/src/core/model-config.ts +287 -0
- package/.references/pi/packages/coding-agent/src/core/model-registry.ts +126 -0
- package/.references/pi/packages/coding-agent/src/core/model-resolver.ts +705 -0
- package/.references/pi/packages/coding-agent/src/core/model-runtime.ts +566 -0
- package/.references/pi/packages/coding-agent/src/core/models-store.ts +57 -0
- package/.references/pi/packages/coding-agent/src/core/output-guard.ts +108 -0
- package/.references/pi/packages/coding-agent/src/core/package-manager.ts +2650 -0
- package/.references/pi/packages/coding-agent/src/core/project-trust.ts +96 -0
- package/.references/pi/packages/coding-agent/src/core/prompt-templates.ts +284 -0
- package/.references/pi/packages/coding-agent/src/core/provider-attribution.ts +97 -0
- package/.references/pi/packages/coding-agent/src/core/provider-composer.ts +548 -0
- package/.references/pi/packages/coding-agent/src/core/radius.ts +1 -0
- package/.references/pi/packages/coding-agent/src/core/remote-catalog-provider.ts +83 -0
- package/.references/pi/packages/coding-agent/src/core/resolve-config-value.ts +287 -0
- package/.references/pi/packages/coding-agent/src/core/resource-loader.ts +1039 -0
- package/.references/pi/packages/coding-agent/src/core/runtime-credentials.ts +48 -0
- package/.references/pi/packages/coding-agent/src/core/sdk.ts +393 -0
- package/.references/pi/packages/coding-agent/src/core/session-cwd.ts +59 -0
- package/.references/pi/packages/coding-agent/src/core/session-manager.ts +1623 -0
- package/.references/pi/packages/coding-agent/src/core/settings-manager.ts +1234 -0
- package/.references/pi/packages/coding-agent/src/core/skills.ts +487 -0
- package/.references/pi/packages/coding-agent/src/core/slash-commands.ts +42 -0
- package/.references/pi/packages/coding-agent/src/core/source-info.ts +40 -0
- package/.references/pi/packages/coding-agent/src/core/system-prompt.ts +162 -0
- package/.references/pi/packages/coding-agent/src/core/telemetry.ts +13 -0
- package/.references/pi/packages/coding-agent/src/core/timings.ts +50 -0
- package/.references/pi/packages/coding-agent/src/core/tools/bash.ts +470 -0
- package/.references/pi/packages/coding-agent/src/core/tools/edit-diff.ts +560 -0
- package/.references/pi/packages/coding-agent/src/core/tools/edit.ts +437 -0
- package/.references/pi/packages/coding-agent/src/core/tools/file-mutation-queue.ts +61 -0
- package/.references/pi/packages/coding-agent/src/core/tools/find.ts +374 -0
- package/.references/pi/packages/coding-agent/src/core/tools/grep.ts +385 -0
- package/.references/pi/packages/coding-agent/src/core/tools/index.ts +196 -0
- package/.references/pi/packages/coding-agent/src/core/tools/ls.ts +225 -0
- package/.references/pi/packages/coding-agent/src/core/tools/output-accumulator.ts +222 -0
- package/.references/pi/packages/coding-agent/src/core/tools/path-utils.ts +118 -0
- package/.references/pi/packages/coding-agent/src/core/tools/read.ts +351 -0
- package/.references/pi/packages/coding-agent/src/core/tools/render-utils.ts +85 -0
- package/.references/pi/packages/coding-agent/src/core/tools/tool-definition-wrapper.ts +45 -0
- package/.references/pi/packages/coding-agent/src/core/tools/truncate.ts +276 -0
- package/.references/pi/packages/coding-agent/src/core/tools/write.ts +267 -0
- package/.references/pi/packages/coding-agent/src/core/trust-manager.ts +244 -0
- package/.references/pi/packages/coding-agent/src/index.ts +394 -0
- package/.references/pi/packages/coding-agent/src/main.ts +857 -0
- package/.references/pi/packages/coding-agent/src/migrations.ts +315 -0
- package/.references/pi/packages/coding-agent/src/modes/index.ts +15 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/assets/clankolas.png +0 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/armin.ts +382 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/assistant-message.ts +180 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/bash-execution.ts +220 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/bordered-loader.ts +68 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/branch-summary-message.ts +58 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/compaction-summary-message.ts +59 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/config-selector.ts +942 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/countdown-timer.ts +39 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/custom-editor.ts +80 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/custom-entry.ts +62 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/custom-message.ts +99 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/daxnuts.ts +164 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/diff.ts +147 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/dynamic-border.ts +25 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/earendil-announcement.ts +53 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/extension-editor.ts +167 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/extension-input.ts +87 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/extension-selector.ts +112 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/first-time-setup.ts +145 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/footer.ts +245 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/index.ts +38 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/keybinding-hints.ts +48 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/login-dialog.ts +233 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/model-selector.ts +361 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/oauth-selector.ts +214 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/scoped-models-selector.ts +360 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/session-selector-search.ts +194 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/session-selector.ts +1031 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/settings-selector.ts +838 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/show-images-selector.ts +50 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/skill-invocation-message.ts +55 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/status-indicator.ts +114 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/theme-selector.ts +67 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/thinking-selector.ts +75 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/tool-execution.ts +377 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/tree-selector.ts +1427 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/trust-selector.ts +134 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/user-message-selector.ts +155 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/user-message.ts +57 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/components/visual-truncate.ts +50 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/interactive-mode.ts +6005 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/model-search.ts +21 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/theme/dark.json +87 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/theme/light.json +86 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/theme/theme-controller.ts +126 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/theme/theme-schema.json +340 -0
- package/.references/pi/packages/coding-agent/src/modes/interactive/theme/theme.ts +1294 -0
- package/.references/pi/packages/coding-agent/src/modes/print-mode.ts +159 -0
- package/.references/pi/packages/coding-agent/src/modes/rpc/jsonl.ts +58 -0
- package/.references/pi/packages/coding-agent/src/modes/rpc/rpc-client.ts +592 -0
- package/.references/pi/packages/coding-agent/src/modes/rpc/rpc-mode.ts +795 -0
- package/.references/pi/packages/coding-agent/src/modes/rpc/rpc-types.ts +281 -0
- package/.references/pi/packages/coding-agent/src/package-manager-cli.ts +887 -0
- package/.references/pi/packages/coding-agent/src/rpc-entry.ts +12 -0
- package/.references/pi/packages/coding-agent/src/utils/ansi.ts +60 -0
- package/.references/pi/packages/coding-agent/src/utils/changelog.ts +196 -0
- package/.references/pi/packages/coding-agent/src/utils/child-process.ts +137 -0
- package/.references/pi/packages/coding-agent/src/utils/clipboard-image.ts +300 -0
- package/.references/pi/packages/coding-agent/src/utils/clipboard-native.ts +33 -0
- package/.references/pi/packages/coding-agent/src/utils/clipboard.ts +141 -0
- package/.references/pi/packages/coding-agent/src/utils/deprecation.ts +14 -0
- package/.references/pi/packages/coding-agent/src/utils/exif-orientation.ts +183 -0
- package/.references/pi/packages/coding-agent/src/utils/frontmatter.ts +39 -0
- package/.references/pi/packages/coding-agent/src/utils/fs-watch.ts +30 -0
- package/.references/pi/packages/coding-agent/src/utils/git.ts +226 -0
- package/.references/pi/packages/coding-agent/src/utils/highlight-js-lib-index.d.ts +19 -0
- package/.references/pi/packages/coding-agent/src/utils/html.ts +51 -0
- package/.references/pi/packages/coding-agent/src/utils/image-convert.ts +49 -0
- package/.references/pi/packages/coding-agent/src/utils/image-process.ts +119 -0
- package/.references/pi/packages/coding-agent/src/utils/image-resize-core.ts +164 -0
- package/.references/pi/packages/coding-agent/src/utils/image-resize-worker.ts +42 -0
- package/.references/pi/packages/coding-agent/src/utils/image-resize.ts +123 -0
- package/.references/pi/packages/coding-agent/src/utils/json.ts +6 -0
- package/.references/pi/packages/coding-agent/src/utils/mime.ts +116 -0
- package/.references/pi/packages/coding-agent/src/utils/open-browser.ts +24 -0
- package/.references/pi/packages/coding-agent/src/utils/paths.ts +118 -0
- package/.references/pi/packages/coding-agent/src/utils/photon.ts +139 -0
- package/.references/pi/packages/coding-agent/src/utils/pi-user-agent.ts +4 -0
- package/.references/pi/packages/coding-agent/src/utils/shell.ts +225 -0
- package/.references/pi/packages/coding-agent/src/utils/sleep.ts +18 -0
- package/.references/pi/packages/coding-agent/src/utils/syntax-highlight.ts +146 -0
- package/.references/pi/packages/coding-agent/src/utils/tools-manager.ts +369 -0
- package/.references/pi/packages/coding-agent/src/utils/version-check.ts +80 -0
- package/.references/pi/packages/coding-agent/src/utils/windows-self-update.ts +84 -0
- package/.references/pi/packages/coding-agent/test/agent-session-auto-compaction-queue.test.ts +450 -0
- package/.references/pi/packages/coding-agent/test/agent-session-branching.test.ts +156 -0
- package/.references/pi/packages/coding-agent/test/agent-session-compaction.test.ts +208 -0
- package/.references/pi/packages/coding-agent/test/agent-session-concurrent.test.ts +629 -0
- package/.references/pi/packages/coding-agent/test/agent-session-dynamic-provider.test.ts +122 -0
- package/.references/pi/packages/coding-agent/test/agent-session-dynamic-tools.test.ts +185 -0
- package/.references/pi/packages/coding-agent/test/agent-session-retry.test.ts +322 -0
- package/.references/pi/packages/coding-agent/test/agent-session-runtime-events.test.ts +257 -0
- package/.references/pi/packages/coding-agent/test/agent-session-stats.test.ts +169 -0
- package/.references/pi/packages/coding-agent/test/agent-session-tree-navigation.test.ts +323 -0
- package/.references/pi/packages/coding-agent/test/ansi-utils.test.ts +110 -0
- package/.references/pi/packages/coding-agent/test/args.test.ts +441 -0
- package/.references/pi/packages/coding-agent/test/assistant-message.test.ts +130 -0
- package/.references/pi/packages/coding-agent/test/auth-storage.test.ts +217 -0
- package/.references/pi/packages/coding-agent/test/bash-close-hang-windows.test.ts +126 -0
- package/.references/pi/packages/coding-agent/test/bash-execution-width.test.ts +80 -0
- package/.references/pi/packages/coding-agent/test/block-images.test.ts +148 -0
- package/.references/pi/packages/coding-agent/test/cache-stats.test.ts +143 -0
- package/.references/pi/packages/coding-agent/test/changelog.test.ts +49 -0
- package/.references/pi/packages/coding-agent/test/clipboard-image-bmp-conversion.test.ts +88 -0
- package/.references/pi/packages/coding-agent/test/clipboard-image.test.ts +184 -0
- package/.references/pi/packages/coding-agent/test/clipboard-native.test.ts +32 -0
- package/.references/pi/packages/coding-agent/test/clipboard.test.ts +166 -0
- package/.references/pi/packages/coding-agent/test/compaction-extensions-example.test.ts +66 -0
- package/.references/pi/packages/coding-agent/test/compaction-extensions.test.ts +415 -0
- package/.references/pi/packages/coding-agent/test/compaction-serialization.test.ts +79 -0
- package/.references/pi/packages/coding-agent/test/compaction-summary-reasoning.test.ts +134 -0
- package/.references/pi/packages/coding-agent/test/compaction.test.ts +596 -0
- package/.references/pi/packages/coding-agent/test/config-value-migration.test.ts +178 -0
- package/.references/pi/packages/coding-agent/test/config.test.ts +437 -0
- package/.references/pi/packages/coding-agent/test/edit-tool-legacy-input.test.ts +116 -0
- package/.references/pi/packages/coding-agent/test/edit-tool-no-full-redraw.test.ts +235 -0
- package/.references/pi/packages/coding-agent/test/experimental.test.ts +44 -0
- package/.references/pi/packages/coding-agent/test/export-html-skill-block.test.ts +40 -0
- package/.references/pi/packages/coding-agent/test/export-html-whitespace.test.ts +42 -0
- package/.references/pi/packages/coding-agent/test/export-html-xss.test.ts +67 -0
- package/.references/pi/packages/coding-agent/test/extensions-discovery.test.ts +528 -0
- package/.references/pi/packages/coding-agent/test/extensions-input-event.test.ts +125 -0
- package/.references/pi/packages/coding-agent/test/extensions-runner.test.ts +986 -0
- package/.references/pi/packages/coding-agent/test/file-mutation-queue.test.ts +274 -0
- package/.references/pi/packages/coding-agent/test/first-time-setup-fork.test.ts +39 -0
- package/.references/pi/packages/coding-agent/test/first-time-setup.test.ts +95 -0
- package/.references/pi/packages/coding-agent/test/fixtures/assistant-message-with-thinking-code.json +33 -0
- package/.references/pi/packages/coding-agent/test/fixtures/before-compaction.jsonl +1003 -0
- package/.references/pi/packages/coding-agent/test/fixtures/empty-agent/.gitkeep +0 -0
- package/.references/pi/packages/coding-agent/test/fixtures/empty-cwd/.gitkeep +0 -0
- package/.references/pi/packages/coding-agent/test/fixtures/large-session.jsonl +1019 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/consecutive-hyphens/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/disable-model-invocation/SKILL.md +9 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/invalid-name-chars/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/invalid-yaml/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/long-name/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/missing-description/SKILL.md +7 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/multiline-description/SKILL.md +11 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/name-mismatch/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/nested/child-skill/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/no-frontmatter/SKILL.md +3 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/root-skill-preferred/SKILL.md +3 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/root-skill-preferred/nested-child/SKILL.md +3 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/unknown-field/SKILL.md +10 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills/valid-skill/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills-collision/first/calendar/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/fixtures/skills-collision/second/calendar/SKILL.md +8 -0
- package/.references/pi/packages/coding-agent/test/footer-data-provider.test.ts +265 -0
- package/.references/pi/packages/coding-agent/test/footer-width.test.ts +144 -0
- package/.references/pi/packages/coding-agent/test/format-resume-command.test.ts +135 -0
- package/.references/pi/packages/coding-agent/test/frontmatter.test.ts +60 -0
- package/.references/pi/packages/coding-agent/test/git-merge-and-resolve-extension.test.ts +206 -0
- package/.references/pi/packages/coding-agent/test/git-ssh-url.test.ts +91 -0
- package/.references/pi/packages/coding-agent/test/git-update.test.ts +484 -0
- package/.references/pi/packages/coding-agent/test/http-dispatcher.test.ts +53 -0
- package/.references/pi/packages/coding-agent/test/image-process.test.ts +53 -0
- package/.references/pi/packages/coding-agent/test/image-processing.test.ts +170 -0
- package/.references/pi/packages/coding-agent/test/image-resize-callers.test.ts +53 -0
- package/.references/pi/packages/coding-agent/test/initial-message.test.ts +48 -0
- package/.references/pi/packages/coding-agent/test/input-transform-streaming-example.test.ts +84 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-anthropic-warning.test.ts +89 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-clone-command.test.ts +72 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-compaction.test.ts +85 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-import-command.test.ts +143 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-startup-input.test.ts +72 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-status.test.ts +1123 -0
- package/.references/pi/packages/coding-agent/test/interactive-mode-suspend.test.ts +149 -0
- package/.references/pi/packages/coding-agent/test/keybindings-migration.test.ts +88 -0
- package/.references/pi/packages/coding-agent/test/max-thinking.test.ts +45 -0
- package/.references/pi/packages/coding-agent/test/model-registry.test.ts +1934 -0
- package/.references/pi/packages/coding-agent/test/model-resolver.test.ts +690 -0
- package/.references/pi/packages/coding-agent/test/model-runtime-auth-options.test.ts +256 -0
- package/.references/pi/packages/coding-agent/test/model-runtime-cloudflare-compat.test.ts +95 -0
- package/.references/pi/packages/coding-agent/test/model-runtime-modify-models-compat.test.ts +85 -0
- package/.references/pi/packages/coding-agent/test/model-runtime-test-utils.ts +25 -0
- package/.references/pi/packages/coding-agent/test/models-store.test.ts +51 -0
- package/.references/pi/packages/coding-agent/test/oauth-selector.test.ts +147 -0
- package/.references/pi/packages/coding-agent/test/package-command-paths.test.ts +746 -0
- package/.references/pi/packages/coding-agent/test/package-manager-ssh.test.ts +97 -0
- package/.references/pi/packages/coding-agent/test/package-manager.test.ts +2512 -0
- package/.references/pi/packages/coding-agent/test/path-utils.test.ts +174 -0
- package/.references/pi/packages/coding-agent/test/paths.test.ts +150 -0
- package/.references/pi/packages/coding-agent/test/pi-user-agent.test.ts +12 -0
- package/.references/pi/packages/coding-agent/test/plan-mode-extension.test.ts +167 -0
- package/.references/pi/packages/coding-agent/test/plan-mode-utils.test.ts +261 -0
- package/.references/pi/packages/coding-agent/test/print-mode.test.ts +142 -0
- package/.references/pi/packages/coding-agent/test/prompt-templates.test.ts +615 -0
- package/.references/pi/packages/coding-agent/test/radius.test.ts +151 -0
- package/.references/pi/packages/coding-agent/test/remote-catalog-provider.test.ts +118 -0
- package/.references/pi/packages/coding-agent/test/resolve-config-value.test.ts +121 -0
- package/.references/pi/packages/coding-agent/test/resource-loader.test.ts +739 -0
- package/.references/pi/packages/coding-agent/test/restore-sandbox-env.test.ts +77 -0
- package/.references/pi/packages/coding-agent/test/rpc-client-clone.test.ts +29 -0
- package/.references/pi/packages/coding-agent/test/rpc-client-process-exit.test.ts +38 -0
- package/.references/pi/packages/coding-agent/test/rpc-example.ts +86 -0
- package/.references/pi/packages/coding-agent/test/rpc-jsonl.test.ts +65 -0
- package/.references/pi/packages/coding-agent/test/rpc-prompt-response-semantics.test.ts +288 -0
- package/.references/pi/packages/coding-agent/test/rpc.test.ts +377 -0
- package/.references/pi/packages/coding-agent/test/runtime-credentials.test.ts +42 -0
- package/.references/pi/packages/coding-agent/test/sdk-codex-cache-probe-tool-loop.ts +497 -0
- package/.references/pi/packages/coding-agent/test/sdk-openrouter-attribution.test.ts +266 -0
- package/.references/pi/packages/coding-agent/test/sdk-session-manager.test.ts +95 -0
- package/.references/pi/packages/coding-agent/test/sdk-skills.test.ts +109 -0
- package/.references/pi/packages/coding-agent/test/sdk-stream-options.test.ts +188 -0
- package/.references/pi/packages/coding-agent/test/session-cwd.test.ts +91 -0
- package/.references/pi/packages/coding-agent/test/session-file-invalid.test.ts +65 -0
- package/.references/pi/packages/coding-agent/test/session-id-readonly.test.ts +190 -0
- package/.references/pi/packages/coding-agent/test/session-info-modified-timestamp.test.ts +83 -0
- package/.references/pi/packages/coding-agent/test/session-manager/build-context.test.ts +305 -0
- package/.references/pi/packages/coding-agent/test/session-manager/custom-session-id.test.ts +169 -0
- package/.references/pi/packages/coding-agent/test/session-manager/file-operations.test.ts +315 -0
- package/.references/pi/packages/coding-agent/test/session-manager/labels.test.ts +211 -0
- package/.references/pi/packages/coding-agent/test/session-manager/migration.test.ts +78 -0
- package/.references/pi/packages/coding-agent/test/session-manager/save-entry.test.ts +55 -0
- package/.references/pi/packages/coding-agent/test/session-manager/tree-traversal.test.ts +533 -0
- package/.references/pi/packages/coding-agent/test/session-selector-path-delete.test.ts +354 -0
- package/.references/pi/packages/coding-agent/test/session-selector-rename.test.ts +111 -0
- package/.references/pi/packages/coding-agent/test/session-selector-search.test.ts +195 -0
- package/.references/pi/packages/coding-agent/test/settings-manager-bug.test.ts +147 -0
- package/.references/pi/packages/coding-agent/test/settings-manager.test.ts +511 -0
- package/.references/pi/packages/coding-agent/test/skills.test.ts +432 -0
- package/.references/pi/packages/coding-agent/test/startup-session-name.test.ts +135 -0
- package/.references/pi/packages/coding-agent/test/status-indicator.test.ts +32 -0
- package/.references/pi/packages/coding-agent/test/stdout-cleanliness.test.ts +128 -0
- package/.references/pi/packages/coding-agent/test/streaming-render-debug.ts +97 -0
- package/.references/pi/packages/coding-agent/test/suite/README.md +16 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-bash-persistence.test.ts +242 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-compaction.test.ts +446 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-model-extension.test.ts +373 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-prompt.test.ts +398 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-queue.test.ts +445 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-retry-events.test.ts +364 -0
- package/.references/pi/packages/coding-agent/test/suite/agent-session-runtime.test.ts +609 -0
- package/.references/pi/packages/coding-agent/test/suite/harness.ts +219 -0
- package/.references/pi/packages/coding-agent/test/suite/lax-message-content.test.ts +162 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/1717-2113-agent-session-event-settlement.test.ts +95 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2023-queued-slash-command-followup.test.ts +80 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2753-reload-stale-resource-settings.test.ts +105 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2781-skill-collision-precedence.test.ts +120 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2791-fswatch-error-crash.test.ts +106 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2835-tools-allowlist-filters-extension-tools.test.ts +94 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/2860-replaced-session-context.test.ts +279 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3217-scoped-model-order.test.ts +104 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3302-find-path-glob.test.ts +72 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3303-find-nested-gitignore.test.ts +83 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3317-network-connection-lost-retry.test.ts +33 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3592-no-builtin-tools-keeps-extension-tools.test.ts +119 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3616-settings-inmemory-reload.test.ts +86 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3686-session-name-event.test.ts +61 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3688-tree-cancel-compacting.test.ts +36 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/3982-message-end-cost-override.test.ts +56 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/4167-thinking-toggle-pending-tool-render.test.ts +182 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5080-signal-shutdown-extension-cleanup.test.ts +185 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5109-exclude-tools.test.ts +81 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5208-late-bash-output.test.ts +29 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5217-compaction-reason.test.ts +95 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5303-bash-output-truncation.test.ts +79 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5433-extension-oauth-prompt-input.test.ts +119 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5596-missing-theme-export.test.ts +89 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5661-uppercase-header-values.test.ts +91 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5724-sigterm-signal-exit.test.ts +94 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5868-rpc-unknown-command-id.test.ts +113 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5943-session-start-notify.test.ts +515 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/5996-session-name-newlines.test.ts +40 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/6019-explicit-provider-retry-message.test.ts +31 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/6162-extension-active-tools-next-turn.test.ts +192 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/6260-inline-extension-naming.test.ts +99 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/6324-branch-summary-ambient-auth.test.ts +61 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/6363-agent-settled-event.test.ts +158 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/extension-factory-cache.test.ts +131 -0
- package/.references/pi/packages/coding-agent/test/suite/regressions/pre-prompt-compaction-no-continue.test.ts +75 -0
- package/.references/pi/packages/coding-agent/test/syntax-highlight.test.ts +76 -0
- package/.references/pi/packages/coding-agent/test/system-prompt.test.ts +114 -0
- package/.references/pi/packages/coding-agent/test/test-harness.test.ts +321 -0
- package/.references/pi/packages/coding-agent/test/test-harness.ts +463 -0
- package/.references/pi/packages/coding-agent/test/test-theme-colors.ts +246 -0
- package/.references/pi/packages/coding-agent/test/theme-detection.test.ts +133 -0
- package/.references/pi/packages/coding-agent/test/theme-export.test.ts +104 -0
- package/.references/pi/packages/coding-agent/test/theme-picker.test.ts +51 -0
- package/.references/pi/packages/coding-agent/test/tool-execution-component.test.ts +529 -0
- package/.references/pi/packages/coding-agent/test/tools.test.ts +1213 -0
- package/.references/pi/packages/coding-agent/test/tree-selector.test.ts +702 -0
- package/.references/pi/packages/coding-agent/test/trigger-compact-extension.test.ts +59 -0
- package/.references/pi/packages/coding-agent/test/truncate-to-width.test.ts +81 -0
- package/.references/pi/packages/coding-agent/test/trust-manager.test.ts +67 -0
- package/.references/pi/packages/coding-agent/test/trust-selector.test.ts +87 -0
- package/.references/pi/packages/coding-agent/test/user-message.test.ts +25 -0
- package/.references/pi/packages/coding-agent/test/utilities.ts +318 -0
- package/.references/pi/packages/coding-agent/test/version-check.test.ts +91 -0
- package/.references/pi/packages/coding-agent/tsconfig.build.json +17 -0
- package/.references/pi/packages/coding-agent/tsconfig.examples.json +16 -0
- package/.references/pi/packages/coding-agent/vitest.config.ts +38 -0
- package/.references/pi/packages/orchestrator/CHANGELOG.md +19 -0
- package/.references/pi/packages/orchestrator/README.md +11 -0
- package/.references/pi/packages/orchestrator/package.json +45 -0
- package/.references/pi/packages/orchestrator/src/cli.ts +161 -0
- package/.references/pi/packages/orchestrator/src/config.ts +69 -0
- package/.references/pi/packages/orchestrator/src/handler.ts +161 -0
- package/.references/pi/packages/orchestrator/src/index.ts +10 -0
- package/.references/pi/packages/orchestrator/src/ipc/client.ts +63 -0
- package/.references/pi/packages/orchestrator/src/ipc/protocol.ts +142 -0
- package/.references/pi/packages/orchestrator/src/ipc/server.ts +209 -0
- package/.references/pi/packages/orchestrator/src/radius.ts +440 -0
- package/.references/pi/packages/orchestrator/src/rpc-process.ts +201 -0
- package/.references/pi/packages/orchestrator/src/serve.ts +77 -0
- package/.references/pi/packages/orchestrator/src/storage.ts +70 -0
- package/.references/pi/packages/orchestrator/src/supervisor.ts +354 -0
- package/.references/pi/packages/orchestrator/src/types.ts +25 -0
- package/.references/pi/packages/orchestrator/tsconfig.build.json +9 -0
- package/.references/pi/packages/tui/CHANGELOG.md +1005 -0
- package/.references/pi/packages/tui/README.md +791 -0
- package/.references/pi/packages/tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
- package/.references/pi/packages/tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/.references/pi/packages/tui/native/darwin/src/darwin-modifiers.c +70 -0
- package/.references/pi/packages/tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/.references/pi/packages/tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/.references/pi/packages/tui/native/win32/src/win32-console-mode.c +53 -0
- package/.references/pi/packages/tui/package.json +47 -0
- package/.references/pi/packages/tui/src/autocomplete.ts +786 -0
- package/.references/pi/packages/tui/src/components/box.ts +137 -0
- package/.references/pi/packages/tui/src/components/cancellable-loader.ts +40 -0
- package/.references/pi/packages/tui/src/components/editor.ts +2333 -0
- package/.references/pi/packages/tui/src/components/image.ts +126 -0
- package/.references/pi/packages/tui/src/components/input.ts +447 -0
- package/.references/pi/packages/tui/src/components/loader.ts +92 -0
- package/.references/pi/packages/tui/src/components/markdown.ts +858 -0
- package/.references/pi/packages/tui/src/components/select-list.ts +229 -0
- package/.references/pi/packages/tui/src/components/settings-list.ts +250 -0
- package/.references/pi/packages/tui/src/components/spacer.ts +28 -0
- package/.references/pi/packages/tui/src/components/text.ts +106 -0
- package/.references/pi/packages/tui/src/components/truncated-text.ts +65 -0
- package/.references/pi/packages/tui/src/editor-component.ts +74 -0
- package/.references/pi/packages/tui/src/fuzzy.ts +137 -0
- package/.references/pi/packages/tui/src/index.ts +114 -0
- package/.references/pi/packages/tui/src/keybindings.ts +244 -0
- package/.references/pi/packages/tui/src/keys.ts +1401 -0
- package/.references/pi/packages/tui/src/kill-ring.ts +46 -0
- package/.references/pi/packages/tui/src/native-modifiers.ts +59 -0
- package/.references/pi/packages/tui/src/stdin-buffer.ts +434 -0
- package/.references/pi/packages/tui/src/terminal-colors.ts +73 -0
- package/.references/pi/packages/tui/src/terminal-image.ts +488 -0
- package/.references/pi/packages/tui/src/terminal.ts +531 -0
- package/.references/pi/packages/tui/src/tui.ts +1714 -0
- package/.references/pi/packages/tui/src/undo-stack.ts +28 -0
- package/.references/pi/packages/tui/src/utils.ts +1209 -0
- package/.references/pi/packages/tui/src/word-navigation.ts +117 -0
- package/.references/pi/packages/tui/test/autocomplete.test.ts +542 -0
- package/.references/pi/packages/tui/test/bug-regression-isimageline-startswith-bug.test.ts +237 -0
- package/.references/pi/packages/tui/test/chat-simple.ts +129 -0
- package/.references/pi/packages/tui/test/editor.test.ts +4051 -0
- package/.references/pi/packages/tui/test/fuzzy.test.ts +112 -0
- package/.references/pi/packages/tui/test/image-test.ts +56 -0
- package/.references/pi/packages/tui/test/input.test.ts +647 -0
- package/.references/pi/packages/tui/test/key-tester.ts +123 -0
- package/.references/pi/packages/tui/test/keybindings.test.ts +46 -0
- package/.references/pi/packages/tui/test/keys.test.ts +622 -0
- package/.references/pi/packages/tui/test/markdown.test.ts +1442 -0
- package/.references/pi/packages/tui/test/overlay-non-capturing.test.ts +1202 -0
- package/.references/pi/packages/tui/test/overlay-options.test.ts +541 -0
- package/.references/pi/packages/tui/test/overlay-short-content.test.ts +61 -0
- package/.references/pi/packages/tui/test/regression-overlay-cjk-boundary.test.ts +68 -0
- package/.references/pi/packages/tui/test/regression-regional-indicator-width.test.ts +52 -0
- package/.references/pi/packages/tui/test/select-list.test.ts +116 -0
- package/.references/pi/packages/tui/test/stdin-buffer.test.ts +458 -0
- package/.references/pi/packages/tui/test/tab-width.test.ts +87 -0
- package/.references/pi/packages/tui/test/terminal-colors.test.ts +249 -0
- package/.references/pi/packages/tui/test/terminal-image.test.ts +492 -0
- package/.references/pi/packages/tui/test/terminal.test.ts +233 -0
- package/.references/pi/packages/tui/test/test-themes.ts +38 -0
- package/.references/pi/packages/tui/test/truncate-to-width.test.ts +76 -0
- package/.references/pi/packages/tui/test/truncated-text.test.ts +129 -0
- package/.references/pi/packages/tui/test/tui-cell-size-input.test.ts +81 -0
- package/.references/pi/packages/tui/test/tui-overlay-style-leak.test.ts +80 -0
- package/.references/pi/packages/tui/test/tui-render.test.ts +767 -0
- package/.references/pi/packages/tui/test/tui-shrink.test.ts +44 -0
- package/.references/pi/packages/tui/test/viewport-overwrite-repro.ts +106 -0
- package/.references/pi/packages/tui/test/virtual-terminal.ts +218 -0
- package/.references/pi/packages/tui/test/word-navigation.test.ts +191 -0
- package/.references/pi/packages/tui/test/wrap-ansi.test.ts +266 -0
- package/.references/pi/packages/tui/tsconfig.build.json +9 -0
- package/.references/pi/packages/tui/vitest.config.ts +7 -0
- package/.references/pi/pi-test.bat +14 -0
- package/.references/pi/pi-test.ps1 +71 -0
- package/.references/pi/pi-test.sh +57 -0
- package/.references/pi/scripts/browser-smoke-entry.ts +61 -0
- package/.references/pi/scripts/build-binaries.sh +245 -0
- package/.references/pi/scripts/check-browser-smoke.mjs +36 -0
- package/.references/pi/scripts/check-lockfile-commit.mjs +120 -0
- package/.references/pi/scripts/check-pinned-deps.mjs +63 -0
- package/.references/pi/scripts/check-ts-relative-imports.mjs +74 -0
- package/.references/pi/scripts/cost.ts +183 -0
- package/.references/pi/scripts/edit-tool-stats.mjs +834 -0
- package/.references/pi/scripts/generate-coding-agent-install-lock.mjs +439 -0
- package/.references/pi/scripts/generate-coding-agent-shrinkwrap.mjs +365 -0
- package/.references/pi/scripts/local-release.mjs +284 -0
- package/.references/pi/scripts/profile-coding-agent-node.mjs +639 -0
- package/.references/pi/scripts/publish-model-catalog.mjs +295 -0
- package/.references/pi/scripts/publish.mjs +125 -0
- package/.references/pi/scripts/read-tool-stats.mjs +505 -0
- package/.references/pi/scripts/release-notes.mjs +364 -0
- package/.references/pi/scripts/release.mjs +207 -0
- package/.references/pi/scripts/repro-5893-wsl-bash.mjs +55 -0
- package/.references/pi/scripts/session-context-stats.mjs +405 -0
- package/.references/pi/scripts/session-transcripts.ts +406 -0
- package/.references/pi/scripts/stats.ts +233 -0
- package/.references/pi/scripts/sync-versions.js +96 -0
- package/.references/pi/scripts/tool-stats.ts +232 -0
- package/.references/pi/scripts/update-source-imports-to-ts.sh +10 -0
- package/.references/pi/test.sh +81 -0
- package/.references/pi/tsconfig.base.json +25 -0
- package/.references/pi/tsconfig.json +27 -0
- package/AGENTS.md +8 -0
- package/Cargo.lock +5169 -0
- package/Cargo.toml +39 -0
- package/LICENSE +21 -0
- package/README.md +43 -0
- package/aliases/pi-rusty/Cargo.toml +19 -0
- package/aliases/pi-rusty/LICENSE +21 -0
- package/aliases/pi-rusty/README.md +10 -0
- package/aliases/pi-rusty/src/main.rs +8 -0
- package/bun.lock +687 -0
- package/crates/pi/Cargo.toml +66 -0
- package/crates/pi/LICENSE +21 -0
- package/crates/pi/assets/export-html/template.css +1066 -0
- package/crates/pi/assets/export-html/template.html +55 -0
- package/crates/pi/assets/export-html/template.js +1864 -0
- package/crates/pi/assets/export-html/vendor/dark.json +29 -0
- package/crates/pi/assets/export-html/vendor/highlight.min.js +1213 -0
- package/crates/pi/assets/export-html/vendor/light.json +6 -0
- package/crates/pi/assets/export-html/vendor/marked.min.js +78 -0
- package/crates/pi/src/cli/args.rs +889 -0
- package/crates/pi/src/cli/bootstrap.rs +2134 -0
- package/crates/pi/src/cli/entry.rs +1332 -0
- package/crates/pi/src/cli/help.rs +326 -0
- package/crates/pi/src/cli/mod.rs +22 -0
- package/crates/pi/src/cli/package_manager_cli.rs +1515 -0
- package/crates/pi/src/core/agent_session/bash.rs +453 -0
- package/crates/pi/src/core/agent_session/compaction.rs +1804 -0
- package/crates/pi/src/core/agent_session/events.rs +621 -0
- package/crates/pi/src/core/agent_session/extension.rs +2146 -0
- package/crates/pi/src/core/agent_session/extension_runner.rs +471 -0
- package/crates/pi/src/core/agent_session/mod.rs +1768 -0
- package/crates/pi/src/core/agent_session/model.rs +775 -0
- package/crates/pi/src/core/agent_session/persistence.rs +265 -0
- package/crates/pi/src/core/agent_session/prompt.rs +2289 -0
- package/crates/pi/src/core/agent_session/retry.rs +448 -0
- package/crates/pi/src/core/agent_session/stats.rs +302 -0
- package/crates/pi/src/core/agent_session/subscribe.rs +450 -0
- package/crates/pi/src/core/agent_session/tools.rs +515 -0
- package/crates/pi/src/core/agent_session/tree.rs +1219 -0
- package/crates/pi/src/core/agent_session_runtime.rs +1612 -0
- package/crates/pi/src/core/agent_session_services.rs +1613 -0
- package/crates/pi/src/core/compaction/branch.rs +767 -0
- package/crates/pi/src/core/compaction/mod.rs +1955 -0
- package/crates/pi/src/core/compaction/utils.rs +357 -0
- package/crates/pi/src/core/config.rs +1102 -0
- package/crates/pi/src/core/config_value.rs +179 -0
- package/crates/pi/src/core/experimental.rs +29 -0
- package/crates/pi/src/core/export_html/ansi_to_html.rs +279 -0
- package/crates/pi/src/core/export_html/mod.rs +787 -0
- package/crates/pi/src/core/export_html/session_data.rs +149 -0
- package/crates/pi/src/core/extension_host/acquire/tests.rs +579 -0
- package/crates/pi/src/core/extension_host/acquire.rs +431 -0
- package/crates/pi/src/core/extension_host/tests.rs +2353 -0
- package/crates/pi/src/core/extension_host.rs +2541 -0
- package/crates/pi/src/core/lockfile.rs +913 -0
- package/crates/pi/src/core/messages.rs +706 -0
- package/crates/pi/src/core/migrations.rs +828 -0
- package/crates/pi/src/core/mod.rs +28 -0
- package/crates/pi/src/core/model_resolver.rs +1473 -0
- package/crates/pi/src/core/model_runtime.rs +2720 -0
- package/crates/pi/src/core/output_guard.rs +977 -0
- package/crates/pi/src/core/package_manager/tests.rs +1304 -0
- package/crates/pi/src/core/package_manager.rs +2015 -0
- package/crates/pi/src/core/platform/clipboard.rs +702 -0
- package/crates/pi/src/core/platform/command.rs +223 -0
- package/crates/pi/src/core/platform/debug_dump.rs +274 -0
- package/crates/pi/src/core/platform/external_editor.rs +294 -0
- package/crates/pi/src/core/platform/first_run.rs +120 -0
- package/crates/pi/src/core/platform/image.rs +237 -0
- package/crates/pi/src/core/platform/mod.rs +27 -0
- package/crates/pi/src/core/platform/open_browser.rs +187 -0
- package/crates/pi/src/core/platform/release_packaging.rs +785 -0
- package/crates/pi/src/core/resources/diagnostics.rs +148 -0
- package/crates/pi/src/core/resources/discovery.rs +2570 -0
- package/crates/pi/src/core/resources/frontmatter.rs +205 -0
- package/crates/pi/src/core/resources/mod.rs +1402 -0
- package/crates/pi/src/core/resources/prompts.rs +510 -0
- package/crates/pi/src/core/resources/skills.rs +981 -0
- package/crates/pi/src/core/resources/slash.rs +199 -0
- package/crates/pi/src/core/resources/source_info.rs +141 -0
- package/crates/pi/src/core/resources/themes.rs +297 -0
- package/crates/pi/src/core/session_transfer.rs +390 -0
- package/crates/pi/src/core/sessions/context.rs +657 -0
- package/crates/pi/src/core/sessions/cwd.rs +176 -0
- package/crates/pi/src/core/sessions/entries.rs +1364 -0
- package/crates/pi/src/core/sessions/list.rs +610 -0
- package/crates/pi/src/core/sessions/mod.rs +2117 -0
- package/crates/pi/src/core/settings.rs +3794 -0
- package/crates/pi/src/core/share.rs +577 -0
- package/crates/pi/src/core/system_prompt.rs +654 -0
- package/crates/pi/src/core/tools/bash.rs +1574 -0
- package/crates/pi/src/core/tools/edit.rs +919 -0
- package/crates/pi/src/core/tools/edit_diff.rs +1150 -0
- package/crates/pi/src/core/tools/find.rs +652 -0
- package/crates/pi/src/core/tools/grep.rs +965 -0
- package/crates/pi/src/core/tools/ls.rs +545 -0
- package/crates/pi/src/core/tools/mod.rs +312 -0
- package/crates/pi/src/core/tools/mutation_queue.rs +392 -0
- package/crates/pi/src/core/tools/output_accumulator.rs +689 -0
- package/crates/pi/src/core/tools/path_utils.rs +517 -0
- package/crates/pi/src/core/tools/read.rs +1413 -0
- package/crates/pi/src/core/tools/truncate.rs +644 -0
- package/crates/pi/src/core/tools/write.rs +524 -0
- package/crates/pi/src/core/trust.rs +1414 -0
- package/crates/pi/src/core/update/changelog.rs +583 -0
- package/crates/pi/src/core/update/deprecation.rs +148 -0
- package/crates/pi/src/core/update/mod.rs +8 -0
- package/crates/pi/src/core/update/self_update.rs +1327 -0
- package/crates/pi/src/core/update/user_agent.rs +59 -0
- package/crates/pi/src/core/update/version_check.rs +511 -0
- package/crates/pi/src/core/update/windows_quarantine.rs +262 -0
- package/crates/pi/src/lib.rs +23 -0
- package/crates/pi/src/main.rs +13 -0
- package/crates/pi/src/modes/interactive/footer.rs +260 -0
- package/crates/pi/src/modes/interactive/header.rs +83 -0
- package/crates/pi/src/modes/interactive/input.rs +923 -0
- package/crates/pi/src/modes/interactive/messages.rs +640 -0
- package/crates/pi/src/modes/interactive/mod.rs +51 -0
- package/crates/pi/src/modes/interactive/progress.rs +181 -0
- package/crates/pi/src/modes/interactive/runtime.rs +7227 -0
- package/crates/pi/src/modes/interactive/selectors.rs +146 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__bash_state_widths.snap +138 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__compact_state_widths.snap +137 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__custom_branch_skill_messages.snap +145 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__empty_state_widths.snap +136 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__error_state_widths.snap +139 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__loading_state_widths.snap +136 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__queue_state_widths.snap +139 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__retry_state_widths.snap +136 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__streaming_state_widths.snap +137 -0
- package/crates/pi/src/modes/interactive/snapshots/pi__modes__interactive__tests__user_assistant_messages.snap +145 -0
- package/crates/pi/src/modes/interactive/startup.rs +194 -0
- package/crates/pi/src/modes/interactive/state.rs +759 -0
- package/crates/pi/src/modes/interactive/status.rs +70 -0
- package/crates/pi/src/modes/interactive/tests.rs +945 -0
- package/crates/pi/src/modes/interactive/theme.rs +1402 -0
- package/crates/pi/src/modes/interactive/tool_renderer.rs +152 -0
- package/crates/pi/src/modes/interactive/view.rs +511 -0
- package/crates/pi/src/modes/mod.rs +6 -0
- package/crates/pi/src/modes/print/input.rs +415 -0
- package/crates/pi/src/modes/print/json.rs +195 -0
- package/crates/pi/src/modes/print/mod.rs +403 -0
- package/crates/pi/src/modes/print/text.rs +412 -0
- package/crates/pi/src/modes/rpc/extension_ui.rs +361 -0
- package/crates/pi/src/modes/rpc/jsonl.rs +429 -0
- package/crates/pi/src/modes/rpc/mod.rs +19 -0
- package/crates/pi/src/modes/rpc/mode_host.rs +466 -0
- package/crates/pi/src/modes/rpc/server.rs +3037 -0
- package/crates/pi/src/modes/rpc/types.rs +2999 -0
- package/crates/pi/src/modes/run.rs +636 -0
- package/crates/pi/tests/fixtures/fake_extension_host.rs +104 -0
- package/crates/pi/tests/fixtures/tool-schemas/bash.json +16 -0
- package/crates/pi/tests/fixtures/tool-schemas/edit.json +34 -0
- package/crates/pi/tests/fixtures/tool-schemas/find.json +20 -0
- package/crates/pi/tests/fixtures/tool-schemas/grep.json +36 -0
- package/crates/pi/tests/fixtures/tool-schemas/ls.json +13 -0
- package/crates/pi/tests/fixtures/tool-schemas/read.json +20 -0
- package/crates/pi/tests/fixtures/tool-schemas/write.json +17 -0
- package/crates/pi-agent/Cargo.toml +30 -0
- package/crates/pi-agent/LICENSE +21 -0
- package/crates/pi-agent/src/agent.rs +1780 -0
- package/crates/pi-agent/src/bus.rs +770 -0
- package/crates/pi-agent/src/config.rs +445 -0
- package/crates/pi-agent/src/drain.rs +941 -0
- package/crates/pi-agent/src/error.rs +61 -0
- package/crates/pi-agent/src/event.rs +270 -0
- package/crates/pi-agent/src/lib.rs +49 -0
- package/crates/pi-agent/src/message.rs +296 -0
- package/crates/pi-agent/src/queue.rs +222 -0
- package/crates/pi-agent/src/run.rs +1870 -0
- package/crates/pi-agent/src/schedule.rs +2153 -0
- package/crates/pi-agent/src/state.rs +377 -0
- package/crates/pi-agent/src/tool.rs +496 -0
- package/crates/pi-ai/Cargo.toml +45 -0
- package/crates/pi-ai/LICENSE +21 -0
- package/crates/pi-ai/data/builtin-models.json +25193 -0
- package/crates/pi-ai/src/auth/config_value.rs +598 -0
- package/crates/pi-ai/src/auth/context.rs +215 -0
- package/crates/pi-ai/src/auth/credential_store.rs +318 -0
- package/crates/pi-ai/src/auth/env_keys.rs +647 -0
- package/crates/pi-ai/src/auth/error.rs +194 -0
- package/crates/pi-ai/src/auth/file_store.rs +1179 -0
- package/crates/pi-ai/src/auth/http.rs +526 -0
- package/crates/pi-ai/src/auth/mod.rs +29 -0
- package/crates/pi-ai/src/auth/oauth/anthropic.rs +1482 -0
- package/crates/pi-ai/src/auth/oauth/callback_server.rs +584 -0
- package/crates/pi-ai/src/auth/oauth/device_code.rs +573 -0
- package/crates/pi-ai/src/auth/oauth/github_copilot.rs +1527 -0
- package/crates/pi-ai/src/auth/oauth/mod.rs +26 -0
- package/crates/pi-ai/src/auth/oauth/openai_codex.rs +2005 -0
- package/crates/pi-ai/src/auth/oauth/page.rs +159 -0
- package/crates/pi-ai/src/auth/oauth/pkce.rs +145 -0
- package/crates/pi-ai/src/auth/oauth/radius.rs +1685 -0
- package/crates/pi-ai/src/auth/oauth/xai.rs +989 -0
- package/crates/pi-ai/src/auth/resolve.rs +701 -0
- package/crates/pi-ai/src/auth/runtime_credentials.rs +226 -0
- package/crates/pi-ai/src/auth/types.rs +534 -0
- package/crates/pi-ai/src/catalog/merge.rs +316 -0
- package/crates/pi-ai/src/catalog/mod.rs +485 -0
- package/crates/pi-ai/src/lib.rs +13 -0
- package/crates/pi-ai/src/models_store.rs +974 -0
- package/crates/pi-ai/src/provider.rs +285 -0
- package/crates/pi-ai/src/providers/anthropic_messages.rs +1473 -0
- package/crates/pi-ai/src/providers/azure_openai_responses.rs +559 -0
- package/crates/pi-ai/src/providers/bedrock_converse_stream.rs +2430 -0
- package/crates/pi-ai/src/providers/google_generative_ai.rs +622 -0
- package/crates/pi-ai/src/providers/google_vertex.rs +1565 -0
- package/crates/pi-ai/src/providers/mistral_conversations.rs +1245 -0
- package/crates/pi-ai/src/providers/mod.rs +35 -0
- package/crates/pi-ai/src/providers/openai_codex_responses.rs +2003 -0
- package/crates/pi-ai/src/providers/openai_completions.rs +1873 -0
- package/crates/pi-ai/src/providers/openai_responses.rs +757 -0
- package/crates/pi-ai/src/providers/pi_messages.rs +1235 -0
- package/crates/pi-ai/src/providers/registry.rs +923 -0
- package/crates/pi-ai/src/providers/shared/google.rs +1193 -0
- package/crates/pi-ai/src/providers/shared/responses.rs +1873 -0
- package/crates/pi-ai/src/providers/shared.rs +671 -0
- package/crates/pi-ai/src/providers/stream_state.rs +683 -0
- package/crates/pi-ai/src/providers/transport.rs +488 -0
- package/crates/pi-ai/src/text.rs +322 -0
- package/crates/pi-ai/src/types.rs +1050 -0
- package/crates/pi-ai/tests/conformance_anthropic_mistral.rs +664 -0
- package/crates/pi-ai/tests/conformance_bedrock_pi_messages.rs +908 -0
- package/crates/pi-ai/tests/conformance_codex.rs +815 -0
- package/crates/pi-ai/tests/conformance_google.rs +743 -0
- package/crates/pi-ai/tests/conformance_openai.rs +607 -0
- package/crates/pi-ai/tests/fixtures/provenance/anthropic-sse-parsing.test.ts +275 -0
- package/crates/pi-ai/tests/fixtures/provenance/mistral-reasoning-mode.test.ts +97 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/anthropic-messages.ts +1313 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/bedrock-converse-stream.ts +1091 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/google-generative-ai.ts +509 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/google-shared.ts +350 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/mistral-conversations.ts +664 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/openai-completions.ts +1355 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/openai-responses-shared.ts +613 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/src/api/openai-responses.ts +318 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/abort.test.ts +303 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/azure-openai-base-url.test.ts +175 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/bedrock-endpoint-resolution.test.ts +208 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/bedrock-thinking-payload.test.ts +246 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/google-vertex-api-key-resolution.test.ts +223 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-codex-stream.test.ts +2028 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-completions-prompt-cache.test.ts +264 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-completions-retry.test.ts +86 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-completions-thinking-as-text.test.ts +218 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-completions-tool-choice.test.ts +1716 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-responses-partial-json-cleanup.test.ts +106 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/openai-responses-terminal-event.test.ts +233 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/pi-messages.test.ts +243 -0
- package/crates/pi-ai/tests/fixtures/provenance/upstream/test/provider-error-body-passthrough.test.ts +78 -0
- package/crates/pi-ai/tests/fixtures/providers/anthropic-messages/cases.jsonl +4 -0
- package/crates/pi-ai/tests/fixtures/providers/azure-openai-responses/cases.jsonl +2 -0
- package/crates/pi-ai/tests/fixtures/providers/bedrock-converse-stream/cases.jsonl +8 -0
- package/crates/pi-ai/tests/fixtures/providers/google-generative-ai/cases.jsonl +6 -0
- package/crates/pi-ai/tests/fixtures/providers/google-vertex/cases.jsonl +6 -0
- package/crates/pi-ai/tests/fixtures/providers/mistral-conversations/cases.jsonl +4 -0
- package/crates/pi-ai/tests/fixtures/providers/openai-codex-responses/cases.jsonl +7 -0
- package/crates/pi-ai/tests/fixtures/providers/openai-completions/cases.jsonl +9 -0
- package/crates/pi-ai/tests/fixtures/providers/openai-responses/cases.jsonl +5 -0
- package/crates/pi-ai/tests/fixtures/providers/pi-messages/cases.jsonl +8 -0
- package/crates/pi-ai/tests/provider_registry_contract.rs +85 -0
- package/crates/pi-ai/tests/support/golden.rs +191 -0
- package/crates/pi-ai/tests/support/http.rs +525 -0
- package/crates/pi-ai/tests/support/mod.rs +4 -0
- package/crates/pi-ext/Cargo.toml +34 -0
- package/crates/pi-ext/LICENSE +21 -0
- package/crates/pi-ext/src/adapters.rs +1915 -0
- package/crates/pi-ext/src/client.rs +1883 -0
- package/crates/pi-ext/src/host.rs +318 -0
- package/crates/pi-ext/src/lib.rs +10 -0
- package/crates/pi-ext/src/protocol.rs +1880 -0
- package/crates/pi-ext/src/sanitize.rs +524 -0
- package/crates/pi-ext/src/test_support.rs +93 -0
- package/crates/pi-ext/tests/fixtures/fake_jsonl_host.rs +35 -0
- package/crates/pi-ext/tests/fixtures/protocol/frames.jsonl +30 -0
- package/crates/pi-ext/tests/scaling.rs +530 -0
- package/crates/pi-tui/Cargo.toml +56 -0
- package/crates/pi-tui/LICENSE +21 -0
- package/crates/pi-tui/src/bin/pi_tui_pty_fixture.rs +722 -0
- package/crates/pi-tui/src/component.rs +101 -0
- package/crates/pi-tui/src/components/editor/mod.rs +2626 -0
- package/crates/pi-tui/src/components/editor/paste.rs +406 -0
- package/crates/pi-tui/src/components/editor/state.rs +240 -0
- package/crates/pi-tui/src/components/image.rs +352 -0
- package/crates/pi-tui/src/components/input.rs +742 -0
- package/crates/pi-tui/src/components/loader.rs +364 -0
- package/crates/pi-tui/src/components/markdown.rs +1154 -0
- package/crates/pi-tui/src/components/mod.rs +30 -0
- package/crates/pi-tui/src/components/padded.rs +212 -0
- package/crates/pi-tui/src/components/select_list.rs +464 -0
- package/crates/pi-tui/src/components/settings_list.rs +597 -0
- package/crates/pi-tui/src/components/spacer.rs +67 -0
- package/crates/pi-tui/src/components/text.rs +225 -0
- package/crates/pi-tui/src/components/truncated_text.rs +137 -0
- package/crates/pi-tui/src/components/util.rs +324 -0
- package/crates/pi-tui/src/editor_support/autocomplete.rs +1039 -0
- package/crates/pi-tui/src/editor_support/history.rs +248 -0
- package/crates/pi-tui/src/editor_support/kill_ring.rs +139 -0
- package/crates/pi-tui/src/editor_support/mod.rs +29 -0
- package/crates/pi-tui/src/editor_support/undo.rs +73 -0
- package/crates/pi-tui/src/editor_support/word_nav.rs +412 -0
- package/crates/pi-tui/src/editor_support/wrap.rs +317 -0
- package/crates/pi-tui/src/focus.rs +564 -0
- package/crates/pi-tui/src/frame.rs +163 -0
- package/crates/pi-tui/src/fuzzy.rs +221 -0
- package/crates/pi-tui/src/image.rs +749 -0
- package/crates/pi-tui/src/keybindings.rs +602 -0
- package/crates/pi-tui/src/keys.rs +1242 -0
- package/crates/pi-tui/src/layout.rs +563 -0
- package/crates/pi-tui/src/lib.rs +16 -0
- package/crates/pi-tui/src/link.rs +408 -0
- package/crates/pi-tui/src/overlay.rs +895 -0
- package/crates/pi-tui/src/terminal/backend.rs +348 -0
- package/crates/pi-tui/src/terminal/caps.rs +237 -0
- package/crates/pi-tui/src/terminal/guard.rs +476 -0
- package/crates/pi-tui/src/terminal/input.rs +266 -0
- package/crates/pi-tui/src/terminal/mod.rs +31 -0
- package/crates/pi-tui/src/terminal/probe.rs +498 -0
- package/crates/pi-tui/src/terminal/sink.rs +128 -0
- package/crates/pi-tui/src/terminal/writer.rs +1541 -0
- package/crates/pi-tui/src/text/ansi.rs +415 -0
- package/crates/pi-tui/src/text/mod.rs +29 -0
- package/crates/pi-tui/src/text/slice.rs +645 -0
- package/crates/pi-tui/src/text/tests.rs +359 -0
- package/crates/pi-tui/src/text/width.rs +311 -0
- package/crates/pi-tui/src/text/wrap.rs +344 -0
- package/crates/pi-tui/tests/pty_no_flicker.rs +929 -0
- package/deny.toml +38 -0
- package/npm-package/bin/pi.js +31 -0
- package/npm-package/package.json +35 -0
- package/npm-package/tests/archive.test.ts +139 -0
- package/npm-package/tests/wrapper.test.ts +70 -0
- package/package.json +34 -0
- package/packages/extension-host/bun.lock +664 -0
- package/packages/extension-host/fixtures/extensions/all-events.ts +55 -0
- package/packages/extension-host/fixtures/extensions/control-compat-shadow.ts +14 -0
- package/packages/extension-host/fixtures/extensions/control-compat.ts +35 -0
- package/packages/extension-host/fixtures/extensions/crash.ts +36 -0
- package/packages/extension-host/fixtures/extensions/hooks.ts +45 -0
- package/packages/extension-host/fixtures/extensions/hostile.ts +39 -0
- package/packages/extension-host/fixtures/extensions/idle.ts +9 -0
- package/packages/extension-host/fixtures/extensions/provider-stream.ts +121 -0
- package/packages/extension-host/fixtures/extensions/terminal-input-fast.ts +20 -0
- package/packages/extension-host/fixtures/extensions/terminal-input-slow.ts +23 -0
- package/packages/extension-host/fixtures/extensions/tool-progress.ts +72 -0
- package/packages/extension-host/fixtures/extensions/tool.ts +71 -0
- package/packages/extension-host/fixtures/extensions/virtual-imports.ts +87 -0
- package/packages/extension-host/fixtures/extensions/widget-active.ts +16 -0
- package/packages/extension-host/fixtures/photon-probe.ts +45 -0
- package/packages/extension-host/fixtures/runtime-import.ts +54 -0
- package/packages/extension-host/package.json +54 -0
- package/packages/extension-host/src/host.ts +1651 -0
- package/packages/extension-host/src/index.ts +21 -0
- package/packages/extension-host/src/main.ts +51 -0
- package/packages/extension-host/src/protocol.ts +10 -0
- package/packages/extension-host/src/refs.d.ts +364 -0
- package/packages/extension-host/src/sanitize.ts +503 -0
- package/packages/extension-host/src/virtual-modules.ts +90 -0
- package/packages/extension-host/tests/acceptance.test.ts +1498 -0
- package/packages/extension-host/tests/host.test.ts +244 -0
- package/packages/extension-host/tests/sanitize.test.ts +359 -0
- package/packages/extension-host/tests/scaling.test.ts +661 -0
- package/packages/extension-host/tests/virtual-modules.test.ts +122 -0
- package/packages/extension-host/tsconfig.build.json +44 -0
- package/packages/extension-host/tsconfig.check.json +29 -0
- package/packages/extension-host/tsconfig.json +8 -0
- package/packages/pi-tui-protocol/package.json +41 -0
- package/packages/pi-tui-protocol/src/client.ts +341 -0
- package/packages/pi-tui-protocol/src/codec.ts +439 -0
- package/packages/pi-tui-protocol/src/index.ts +77 -0
- package/packages/pi-tui-protocol/src/types.ts +358 -0
- package/packages/pi-tui-protocol/tests/client.test.ts +175 -0
- package/packages/pi-tui-protocol/tests/codec.test.ts +196 -0
- package/packages/pi-tui-protocol/tests/fixtures/frames.jsonl +30 -0
- package/packages/pi-tui-protocol/tsconfig.build.json +23 -0
- package/packages/pi-tui-protocol/tsconfig.json +9 -0
- package/rust-toolchain.toml +3 -0
- package/rustfmt.toml +5 -0
- package/scripts/bench-extension-scaling.ts +466 -0
- package/scripts/build-extension-host.ts +51 -0
- package/scripts/generate-builtin-models.ts +344 -0
- package/scripts/generate-session-fixtures.ts +1758 -0
- package/scripts/generate-tool-schemas.ts +444 -0
- package/scripts/package-npm.ts +263 -0
- package/scripts/package-release.ts +422 -0
- package/scripts/release/archive.ts +594 -0
- package/scripts/release/args.ts +187 -0
- package/scripts/release/extract-host-asset.ts +224 -0
- package/scripts/release/host.ts +825 -0
- package/scripts/release/runner.ts +435 -0
- package/scripts/release/runtime.ts +130 -0
- package/scripts/release/stage.ts +437 -0
- package/scripts/release/targets.ts +150 -0
- package/scripts/tests/archive.test.ts +210 -0
- package/scripts/tests/args.test.ts +180 -0
- package/scripts/tests/cli-dry-run.test.ts +61 -0
- package/scripts/tests/compat-authority.test.ts +79 -0
- package/scripts/tests/compat-matrix.test.ts +389 -0
- package/scripts/tests/extract-host-asset.test.ts +176 -0
- package/scripts/tests/host.test.ts +443 -0
- package/scripts/tests/npm-installed-smoke.test.ts +104 -0
- package/scripts/tests/package-release.test.ts +516 -0
- package/scripts/tests/repro-guards.test.ts +241 -0
- package/scripts/tests/runner.test.ts +188 -0
- package/scripts/tests/stage.test.ts +232 -0
- package/scripts/tests/targets.test.ts +93 -0
- package/scripts/tsconfig.json +47 -0
- package/scripts/verification/compat-matrix.json +455 -0
- package/scripts/verification/compat-matrix.ts +632 -0
- package/scripts/verification/e2e-smoke.ts +1093 -0
- package/scripts/verification/extension.ts +339 -0
- package/scripts/verification/foundation.test.ts +339 -0
- package/scripts/verification/npm-installed-smoke.ts +117 -0
- package/scripts/verification/performance.ts +1425 -0
- package/scripts/verification/pty.ts +332 -0
|
@@ -0,0 +1,1294 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import * as path from "node:path";
|
|
3
|
+
import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
|
|
4
|
+
import {
|
|
5
|
+
type EditorTheme,
|
|
6
|
+
getCapabilities,
|
|
7
|
+
type MarkdownTheme,
|
|
8
|
+
type RgbColor,
|
|
9
|
+
type SelectListTheme,
|
|
10
|
+
type SettingsListTheme,
|
|
11
|
+
} from "@earendil-works/pi-tui";
|
|
12
|
+
import chalk from "chalk";
|
|
13
|
+
import { type Static, Type } from "typebox";
|
|
14
|
+
import { Compile } from "typebox/compile";
|
|
15
|
+
import { getCustomThemesDir, getThemesDir } from "../../../config.ts";
|
|
16
|
+
import type { SourceInfo } from "../../../core/source-info.ts";
|
|
17
|
+
import { closeWatcher, watchWithErrorHandler } from "../../../utils/fs-watch.ts";
|
|
18
|
+
import { highlight, supportsLanguage } from "../../../utils/syntax-highlight.ts";
|
|
19
|
+
|
|
20
|
+
// ============================================================================
|
|
21
|
+
// Types & Schema
|
|
22
|
+
// ============================================================================
|
|
23
|
+
|
|
24
|
+
const ColorValueSchema = Type.Union([
|
|
25
|
+
Type.String(), // hex "#ff0000", var ref "primary", or empty ""
|
|
26
|
+
Type.Integer({ minimum: 0, maximum: 255 }), // 256-color index
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
type ColorValue = Static<typeof ColorValueSchema>;
|
|
30
|
+
|
|
31
|
+
const ThemeJsonSchema = Type.Object({
|
|
32
|
+
$schema: Type.Optional(Type.String()),
|
|
33
|
+
name: Type.String(),
|
|
34
|
+
vars: Type.Optional(Type.Record(Type.String(), ColorValueSchema)),
|
|
35
|
+
colors: Type.Object({
|
|
36
|
+
// Core UI (10 colors)
|
|
37
|
+
accent: ColorValueSchema,
|
|
38
|
+
border: ColorValueSchema,
|
|
39
|
+
borderAccent: ColorValueSchema,
|
|
40
|
+
borderMuted: ColorValueSchema,
|
|
41
|
+
success: ColorValueSchema,
|
|
42
|
+
error: ColorValueSchema,
|
|
43
|
+
warning: ColorValueSchema,
|
|
44
|
+
muted: ColorValueSchema,
|
|
45
|
+
dim: ColorValueSchema,
|
|
46
|
+
text: ColorValueSchema,
|
|
47
|
+
thinkingText: ColorValueSchema,
|
|
48
|
+
// Backgrounds & Content Text (11 colors)
|
|
49
|
+
selectedBg: ColorValueSchema,
|
|
50
|
+
userMessageBg: ColorValueSchema,
|
|
51
|
+
userMessageText: ColorValueSchema,
|
|
52
|
+
customMessageBg: ColorValueSchema,
|
|
53
|
+
customMessageText: ColorValueSchema,
|
|
54
|
+
customMessageLabel: ColorValueSchema,
|
|
55
|
+
toolPendingBg: ColorValueSchema,
|
|
56
|
+
toolSuccessBg: ColorValueSchema,
|
|
57
|
+
toolErrorBg: ColorValueSchema,
|
|
58
|
+
toolTitle: ColorValueSchema,
|
|
59
|
+
toolOutput: ColorValueSchema,
|
|
60
|
+
// Markdown (10 colors)
|
|
61
|
+
mdHeading: ColorValueSchema,
|
|
62
|
+
mdLink: ColorValueSchema,
|
|
63
|
+
mdLinkUrl: ColorValueSchema,
|
|
64
|
+
mdCode: ColorValueSchema,
|
|
65
|
+
mdCodeBlock: ColorValueSchema,
|
|
66
|
+
mdCodeBlockBorder: ColorValueSchema,
|
|
67
|
+
mdQuote: ColorValueSchema,
|
|
68
|
+
mdQuoteBorder: ColorValueSchema,
|
|
69
|
+
mdHr: ColorValueSchema,
|
|
70
|
+
mdListBullet: ColorValueSchema,
|
|
71
|
+
// Tool Diffs (3 colors)
|
|
72
|
+
toolDiffAdded: ColorValueSchema,
|
|
73
|
+
toolDiffRemoved: ColorValueSchema,
|
|
74
|
+
toolDiffContext: ColorValueSchema,
|
|
75
|
+
// Syntax Highlighting (9 colors)
|
|
76
|
+
syntaxComment: ColorValueSchema,
|
|
77
|
+
syntaxKeyword: ColorValueSchema,
|
|
78
|
+
syntaxFunction: ColorValueSchema,
|
|
79
|
+
syntaxVariable: ColorValueSchema,
|
|
80
|
+
syntaxString: ColorValueSchema,
|
|
81
|
+
syntaxNumber: ColorValueSchema,
|
|
82
|
+
syntaxType: ColorValueSchema,
|
|
83
|
+
syntaxOperator: ColorValueSchema,
|
|
84
|
+
syntaxPunctuation: ColorValueSchema,
|
|
85
|
+
// Thinking Level Borders (6 colors)
|
|
86
|
+
thinkingOff: ColorValueSchema,
|
|
87
|
+
thinkingMinimal: ColorValueSchema,
|
|
88
|
+
thinkingLow: ColorValueSchema,
|
|
89
|
+
thinkingMedium: ColorValueSchema,
|
|
90
|
+
thinkingHigh: ColorValueSchema,
|
|
91
|
+
thinkingXhigh: ColorValueSchema,
|
|
92
|
+
thinkingMax: Type.Optional(ColorValueSchema),
|
|
93
|
+
// Bash Mode (1 color)
|
|
94
|
+
bashMode: ColorValueSchema,
|
|
95
|
+
}),
|
|
96
|
+
export: Type.Optional(
|
|
97
|
+
Type.Object({
|
|
98
|
+
pageBg: Type.Optional(ColorValueSchema),
|
|
99
|
+
cardBg: Type.Optional(ColorValueSchema),
|
|
100
|
+
infoBg: Type.Optional(ColorValueSchema),
|
|
101
|
+
}),
|
|
102
|
+
),
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
type ThemeJson = Static<typeof ThemeJsonSchema>;
|
|
106
|
+
|
|
107
|
+
const validateThemeJson = Compile(ThemeJsonSchema);
|
|
108
|
+
|
|
109
|
+
export type ThemeColor =
|
|
110
|
+
| "accent"
|
|
111
|
+
| "border"
|
|
112
|
+
| "borderAccent"
|
|
113
|
+
| "borderMuted"
|
|
114
|
+
| "success"
|
|
115
|
+
| "error"
|
|
116
|
+
| "warning"
|
|
117
|
+
| "muted"
|
|
118
|
+
| "dim"
|
|
119
|
+
| "text"
|
|
120
|
+
| "thinkingText"
|
|
121
|
+
| "userMessageText"
|
|
122
|
+
| "customMessageText"
|
|
123
|
+
| "customMessageLabel"
|
|
124
|
+
| "toolTitle"
|
|
125
|
+
| "toolOutput"
|
|
126
|
+
| "mdHeading"
|
|
127
|
+
| "mdLink"
|
|
128
|
+
| "mdLinkUrl"
|
|
129
|
+
| "mdCode"
|
|
130
|
+
| "mdCodeBlock"
|
|
131
|
+
| "mdCodeBlockBorder"
|
|
132
|
+
| "mdQuote"
|
|
133
|
+
| "mdQuoteBorder"
|
|
134
|
+
| "mdHr"
|
|
135
|
+
| "mdListBullet"
|
|
136
|
+
| "toolDiffAdded"
|
|
137
|
+
| "toolDiffRemoved"
|
|
138
|
+
| "toolDiffContext"
|
|
139
|
+
| "syntaxComment"
|
|
140
|
+
| "syntaxKeyword"
|
|
141
|
+
| "syntaxFunction"
|
|
142
|
+
| "syntaxVariable"
|
|
143
|
+
| "syntaxString"
|
|
144
|
+
| "syntaxNumber"
|
|
145
|
+
| "syntaxType"
|
|
146
|
+
| "syntaxOperator"
|
|
147
|
+
| "syntaxPunctuation"
|
|
148
|
+
| "thinkingOff"
|
|
149
|
+
| "thinkingMinimal"
|
|
150
|
+
| "thinkingLow"
|
|
151
|
+
| "thinkingMedium"
|
|
152
|
+
| "thinkingHigh"
|
|
153
|
+
| "thinkingXhigh"
|
|
154
|
+
| "thinkingMax"
|
|
155
|
+
| "bashMode";
|
|
156
|
+
|
|
157
|
+
export type ThemeBg =
|
|
158
|
+
| "selectedBg"
|
|
159
|
+
| "userMessageBg"
|
|
160
|
+
| "customMessageBg"
|
|
161
|
+
| "toolPendingBg"
|
|
162
|
+
| "toolSuccessBg"
|
|
163
|
+
| "toolErrorBg";
|
|
164
|
+
|
|
165
|
+
type ColorMode = "truecolor" | "256color";
|
|
166
|
+
|
|
167
|
+
// ============================================================================
|
|
168
|
+
// Color Utilities
|
|
169
|
+
// ============================================================================
|
|
170
|
+
|
|
171
|
+
function hexToRgb(hex: string): { r: number; g: number; b: number } {
|
|
172
|
+
const cleaned = hex.replace("#", "");
|
|
173
|
+
if (cleaned.length !== 6) {
|
|
174
|
+
throw new Error(`Invalid hex color: ${hex}`);
|
|
175
|
+
}
|
|
176
|
+
const r = parseInt(cleaned.substring(0, 2), 16);
|
|
177
|
+
const g = parseInt(cleaned.substring(2, 4), 16);
|
|
178
|
+
const b = parseInt(cleaned.substring(4, 6), 16);
|
|
179
|
+
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
|
|
180
|
+
throw new Error(`Invalid hex color: ${hex}`);
|
|
181
|
+
}
|
|
182
|
+
return { r, g, b };
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// The 6x6x6 color cube channel values (indices 0-5)
|
|
186
|
+
const CUBE_VALUES = [0, 95, 135, 175, 215, 255];
|
|
187
|
+
|
|
188
|
+
// Grayscale ramp values (indices 232-255, 24 grays from 8 to 238)
|
|
189
|
+
const GRAY_VALUES = Array.from({ length: 24 }, (_, i) => 8 + i * 10);
|
|
190
|
+
|
|
191
|
+
function findClosestCubeIndex(value: number): number {
|
|
192
|
+
let minDist = Infinity;
|
|
193
|
+
let minIdx = 0;
|
|
194
|
+
for (let i = 0; i < CUBE_VALUES.length; i++) {
|
|
195
|
+
const dist = Math.abs(value - CUBE_VALUES[i]);
|
|
196
|
+
if (dist < minDist) {
|
|
197
|
+
minDist = dist;
|
|
198
|
+
minIdx = i;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return minIdx;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function findClosestGrayIndex(gray: number): number {
|
|
205
|
+
let minDist = Infinity;
|
|
206
|
+
let minIdx = 0;
|
|
207
|
+
for (let i = 0; i < GRAY_VALUES.length; i++) {
|
|
208
|
+
const dist = Math.abs(gray - GRAY_VALUES[i]);
|
|
209
|
+
if (dist < minDist) {
|
|
210
|
+
minDist = dist;
|
|
211
|
+
minIdx = i;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return minIdx;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function colorDistance(r1: number, g1: number, b1: number, r2: number, g2: number, b2: number): number {
|
|
218
|
+
// Weighted Euclidean distance (human eye is more sensitive to green)
|
|
219
|
+
const dr = r1 - r2;
|
|
220
|
+
const dg = g1 - g2;
|
|
221
|
+
const db = b1 - b2;
|
|
222
|
+
return dr * dr * 0.299 + dg * dg * 0.587 + db * db * 0.114;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
function rgbTo256(r: number, g: number, b: number): number {
|
|
226
|
+
// Find closest color in the 6x6x6 cube
|
|
227
|
+
const rIdx = findClosestCubeIndex(r);
|
|
228
|
+
const gIdx = findClosestCubeIndex(g);
|
|
229
|
+
const bIdx = findClosestCubeIndex(b);
|
|
230
|
+
const cubeR = CUBE_VALUES[rIdx];
|
|
231
|
+
const cubeG = CUBE_VALUES[gIdx];
|
|
232
|
+
const cubeB = CUBE_VALUES[bIdx];
|
|
233
|
+
const cubeIndex = 16 + 36 * rIdx + 6 * gIdx + bIdx;
|
|
234
|
+
const cubeDist = colorDistance(r, g, b, cubeR, cubeG, cubeB);
|
|
235
|
+
|
|
236
|
+
// Find closest grayscale
|
|
237
|
+
const gray = Math.round(0.299 * r + 0.587 * g + 0.114 * b);
|
|
238
|
+
const grayIdx = findClosestGrayIndex(gray);
|
|
239
|
+
const grayValue = GRAY_VALUES[grayIdx];
|
|
240
|
+
const grayIndex = 232 + grayIdx;
|
|
241
|
+
const grayDist = colorDistance(r, g, b, grayValue, grayValue, grayValue);
|
|
242
|
+
|
|
243
|
+
// Check if color has noticeable saturation (hue matters)
|
|
244
|
+
// If max-min spread is significant, prefer cube to preserve tint
|
|
245
|
+
const maxC = Math.max(r, g, b);
|
|
246
|
+
const minC = Math.min(r, g, b);
|
|
247
|
+
const spread = maxC - minC;
|
|
248
|
+
|
|
249
|
+
// Only consider grayscale if color is nearly neutral (spread < 10)
|
|
250
|
+
// AND grayscale is actually closer
|
|
251
|
+
if (spread < 10 && grayDist < cubeDist) {
|
|
252
|
+
return grayIndex;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return cubeIndex;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function hexTo256(hex: string): number {
|
|
259
|
+
const { r, g, b } = hexToRgb(hex);
|
|
260
|
+
return rgbTo256(r, g, b);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function fgAnsi(color: string | number, mode: ColorMode): string {
|
|
264
|
+
if (color === "") return "\x1b[39m";
|
|
265
|
+
if (typeof color === "number") return `\x1b[38;5;${color}m`;
|
|
266
|
+
if (color.startsWith("#")) {
|
|
267
|
+
if (mode === "truecolor") {
|
|
268
|
+
const { r, g, b } = hexToRgb(color);
|
|
269
|
+
return `\x1b[38;2;${r};${g};${b}m`;
|
|
270
|
+
} else {
|
|
271
|
+
const index = hexTo256(color);
|
|
272
|
+
return `\x1b[38;5;${index}m`;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
throw new Error(`Invalid color value: ${color}`);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function bgAnsi(color: string | number, mode: ColorMode): string {
|
|
279
|
+
if (color === "") return "\x1b[49m";
|
|
280
|
+
if (typeof color === "number") return `\x1b[48;5;${color}m`;
|
|
281
|
+
if (color.startsWith("#")) {
|
|
282
|
+
if (mode === "truecolor") {
|
|
283
|
+
const { r, g, b } = hexToRgb(color);
|
|
284
|
+
return `\x1b[48;2;${r};${g};${b}m`;
|
|
285
|
+
} else {
|
|
286
|
+
const index = hexTo256(color);
|
|
287
|
+
return `\x1b[48;5;${index}m`;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
throw new Error(`Invalid color value: ${color}`);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
function resolveVarRefs(
|
|
294
|
+
value: ColorValue,
|
|
295
|
+
vars: Record<string, ColorValue>,
|
|
296
|
+
visited = new Set<string>(),
|
|
297
|
+
): string | number {
|
|
298
|
+
if (typeof value === "number" || value === "" || value.startsWith("#")) {
|
|
299
|
+
return value;
|
|
300
|
+
}
|
|
301
|
+
if (visited.has(value)) {
|
|
302
|
+
throw new Error(`Circular variable reference detected: ${value}`);
|
|
303
|
+
}
|
|
304
|
+
if (!(value in vars)) {
|
|
305
|
+
throw new Error(`Variable reference not found: ${value}`);
|
|
306
|
+
}
|
|
307
|
+
visited.add(value);
|
|
308
|
+
return resolveVarRefs(vars[value], vars, visited);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function resolveThemeColors<T extends Record<string, ColorValue>>(
|
|
312
|
+
colors: T,
|
|
313
|
+
vars: Record<string, ColorValue> = {},
|
|
314
|
+
): Record<keyof T, string | number> {
|
|
315
|
+
const resolved: Record<string, string | number> = {};
|
|
316
|
+
for (const [key, value] of Object.entries(colors)) {
|
|
317
|
+
resolved[key] = resolveVarRefs(value, vars);
|
|
318
|
+
}
|
|
319
|
+
return resolved as Record<keyof T, string | number>;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
function withThemeColorFallbacks(colors: ThemeJson["colors"]): ThemeJson["colors"] & { thinkingMax: ColorValue } {
|
|
323
|
+
return { ...colors, thinkingMax: colors.thinkingMax ?? colors.thinkingXhigh };
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// ============================================================================
|
|
327
|
+
// Theme Class
|
|
328
|
+
// ============================================================================
|
|
329
|
+
|
|
330
|
+
export class Theme {
|
|
331
|
+
readonly name?: string;
|
|
332
|
+
readonly sourcePath?: string;
|
|
333
|
+
sourceInfo?: SourceInfo;
|
|
334
|
+
private fgColors: Map<ThemeColor, string>;
|
|
335
|
+
private bgColors: Map<ThemeBg, string>;
|
|
336
|
+
private mode: ColorMode;
|
|
337
|
+
|
|
338
|
+
constructor(
|
|
339
|
+
fgColors: Record<ThemeColor, string | number>,
|
|
340
|
+
bgColors: Record<ThemeBg, string | number>,
|
|
341
|
+
mode: ColorMode,
|
|
342
|
+
options: { name?: string; sourcePath?: string; sourceInfo?: SourceInfo } = {},
|
|
343
|
+
) {
|
|
344
|
+
this.name = options.name;
|
|
345
|
+
this.sourcePath = options.sourcePath;
|
|
346
|
+
this.sourceInfo = options.sourceInfo;
|
|
347
|
+
this.mode = mode;
|
|
348
|
+
this.fgColors = new Map();
|
|
349
|
+
const colors = { ...fgColors, thinkingMax: fgColors.thinkingMax ?? fgColors.thinkingXhigh };
|
|
350
|
+
for (const [key, value] of Object.entries(colors) as [ThemeColor, string | number][]) {
|
|
351
|
+
this.fgColors.set(key, fgAnsi(value, mode));
|
|
352
|
+
}
|
|
353
|
+
this.bgColors = new Map();
|
|
354
|
+
for (const [key, value] of Object.entries(bgColors) as [ThemeBg, string | number][]) {
|
|
355
|
+
this.bgColors.set(key, bgAnsi(value, mode));
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
fg(color: ThemeColor, text: string): string {
|
|
360
|
+
const ansi = this.fgColors.get(color);
|
|
361
|
+
if (!ansi) throw new Error(`Unknown theme color: ${color}`);
|
|
362
|
+
return `${ansi}${text}\x1b[39m`; // Reset only foreground color
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
bg(color: ThemeBg, text: string): string {
|
|
366
|
+
const ansi = this.bgColors.get(color);
|
|
367
|
+
if (!ansi) throw new Error(`Unknown theme background color: ${color}`);
|
|
368
|
+
return `${ansi}${text}\x1b[49m`; // Reset only background color
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
bold(text: string): string {
|
|
372
|
+
return chalk.bold(text);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
italic(text: string): string {
|
|
376
|
+
return chalk.italic(text);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
underline(text: string): string {
|
|
380
|
+
return chalk.underline(text);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
inverse(text: string): string {
|
|
384
|
+
return chalk.inverse(text);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
strikethrough(text: string): string {
|
|
388
|
+
return chalk.strikethrough(text);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
getFgAnsi(color: ThemeColor): string {
|
|
392
|
+
const ansi = this.fgColors.get(color);
|
|
393
|
+
if (!ansi) throw new Error(`Unknown theme color: ${color}`);
|
|
394
|
+
return ansi;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
getBgAnsi(color: ThemeBg): string {
|
|
398
|
+
const ansi = this.bgColors.get(color);
|
|
399
|
+
if (!ansi) throw new Error(`Unknown theme background color: ${color}`);
|
|
400
|
+
return ansi;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
getColorMode(): ColorMode {
|
|
404
|
+
return this.mode;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
getThinkingBorderColor(level: ThinkingLevel): (str: string) => string {
|
|
408
|
+
// Map thinking levels to dedicated theme colors
|
|
409
|
+
switch (level) {
|
|
410
|
+
case "off":
|
|
411
|
+
return (str: string) => this.fg("thinkingOff", str);
|
|
412
|
+
case "minimal":
|
|
413
|
+
return (str: string) => this.fg("thinkingMinimal", str);
|
|
414
|
+
case "low":
|
|
415
|
+
return (str: string) => this.fg("thinkingLow", str);
|
|
416
|
+
case "medium":
|
|
417
|
+
return (str: string) => this.fg("thinkingMedium", str);
|
|
418
|
+
case "high":
|
|
419
|
+
return (str: string) => this.fg("thinkingHigh", str);
|
|
420
|
+
case "xhigh":
|
|
421
|
+
return (str: string) => this.fg("thinkingXhigh", str);
|
|
422
|
+
case "max":
|
|
423
|
+
return (str: string) => this.fg("thinkingMax", str);
|
|
424
|
+
default:
|
|
425
|
+
return (str: string) => this.fg("thinkingOff", str);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
getBashModeBorderColor(): (str: string) => string {
|
|
430
|
+
return (str: string) => this.fg("bashMode", str);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
// ============================================================================
|
|
435
|
+
// Theme Loading
|
|
436
|
+
// ============================================================================
|
|
437
|
+
|
|
438
|
+
let BUILTIN_THEMES: Record<string, ThemeJson> | undefined;
|
|
439
|
+
|
|
440
|
+
function getBuiltinThemes(): Record<string, ThemeJson> {
|
|
441
|
+
if (!BUILTIN_THEMES) {
|
|
442
|
+
const themesDir = getThemesDir();
|
|
443
|
+
const darkPath = path.join(themesDir, "dark.json");
|
|
444
|
+
const lightPath = path.join(themesDir, "light.json");
|
|
445
|
+
BUILTIN_THEMES = {
|
|
446
|
+
dark: JSON.parse(fs.readFileSync(darkPath, "utf-8")) as ThemeJson,
|
|
447
|
+
light: JSON.parse(fs.readFileSync(lightPath, "utf-8")) as ThemeJson,
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
return BUILTIN_THEMES;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export function getAvailableThemes(): string[] {
|
|
454
|
+
return getAvailableThemesWithPaths().map(({ name }) => name);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
export interface ThemeInfo {
|
|
458
|
+
name: string;
|
|
459
|
+
path: string | undefined;
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
export function getAvailableThemesWithPaths(): ThemeInfo[] {
|
|
463
|
+
const themesDir = getThemesDir();
|
|
464
|
+
const result: ThemeInfo[] = [];
|
|
465
|
+
const seen = new Set<string>();
|
|
466
|
+
const addTheme = (themeInfo: ThemeInfo) => {
|
|
467
|
+
if (seen.has(themeInfo.name)) {
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
seen.add(themeInfo.name);
|
|
471
|
+
result.push(themeInfo);
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
// Built-in themes
|
|
475
|
+
for (const name of Object.keys(getBuiltinThemes())) {
|
|
476
|
+
addTheme({ name, path: path.join(themesDir, `${name}.json`) });
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Custom themes
|
|
480
|
+
for (const themeInfo of getCustomThemeInfos()) {
|
|
481
|
+
addTheme(themeInfo);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
for (const [name, theme] of registeredThemes.entries()) {
|
|
485
|
+
addTheme({ name, path: theme.sourcePath });
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
return result.sort((a, b) => a.name.localeCompare(b.name));
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
function getCustomThemeInfos(): ThemeInfo[] {
|
|
492
|
+
const customThemesDir = getCustomThemesDir();
|
|
493
|
+
const result: ThemeInfo[] = [];
|
|
494
|
+
if (!fs.existsSync(customThemesDir)) {
|
|
495
|
+
return result;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
for (const file of fs.readdirSync(customThemesDir)) {
|
|
499
|
+
if (!file.endsWith(".json")) {
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
const themePath = path.join(customThemesDir, file);
|
|
503
|
+
try {
|
|
504
|
+
const customTheme = loadThemeFromPath(themePath);
|
|
505
|
+
if (customTheme.name) {
|
|
506
|
+
result.push({ name: customTheme.name, path: themePath });
|
|
507
|
+
}
|
|
508
|
+
} catch {
|
|
509
|
+
// Invalid themes are ignored here; the resource loader reports them
|
|
510
|
+
// during normal startup/reload.
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return result;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
function assertThemeNameIsValid(name: string): void {
|
|
517
|
+
if (name.includes("/")) {
|
|
518
|
+
throw new Error(
|
|
519
|
+
`Invalid theme name "${name}": theme names cannot contain "/" because it is reserved for automatic light/dark theme settings.`,
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function parseThemeJson(label: string, json: unknown): ThemeJson {
|
|
525
|
+
if (!validateThemeJson.Check(json)) {
|
|
526
|
+
const errors = Array.from(validateThemeJson.Errors(json));
|
|
527
|
+
const missingColors = new Set<string>();
|
|
528
|
+
const otherErrors: string[] = [];
|
|
529
|
+
|
|
530
|
+
for (const error of errors) {
|
|
531
|
+
if (error.keyword === "required" && error.instancePath === "/colors") {
|
|
532
|
+
const requiredProperties = (error.params as { requiredProperties?: string[] }).requiredProperties;
|
|
533
|
+
for (const requiredProperty of requiredProperties ?? []) {
|
|
534
|
+
missingColors.add(requiredProperty);
|
|
535
|
+
}
|
|
536
|
+
continue;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
const path = error.instancePath || "/";
|
|
540
|
+
otherErrors.push(` - ${path}: ${error.message}`);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
let errorMessage = `Invalid theme "${label}":\n`;
|
|
544
|
+
if (missingColors.size > 0) {
|
|
545
|
+
errorMessage += "\nMissing required color tokens:\n";
|
|
546
|
+
errorMessage += Array.from(missingColors)
|
|
547
|
+
.sort()
|
|
548
|
+
.map((color) => ` - ${color}`)
|
|
549
|
+
.join("\n");
|
|
550
|
+
errorMessage += '\n\nPlease add these colors to your theme\'s "colors" object.';
|
|
551
|
+
errorMessage += "\nSee the built-in themes (dark.json, light.json) for reference values.";
|
|
552
|
+
}
|
|
553
|
+
if (otherErrors.length > 0) {
|
|
554
|
+
errorMessage += `\n\nOther errors:\n${otherErrors.join("\n")}`;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
throw new Error(errorMessage);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
const themeJson = json as ThemeJson;
|
|
561
|
+
assertThemeNameIsValid(themeJson.name);
|
|
562
|
+
return themeJson;
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function parseThemeJsonContent(label: string, content: string): ThemeJson {
|
|
566
|
+
let json: unknown;
|
|
567
|
+
try {
|
|
568
|
+
json = JSON.parse(content);
|
|
569
|
+
} catch (error) {
|
|
570
|
+
throw new Error(`Failed to parse theme ${label}: ${error}`);
|
|
571
|
+
}
|
|
572
|
+
return parseThemeJson(label, json);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
function loadThemeJson(name: string): ThemeJson {
|
|
576
|
+
const builtinThemes = getBuiltinThemes();
|
|
577
|
+
if (name in builtinThemes) {
|
|
578
|
+
return builtinThemes[name];
|
|
579
|
+
}
|
|
580
|
+
const registeredTheme = registeredThemes.get(name);
|
|
581
|
+
if (registeredTheme?.sourcePath) {
|
|
582
|
+
const content = fs.readFileSync(registeredTheme.sourcePath, "utf-8");
|
|
583
|
+
return parseThemeJsonContent(registeredTheme.sourcePath, content);
|
|
584
|
+
}
|
|
585
|
+
if (registeredTheme) {
|
|
586
|
+
throw new Error(`Theme "${name}" does not have a source path for export`);
|
|
587
|
+
}
|
|
588
|
+
const customThemesDir = getCustomThemesDir();
|
|
589
|
+
const themePath = path.join(customThemesDir, `${name}.json`);
|
|
590
|
+
if (!fs.existsSync(themePath)) {
|
|
591
|
+
throw new Error(`Theme not found: ${name}`);
|
|
592
|
+
}
|
|
593
|
+
const content = fs.readFileSync(themePath, "utf-8");
|
|
594
|
+
return parseThemeJsonContent(name, content);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
function createTheme(themeJson: ThemeJson, mode?: ColorMode, sourcePath?: string): Theme {
|
|
598
|
+
const colorMode = mode ?? (getCapabilities().trueColor ? "truecolor" : "256color");
|
|
599
|
+
const resolvedColors = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);
|
|
600
|
+
const fgColors: Record<ThemeColor, string | number> = {} as Record<ThemeColor, string | number>;
|
|
601
|
+
const bgColors: Record<ThemeBg, string | number> = {} as Record<ThemeBg, string | number>;
|
|
602
|
+
const bgColorKeys: Set<string> = new Set([
|
|
603
|
+
"selectedBg",
|
|
604
|
+
"userMessageBg",
|
|
605
|
+
"customMessageBg",
|
|
606
|
+
"toolPendingBg",
|
|
607
|
+
"toolSuccessBg",
|
|
608
|
+
"toolErrorBg",
|
|
609
|
+
]);
|
|
610
|
+
for (const [key, value] of Object.entries(resolvedColors)) {
|
|
611
|
+
if (bgColorKeys.has(key)) {
|
|
612
|
+
bgColors[key as ThemeBg] = value;
|
|
613
|
+
} else {
|
|
614
|
+
fgColors[key as ThemeColor] = value;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
return new Theme(fgColors, bgColors, colorMode, {
|
|
618
|
+
name: themeJson.name,
|
|
619
|
+
sourcePath,
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
export function loadThemeFromPath(themePath: string, mode?: ColorMode): Theme {
|
|
624
|
+
const content = fs.readFileSync(themePath, "utf-8");
|
|
625
|
+
const themeJson = parseThemeJsonContent(themePath, content);
|
|
626
|
+
return createTheme(themeJson, mode, themePath);
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
function loadTheme(name: string, mode?: ColorMode): Theme {
|
|
630
|
+
const registeredTheme = registeredThemes.get(name);
|
|
631
|
+
if (registeredTheme) {
|
|
632
|
+
return registeredTheme;
|
|
633
|
+
}
|
|
634
|
+
const themeJson = loadThemeJson(name);
|
|
635
|
+
return createTheme(themeJson, mode);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
export function getThemeByName(name: string): Theme | undefined {
|
|
639
|
+
try {
|
|
640
|
+
return loadTheme(name);
|
|
641
|
+
} catch {
|
|
642
|
+
return undefined;
|
|
643
|
+
}
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
export type TerminalTheme = "dark" | "light";
|
|
647
|
+
|
|
648
|
+
export function parseAutoThemeSetting(
|
|
649
|
+
themeSetting: string | undefined,
|
|
650
|
+
): { lightTheme: string; darkTheme: string } | undefined {
|
|
651
|
+
if (!themeSetting) return undefined;
|
|
652
|
+
const slashIndex = themeSetting.indexOf("/");
|
|
653
|
+
if (slashIndex === -1 || themeSetting.indexOf("/", slashIndex + 1) !== -1) {
|
|
654
|
+
return undefined;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const lightTheme = themeSetting.slice(0, slashIndex).trim();
|
|
658
|
+
const darkTheme = themeSetting.slice(slashIndex + 1).trim();
|
|
659
|
+
if (!lightTheme || !darkTheme) {
|
|
660
|
+
return undefined;
|
|
661
|
+
}
|
|
662
|
+
return { lightTheme, darkTheme };
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
export function resolveThemeSetting(
|
|
666
|
+
themeSetting: string | undefined,
|
|
667
|
+
terminalTheme: TerminalTheme,
|
|
668
|
+
): string | undefined {
|
|
669
|
+
const autoTheme = parseAutoThemeSetting(themeSetting);
|
|
670
|
+
if (autoTheme) {
|
|
671
|
+
return terminalTheme === "light" ? autoTheme.lightTheme : autoTheme.darkTheme;
|
|
672
|
+
}
|
|
673
|
+
if (themeSetting?.includes("/")) return undefined;
|
|
674
|
+
if (typeof themeSetting === "string") return themeSetting;
|
|
675
|
+
return undefined;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
export interface TerminalThemeDetection {
|
|
679
|
+
theme: TerminalTheme;
|
|
680
|
+
source: "terminal background" | "COLORFGBG" | "fallback";
|
|
681
|
+
detail: string;
|
|
682
|
+
confidence: "high" | "low";
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
export interface TerminalThemeDetectionOptions {
|
|
686
|
+
env?: NodeJS.ProcessEnv;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
export interface TerminalBackgroundThemeDetector {
|
|
690
|
+
queryTerminalBackgroundColor({ timeoutMs }: { timeoutMs: number }): Promise<RgbColor | undefined>;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
export interface TerminalAutoThemeDetector extends TerminalBackgroundThemeDetector {
|
|
694
|
+
queryTerminalColorScheme?({ timeoutMs }: { timeoutMs: number }): Promise<TerminalTheme | undefined>;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
export interface TerminalBackgroundThemeDetectionOptions extends TerminalThemeDetectionOptions {
|
|
698
|
+
ui: TerminalBackgroundThemeDetector;
|
|
699
|
+
timeoutMs: number;
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
export interface TerminalAutoThemeDetectionOptions extends TerminalThemeDetectionOptions {
|
|
703
|
+
ui: TerminalAutoThemeDetector;
|
|
704
|
+
timeoutMs: number;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
function getColorFgBgBackgroundIndex(colorfgbg: string): number | undefined {
|
|
708
|
+
const parts = colorfgbg.split(";");
|
|
709
|
+
for (let i = parts.length - 1; i >= 0; i--) {
|
|
710
|
+
const bg = parseInt(parts[i].trim(), 10);
|
|
711
|
+
if (Number.isInteger(bg) && bg >= 0 && bg <= 255) {
|
|
712
|
+
return bg;
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return undefined;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
function getRgbColorLuminance({ r, g, b }: RgbColor): number {
|
|
719
|
+
const toLinear = (channel: number) => {
|
|
720
|
+
const value = channel / 255;
|
|
721
|
+
return value <= 0.03928 ? value / 12.92 : ((value + 0.055) / 1.055) ** 2.4;
|
|
722
|
+
};
|
|
723
|
+
return 0.2126 * toLinear(r) + 0.7152 * toLinear(g) + 0.0722 * toLinear(b);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
function getAnsiColorLuminance(index: number): number {
|
|
727
|
+
return getRgbColorLuminance(hexToRgb(ansi256ToHex(index)));
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
export function getThemeForRgbColor(rgb: RgbColor): TerminalTheme {
|
|
731
|
+
return getRgbColorLuminance(rgb) >= 0.5 ? "light" : "dark";
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
export function detectTerminalBackgroundFromEnv(options: TerminalThemeDetectionOptions = {}): TerminalThemeDetection {
|
|
735
|
+
const env = options.env ?? process.env;
|
|
736
|
+
const colorfgbg = env.COLORFGBG || "";
|
|
737
|
+
const bg = getColorFgBgBackgroundIndex(colorfgbg);
|
|
738
|
+
if (bg !== undefined) {
|
|
739
|
+
return {
|
|
740
|
+
theme: getAnsiColorLuminance(bg) >= 0.5 ? "light" : "dark",
|
|
741
|
+
source: "COLORFGBG",
|
|
742
|
+
detail: `background color index ${bg}`,
|
|
743
|
+
confidence: "high",
|
|
744
|
+
};
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
return {
|
|
748
|
+
theme: "dark",
|
|
749
|
+
source: "fallback",
|
|
750
|
+
detail: "no terminal background hint found",
|
|
751
|
+
confidence: "low",
|
|
752
|
+
};
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
export async function detectTerminalBackgroundTheme({
|
|
756
|
+
ui,
|
|
757
|
+
timeoutMs,
|
|
758
|
+
env,
|
|
759
|
+
}: TerminalBackgroundThemeDetectionOptions): Promise<TerminalThemeDetection> {
|
|
760
|
+
try {
|
|
761
|
+
const rgb = await ui.queryTerminalBackgroundColor({ timeoutMs });
|
|
762
|
+
if (rgb) {
|
|
763
|
+
return {
|
|
764
|
+
theme: getThemeForRgbColor(rgb),
|
|
765
|
+
source: "terminal background",
|
|
766
|
+
detail: `OSC 11 background rgb(${rgb.r}, ${rgb.g}, ${rgb.b})`,
|
|
767
|
+
confidence: "high",
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
} catch {
|
|
771
|
+
// Fall back to environment-based detection when the terminal query fails.
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
return detectTerminalBackgroundFromEnv({ env });
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
export async function detectTerminalThemeForAuto({
|
|
778
|
+
ui,
|
|
779
|
+
timeoutMs,
|
|
780
|
+
env,
|
|
781
|
+
}: TerminalAutoThemeDetectionOptions): Promise<TerminalTheme> {
|
|
782
|
+
try {
|
|
783
|
+
const colorScheme = await ui.queryTerminalColorScheme?.({ timeoutMs });
|
|
784
|
+
if (colorScheme) return colorScheme;
|
|
785
|
+
} catch {
|
|
786
|
+
// Fall back to OSC 11 / COLORFGBG detection when color-scheme DSR is unsupported.
|
|
787
|
+
}
|
|
788
|
+
return (await detectTerminalBackgroundTheme({ ui, timeoutMs, env })).theme;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
export function getDefaultTheme(): string {
|
|
792
|
+
return detectTerminalBackgroundFromEnv().theme;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// ============================================================================
|
|
796
|
+
// Global Theme Instance
|
|
797
|
+
// ============================================================================
|
|
798
|
+
|
|
799
|
+
// Use globalThis to share theme across module loaders (tsx + jiti in dev mode)
|
|
800
|
+
const THEME_KEY = Symbol.for("@earendil-works/pi-coding-agent:theme");
|
|
801
|
+
const THEME_KEY_OLD = Symbol.for("@mariozechner/pi-coding-agent:theme");
|
|
802
|
+
|
|
803
|
+
// Export theme as a getter that reads from globalThis
|
|
804
|
+
// This ensures all module instances (tsx, jiti) see the same theme
|
|
805
|
+
export const theme: Theme = new Proxy({} as Theme, {
|
|
806
|
+
get(_target, prop) {
|
|
807
|
+
const t = (globalThis as Record<symbol, Theme>)[THEME_KEY];
|
|
808
|
+
if (!t) throw new Error("Theme not initialized. Call initTheme() first.");
|
|
809
|
+
return (t as unknown as Record<string | symbol, unknown>)[prop];
|
|
810
|
+
},
|
|
811
|
+
});
|
|
812
|
+
|
|
813
|
+
function setGlobalTheme(t: Theme): void {
|
|
814
|
+
(globalThis as Record<symbol, Theme>)[THEME_KEY] = t;
|
|
815
|
+
(globalThis as Record<symbol, Theme>)[THEME_KEY_OLD] = t;
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
let currentThemeName: string | undefined;
|
|
819
|
+
let themeWatcher: fs.FSWatcher | undefined;
|
|
820
|
+
let themeReloadTimer: NodeJS.Timeout | undefined;
|
|
821
|
+
let onThemeChangeCallback: (() => void) | undefined;
|
|
822
|
+
const registeredThemes = new Map<string, Theme>();
|
|
823
|
+
|
|
824
|
+
export function setRegisteredThemes(themes: Theme[]): void {
|
|
825
|
+
registeredThemes.clear();
|
|
826
|
+
for (const theme of themes) {
|
|
827
|
+
if (theme.name) {
|
|
828
|
+
assertThemeNameIsValid(theme.name);
|
|
829
|
+
registeredThemes.set(theme.name, theme);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
export function initTheme(themeName?: string, enableWatcher: boolean = false): void {
|
|
835
|
+
const name = themeName ?? getDefaultTheme();
|
|
836
|
+
currentThemeName = name;
|
|
837
|
+
try {
|
|
838
|
+
setGlobalTheme(loadTheme(name));
|
|
839
|
+
if (enableWatcher) {
|
|
840
|
+
startThemeWatcher();
|
|
841
|
+
}
|
|
842
|
+
} catch (_error) {
|
|
843
|
+
// Theme is invalid - fall back to dark theme silently
|
|
844
|
+
currentThemeName = "dark";
|
|
845
|
+
setGlobalTheme(loadTheme("dark"));
|
|
846
|
+
// Don't start watcher for fallback theme
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
export function setTheme(name: string, enableWatcher: boolean = false): { success: boolean; error?: string } {
|
|
851
|
+
currentThemeName = name;
|
|
852
|
+
try {
|
|
853
|
+
setGlobalTheme(loadTheme(name));
|
|
854
|
+
if (enableWatcher) {
|
|
855
|
+
startThemeWatcher();
|
|
856
|
+
}
|
|
857
|
+
if (onThemeChangeCallback) {
|
|
858
|
+
onThemeChangeCallback();
|
|
859
|
+
}
|
|
860
|
+
return { success: true };
|
|
861
|
+
} catch (error) {
|
|
862
|
+
// Theme is invalid - fall back to dark theme
|
|
863
|
+
currentThemeName = "dark";
|
|
864
|
+
setGlobalTheme(loadTheme("dark"));
|
|
865
|
+
// Don't start watcher for fallback theme
|
|
866
|
+
return {
|
|
867
|
+
success: false,
|
|
868
|
+
error: error instanceof Error ? error.message : String(error),
|
|
869
|
+
};
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
export function setThemeInstance(themeInstance: Theme): void {
|
|
874
|
+
setGlobalTheme(themeInstance);
|
|
875
|
+
currentThemeName = "<in-memory>";
|
|
876
|
+
stopThemeWatcher(); // Can't watch a direct instance
|
|
877
|
+
if (onThemeChangeCallback) {
|
|
878
|
+
onThemeChangeCallback();
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
export function onThemeChange(callback: () => void): void {
|
|
883
|
+
onThemeChangeCallback = callback;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
function startThemeWatcher(): void {
|
|
887
|
+
stopThemeWatcher();
|
|
888
|
+
|
|
889
|
+
// Only watch if it's a custom theme (not built-in)
|
|
890
|
+
if (!currentThemeName || currentThemeName === "dark" || currentThemeName === "light") {
|
|
891
|
+
return;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
const customThemesDir = getCustomThemesDir();
|
|
895
|
+
const watchedThemeName = currentThemeName;
|
|
896
|
+
const watchedFileName = `${watchedThemeName}.json`;
|
|
897
|
+
const themeFile = path.join(customThemesDir, watchedFileName);
|
|
898
|
+
|
|
899
|
+
// Only watch if the file exists
|
|
900
|
+
if (!fs.existsSync(themeFile)) {
|
|
901
|
+
return;
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
const scheduleReload = () => {
|
|
905
|
+
if (themeReloadTimer) {
|
|
906
|
+
clearTimeout(themeReloadTimer);
|
|
907
|
+
}
|
|
908
|
+
themeReloadTimer = setTimeout(() => {
|
|
909
|
+
themeReloadTimer = undefined;
|
|
910
|
+
|
|
911
|
+
// Ignore stale timers after switching themes or stopping the watcher
|
|
912
|
+
if (currentThemeName !== watchedThemeName) {
|
|
913
|
+
return;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
// Keep the last successfully loaded theme active if the file is temporarily missing
|
|
917
|
+
if (!fs.existsSync(themeFile)) {
|
|
918
|
+
return;
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
try {
|
|
922
|
+
// Reload the theme from disk and refresh the registry cache
|
|
923
|
+
const reloadedTheme = loadThemeFromPath(themeFile);
|
|
924
|
+
registeredThemes.set(watchedThemeName, reloadedTheme);
|
|
925
|
+
setGlobalTheme(reloadedTheme);
|
|
926
|
+
// Notify callback (to invalidate UI)
|
|
927
|
+
if (onThemeChangeCallback) {
|
|
928
|
+
onThemeChangeCallback();
|
|
929
|
+
}
|
|
930
|
+
} catch (_error) {
|
|
931
|
+
// Ignore errors (file might be in invalid state while being edited)
|
|
932
|
+
}
|
|
933
|
+
}, 100);
|
|
934
|
+
};
|
|
935
|
+
|
|
936
|
+
themeWatcher =
|
|
937
|
+
watchWithErrorHandler(
|
|
938
|
+
customThemesDir,
|
|
939
|
+
(_eventType, filename) => {
|
|
940
|
+
if (currentThemeName !== watchedThemeName) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
if (!filename) {
|
|
944
|
+
scheduleReload();
|
|
945
|
+
return;
|
|
946
|
+
}
|
|
947
|
+
if (filename !== watchedFileName) {
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
scheduleReload();
|
|
951
|
+
},
|
|
952
|
+
() => {
|
|
953
|
+
closeWatcher(themeWatcher);
|
|
954
|
+
themeWatcher = undefined;
|
|
955
|
+
},
|
|
956
|
+
) ?? undefined;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
export function stopThemeWatcher(): void {
|
|
960
|
+
if (themeReloadTimer) {
|
|
961
|
+
clearTimeout(themeReloadTimer);
|
|
962
|
+
themeReloadTimer = undefined;
|
|
963
|
+
}
|
|
964
|
+
closeWatcher(themeWatcher);
|
|
965
|
+
themeWatcher = undefined;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
// ============================================================================
|
|
969
|
+
// HTML Export Helpers
|
|
970
|
+
// ============================================================================
|
|
971
|
+
|
|
972
|
+
/**
|
|
973
|
+
* Convert a 256-color index to hex string.
|
|
974
|
+
* Indices 0-15: basic colors (approximate)
|
|
975
|
+
* Indices 16-231: 6x6x6 color cube
|
|
976
|
+
* Indices 232-255: grayscale ramp
|
|
977
|
+
*/
|
|
978
|
+
function ansi256ToHex(index: number): string {
|
|
979
|
+
// Basic colors (0-15) - approximate common terminal values
|
|
980
|
+
const basicColors = [
|
|
981
|
+
"#000000",
|
|
982
|
+
"#800000",
|
|
983
|
+
"#008000",
|
|
984
|
+
"#808000",
|
|
985
|
+
"#000080",
|
|
986
|
+
"#800080",
|
|
987
|
+
"#008080",
|
|
988
|
+
"#c0c0c0",
|
|
989
|
+
"#808080",
|
|
990
|
+
"#ff0000",
|
|
991
|
+
"#00ff00",
|
|
992
|
+
"#ffff00",
|
|
993
|
+
"#0000ff",
|
|
994
|
+
"#ff00ff",
|
|
995
|
+
"#00ffff",
|
|
996
|
+
"#ffffff",
|
|
997
|
+
];
|
|
998
|
+
if (index < 16) {
|
|
999
|
+
return basicColors[index];
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
// Color cube (16-231): 6x6x6 = 216 colors
|
|
1003
|
+
if (index < 232) {
|
|
1004
|
+
const cubeIndex = index - 16;
|
|
1005
|
+
const r = Math.floor(cubeIndex / 36);
|
|
1006
|
+
const g = Math.floor((cubeIndex % 36) / 6);
|
|
1007
|
+
const b = cubeIndex % 6;
|
|
1008
|
+
const toHex = (n: number) => (n === 0 ? 0 : 55 + n * 40).toString(16).padStart(2, "0");
|
|
1009
|
+
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
// Grayscale (232-255): 24 shades
|
|
1013
|
+
const gray = 8 + (index - 232) * 10;
|
|
1014
|
+
const grayHex = gray.toString(16).padStart(2, "0");
|
|
1015
|
+
return `#${grayHex}${grayHex}${grayHex}`;
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
/**
|
|
1019
|
+
* Get resolved theme colors as CSS-compatible hex strings.
|
|
1020
|
+
* Used by HTML export to generate CSS custom properties.
|
|
1021
|
+
*/
|
|
1022
|
+
export function getResolvedThemeColors(themeName?: string): Record<string, string> {
|
|
1023
|
+
const name = themeName ?? currentThemeName ?? getDefaultTheme();
|
|
1024
|
+
const isLight = name === "light";
|
|
1025
|
+
const themeJson = loadThemeJson(name);
|
|
1026
|
+
const resolved = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);
|
|
1027
|
+
|
|
1028
|
+
// Default text color for empty values (terminal uses default fg color)
|
|
1029
|
+
const defaultText = isLight ? "#000000" : "#e5e5e7";
|
|
1030
|
+
|
|
1031
|
+
const cssColors: Record<string, string> = {};
|
|
1032
|
+
for (const [key, value] of Object.entries(resolved)) {
|
|
1033
|
+
if (typeof value === "number") {
|
|
1034
|
+
cssColors[key] = ansi256ToHex(value);
|
|
1035
|
+
} else if (value === "") {
|
|
1036
|
+
// Empty means default terminal color - use sensible fallback for HTML
|
|
1037
|
+
cssColors[key] = defaultText;
|
|
1038
|
+
} else {
|
|
1039
|
+
cssColors[key] = value;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
return cssColors;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* Check if a theme is a "light" theme (for CSS that needs light/dark variants).
|
|
1047
|
+
*/
|
|
1048
|
+
export function isLightTheme(themeName?: string): boolean {
|
|
1049
|
+
// Currently just check the name - could be extended to analyze colors
|
|
1050
|
+
return themeName === "light";
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* Get explicit export colors from theme JSON, if specified.
|
|
1055
|
+
* Returns undefined for each color that isn't explicitly set.
|
|
1056
|
+
*/
|
|
1057
|
+
export function getThemeExportColors(themeName?: string): {
|
|
1058
|
+
pageBg?: string;
|
|
1059
|
+
cardBg?: string;
|
|
1060
|
+
infoBg?: string;
|
|
1061
|
+
} {
|
|
1062
|
+
const name = themeName ?? currentThemeName ?? getDefaultTheme();
|
|
1063
|
+
try {
|
|
1064
|
+
const themeJson = loadThemeJson(name);
|
|
1065
|
+
const exportSection = themeJson.export;
|
|
1066
|
+
if (!exportSection) return {};
|
|
1067
|
+
|
|
1068
|
+
const vars = themeJson.vars ?? {};
|
|
1069
|
+
const resolve = (value: ColorValue | undefined): string | undefined => {
|
|
1070
|
+
if (value === undefined) return undefined;
|
|
1071
|
+
const resolved = resolveVarRefs(value, vars);
|
|
1072
|
+
if (typeof resolved === "number") return ansi256ToHex(resolved);
|
|
1073
|
+
if (resolved === "") return undefined;
|
|
1074
|
+
return resolved;
|
|
1075
|
+
};
|
|
1076
|
+
|
|
1077
|
+
return {
|
|
1078
|
+
pageBg: resolve(exportSection.pageBg),
|
|
1079
|
+
cardBg: resolve(exportSection.cardBg),
|
|
1080
|
+
infoBg: resolve(exportSection.infoBg),
|
|
1081
|
+
};
|
|
1082
|
+
} catch {
|
|
1083
|
+
return {};
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
// ============================================================================
|
|
1088
|
+
// TUI Helpers
|
|
1089
|
+
// ============================================================================
|
|
1090
|
+
|
|
1091
|
+
type CliHighlightTheme = Record<string, (s: string) => string>;
|
|
1092
|
+
|
|
1093
|
+
let cachedHighlightThemeFor: Theme | undefined;
|
|
1094
|
+
let cachedCliHighlightTheme: CliHighlightTheme | undefined;
|
|
1095
|
+
|
|
1096
|
+
function buildCliHighlightTheme(t: Theme): CliHighlightTheme {
|
|
1097
|
+
return {
|
|
1098
|
+
keyword: (s: string) => t.fg("syntaxKeyword", s),
|
|
1099
|
+
built_in: (s: string) => t.fg("syntaxType", s),
|
|
1100
|
+
literal: (s: string) => t.fg("syntaxNumber", s),
|
|
1101
|
+
number: (s: string) => t.fg("syntaxNumber", s),
|
|
1102
|
+
regexp: (s: string) => t.fg("syntaxString", s),
|
|
1103
|
+
string: (s: string) => t.fg("syntaxString", s),
|
|
1104
|
+
comment: (s: string) => t.fg("syntaxComment", s),
|
|
1105
|
+
doctag: (s: string) => t.fg("syntaxComment", s),
|
|
1106
|
+
meta: (s: string) => t.fg("muted", s),
|
|
1107
|
+
function: (s: string) => t.fg("syntaxFunction", s),
|
|
1108
|
+
title: (s: string) => t.fg("syntaxFunction", s),
|
|
1109
|
+
class: (s: string) => t.fg("syntaxType", s),
|
|
1110
|
+
type: (s: string) => t.fg("syntaxType", s),
|
|
1111
|
+
tag: (s: string) => t.fg("syntaxPunctuation", s),
|
|
1112
|
+
name: (s: string) => t.fg("syntaxKeyword", s),
|
|
1113
|
+
attr: (s: string) => t.fg("syntaxVariable", s),
|
|
1114
|
+
variable: (s: string) => t.fg("syntaxVariable", s),
|
|
1115
|
+
params: (s: string) => t.fg("syntaxVariable", s),
|
|
1116
|
+
operator: (s: string) => t.fg("syntaxOperator", s),
|
|
1117
|
+
punctuation: (s: string) => t.fg("syntaxPunctuation", s),
|
|
1118
|
+
emphasis: (s: string) => t.italic(s),
|
|
1119
|
+
strong: (s: string) => t.bold(s),
|
|
1120
|
+
link: (s: string) => t.underline(s),
|
|
1121
|
+
addition: (s: string) => t.fg("toolDiffAdded", s),
|
|
1122
|
+
deletion: (s: string) => t.fg("toolDiffRemoved", s),
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
function getCliHighlightTheme(t: Theme): CliHighlightTheme {
|
|
1127
|
+
if (cachedHighlightThemeFor !== t || !cachedCliHighlightTheme) {
|
|
1128
|
+
cachedHighlightThemeFor = t;
|
|
1129
|
+
cachedCliHighlightTheme = buildCliHighlightTheme(t);
|
|
1130
|
+
}
|
|
1131
|
+
return cachedCliHighlightTheme;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Highlight code with syntax coloring based on file extension or language.
|
|
1136
|
+
* Returns array of highlighted lines.
|
|
1137
|
+
*/
|
|
1138
|
+
export function highlightCode(code: string, lang?: string): string[] {
|
|
1139
|
+
// Validate language before highlighting to avoid stderr spam from cli-highlight
|
|
1140
|
+
const validLang = lang && supportsLanguage(lang) ? lang : undefined;
|
|
1141
|
+
// Skip highlighting when no valid language is specified. cli-highlight's
|
|
1142
|
+
// auto-detection is unreliable and can misidentify prose as AppleScript,
|
|
1143
|
+
// LiveCodeServer, etc., coloring random English words as keywords.
|
|
1144
|
+
if (!validLang) {
|
|
1145
|
+
return code.split("\n").map((line) => theme.fg("mdCodeBlock", line));
|
|
1146
|
+
}
|
|
1147
|
+
const opts = {
|
|
1148
|
+
language: validLang,
|
|
1149
|
+
ignoreIllegals: true,
|
|
1150
|
+
theme: getCliHighlightTheme(theme),
|
|
1151
|
+
};
|
|
1152
|
+
try {
|
|
1153
|
+
return highlight(code, opts).split("\n");
|
|
1154
|
+
} catch {
|
|
1155
|
+
return code.split("\n");
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
/**
|
|
1160
|
+
* Get language identifier from file path extension.
|
|
1161
|
+
*/
|
|
1162
|
+
export function getLanguageFromPath(filePath: string): string | undefined {
|
|
1163
|
+
const ext = filePath.split(".").pop()?.toLowerCase();
|
|
1164
|
+
if (!ext) return undefined;
|
|
1165
|
+
|
|
1166
|
+
const extToLang: Record<string, string> = {
|
|
1167
|
+
ts: "typescript",
|
|
1168
|
+
tsx: "typescript",
|
|
1169
|
+
js: "javascript",
|
|
1170
|
+
jsx: "javascript",
|
|
1171
|
+
mjs: "javascript",
|
|
1172
|
+
cjs: "javascript",
|
|
1173
|
+
py: "python",
|
|
1174
|
+
rb: "ruby",
|
|
1175
|
+
rs: "rust",
|
|
1176
|
+
go: "go",
|
|
1177
|
+
java: "java",
|
|
1178
|
+
kt: "kotlin",
|
|
1179
|
+
swift: "swift",
|
|
1180
|
+
c: "c",
|
|
1181
|
+
h: "c",
|
|
1182
|
+
cpp: "cpp",
|
|
1183
|
+
cc: "cpp",
|
|
1184
|
+
cxx: "cpp",
|
|
1185
|
+
hpp: "cpp",
|
|
1186
|
+
cs: "csharp",
|
|
1187
|
+
php: "php",
|
|
1188
|
+
sh: "bash",
|
|
1189
|
+
bash: "bash",
|
|
1190
|
+
zsh: "bash",
|
|
1191
|
+
fish: "fish",
|
|
1192
|
+
ps1: "powershell",
|
|
1193
|
+
sql: "sql",
|
|
1194
|
+
html: "html",
|
|
1195
|
+
htm: "html",
|
|
1196
|
+
css: "css",
|
|
1197
|
+
scss: "scss",
|
|
1198
|
+
sass: "sass",
|
|
1199
|
+
less: "less",
|
|
1200
|
+
json: "json",
|
|
1201
|
+
yaml: "yaml",
|
|
1202
|
+
yml: "yaml",
|
|
1203
|
+
toml: "toml",
|
|
1204
|
+
xml: "xml",
|
|
1205
|
+
md: "markdown",
|
|
1206
|
+
markdown: "markdown",
|
|
1207
|
+
dockerfile: "dockerfile",
|
|
1208
|
+
makefile: "makefile",
|
|
1209
|
+
cmake: "cmake",
|
|
1210
|
+
lua: "lua",
|
|
1211
|
+
perl: "perl",
|
|
1212
|
+
r: "r",
|
|
1213
|
+
scala: "scala",
|
|
1214
|
+
clj: "clojure",
|
|
1215
|
+
ex: "elixir",
|
|
1216
|
+
exs: "elixir",
|
|
1217
|
+
erl: "erlang",
|
|
1218
|
+
hs: "haskell",
|
|
1219
|
+
ml: "ocaml",
|
|
1220
|
+
vim: "vim",
|
|
1221
|
+
graphql: "graphql",
|
|
1222
|
+
proto: "protobuf",
|
|
1223
|
+
tf: "hcl",
|
|
1224
|
+
hcl: "hcl",
|
|
1225
|
+
};
|
|
1226
|
+
|
|
1227
|
+
return extToLang[ext];
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
export function getMarkdownTheme(): MarkdownTheme {
|
|
1231
|
+
return {
|
|
1232
|
+
heading: (text: string) => theme.fg("mdHeading", text),
|
|
1233
|
+
link: (text: string) => theme.fg("mdLink", text),
|
|
1234
|
+
linkUrl: (text: string) => theme.fg("mdLinkUrl", text),
|
|
1235
|
+
code: (text: string) => theme.fg("mdCode", text),
|
|
1236
|
+
codeBlock: (text: string) => theme.fg("mdCodeBlock", text),
|
|
1237
|
+
codeBlockBorder: (text: string) => theme.fg("mdCodeBlockBorder", text),
|
|
1238
|
+
quote: (text: string) => theme.fg("mdQuote", text),
|
|
1239
|
+
quoteBorder: (text: string) => theme.fg("mdQuoteBorder", text),
|
|
1240
|
+
hr: (text: string) => theme.fg("mdHr", text),
|
|
1241
|
+
listBullet: (text: string) => theme.fg("mdListBullet", text),
|
|
1242
|
+
bold: (text: string) => theme.bold(text),
|
|
1243
|
+
italic: (text: string) => theme.italic(text),
|
|
1244
|
+
underline: (text: string) => theme.underline(text),
|
|
1245
|
+
strikethrough: (text: string) => chalk.strikethrough(text),
|
|
1246
|
+
highlightCode: (code: string, lang?: string): string[] => {
|
|
1247
|
+
// Validate language before highlighting to avoid stderr spam from cli-highlight
|
|
1248
|
+
const validLang = lang && supportsLanguage(lang) ? lang : undefined;
|
|
1249
|
+
// Skip highlighting when no valid language is specified. cli-highlight's
|
|
1250
|
+
// auto-detection is unreliable and can misidentify prose as AppleScript,
|
|
1251
|
+
// LiveCodeServer, etc., coloring random English words as keywords.
|
|
1252
|
+
if (!validLang) {
|
|
1253
|
+
return code.split("\n").map((line) => theme.fg("mdCodeBlock", line));
|
|
1254
|
+
}
|
|
1255
|
+
const opts = {
|
|
1256
|
+
language: validLang,
|
|
1257
|
+
ignoreIllegals: true,
|
|
1258
|
+
theme: getCliHighlightTheme(theme),
|
|
1259
|
+
};
|
|
1260
|
+
try {
|
|
1261
|
+
return highlight(code, opts).split("\n");
|
|
1262
|
+
} catch {
|
|
1263
|
+
return code.split("\n").map((line) => theme.fg("mdCodeBlock", line));
|
|
1264
|
+
}
|
|
1265
|
+
},
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
export function getSelectListTheme(): SelectListTheme {
|
|
1270
|
+
return {
|
|
1271
|
+
selectedPrefix: (text: string) => theme.fg("accent", text),
|
|
1272
|
+
selectedText: (text: string) => theme.fg("accent", text),
|
|
1273
|
+
description: (text: string) => theme.fg("muted", text),
|
|
1274
|
+
scrollInfo: (text: string) => theme.fg("muted", text),
|
|
1275
|
+
noMatch: (text: string) => theme.fg("muted", text),
|
|
1276
|
+
};
|
|
1277
|
+
}
|
|
1278
|
+
|
|
1279
|
+
export function getEditorTheme(): EditorTheme {
|
|
1280
|
+
return {
|
|
1281
|
+
borderColor: (text: string) => theme.fg("borderMuted", text),
|
|
1282
|
+
selectList: getSelectListTheme(),
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
export function getSettingsListTheme(): SettingsListTheme {
|
|
1287
|
+
return {
|
|
1288
|
+
label: (text: string, selected: boolean) => (selected ? theme.fg("accent", text) : text),
|
|
1289
|
+
value: (text: string, selected: boolean) => (selected ? theme.fg("accent", text) : theme.fg("muted", text)),
|
|
1290
|
+
description: (text: string) => theme.fg("dim", text),
|
|
1291
|
+
cursor: theme.fg("accent", "→ "),
|
|
1292
|
+
hint: (text: string) => theme.fg("dim", text),
|
|
1293
|
+
};
|
|
1294
|
+
}
|