pi-namespace-patch 1.0.2-namespace.2 → 1.0.4-namespace.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/README.md +8 -8
- package/dist/bundle/chunks/{anthropic-messages-MVG2FL56.js → anthropic-messages-Y22YDKSW.js} +1 -1
- package/dist/bundle/chunks/azure-openai-responses-YJDJIIDQ.js +2 -0
- package/dist/bundle/chunks/chunk-22CYIUS4.js +2 -0
- package/dist/bundle/chunks/{chunk-WCQZGZ6I.js → chunk-2QSWSXFK.js} +4 -4
- package/dist/bundle/chunks/{chunk-6FX7UEPL.js → chunk-64GOPQSC.js} +6 -4
- package/dist/bundle/chunks/{chunk-OSKPX3Z5.js → chunk-C47CLQZK.js} +1 -1
- package/dist/bundle/chunks/{chunk-OLBCNJCL.js → chunk-ERIW6MDO.js} +51 -47
- package/dist/bundle/chunks/chunk-F4TCZWQO.js +20 -0
- package/dist/bundle/chunks/{chunk-2KAZSACP.js → chunk-FKGBRPJC.js} +1 -1
- package/dist/bundle/chunks/{chunk-IKZJX7ZT.js → chunk-HQHD6PZI.js} +1 -1
- package/dist/bundle/chunks/chunk-KJUDFE6Y.js +11 -0
- package/dist/bundle/chunks/{chunk-G7EDXK4D.js → chunk-TAOL3JFA.js} +1 -1
- package/dist/bundle/chunks/chunk-VLMAON6X.js +15 -0
- package/dist/bundle/chunks/{chunk-BYB6ZAAQ.js → chunk-WE4MXUQS.js} +1 -1
- package/dist/bundle/chunks/{chunk-ZSI3BL5Q.js → chunk-XXKX4I4Z.js} +1 -1
- package/dist/bundle/chunks/{chunk-SYF2TF6W.js → chunk-YKYP4C4A.js} +9 -6
- package/dist/bundle/chunks/{chunk-DN3QEIXS.js → chunk-YTMEKMOC.js} +1 -1
- package/dist/bundle/chunks/chunk-ZBURYEWF.js +2 -0
- package/dist/bundle/chunks/{cli-KILDDGW3.js → cli-FRW732V6.js} +1 -1
- package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-X5PVWWYJ.js → cloudflare-workers-ai-system-one-NM3JRRWQ.js} +1 -1
- package/dist/bundle/chunks/codemode-worker.js +99 -4
- package/dist/bundle/chunks/{easter-egg-3d-T5FFWIBR.js → easter-egg-3d-GBYHZI2E.js} +1 -1
- package/dist/bundle/chunks/execute-MNHU53Y5.js +484 -0
- package/dist/bundle/chunks/{google-generative-ai-ZOK6CV7D.js → google-generative-ai-XMFHGQC5.js} +1 -1
- package/dist/bundle/chunks/{google-vertex-VKWZQ3AY.js → google-vertex-4XRRNP74.js} +1 -1
- package/dist/bundle/chunks/{mistral-conversations-7DAUEE4N.js → mistral-conversations-Q22M3IBG.js} +1 -1
- package/dist/bundle/chunks/{openai-codex-responses-TC3OK7B4.js → openai-codex-responses-4MYQSO5E.js} +1 -1
- package/dist/bundle/chunks/{openai-completions-GWHGMQ3T.js → openai-completions-OSRCWAAA.js} +1 -1
- package/dist/bundle/chunks/{openai-responses-EZ7FJ2KL.js → openai-responses-UHF3DHNG.js} +1 -1
- package/dist/bundle/chunks/{runtime-D5I2NTIF.js → runtime-FW2HXAJ6.js} +1 -1
- package/dist/bundle/chunks/{typesafe-system-one-A4CZTQWZ.js → typesafe-system-one-PRR5K6CI.js} +1 -1
- package/dist/bundle/chunks/virtual-modules-3HQKVCRO.js +2 -0
- package/dist/bundle/cli-runtime.js +1 -1
- package/dist/bundle/index.js +1 -1
- package/dist/bundle/rpc-entry.js +1 -1
- package/dist/cli/args.d.ts +1 -0
- package/dist/cli/args.d.ts.map +1 -1
- package/dist/cli/args.js +11 -4
- package/dist/cli/args.js.map +1 -1
- package/dist/config.d.ts +18 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +44 -6
- package/dist/config.js.map +1 -1
- package/dist/core/agent-session.d.ts +26 -4
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +47 -14
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/bash-executor.d.ts.map +1 -1
- package/dist/core/bash-executor.js +2 -7
- package/dist/core/bash-executor.js.map +1 -1
- package/dist/core/extensions/types.d.ts +2 -0
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/keybindings.d.ts +4 -4
- package/dist/core/mcp-servers.d.ts +8 -0
- package/dist/core/mcp-servers.d.ts.map +1 -1
- package/dist/core/mcp-servers.js +30 -7
- package/dist/core/mcp-servers.js.map +1 -1
- package/dist/core/model-resolver.js +1 -1
- package/dist/core/model-resolver.js.map +1 -1
- package/dist/core/resource-loader.d.ts +3 -0
- package/dist/core/resource-loader.d.ts.map +1 -1
- package/dist/core/resource-loader.js +4 -3
- package/dist/core/resource-loader.js.map +1 -1
- package/dist/core/sdk.d.ts +9 -4
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +3 -2
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/skills.d.ts +4 -1
- package/dist/core/skills.d.ts.map +1 -1
- package/dist/core/skills.js +6 -1
- package/dist/core/skills.js.map +1 -1
- package/dist/core/system-prompt.d.ts +6 -0
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +9 -4
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/core/tools/output-accumulator.d.ts.map +1 -1
- package/dist/core/tools/output-accumulator.js +4 -10
- package/dist/core/tools/output-accumulator.js.map +1 -1
- package/dist/core/tools/read.d.ts +13 -0
- package/dist/core/tools/read.d.ts.map +1 -1
- package/dist/core/tools/read.js +18 -1
- package/dist/core/tools/read.js.map +1 -1
- package/dist/extensions/codemode/execute.d.ts.map +1 -1
- package/dist/extensions/codemode/execute.js +51 -9
- package/dist/extensions/codemode/execute.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +1 -0
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +9 -2
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +13 -5
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/mcp/resources.d.ts +3 -4
- package/dist/extensions/mcp/resources.d.ts.map +1 -1
- package/dist/extensions/mcp/resources.js +3 -4
- package/dist/extensions/mcp/resources.js.map +1 -1
- package/dist/extensions/mcp/runtime.d.ts +4 -1
- package/dist/extensions/mcp/runtime.d.ts.map +1 -1
- package/dist/extensions/mcp/runtime.js +22 -5
- package/dist/extensions/mcp/runtime.js.map +1 -1
- package/dist/extensions/mcp/tools.d.ts +2 -1
- package/dist/extensions/mcp/tools.d.ts.map +1 -1
- package/dist/extensions/mcp/tools.js +6 -10
- package/dist/extensions/mcp/tools.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +1 -0
- package/dist/main.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +7 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +42 -6
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme.js +1 -0
- package/dist/modes/interactive/theme/theme.js.map +1 -1
- package/dist/utils/output-files.d.ts +15 -0
- package/dist/utils/output-files.d.ts.map +1 -0
- package/dist/utils/output-files.js +30 -0
- package/dist/utils/output-files.js.map +1 -0
- package/dist/utils/syntax-highlight.d.ts.map +1 -1
- package/dist/utils/syntax-highlight.js +6 -1
- package/dist/utils/syntax-highlight.js.map +1 -1
- package/docs/cli.md +15 -3
- package/docs/codemode.md +6 -5
- package/docs/extensions.md +1 -1
- package/docs/keybindings.md +4 -4
- package/docs/mcp.md +3 -1
- package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
- package/examples/extensions/custom-provider-anthropic/package.json +1 -1
- package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
- package/examples/extensions/gondolin/package-lock.json +2 -2
- package/examples/extensions/gondolin/package.json +1 -1
- package/examples/extensions/sandbox/package-lock.json +2 -2
- package/examples/extensions/sandbox/package.json +1 -1
- package/examples/extensions/with-deps/package-lock.json +2 -2
- package/examples/extensions/with-deps/package.json +1 -1
- package/package.json +10 -10
- package/dist/bundle/chunks/azure-openai-responses-7AMFUIWJ.js +0 -2
- package/dist/bundle/chunks/chunk-7JGR3GZN.js +0 -11
- package/dist/bundle/chunks/chunk-OYBSLV7Y.js +0 -16
- package/dist/bundle/chunks/chunk-PDFMCAOZ.js +0 -19
- package/dist/bundle/chunks/chunk-VIV3CWXG.js +0 -2
- package/dist/bundle/chunks/execute-RYVK27GT.js +0 -388
- package/dist/bundle/chunks/virtual-modules-J2M3WAR2.js +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAEN,KAAK,KAAK,EAGV,KAAK,WAAW,EAIhB,KAAK,aAAa,EAKlB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EAEtB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAM/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAMtD,iGAAiG;AACjG,OAAO,KAAK,EAAiC,kBAAkB,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEtG,YAAY,EAAE,kBAAkB,IAAI,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEvE,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,SAAS,CAAC;AAI7E;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,kBAAkB,GAAG,IAA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AED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,KAAK,GAAG,IAAI,CAO3D;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,IAAI,CAExD;AAgFD,wBAAgB,gBAAgB,IAAI,IAAI,CAOvC;AAMD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGjF;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB,CA2BA;AAkDD;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAmBnE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAkExE;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAqChD;AAED,wBAAgB,kBAAkB,IAAI,eAAe,CAQpD;AAED,wBAAgB,cAAc,IAAI,WAAW,CAK5C;AAED,wBAAgB,oBAAoB,IAAI,iBAAiB,CAQxD"}
|
|
@@ -724,6 +724,7 @@ function buildCliHighlightTheme(t) {
|
|
|
724
724
|
number: (s) => t.fg("syntaxNumber", s),
|
|
725
725
|
regexp: (s) => t.fg("syntaxString", s),
|
|
726
726
|
string: (s) => t.fg("syntaxString", s),
|
|
727
|
+
subst: (s) => t.fg("text", s),
|
|
727
728
|
comment: (s) => t.fg("syntaxComment", s),
|
|
728
729
|
doctag: (s) => t.fg("syntaxComment", s),
|
|
729
730
|
meta: (s) => t.fg("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AAU,oBAAoB;IACnC,OAAO;QACN,KAAK,EAAE,CAAC,IAAY,EAAE,QAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACxF,KAAK,EAAE,CAAC,IAAY,EAAE,QAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3G,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;QACpD,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC;QAChC,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;KAC7C,CAAC;AACH,CAAC","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport {\n\tbackgroundAnsi,\n\ttype Color,\n\tcolorToHex,\n\tcolorToOklch,\n\ttype EditorTheme,\n\tforegroundAnsi,\n\tgetTerminalColorMode,\n\tindexedColor,\n\ttype MarkdownTheme,\n\tmixColors,\n\tparseColor,\n\ttype RgbColor,\n\trgbColor,\n\ttype SelectListTheme,\n\ttype SettingsListTheme,\n\tstyleTextWithAnsi,\n\ttype TerminalColorMode,\n\ttype TerminalColors,\n\ttype TextAttributes,\n} from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { getCustomThemesDir, getThemesDir } from \"../../../config.ts\";\nimport type { SourceInfo } from \"../../../core/source-info.ts\";\nimport { closeWatcher, watchWithErrorHandler } from \"../../../utils/fs-watch.ts\";\nimport { highlight, supportsLanguage } from \"../../../utils/syntax-highlight.ts\";\nimport { stripBom } from \"../../../utils/text.ts\";\nimport { generateSystemThemeColors, SYSTEM_THEME_NAME, terminalAppearance } from \"./system-theme.ts\";\n\nexport { SYSTEM_THEME_NAME } from \"./system-theme.ts\";\n\n// ============================================================================\n// Types & Schema\n// ============================================================================\n\n/** The schema that validates this shape lives in `theme-json.ts`; importing the type is free. */\nimport type { ThemeColorValue as ColorValue, ValidatedThemeJson as ThemeJson } from \"./theme-json.ts\";\n\nexport type { ValidatedThemeJson as ThemeJson } from \"./theme-json.ts\";\n\nexport type ThemeJsonValidator = (label: string, json: unknown) => ThemeJson;\n\nlet themeJsonValidator: ThemeJsonValidator | undefined;\n\n/**\n * Install full theme validation. Without it, documents are accepted as-is, which is what built-in\n * themes already do: validating user-authored JSON needs typebox, and a presentation that only uses\n * built-in themes should not pay ~17 MB of module graph for it.\n */\nexport function setThemeJsonValidator(validator: ThemeJsonValidator): void {\n\tthemeJsonValidator = validator;\n}\n\nexport type ThemeColor =\n\t| \"accent\"\n\t| \"border\"\n\t| \"borderAccent\"\n\t| \"borderMuted\"\n\t| \"success\"\n\t| \"error\"\n\t| \"warning\"\n\t| \"muted\"\n\t| \"dim\"\n\t| \"text\"\n\t| \"thinkingText\"\n\t| \"scrollbarTrack\"\n\t| \"scrollbarThumb\"\n\t| \"searchMatchText\"\n\t| \"userMessageText\"\n\t| \"customMessageText\"\n\t| \"customMessageLabel\"\n\t| \"toolTitle\"\n\t| \"toolOutput\"\n\t| \"mdHeading\"\n\t| \"mdLink\"\n\t| \"mdLinkUrl\"\n\t| \"mdCode\"\n\t| \"mdCodeBlock\"\n\t| \"mdCodeBlockBorder\"\n\t| \"mdQuote\"\n\t| \"mdQuoteBorder\"\n\t| \"mdHr\"\n\t| \"mdListBullet\"\n\t| \"toolDiffAdded\"\n\t| \"toolDiffRemoved\"\n\t| \"toolDiffContext\"\n\t| \"syntaxComment\"\n\t| \"syntaxKeyword\"\n\t| \"syntaxFunction\"\n\t| \"syntaxVariable\"\n\t| \"syntaxString\"\n\t| \"syntaxNumber\"\n\t| \"syntaxType\"\n\t| \"syntaxOperator\"\n\t| \"syntaxPunctuation\"\n\t| \"thinkingOff\"\n\t| \"thinkingMinimal\"\n\t| \"thinkingLow\"\n\t| \"thinkingMedium\"\n\t| \"thinkingHigh\"\n\t| \"thinkingXhigh\"\n\t| \"thinkingMax\"\n\t| \"bashMode\";\n\nexport type ThemeBg =\n\t| \"selectedBg\"\n\t| \"searchMatchBg\"\n\t| \"userMessageBg\"\n\t| \"customMessageBg\"\n\t| \"toolPendingBg\"\n\t| \"toolSuccessBg\"\n\t| \"toolErrorBg\";\n\nexport type ThemeToken = ThemeColor | ThemeBg;\n\n/**\n * Tokens are only accepted in their own slot, because \"\" (terminal default) means the default foreground\n * or background depending on the slot. Use `theme.colors[token]` to use a token's color in the other slot.\n */\nexport interface ThemeStyle extends TextAttributes {\n\tfg?: ThemeColor | Color;\n\tbg?: ThemeBg | Color;\n}\n\ntype OptionalThemeColor = \"scrollbarTrack\" | \"scrollbarThumb\" | \"thinkingMax\" | \"searchMatchText\";\ntype OptionalThemeBg = \"searchMatchBg\";\n\n// ============================================================================\n// Color Utilities\n// ============================================================================\n\nfunction resolveVarRefs(\n\tvalue: ColorValue,\n\tvars: Record<string, ColorValue>,\n\tvisited = new Set<string>(),\n): string | number {\n\tif (typeof value === \"number\" || value === \"\" || value.startsWith(\"#\") || /^ok(lch|hsl)\\(/i.test(value)) {\n\t\treturn value;\n\t}\n\tif (visited.has(value)) {\n\t\tthrow new Error(`Circular variable reference detected: ${value}`);\n\t}\n\tif (!(value in vars)) {\n\t\tthrow new Error(`Variable reference not found: ${value}`);\n\t}\n\tvisited.add(value);\n\treturn resolveVarRefs(vars[value], vars, visited);\n}\n\nfunction resolveThemeColors<T extends Record<string, ColorValue>>(\n\tcolors: T,\n\tvars: Record<string, ColorValue> = {},\n): Record<keyof T, string | number> {\n\tconst resolved: Record<string, string | number> = {};\n\tfor (const [key, value] of Object.entries(colors)) {\n\t\tresolved[key] = resolveVarRefs(value, vars);\n\t}\n\treturn resolved as Record<keyof T, string | number>;\n}\n\nfunction withThemeColorFallbacks(colors: ThemeJson[\"colors\"]): ThemeJson[\"colors\"] & {\n\tscrollbarTrack: ColorValue;\n\tscrollbarThumb: ColorValue;\n\tthinkingMax: ColorValue;\n\tsearchMatchBg: ColorValue;\n\tsearchMatchText: ColorValue;\n} {\n\treturn {\n\t\t...colors,\n\t\tscrollbarTrack: colors.scrollbarTrack ?? colors.muted,\n\t\tscrollbarThumb: colors.scrollbarThumb ?? colors.text,\n\t\tthinkingMax: colors.thinkingMax ?? colors.thinkingXhigh,\n\t\tsearchMatchBg: colors.searchMatchBg ?? colors.selectedBg,\n\t\tsearchMatchText: colors.searchMatchText ?? colors.text,\n\t};\n}\n\n// ============================================================================\n// Appearance & Terminal Default Colors\n// ============================================================================\n\n/** The background a theme is designed for. */\nexport type ThemeAppearance = TerminalTheme;\n\n// The terminal's reported colors. Replaced (never mutated) on update, so themes can cache resolved colors\n// by identity.\nlet terminalColors: TerminalColors = {};\n// While the terminal color query is in flight, the system theme renders in grayscale.\nlet terminalColorsPending = false;\n// The terminal's last light/dark report (mode 2031). Only used while it has not reported a background.\nlet terminalColorScheme: TerminalTheme | undefined;\n\n/**\n * Record the terminal's reported colors. Themes use the default colors for tokens set to \"\" (terminal\n * default); the system theme is generated from all of them. Ends the pending state.\n */\nexport function setTerminalColors(colors: TerminalColors): void {\n\tterminalColors = { ...colors };\n\tterminalColorsPending = false;\n}\n\n/** Record the terminal's light/dark report, the fallback for terminals that do not report their background. */\nexport function setTerminalColorScheme(scheme: TerminalTheme | undefined): void {\n\tterminalColorScheme = scheme;\n}\n\n/** Render the system theme in grayscale until `setTerminalColors()` reports the terminal's colors. */\nexport function markTerminalColorsPending(): void {\n\tterminalColorsPending = true;\n}\n\n/** Assumed terminal default colors when the terminal does not report them. */\nconst GUESSED_DEFAULT_COLORS: Record<ThemeAppearance, { foreground: Color; background: Color }> = {\n\tdark: { foreground: parseColor(\"#e5e5e7\"), background: parseColor(\"#000000\") },\n\tlight: { foreground: parseColor(\"#000000\"), background: parseColor(\"#ffffff\") },\n};\n\nfunction averageLightness(colors: Color[]): number | undefined {\n\t// Palette colors 0-15 follow the user's terminal palette, so they say nothing about the theme.\n\tconst fixed = colors.filter((color) => color.kind !== \"indexed\" || color.index >= 16);\n\tif (fixed.length === 0) return undefined;\n\treturn fixed.reduce((sum, color) => sum + colorToOklch(color).l, 0) / fixed.length;\n}\n\n/** Detect the background a theme is designed for from the lightness of its own colors. */\nfunction detectAppearance(foregrounds: Color[], backgrounds: Color[]): ThemeAppearance | undefined {\n\tconst fg = averageLightness(foregrounds);\n\tconst bg = averageLightness(backgrounds);\n\tif (fg !== undefined && bg !== undefined) return bg < fg ? \"dark\" : \"light\";\n\tif (bg !== undefined) return bg < 0.5 ? \"dark\" : \"light\";\n\tif (fg !== undefined) return fg > 0.5 ? \"dark\" : \"light\";\n\treturn undefined;\n}\n\n// ============================================================================\n// Theme Class\n// ============================================================================\n\nexport class Theme {\n\treadonly name?: string;\n\treadonly sourcePath?: string;\n\tsourceInfo?: SourceInfo;\n\tprivate mode: TerminalColorMode;\n\t// Precomputed escape sequences keep fg()/bg() on the render hot path to a lookup and concat.\n\tprivate readonly fgAnsi = new Map<ThemeColor, string>();\n\tprivate readonly bgAnsi = new Map<ThemeBg, string>();\n\t// Tokens set to \"\" have no color of their own; `colors` fills them from the terminal defaults.\n\tprivate readonly concreteColors: Partial<Record<ThemeToken, Color>> = {};\n\tprivate readonly defaultForegroundTokens: ThemeToken[] = [];\n\tprivate readonly defaultBackgroundTokens: ThemeToken[] = [];\n\t// Foreground tokens rendered faint (SGR 2) on top of their color.\n\tprivate readonly dimTokens: ReadonlySet<ThemeColor>;\n\tprivate readonly ownAppearance: ThemeAppearance | undefined;\n\tprivate resolvedColors: { terminal: TerminalColors; colors: Readonly<Record<ThemeToken, Color>> } | undefined;\n\n\tconstructor(\n\t\tfgColors: Record<Exclude<ThemeColor, OptionalThemeColor>, string | number> &\n\t\t\tPartial<Record<OptionalThemeColor, string | number>>,\n\t\tbgColors: Record<Exclude<ThemeBg, OptionalThemeBg>, string | number> &\n\t\t\tPartial<Record<OptionalThemeBg, string | number>>,\n\t\tmode: TerminalColorMode,\n\t\toptions: {\n\t\t\tname?: string;\n\t\t\tsourcePath?: string;\n\t\t\tsourceInfo?: SourceInfo;\n\t\t\tappearance?: ThemeAppearance;\n\t\t\t/** Foreground tokens to render faint (SGR 2). */\n\t\t\tdim?: readonly ThemeColor[];\n\t\t} = {},\n\t) {\n\t\tthis.name = options.name;\n\t\tthis.sourcePath = options.sourcePath;\n\t\tthis.sourceInfo = options.sourceInfo;\n\t\tthis.mode = mode;\n\t\tthis.dimTokens = new Set(options.dim);\n\t\tconst foregrounds = {\n\t\t\t...fgColors,\n\t\t\tscrollbarTrack: fgColors.scrollbarTrack ?? fgColors.muted,\n\t\t\tscrollbarThumb: fgColors.scrollbarThumb ?? fgColors.text,\n\t\t\tthinkingMax: fgColors.thinkingMax ?? fgColors.thinkingXhigh,\n\t\t\tsearchMatchText: fgColors.searchMatchText ?? fgColors.text,\n\t\t};\n\t\tconst backgrounds = { ...bgColors, searchMatchBg: bgColors.searchMatchBg ?? bgColors.selectedBg };\n\t\tconst concreteForegrounds: Color[] = [];\n\t\tconst concreteBackgrounds: Color[] = [];\n\t\t// Returns the escape sequence for the token's own slot.\n\t\tconst addToken = (token: ThemeToken, value: string | number, isBackground: boolean): string => {\n\t\t\tif (value === \"\") {\n\t\t\t\t(isBackground ? this.defaultBackgroundTokens : this.defaultForegroundTokens).push(token);\n\t\t\t\treturn isBackground ? \"\\x1b[49m\" : \"\\x1b[39m\";\n\t\t\t}\n\t\t\tconst color = parseColor(value);\n\t\t\tthis.concreteColors[token] = color;\n\t\t\t(isBackground ? concreteBackgrounds : concreteForegrounds).push(color);\n\t\t\treturn isBackground ? backgroundAnsi(color, mode) : foregroundAnsi(color, mode);\n\t\t};\n\t\tfor (const [token, value] of Object.entries(foregrounds) as [ThemeColor, string | number][]) {\n\t\t\tthis.fgAnsi.set(token, addToken(token, value, false));\n\t\t}\n\t\tfor (const [token, value] of Object.entries(backgrounds) as [ThemeBg, string | number][]) {\n\t\t\tthis.bgAnsi.set(token, addToken(token, value, true));\n\t\t}\n\t\tthis.ownAppearance = options.appearance ?? detectAppearance(concreteForegrounds, concreteBackgrounds);\n\t}\n\n\t/**\n\t * The background the theme is designed for: declared in the theme JSON, detected from its colors,\n\t * or, for themes without usable colors, the terminal's appearance.\n\t */\n\tget appearance(): ThemeAppearance {\n\t\treturn this.ownAppearance ?? getTerminalTheme();\n\t}\n\n\t/**\n\t * Concrete colors for all tokens. Tokens set to \"\" (terminal default) use the terminal's reported\n\t * default colors, or a guess based on `appearance` when the terminal did not report them. Faint\n\t * tokens are approximated by mixing their color toward the background.\n\t */\n\tget colors(): Readonly<Record<ThemeToken, Color>> {\n\t\tconst terminal = terminalColors;\n\t\tif (this.resolvedColors?.terminal !== terminal) {\n\t\t\tconst guess = GUESSED_DEFAULT_COLORS[this.appearance];\n\t\t\tconst toColor = (rgb: RgbColor | undefined, fallback: Color) =>\n\t\t\t\trgb ? rgbColor(rgb.r, rgb.g, rgb.b) : fallback;\n\t\t\tconst foreground = toColor(terminal.foreground, guess.foreground);\n\t\t\tconst background = toColor(terminal.background, guess.background);\n\t\t\tconst colors = { ...this.concreteColors };\n\t\t\tfor (const token of this.defaultForegroundTokens) colors[token] = foreground;\n\t\t\tfor (const token of this.defaultBackgroundTokens) colors[token] = background;\n\t\t\tfor (const token of this.dimTokens) {\n\t\t\t\tconst color = colors[token];\n\t\t\t\tif (color) colors[token] = mixColors(color, background, 0.4);\n\t\t\t}\n\t\t\tthis.resolvedColors = { terminal, colors: Object.freeze(colors as Record<ThemeToken, Color>) };\n\t\t}\n\t\treturn this.resolvedColors.colors;\n\t}\n\n\tstyle(text: string, options: ThemeStyle): string {\n\t\tconst { fg, bg } = options;\n\t\tif (typeof fg === \"string\" && this.dimTokens.has(fg)) options = { ...options, dim: true };\n\t\treturn styleTextWithAnsi(\n\t\t\ttext,\n\t\t\tfg === undefined\n\t\t\t\t? undefined\n\t\t\t\t: typeof fg === \"string\"\n\t\t\t\t\t? this.tokenAnsi(this.fgAnsi, fg)\n\t\t\t\t\t: foregroundAnsi(fg, this.mode),\n\t\t\tbg === undefined\n\t\t\t\t? undefined\n\t\t\t\t: typeof bg === \"string\"\n\t\t\t\t\t? this.tokenAnsi(this.bgAnsi, bg)\n\t\t\t\t\t: backgroundAnsi(bg, this.mode),\n\t\t\toptions,\n\t\t);\n\t}\n\n\tfg(color: ThemeColor, text: string): string {\n\t\tconst ansi = this.tokenAnsi(this.fgAnsi, color);\n\t\tif (this.dimTokens.has(color)) return `${ansi}\\x1b[2m${text}\\x1b[22;39m`;\n\t\treturn `${ansi}${text}\\x1b[39m`;\n\t}\n\n\tbg(color: ThemeBg, text: string): string {\n\t\tconst ansi = this.tokenAnsi(this.bgAnsi, color);\n\t\treturn `${ansi}${text}\\x1b[49m`;\n\t}\n\n\tprivate tokenAnsi<T extends ThemeToken>(ansi: Map<T, string>, token: T): string {\n\t\tconst value = ansi.get(token);\n\t\tif (value === undefined) throw new Error(`Unknown theme color: ${token}`);\n\t\treturn value;\n\t}\n\n\tbold(text: string): string {\n\t\treturn chalk.bold(text);\n\t}\n\n\titalic(text: string): string {\n\t\treturn chalk.italic(text);\n\t}\n\n\tunderline(text: string): string {\n\t\treturn chalk.underline(text);\n\t}\n\n\tinverse(text: string): string {\n\t\treturn chalk.inverse(text);\n\t}\n\n\tstrikethrough(text: string): string {\n\t\treturn chalk.strikethrough(text);\n\t}\n\n\t/** Opening escape sequence for a foreground token. Faint tokens include SGR 2, which `\\x1b[22m` closes. */\n\tgetFgAnsi(color: ThemeColor): string {\n\t\tconst ansi = this.tokenAnsi(this.fgAnsi, color);\n\t\treturn this.dimTokens.has(color) ? `${ansi}\\x1b[2m` : ansi;\n\t}\n\n\tgetBgAnsi(color: ThemeBg): string {\n\t\treturn this.tokenAnsi(this.bgAnsi, color);\n\t}\n\n\tgetColorMode(): TerminalColorMode {\n\t\treturn this.mode;\n\t}\n\n\tgetThinkingBorderColor(level: ThinkingLevel): (str: string) => string {\n\t\t// Map thinking levels to dedicated theme colors\n\t\tswitch (level) {\n\t\t\tcase \"off\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingOff\", str);\n\t\t\tcase \"minimal\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMinimal\", str);\n\t\t\tcase \"low\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingLow\", str);\n\t\t\tcase \"medium\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMedium\", str);\n\t\t\tcase \"high\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingHigh\", str);\n\t\t\tcase \"xhigh\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingXhigh\", str);\n\t\t\tcase \"max\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMax\", str);\n\t\t\tdefault:\n\t\t\t\treturn (str: string) => this.fg(\"thinkingOff\", str);\n\t\t}\n\t}\n\n\tgetBashModeBorderColor(): (str: string) => string {\n\t\treturn (str: string) => this.fg(\"bashMode\", str);\n\t}\n}\n\n// ============================================================================\n// Theme Loading\n// ============================================================================\n\nlet BUILTIN_THEMES: Record<string, ThemeJson> | undefined;\n\nfunction getBuiltinThemes(): Record<string, ThemeJson> {\n\tif (!BUILTIN_THEMES) {\n\t\tconst themesDir = getThemesDir();\n\t\tconst darkPath = path.join(themesDir, \"dark.json\");\n\t\tconst lightPath = path.join(themesDir, \"light.json\");\n\t\tBUILTIN_THEMES = {\n\t\t\tdark: JSON.parse(stripBom(fs.readFileSync(darkPath, \"utf-8\"))) as ThemeJson,\n\t\t\tlight: JSON.parse(stripBom(fs.readFileSync(lightPath, \"utf-8\"))) as ThemeJson,\n\t\t};\n\t}\n\treturn BUILTIN_THEMES;\n}\n\nexport function getAvailableThemes(): string[] {\n\treturn getAvailableThemesWithPaths().map(({ name }) => name);\n}\n\nexport interface ThemeInfo {\n\tname: string;\n\tpath: string | undefined;\n}\n\nexport function getAvailableThemesWithPaths(): ThemeInfo[] {\n\tconst themesDir = getThemesDir();\n\tconst result: ThemeInfo[] = [];\n\tconst seen = new Set<string>();\n\tconst addTheme = (themeInfo: ThemeInfo) => {\n\t\tif (seen.has(themeInfo.name)) {\n\t\t\treturn;\n\t\t}\n\t\tseen.add(themeInfo.name);\n\t\tresult.push(themeInfo);\n\t};\n\n\t// Built-in themes. The system theme is generated, so it has no file.\n\taddTheme({ name: SYSTEM_THEME_NAME, path: undefined });\n\tfor (const name of Object.keys(getBuiltinThemes())) {\n\t\taddTheme({ name, path: path.join(themesDir, `${name}.json`) });\n\t}\n\n\t// Custom themes\n\tfor (const themeInfo of getCustomThemeInfos()) {\n\t\taddTheme(themeInfo);\n\t}\n\n\tfor (const [name, theme] of registeredThemes.entries()) {\n\t\taddTheme({ name, path: theme.sourcePath });\n\t}\n\n\t// The system theme comes first: it is the default and adapts to every terminal.\n\treturn result.sort((a, b) =>\n\t\ta.name === SYSTEM_THEME_NAME ? -1 : b.name === SYSTEM_THEME_NAME ? 1 : a.name.localeCompare(b.name),\n\t);\n}\n\nfunction getCustomThemeInfos(): ThemeInfo[] {\n\tconst customThemesDir = getCustomThemesDir();\n\tconst result: ThemeInfo[] = [];\n\tif (!fs.existsSync(customThemesDir)) {\n\t\treturn result;\n\t}\n\n\tfor (const file of fs.readdirSync(customThemesDir)) {\n\t\tif (!file.endsWith(\".json\")) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst themePath = path.join(customThemesDir, file);\n\t\ttry {\n\t\t\tconst customTheme = loadThemeFromPath(themePath);\n\t\t\tif (customTheme.name) {\n\t\t\t\tresult.push({ name: customTheme.name, path: themePath });\n\t\t\t}\n\t\t} catch {\n\t\t\t// Invalid themes are ignored here; the resource loader reports them\n\t\t\t// during normal startup/reload.\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction assertThemeNameIsValid(name: string): void {\n\tif (name.includes(\"/\")) {\n\t\tthrow new Error(\n\t\t\t`Invalid theme name \"${name}\": theme names cannot contain \"/\" because it is reserved for automatic light/dark theme settings.`,\n\t\t);\n\t}\n}\n\nfunction parseThemeJson(label: string, json: unknown): ThemeJson {\n\tif (themeJsonValidator) return themeJsonValidator(label, json);\n\tif (typeof json !== \"object\" || json === null || !(\"colors\" in json)) {\n\t\tthrow new Error(`Invalid theme \"${label}\": expected an object with a \"colors\" map.`);\n\t}\n\treturn json as ThemeJson;\n}\n\nfunction parseThemeJsonContent(label: string, content: string): ThemeJson {\n\tlet json: unknown;\n\ttry {\n\t\tjson = JSON.parse(stripBom(content));\n\t} catch (error) {\n\t\tthrow new Error(`Failed to parse theme ${label}: ${error}`);\n\t}\n\treturn parseThemeJson(label, json);\n}\n\nfunction loadThemeJson(name: string): ThemeJson {\n\tconst builtinThemes = getBuiltinThemes();\n\tif (name in builtinThemes) {\n\t\treturn builtinThemes[name];\n\t}\n\tconst registeredTheme = registeredThemes.get(name);\n\tif (registeredTheme?.sourcePath) {\n\t\tconst content = fs.readFileSync(registeredTheme.sourcePath, \"utf-8\");\n\t\treturn parseThemeJsonContent(registeredTheme.sourcePath, content);\n\t}\n\tif (registeredTheme) {\n\t\tthrow new Error(`Theme \"${name}\" does not have a source path for export`);\n\t}\n\tconst customThemesDir = getCustomThemesDir();\n\tconst themePath = path.join(customThemesDir, `${name}.json`);\n\tif (!fs.existsSync(themePath)) {\n\t\tthrow new Error(`Theme not found: ${name}`);\n\t}\n\tconst content = fs.readFileSync(themePath, \"utf-8\");\n\treturn parseThemeJsonContent(name, content);\n}\n\nconst BACKGROUND_TOKENS: ReadonlySet<string> = new Set<ThemeBg>([\n\t\"selectedBg\",\n\t\"searchMatchBg\",\n\t\"userMessageBg\",\n\t\"customMessageBg\",\n\t\"toolPendingBg\",\n\t\"toolSuccessBg\",\n\t\"toolErrorBg\",\n]);\n\nfunction splitThemeColors(colors: Record<string, string | number>): {\n\tfgColors: Record<ThemeColor, string | number>;\n\tbgColors: Record<ThemeBg, string | number>;\n} {\n\tconst fgColors = {} as Record<ThemeColor, string | number>;\n\tconst bgColors = {} as Record<ThemeBg, string | number>;\n\tfor (const [key, value] of Object.entries(colors)) {\n\t\tif (BACKGROUND_TOKENS.has(key)) {\n\t\t\tbgColors[key as ThemeBg] = value;\n\t\t} else {\n\t\t\tfgColors[key as ThemeColor] = value;\n\t\t}\n\t}\n\treturn { fgColors, bgColors };\n}\n\nfunction createTheme(themeJson: ThemeJson, mode?: TerminalColorMode, sourcePath?: string): Theme {\n\tconst colorMode = mode ?? getTerminalColorMode();\n\tconst resolvedColors = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);\n\tconst { fgColors, bgColors } = splitThemeColors(resolvedColors);\n\treturn new Theme(fgColors, bgColors, colorMode, {\n\t\tname: themeJson.name,\n\t\tsourcePath,\n\t\tappearance: themeJson.appearance,\n\t});\n}\n\n/** Generate the system theme from the terminal's reported colors (grayscale while they are pending). */\nfunction createSystemTheme(mode?: TerminalColorMode): Theme {\n\tconst generated = generateSystemThemeColors({\n\t\t...terminalColors,\n\t\tsaturation: terminalColorsPending ? 0 : 1,\n\t\tappearanceHint: getTerminalTheme(),\n\t});\n\tconst { fgColors, bgColors } = splitThemeColors(generated.colors);\n\treturn new Theme(fgColors, bgColors, mode ?? getTerminalColorMode(), {\n\t\tname: SYSTEM_THEME_NAME,\n\t\tappearance: generated.appearance,\n\t\tdim: generated.dim,\n\t});\n}\n\nexport function loadThemeFromPath(themePath: string, mode?: TerminalColorMode): Theme {\n\tconst content = fs.readFileSync(themePath, \"utf-8\");\n\tconst themeJson = parseThemeJsonContent(themePath, content);\n\treturn createTheme(themeJson, mode, themePath);\n}\n\nfunction loadTheme(name: string, mode?: TerminalColorMode): Theme {\n\t// The system theme name is reserved: it takes precedence over custom themes of the same name.\n\tif (name === SYSTEM_THEME_NAME) return createSystemTheme(mode);\n\tconst registeredTheme = registeredThemes.get(name);\n\tif (registeredTheme) {\n\t\treturn registeredTheme;\n\t}\n\tconst themeJson = loadThemeJson(name);\n\treturn createTheme(themeJson, mode);\n}\n\nexport function getThemeByName(name: string): Theme | undefined {\n\ttry {\n\t\treturn loadTheme(name);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport type TerminalTheme = \"dark\" | \"light\";\n\nexport function parseAutoThemeSetting(\n\tthemeSetting: string | undefined,\n): { lightTheme: string; darkTheme: string } | undefined {\n\tif (!themeSetting) return undefined;\n\tconst slashIndex = themeSetting.indexOf(\"/\");\n\tif (slashIndex === -1 || themeSetting.indexOf(\"/\", slashIndex + 1) !== -1) {\n\t\treturn undefined;\n\t}\n\n\tconst lightTheme = themeSetting.slice(0, slashIndex).trim();\n\tconst darkTheme = themeSetting.slice(slashIndex + 1).trim();\n\tif (!lightTheme || !darkTheme) {\n\t\treturn undefined;\n\t}\n\treturn { lightTheme, darkTheme };\n}\n\nexport function resolveThemeSetting(\n\tthemeSetting: string | undefined,\n\tterminalTheme: TerminalTheme,\n): string | undefined {\n\tconst autoTheme = parseAutoThemeSetting(themeSetting);\n\tif (autoTheme) {\n\t\treturn terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme;\n\t}\n\tif (themeSetting?.includes(\"/\")) return undefined;\n\tif (typeof themeSetting === \"string\") return themeSetting;\n\treturn undefined;\n}\n\n/**\n * Dark or light from the `COLORFGBG` environment variable some terminals set, or undefined without a\n * usable background index. The value is `fg;bg` or `fg;xpm;bg` (rxvt), where a field is an ANSI color\n * index or `default` when the color is not in the palette. The index refers to the terminal's own palette,\n * whose colors are unknown here, so it is classified by index like Vim does: 0-6 and 8 (bright black, e.g.\n * Solarized Dark's background) are dark, 7 and 9-15 are light.\n */\nexport function detectColorFgBgTheme(env: NodeJS.ProcessEnv = process.env): TerminalTheme | undefined {\n\tconst bg = env.COLORFGBG?.split(\";\").at(-1)?.trim();\n\tif (!bg || !/^\\d{1,2}$/.test(bg)) return undefined;\n\tconst index = Number(bg);\n\tif (index > 15) return undefined;\n\treturn index <= 6 || index === 8 ? \"dark\" : \"light\";\n}\n\n/**\n * Whether the terminal is dark or light. The background it renders decides, classified the same way the\n * system theme does. Without a reported background: the terminal's light/dark report, then COLORFGBG,\n * then dark.\n */\nexport function detectTerminalTheme(\n\tcolors: TerminalColors = {},\n\treportedScheme?: TerminalTheme,\n\tenv: NodeJS.ProcessEnv = process.env,\n): TerminalTheme {\n\tconst { background, foreground } = colors;\n\tif (background) return terminalAppearance(background, foreground);\n\treturn reportedScheme ?? detectColorFgBgTheme(env) ?? \"dark\";\n}\n\n/** Whether the terminal is dark or light, from everything it reported so far. See `detectTerminalTheme()`. */\nexport function getTerminalTheme(): TerminalTheme {\n\treturn detectTerminalTheme(terminalColors, terminalColorScheme);\n}\n\n// ============================================================================\n// Global Theme Instance\n// ============================================================================\n\n// Use globalThis to share theme across module loaders (node + jiti in dev mode)\nconst THEME_KEY = Symbol.for(\"@earendil-works/pi-coding-agent:theme\");\nconst THEME_KEY_OLD = Symbol.for(\"@mariozechner/pi-coding-agent:theme\");\n\n// Export theme as a getter that reads from globalThis\n// This ensures all module instances (node, jiti) see the same theme\nexport const theme: Theme = new Proxy({} as Theme, {\n\tget(_target, prop) {\n\t\tconst t = (globalThis as Record<symbol, Theme>)[THEME_KEY];\n\t\tif (!t) throw new Error(\"Theme not initialized. Call initTheme() first.\");\n\t\treturn (t as unknown as Record<string | symbol, unknown>)[prop];\n\t},\n});\n\nfunction setGlobalTheme(t: Theme): void {\n\t(globalThis as Record<symbol, Theme>)[THEME_KEY] = t;\n\t(globalThis as Record<symbol, Theme>)[THEME_KEY_OLD] = t;\n}\n\nlet currentThemeName: string | undefined;\nlet themeWatcher: fs.FSWatcher | undefined;\nlet themeReloadTimer: NodeJS.Timeout | undefined;\nlet onThemeChangeCallback: (() => void) | undefined;\nconst registeredThemes = new Map<string, Theme>();\n\nexport function setRegisteredThemes(themes: Theme[]): void {\n\tregisteredThemes.clear();\n\tfor (const theme of themes) {\n\t\tif (theme.name) {\n\t\t\tassertThemeNameIsValid(theme.name);\n\t\t\tregisteredThemes.set(theme.name, theme);\n\t\t}\n\t}\n}\n\nexport function initTheme(themeName?: string, enableWatcher: boolean = false): void {\n\tconst name = themeName ?? SYSTEM_THEME_NAME;\n\tcurrentThemeName = name;\n\ttry {\n\t\tsetGlobalTheme(loadTheme(name));\n\t\tif (enableWatcher) {\n\t\t\tstartThemeWatcher();\n\t\t}\n\t} catch (_error) {\n\t\t// Theme is invalid - fall back to the system theme silently\n\t\tcurrentThemeName = SYSTEM_THEME_NAME;\n\t\tsetGlobalTheme(loadTheme(SYSTEM_THEME_NAME));\n\t\t// Don't start watcher for fallback theme\n\t}\n}\n\nexport function setTheme(name: string, enableWatcher: boolean = false): { success: boolean; error?: string } {\n\tcurrentThemeName = name;\n\ttry {\n\t\tsetGlobalTheme(loadTheme(name));\n\t\tif (enableWatcher) {\n\t\t\tstartThemeWatcher();\n\t\t}\n\t\tif (onThemeChangeCallback) {\n\t\t\tonThemeChangeCallback();\n\t\t}\n\t\treturn { success: true };\n\t} catch (error) {\n\t\t// Theme is invalid - fall back to the system theme\n\t\tcurrentThemeName = SYSTEM_THEME_NAME;\n\t\tsetGlobalTheme(loadTheme(SYSTEM_THEME_NAME));\n\t\t// Don't start watcher for fallback theme\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t};\n\t}\n}\n\nexport function setThemeInstance(themeInstance: Theme): void {\n\tsetGlobalTheme(themeInstance);\n\tcurrentThemeName = \"<in-memory>\";\n\tstopThemeWatcher(); // Can't watch a direct instance\n\tif (onThemeChangeCallback) {\n\t\tonThemeChangeCallback();\n\t}\n}\n\nexport function onThemeChange(callback: () => void): void {\n\tonThemeChangeCallback = callback;\n}\n\nfunction startThemeWatcher(): void {\n\tstopThemeWatcher();\n\n\t// Only watch if it's a custom theme (not built-in)\n\tif (\n\t\t!currentThemeName ||\n\t\tcurrentThemeName === \"dark\" ||\n\t\tcurrentThemeName === \"light\" ||\n\t\tcurrentThemeName === SYSTEM_THEME_NAME\n\t) {\n\t\treturn;\n\t}\n\n\tconst customThemesDir = getCustomThemesDir();\n\tconst watchedThemeName = currentThemeName;\n\tconst watchedFileName = `${watchedThemeName}.json`;\n\tconst themeFile = path.join(customThemesDir, watchedFileName);\n\n\t// Only watch if the file exists\n\tif (!fs.existsSync(themeFile)) {\n\t\treturn;\n\t}\n\n\tconst scheduleReload = () => {\n\t\tif (themeReloadTimer) {\n\t\t\tclearTimeout(themeReloadTimer);\n\t\t}\n\t\tthemeReloadTimer = setTimeout(() => {\n\t\t\tthemeReloadTimer = undefined;\n\n\t\t\t// Ignore stale timers after switching themes or stopping the watcher\n\t\t\tif (currentThemeName !== watchedThemeName) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Keep the last successfully loaded theme active if the file is temporarily missing\n\t\t\tif (!fs.existsSync(themeFile)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// Reload the theme from disk and refresh the registry cache\n\t\t\t\tconst reloadedTheme = loadThemeFromPath(themeFile);\n\t\t\t\tregisteredThemes.set(watchedThemeName, reloadedTheme);\n\t\t\t\tsetGlobalTheme(reloadedTheme);\n\t\t\t\t// Notify callback (to invalidate UI)\n\t\t\t\tif (onThemeChangeCallback) {\n\t\t\t\t\tonThemeChangeCallback();\n\t\t\t\t}\n\t\t\t} catch (_error) {\n\t\t\t\t// Ignore errors (file might be in invalid state while being edited)\n\t\t\t}\n\t\t}, 100);\n\t};\n\n\tthemeWatcher =\n\t\twatchWithErrorHandler(\n\t\t\tcustomThemesDir,\n\t\t\t(_eventType, filename) => {\n\t\t\t\tif (currentThemeName !== watchedThemeName) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!filename) {\n\t\t\t\t\tscheduleReload();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (filename !== watchedFileName) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tscheduleReload();\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tcloseWatcher(themeWatcher);\n\t\t\t\tthemeWatcher = undefined;\n\t\t\t},\n\t\t) ?? undefined;\n}\n\nexport function stopThemeWatcher(): void {\n\tif (themeReloadTimer) {\n\t\tclearTimeout(themeReloadTimer);\n\t\tthemeReloadTimer = undefined;\n\t}\n\tcloseWatcher(themeWatcher);\n\tthemeWatcher = undefined;\n}\n\n// ============================================================================\n// HTML Export Helpers\n// ============================================================================\n\n/**\n * Get resolved theme colors as CSS-compatible hex strings.\n * Used by HTML export to generate CSS custom properties.\n */\nexport function getResolvedThemeColors(themeName?: string): Record<string, string> {\n\tconst colors = loadTheme(themeName ?? currentThemeName ?? SYSTEM_THEME_NAME).colors;\n\treturn Object.fromEntries(Object.entries(colors).map(([token, color]) => [token, colorToHex(color)]));\n}\n\n/**\n * Check if a theme is a \"light\" theme (for CSS that needs light/dark variants).\n */\nexport function isLightTheme(themeName?: string): boolean {\n\treturn loadTheme(themeName ?? currentThemeName ?? SYSTEM_THEME_NAME).appearance === \"light\";\n}\n\n/**\n * Get explicit export colors from theme JSON, if specified.\n * Returns undefined for each color that isn't explicitly set.\n */\nexport function getThemeExportColors(themeName?: string): {\n\tpageBg?: string;\n\tcardBg?: string;\n\tinfoBg?: string;\n} {\n\tconst name = themeName ?? currentThemeName ?? SYSTEM_THEME_NAME;\n\tif (name === SYSTEM_THEME_NAME) return {};\n\ttry {\n\t\tconst themeJson = loadThemeJson(name);\n\t\tconst exportSection = themeJson.export;\n\t\tif (!exportSection) return {};\n\n\t\tconst vars = themeJson.vars ?? {};\n\t\t// Export colors end up in CSS, which understands hex and oklch() values directly but not okhsl().\n\t\tconst resolve = (value: ColorValue | undefined): string | undefined => {\n\t\t\tif (value === undefined) return undefined;\n\t\t\tconst resolved = resolveVarRefs(value, vars);\n\t\t\tif (typeof resolved === \"number\") return colorToHex(indexedColor(resolved));\n\t\t\tif (resolved === \"\") return undefined;\n\t\t\tif (/^okhsl\\(/i.test(resolved)) return colorToHex(parseColor(resolved));\n\t\t\treturn resolved;\n\t\t};\n\n\t\treturn {\n\t\t\tpageBg: resolve(exportSection.pageBg),\n\t\t\tcardBg: resolve(exportSection.cardBg),\n\t\t\tinfoBg: resolve(exportSection.infoBg),\n\t\t};\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n// ============================================================================\n// TUI Helpers\n// ============================================================================\n\ntype CliHighlightTheme = Record<string, (s: string) => string>;\n\nlet cachedHighlightThemeFor: Theme | undefined;\nlet cachedCliHighlightTheme: CliHighlightTheme | undefined;\n\nfunction buildCliHighlightTheme(t: Theme): CliHighlightTheme {\n\treturn {\n\t\tkeyword: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tbuilt_in: (s: string) => t.fg(\"syntaxType\", s),\n\t\tliteral: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tnumber: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tregexp: (s: string) => t.fg(\"syntaxString\", s),\n\t\tstring: (s: string) => t.fg(\"syntaxString\", s),\n\t\tcomment: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tdoctag: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tmeta: (s: string) => t.fg(\"muted\", s),\n\t\tfunction: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\ttitle: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\tclass: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttype: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttag: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\tname: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tattr: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tvariable: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tparams: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\toperator: (s: string) => t.fg(\"syntaxOperator\", s),\n\t\tpunctuation: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\temphasis: (s: string) => t.italic(s),\n\t\tstrong: (s: string) => t.bold(s),\n\t\tlink: (s: string) => t.underline(s),\n\t\taddition: (s: string) => t.fg(\"toolDiffAdded\", s),\n\t\tdeletion: (s: string) => t.fg(\"toolDiffRemoved\", s),\n\t};\n}\n\nfunction getCliHighlightTheme(t: Theme): CliHighlightTheme {\n\tif (cachedHighlightThemeFor !== t || !cachedCliHighlightTheme) {\n\t\tcachedHighlightThemeFor = t;\n\t\tcachedCliHighlightTheme = buildCliHighlightTheme(t);\n\t}\n\treturn cachedCliHighlightTheme;\n}\n\n/**\n * Highlight code with syntax coloring based on file extension or language.\n * Returns array of highlighted lines.\n */\nexport function highlightCode(code: string, lang?: string): string[] {\n\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t// LiveCodeServer, etc., coloring random English words as keywords.\n\tif (!validLang) {\n\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t}\n\tconst opts = {\n\t\tlanguage: validLang,\n\t\tignoreIllegals: true,\n\t\ttheme: getCliHighlightTheme(theme),\n\t};\n\ttry {\n\t\treturn highlight(code, opts).split(\"\\n\");\n\t} catch {\n\t\treturn code.split(\"\\n\");\n\t}\n}\n\n/**\n * Get language identifier from file path extension.\n */\nexport function getLanguageFromPath(filePath: string): string | undefined {\n\tconst ext = filePath.split(\".\").pop()?.toLowerCase();\n\tif (!ext) return undefined;\n\n\tconst extToLang: Record<string, string> = {\n\t\tts: \"typescript\",\n\t\ttsx: \"typescript\",\n\t\tjs: \"javascript\",\n\t\tjsx: \"javascript\",\n\t\tmjs: \"javascript\",\n\t\tcjs: \"javascript\",\n\t\tpy: \"python\",\n\t\trb: \"ruby\",\n\t\trs: \"rust\",\n\t\tgo: \"go\",\n\t\tjava: \"java\",\n\t\tkt: \"kotlin\",\n\t\tswift: \"swift\",\n\t\tc: \"c\",\n\t\th: \"c\",\n\t\tcpp: \"cpp\",\n\t\tcc: \"cpp\",\n\t\tcxx: \"cpp\",\n\t\thpp: \"cpp\",\n\t\tcs: \"csharp\",\n\t\tphp: \"php\",\n\t\tsh: \"bash\",\n\t\tbash: \"bash\",\n\t\tzsh: \"bash\",\n\t\tfish: \"fish\",\n\t\tps1: \"powershell\",\n\t\tsql: \"sql\",\n\t\thtml: \"html\",\n\t\thtm: \"html\",\n\t\tcss: \"css\",\n\t\tscss: \"scss\",\n\t\tsass: \"sass\",\n\t\tless: \"less\",\n\t\tjson: \"json\",\n\t\tyaml: \"yaml\",\n\t\tyml: \"yaml\",\n\t\ttoml: \"toml\",\n\t\txml: \"xml\",\n\t\tmd: \"markdown\",\n\t\tmarkdown: \"markdown\",\n\t\tdockerfile: \"dockerfile\",\n\t\tmakefile: \"makefile\",\n\t\tcmake: \"cmake\",\n\t\tlua: \"lua\",\n\t\tperl: \"perl\",\n\t\tr: \"r\",\n\t\tscala: \"scala\",\n\t\tclj: \"clojure\",\n\t\tex: \"elixir\",\n\t\texs: \"elixir\",\n\t\terl: \"erlang\",\n\t\ths: \"haskell\",\n\t\tml: \"ocaml\",\n\t\tvim: \"vim\",\n\t\tgraphql: \"graphql\",\n\t\tproto: \"protobuf\",\n\t\ttf: \"hcl\",\n\t\thcl: \"hcl\",\n\t};\n\n\treturn extToLang[ext];\n}\n\nexport function getMarkdownTheme(): MarkdownTheme {\n\treturn {\n\t\theading: (text: string) => theme.fg(\"mdHeading\", text),\n\t\tlink: (text: string) => theme.fg(\"mdLink\", text),\n\t\tlinkUrl: (text: string) => theme.fg(\"mdLinkUrl\", text),\n\t\tcode: (text: string) => theme.fg(\"mdCode\", text),\n\t\tcodeBlock: (text: string) => theme.fg(\"mdCodeBlock\", text),\n\t\tcodeBlockBorder: (text: string) => theme.fg(\"mdCodeBlockBorder\", text),\n\t\tquote: (text: string) => theme.fg(\"mdQuote\", text),\n\t\tquoteBorder: (text: string) => theme.fg(\"mdQuoteBorder\", text),\n\t\thr: (text: string) => theme.fg(\"mdHr\", text),\n\t\tlistBullet: (text: string) => theme.fg(\"mdListBullet\", text),\n\t\tbold: (text: string) => theme.bold(text),\n\t\titalic: (text: string) => theme.italic(text),\n\t\tunderline: (text: string) => theme.underline(text),\n\t\tstrikethrough: (text: string) => theme.strikethrough(text),\n\t\thighlightCode: (code: string, lang?: string): string[] => {\n\t\t\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\t\t\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t\t\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t\t\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t\t\t// LiveCodeServer, etc., coloring random English words as keywords.\n\t\t\tif (!validLang) {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t\tconst opts = {\n\t\t\t\tlanguage: validLang,\n\t\t\t\tignoreIllegals: true,\n\t\t\t\ttheme: getCliHighlightTheme(theme),\n\t\t\t};\n\t\t\ttry {\n\t\t\t\treturn highlight(code, opts).split(\"\\n\");\n\t\t\t} catch {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport function getSelectListTheme(): SelectListTheme {\n\treturn {\n\t\tselectedPrefix: (text: string) => theme.fg(\"accent\", text),\n\t\tselectedText: (text: string) => theme.fg(\"accent\", text),\n\t\tdescription: (text: string) => theme.fg(\"muted\", text),\n\t\tscrollInfo: (text: string) => theme.fg(\"muted\", text),\n\t\tnoMatch: (text: string) => theme.fg(\"muted\", text),\n\t};\n}\n\nexport function getEditorTheme(): EditorTheme {\n\treturn {\n\t\tborderColor: (text: string) => theme.fg(\"borderMuted\", text),\n\t\tselectList: getSelectListTheme(),\n\t};\n}\n\nexport function getSettingsListTheme(): SettingsListTheme {\n\treturn {\n\t\tlabel: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : text),\n\t\tvalue: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : theme.fg(\"muted\", text)),\n\t\tdescription: (text: string) => theme.fg(\"dim\", text),\n\t\tcursor: theme.fg(\"accent\", \"→ \"),\n\t\thint: (text: string) => theme.fg(\"dim\", text),\n\t};\n}\n"]}
|
|
1
|
+
{"version":3,"file":"theme.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACN,cAAc,EAEd,UAAU,EACV,YAAY,EAEZ,cAAc,EACd,oBAAoB,EACpB,YAAY,EAEZ,SAAS,EACT,UAAU,EAEV,QAAQ,EAGR,iBAAiB,GAIjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACjF,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAErG,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAatD,IAAI,kBAAkD,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,SAA6B;IAClE,kBAAkB,GAAG,SAAS,CAAC;AAChC,CAAC;AA4ED,+EAA+E;AAC/E,kBAAkB;AAClB,+EAA+E;AAE/E,SAAS,cAAc,C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E,CAAC,OAAO,EAAE,IAAI,CAAC;QACrD,OAAO,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC;KAClD,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc;IAC7B,OAAO;QACN,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC;QAC5D,UAAU,EAAE,kBAAkB,EAAE;KAChC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB;IACnC,OAAO;QACN,KAAK,EAAE,CAAC,IAAY,EAAE,QAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACxF,KAAK,EAAE,CAAC,IAAY,EAAE,QAAiB,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAC3G,WAAW,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;QACpD,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC;QAChC,IAAI,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;KAC7C,CAAC;AACH,CAAC","sourcesContent":["import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport {\n\tbackgroundAnsi,\n\ttype Color,\n\tcolorToHex,\n\tcolorToOklch,\n\ttype EditorTheme,\n\tforegroundAnsi,\n\tgetTerminalColorMode,\n\tindexedColor,\n\ttype MarkdownTheme,\n\tmixColors,\n\tparseColor,\n\ttype RgbColor,\n\trgbColor,\n\ttype SelectListTheme,\n\ttype SettingsListTheme,\n\tstyleTextWithAnsi,\n\ttype TerminalColorMode,\n\ttype TerminalColors,\n\ttype TextAttributes,\n} from \"@earendil-works/pi-tui\";\nimport chalk from \"chalk\";\nimport { getCustomThemesDir, getThemesDir } from \"../../../config.ts\";\nimport type { SourceInfo } from \"../../../core/source-info.ts\";\nimport { closeWatcher, watchWithErrorHandler } from \"../../../utils/fs-watch.ts\";\nimport { highlight, supportsLanguage } from \"../../../utils/syntax-highlight.ts\";\nimport { stripBom } from \"../../../utils/text.ts\";\nimport { generateSystemThemeColors, SYSTEM_THEME_NAME, terminalAppearance } from \"./system-theme.ts\";\n\nexport { SYSTEM_THEME_NAME } from \"./system-theme.ts\";\n\n// ============================================================================\n// Types & Schema\n// ============================================================================\n\n/** The schema that validates this shape lives in `theme-json.ts`; importing the type is free. */\nimport type { ThemeColorValue as ColorValue, ValidatedThemeJson as ThemeJson } from \"./theme-json.ts\";\n\nexport type { ValidatedThemeJson as ThemeJson } from \"./theme-json.ts\";\n\nexport type ThemeJsonValidator = (label: string, json: unknown) => ThemeJson;\n\nlet themeJsonValidator: ThemeJsonValidator | undefined;\n\n/**\n * Install full theme validation. Without it, documents are accepted as-is, which is what built-in\n * themes already do: validating user-authored JSON needs typebox, and a presentation that only uses\n * built-in themes should not pay ~17 MB of module graph for it.\n */\nexport function setThemeJsonValidator(validator: ThemeJsonValidator): void {\n\tthemeJsonValidator = validator;\n}\n\nexport type ThemeColor =\n\t| \"accent\"\n\t| \"border\"\n\t| \"borderAccent\"\n\t| \"borderMuted\"\n\t| \"success\"\n\t| \"error\"\n\t| \"warning\"\n\t| \"muted\"\n\t| \"dim\"\n\t| \"text\"\n\t| \"thinkingText\"\n\t| \"scrollbarTrack\"\n\t| \"scrollbarThumb\"\n\t| \"searchMatchText\"\n\t| \"userMessageText\"\n\t| \"customMessageText\"\n\t| \"customMessageLabel\"\n\t| \"toolTitle\"\n\t| \"toolOutput\"\n\t| \"mdHeading\"\n\t| \"mdLink\"\n\t| \"mdLinkUrl\"\n\t| \"mdCode\"\n\t| \"mdCodeBlock\"\n\t| \"mdCodeBlockBorder\"\n\t| \"mdQuote\"\n\t| \"mdQuoteBorder\"\n\t| \"mdHr\"\n\t| \"mdListBullet\"\n\t| \"toolDiffAdded\"\n\t| \"toolDiffRemoved\"\n\t| \"toolDiffContext\"\n\t| \"syntaxComment\"\n\t| \"syntaxKeyword\"\n\t| \"syntaxFunction\"\n\t| \"syntaxVariable\"\n\t| \"syntaxString\"\n\t| \"syntaxNumber\"\n\t| \"syntaxType\"\n\t| \"syntaxOperator\"\n\t| \"syntaxPunctuation\"\n\t| \"thinkingOff\"\n\t| \"thinkingMinimal\"\n\t| \"thinkingLow\"\n\t| \"thinkingMedium\"\n\t| \"thinkingHigh\"\n\t| \"thinkingXhigh\"\n\t| \"thinkingMax\"\n\t| \"bashMode\";\n\nexport type ThemeBg =\n\t| \"selectedBg\"\n\t| \"searchMatchBg\"\n\t| \"userMessageBg\"\n\t| \"customMessageBg\"\n\t| \"toolPendingBg\"\n\t| \"toolSuccessBg\"\n\t| \"toolErrorBg\";\n\nexport type ThemeToken = ThemeColor | ThemeBg;\n\n/**\n * Tokens are only accepted in their own slot, because \"\" (terminal default) means the default foreground\n * or background depending on the slot. Use `theme.colors[token]` to use a token's color in the other slot.\n */\nexport interface ThemeStyle extends TextAttributes {\n\tfg?: ThemeColor | Color;\n\tbg?: ThemeBg | Color;\n}\n\ntype OptionalThemeColor = \"scrollbarTrack\" | \"scrollbarThumb\" | \"thinkingMax\" | \"searchMatchText\";\ntype OptionalThemeBg = \"searchMatchBg\";\n\n// ============================================================================\n// Color Utilities\n// ============================================================================\n\nfunction resolveVarRefs(\n\tvalue: ColorValue,\n\tvars: Record<string, ColorValue>,\n\tvisited = new Set<string>(),\n): string | number {\n\tif (typeof value === \"number\" || value === \"\" || value.startsWith(\"#\") || /^ok(lch|hsl)\\(/i.test(value)) {\n\t\treturn value;\n\t}\n\tif (visited.has(value)) {\n\t\tthrow new Error(`Circular variable reference detected: ${value}`);\n\t}\n\tif (!(value in vars)) {\n\t\tthrow new Error(`Variable reference not found: ${value}`);\n\t}\n\tvisited.add(value);\n\treturn resolveVarRefs(vars[value], vars, visited);\n}\n\nfunction resolveThemeColors<T extends Record<string, ColorValue>>(\n\tcolors: T,\n\tvars: Record<string, ColorValue> = {},\n): Record<keyof T, string | number> {\n\tconst resolved: Record<string, string | number> = {};\n\tfor (const [key, value] of Object.entries(colors)) {\n\t\tresolved[key] = resolveVarRefs(value, vars);\n\t}\n\treturn resolved as Record<keyof T, string | number>;\n}\n\nfunction withThemeColorFallbacks(colors: ThemeJson[\"colors\"]): ThemeJson[\"colors\"] & {\n\tscrollbarTrack: ColorValue;\n\tscrollbarThumb: ColorValue;\n\tthinkingMax: ColorValue;\n\tsearchMatchBg: ColorValue;\n\tsearchMatchText: ColorValue;\n} {\n\treturn {\n\t\t...colors,\n\t\tscrollbarTrack: colors.scrollbarTrack ?? colors.muted,\n\t\tscrollbarThumb: colors.scrollbarThumb ?? colors.text,\n\t\tthinkingMax: colors.thinkingMax ?? colors.thinkingXhigh,\n\t\tsearchMatchBg: colors.searchMatchBg ?? colors.selectedBg,\n\t\tsearchMatchText: colors.searchMatchText ?? colors.text,\n\t};\n}\n\n// ============================================================================\n// Appearance & Terminal Default Colors\n// ============================================================================\n\n/** The background a theme is designed for. */\nexport type ThemeAppearance = TerminalTheme;\n\n// The terminal's reported colors. Replaced (never mutated) on update, so themes can cache resolved colors\n// by identity.\nlet terminalColors: TerminalColors = {};\n// While the terminal color query is in flight, the system theme renders in grayscale.\nlet terminalColorsPending = false;\n// The terminal's last light/dark report (mode 2031). Only used while it has not reported a background.\nlet terminalColorScheme: TerminalTheme | undefined;\n\n/**\n * Record the terminal's reported colors. Themes use the default colors for tokens set to \"\" (terminal\n * default); the system theme is generated from all of them. Ends the pending state.\n */\nexport function setTerminalColors(colors: TerminalColors): void {\n\tterminalColors = { ...colors };\n\tterminalColorsPending = false;\n}\n\n/** Record the terminal's light/dark report, the fallback for terminals that do not report their background. */\nexport function setTerminalColorScheme(scheme: TerminalTheme | undefined): void {\n\tterminalColorScheme = scheme;\n}\n\n/** Render the system theme in grayscale until `setTerminalColors()` reports the terminal's colors. */\nexport function markTerminalColorsPending(): void {\n\tterminalColorsPending = true;\n}\n\n/** Assumed terminal default colors when the terminal does not report them. */\nconst GUESSED_DEFAULT_COLORS: Record<ThemeAppearance, { foreground: Color; background: Color }> = {\n\tdark: { foreground: parseColor(\"#e5e5e7\"), background: parseColor(\"#000000\") },\n\tlight: { foreground: parseColor(\"#000000\"), background: parseColor(\"#ffffff\") },\n};\n\nfunction averageLightness(colors: Color[]): number | undefined {\n\t// Palette colors 0-15 follow the user's terminal palette, so they say nothing about the theme.\n\tconst fixed = colors.filter((color) => color.kind !== \"indexed\" || color.index >= 16);\n\tif (fixed.length === 0) return undefined;\n\treturn fixed.reduce((sum, color) => sum + colorToOklch(color).l, 0) / fixed.length;\n}\n\n/** Detect the background a theme is designed for from the lightness of its own colors. */\nfunction detectAppearance(foregrounds: Color[], backgrounds: Color[]): ThemeAppearance | undefined {\n\tconst fg = averageLightness(foregrounds);\n\tconst bg = averageLightness(backgrounds);\n\tif (fg !== undefined && bg !== undefined) return bg < fg ? \"dark\" : \"light\";\n\tif (bg !== undefined) return bg < 0.5 ? \"dark\" : \"light\";\n\tif (fg !== undefined) return fg > 0.5 ? \"dark\" : \"light\";\n\treturn undefined;\n}\n\n// ============================================================================\n// Theme Class\n// ============================================================================\n\nexport class Theme {\n\treadonly name?: string;\n\treadonly sourcePath?: string;\n\tsourceInfo?: SourceInfo;\n\tprivate mode: TerminalColorMode;\n\t// Precomputed escape sequences keep fg()/bg() on the render hot path to a lookup and concat.\n\tprivate readonly fgAnsi = new Map<ThemeColor, string>();\n\tprivate readonly bgAnsi = new Map<ThemeBg, string>();\n\t// Tokens set to \"\" have no color of their own; `colors` fills them from the terminal defaults.\n\tprivate readonly concreteColors: Partial<Record<ThemeToken, Color>> = {};\n\tprivate readonly defaultForegroundTokens: ThemeToken[] = [];\n\tprivate readonly defaultBackgroundTokens: ThemeToken[] = [];\n\t// Foreground tokens rendered faint (SGR 2) on top of their color.\n\tprivate readonly dimTokens: ReadonlySet<ThemeColor>;\n\tprivate readonly ownAppearance: ThemeAppearance | undefined;\n\tprivate resolvedColors: { terminal: TerminalColors; colors: Readonly<Record<ThemeToken, Color>> } | undefined;\n\n\tconstructor(\n\t\tfgColors: Record<Exclude<ThemeColor, OptionalThemeColor>, string | number> &\n\t\t\tPartial<Record<OptionalThemeColor, string | number>>,\n\t\tbgColors: Record<Exclude<ThemeBg, OptionalThemeBg>, string | number> &\n\t\t\tPartial<Record<OptionalThemeBg, string | number>>,\n\t\tmode: TerminalColorMode,\n\t\toptions: {\n\t\t\tname?: string;\n\t\t\tsourcePath?: string;\n\t\t\tsourceInfo?: SourceInfo;\n\t\t\tappearance?: ThemeAppearance;\n\t\t\t/** Foreground tokens to render faint (SGR 2). */\n\t\t\tdim?: readonly ThemeColor[];\n\t\t} = {},\n\t) {\n\t\tthis.name = options.name;\n\t\tthis.sourcePath = options.sourcePath;\n\t\tthis.sourceInfo = options.sourceInfo;\n\t\tthis.mode = mode;\n\t\tthis.dimTokens = new Set(options.dim);\n\t\tconst foregrounds = {\n\t\t\t...fgColors,\n\t\t\tscrollbarTrack: fgColors.scrollbarTrack ?? fgColors.muted,\n\t\t\tscrollbarThumb: fgColors.scrollbarThumb ?? fgColors.text,\n\t\t\tthinkingMax: fgColors.thinkingMax ?? fgColors.thinkingXhigh,\n\t\t\tsearchMatchText: fgColors.searchMatchText ?? fgColors.text,\n\t\t};\n\t\tconst backgrounds = { ...bgColors, searchMatchBg: bgColors.searchMatchBg ?? bgColors.selectedBg };\n\t\tconst concreteForegrounds: Color[] = [];\n\t\tconst concreteBackgrounds: Color[] = [];\n\t\t// Returns the escape sequence for the token's own slot.\n\t\tconst addToken = (token: ThemeToken, value: string | number, isBackground: boolean): string => {\n\t\t\tif (value === \"\") {\n\t\t\t\t(isBackground ? this.defaultBackgroundTokens : this.defaultForegroundTokens).push(token);\n\t\t\t\treturn isBackground ? \"\\x1b[49m\" : \"\\x1b[39m\";\n\t\t\t}\n\t\t\tconst color = parseColor(value);\n\t\t\tthis.concreteColors[token] = color;\n\t\t\t(isBackground ? concreteBackgrounds : concreteForegrounds).push(color);\n\t\t\treturn isBackground ? backgroundAnsi(color, mode) : foregroundAnsi(color, mode);\n\t\t};\n\t\tfor (const [token, value] of Object.entries(foregrounds) as [ThemeColor, string | number][]) {\n\t\t\tthis.fgAnsi.set(token, addToken(token, value, false));\n\t\t}\n\t\tfor (const [token, value] of Object.entries(backgrounds) as [ThemeBg, string | number][]) {\n\t\t\tthis.bgAnsi.set(token, addToken(token, value, true));\n\t\t}\n\t\tthis.ownAppearance = options.appearance ?? detectAppearance(concreteForegrounds, concreteBackgrounds);\n\t}\n\n\t/**\n\t * The background the theme is designed for: declared in the theme JSON, detected from its colors,\n\t * or, for themes without usable colors, the terminal's appearance.\n\t */\n\tget appearance(): ThemeAppearance {\n\t\treturn this.ownAppearance ?? getTerminalTheme();\n\t}\n\n\t/**\n\t * Concrete colors for all tokens. Tokens set to \"\" (terminal default) use the terminal's reported\n\t * default colors, or a guess based on `appearance` when the terminal did not report them. Faint\n\t * tokens are approximated by mixing their color toward the background.\n\t */\n\tget colors(): Readonly<Record<ThemeToken, Color>> {\n\t\tconst terminal = terminalColors;\n\t\tif (this.resolvedColors?.terminal !== terminal) {\n\t\t\tconst guess = GUESSED_DEFAULT_COLORS[this.appearance];\n\t\t\tconst toColor = (rgb: RgbColor | undefined, fallback: Color) =>\n\t\t\t\trgb ? rgbColor(rgb.r, rgb.g, rgb.b) : fallback;\n\t\t\tconst foreground = toColor(terminal.foreground, guess.foreground);\n\t\t\tconst background = toColor(terminal.background, guess.background);\n\t\t\tconst colors = { ...this.concreteColors };\n\t\t\tfor (const token of this.defaultForegroundTokens) colors[token] = foreground;\n\t\t\tfor (const token of this.defaultBackgroundTokens) colors[token] = background;\n\t\t\tfor (const token of this.dimTokens) {\n\t\t\t\tconst color = colors[token];\n\t\t\t\tif (color) colors[token] = mixColors(color, background, 0.4);\n\t\t\t}\n\t\t\tthis.resolvedColors = { terminal, colors: Object.freeze(colors as Record<ThemeToken, Color>) };\n\t\t}\n\t\treturn this.resolvedColors.colors;\n\t}\n\n\tstyle(text: string, options: ThemeStyle): string {\n\t\tconst { fg, bg } = options;\n\t\tif (typeof fg === \"string\" && this.dimTokens.has(fg)) options = { ...options, dim: true };\n\t\treturn styleTextWithAnsi(\n\t\t\ttext,\n\t\t\tfg === undefined\n\t\t\t\t? undefined\n\t\t\t\t: typeof fg === \"string\"\n\t\t\t\t\t? this.tokenAnsi(this.fgAnsi, fg)\n\t\t\t\t\t: foregroundAnsi(fg, this.mode),\n\t\t\tbg === undefined\n\t\t\t\t? undefined\n\t\t\t\t: typeof bg === \"string\"\n\t\t\t\t\t? this.tokenAnsi(this.bgAnsi, bg)\n\t\t\t\t\t: backgroundAnsi(bg, this.mode),\n\t\t\toptions,\n\t\t);\n\t}\n\n\tfg(color: ThemeColor, text: string): string {\n\t\tconst ansi = this.tokenAnsi(this.fgAnsi, color);\n\t\tif (this.dimTokens.has(color)) return `${ansi}\\x1b[2m${text}\\x1b[22;39m`;\n\t\treturn `${ansi}${text}\\x1b[39m`;\n\t}\n\n\tbg(color: ThemeBg, text: string): string {\n\t\tconst ansi = this.tokenAnsi(this.bgAnsi, color);\n\t\treturn `${ansi}${text}\\x1b[49m`;\n\t}\n\n\tprivate tokenAnsi<T extends ThemeToken>(ansi: Map<T, string>, token: T): string {\n\t\tconst value = ansi.get(token);\n\t\tif (value === undefined) throw new Error(`Unknown theme color: ${token}`);\n\t\treturn value;\n\t}\n\n\tbold(text: string): string {\n\t\treturn chalk.bold(text);\n\t}\n\n\titalic(text: string): string {\n\t\treturn chalk.italic(text);\n\t}\n\n\tunderline(text: string): string {\n\t\treturn chalk.underline(text);\n\t}\n\n\tinverse(text: string): string {\n\t\treturn chalk.inverse(text);\n\t}\n\n\tstrikethrough(text: string): string {\n\t\treturn chalk.strikethrough(text);\n\t}\n\n\t/** Opening escape sequence for a foreground token. Faint tokens include SGR 2, which `\\x1b[22m` closes. */\n\tgetFgAnsi(color: ThemeColor): string {\n\t\tconst ansi = this.tokenAnsi(this.fgAnsi, color);\n\t\treturn this.dimTokens.has(color) ? `${ansi}\\x1b[2m` : ansi;\n\t}\n\n\tgetBgAnsi(color: ThemeBg): string {\n\t\treturn this.tokenAnsi(this.bgAnsi, color);\n\t}\n\n\tgetColorMode(): TerminalColorMode {\n\t\treturn this.mode;\n\t}\n\n\tgetThinkingBorderColor(level: ThinkingLevel): (str: string) => string {\n\t\t// Map thinking levels to dedicated theme colors\n\t\tswitch (level) {\n\t\t\tcase \"off\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingOff\", str);\n\t\t\tcase \"minimal\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMinimal\", str);\n\t\t\tcase \"low\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingLow\", str);\n\t\t\tcase \"medium\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMedium\", str);\n\t\t\tcase \"high\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingHigh\", str);\n\t\t\tcase \"xhigh\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingXhigh\", str);\n\t\t\tcase \"max\":\n\t\t\t\treturn (str: string) => this.fg(\"thinkingMax\", str);\n\t\t\tdefault:\n\t\t\t\treturn (str: string) => this.fg(\"thinkingOff\", str);\n\t\t}\n\t}\n\n\tgetBashModeBorderColor(): (str: string) => string {\n\t\treturn (str: string) => this.fg(\"bashMode\", str);\n\t}\n}\n\n// ============================================================================\n// Theme Loading\n// ============================================================================\n\nlet BUILTIN_THEMES: Record<string, ThemeJson> | undefined;\n\nfunction getBuiltinThemes(): Record<string, ThemeJson> {\n\tif (!BUILTIN_THEMES) {\n\t\tconst themesDir = getThemesDir();\n\t\tconst darkPath = path.join(themesDir, \"dark.json\");\n\t\tconst lightPath = path.join(themesDir, \"light.json\");\n\t\tBUILTIN_THEMES = {\n\t\t\tdark: JSON.parse(stripBom(fs.readFileSync(darkPath, \"utf-8\"))) as ThemeJson,\n\t\t\tlight: JSON.parse(stripBom(fs.readFileSync(lightPath, \"utf-8\"))) as ThemeJson,\n\t\t};\n\t}\n\treturn BUILTIN_THEMES;\n}\n\nexport function getAvailableThemes(): string[] {\n\treturn getAvailableThemesWithPaths().map(({ name }) => name);\n}\n\nexport interface ThemeInfo {\n\tname: string;\n\tpath: string | undefined;\n}\n\nexport function getAvailableThemesWithPaths(): ThemeInfo[] {\n\tconst themesDir = getThemesDir();\n\tconst result: ThemeInfo[] = [];\n\tconst seen = new Set<string>();\n\tconst addTheme = (themeInfo: ThemeInfo) => {\n\t\tif (seen.has(themeInfo.name)) {\n\t\t\treturn;\n\t\t}\n\t\tseen.add(themeInfo.name);\n\t\tresult.push(themeInfo);\n\t};\n\n\t// Built-in themes. The system theme is generated, so it has no file.\n\taddTheme({ name: SYSTEM_THEME_NAME, path: undefined });\n\tfor (const name of Object.keys(getBuiltinThemes())) {\n\t\taddTheme({ name, path: path.join(themesDir, `${name}.json`) });\n\t}\n\n\t// Custom themes\n\tfor (const themeInfo of getCustomThemeInfos()) {\n\t\taddTheme(themeInfo);\n\t}\n\n\tfor (const [name, theme] of registeredThemes.entries()) {\n\t\taddTheme({ name, path: theme.sourcePath });\n\t}\n\n\t// The system theme comes first: it is the default and adapts to every terminal.\n\treturn result.sort((a, b) =>\n\t\ta.name === SYSTEM_THEME_NAME ? -1 : b.name === SYSTEM_THEME_NAME ? 1 : a.name.localeCompare(b.name),\n\t);\n}\n\nfunction getCustomThemeInfos(): ThemeInfo[] {\n\tconst customThemesDir = getCustomThemesDir();\n\tconst result: ThemeInfo[] = [];\n\tif (!fs.existsSync(customThemesDir)) {\n\t\treturn result;\n\t}\n\n\tfor (const file of fs.readdirSync(customThemesDir)) {\n\t\tif (!file.endsWith(\".json\")) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst themePath = path.join(customThemesDir, file);\n\t\ttry {\n\t\t\tconst customTheme = loadThemeFromPath(themePath);\n\t\t\tif (customTheme.name) {\n\t\t\t\tresult.push({ name: customTheme.name, path: themePath });\n\t\t\t}\n\t\t} catch {\n\t\t\t// Invalid themes are ignored here; the resource loader reports them\n\t\t\t// during normal startup/reload.\n\t\t}\n\t}\n\treturn result;\n}\n\nfunction assertThemeNameIsValid(name: string): void {\n\tif (name.includes(\"/\")) {\n\t\tthrow new Error(\n\t\t\t`Invalid theme name \"${name}\": theme names cannot contain \"/\" because it is reserved for automatic light/dark theme settings.`,\n\t\t);\n\t}\n}\n\nfunction parseThemeJson(label: string, json: unknown): ThemeJson {\n\tif (themeJsonValidator) return themeJsonValidator(label, json);\n\tif (typeof json !== \"object\" || json === null || !(\"colors\" in json)) {\n\t\tthrow new Error(`Invalid theme \"${label}\": expected an object with a \"colors\" map.`);\n\t}\n\treturn json as ThemeJson;\n}\n\nfunction parseThemeJsonContent(label: string, content: string): ThemeJson {\n\tlet json: unknown;\n\ttry {\n\t\tjson = JSON.parse(stripBom(content));\n\t} catch (error) {\n\t\tthrow new Error(`Failed to parse theme ${label}: ${error}`);\n\t}\n\treturn parseThemeJson(label, json);\n}\n\nfunction loadThemeJson(name: string): ThemeJson {\n\tconst builtinThemes = getBuiltinThemes();\n\tif (name in builtinThemes) {\n\t\treturn builtinThemes[name];\n\t}\n\tconst registeredTheme = registeredThemes.get(name);\n\tif (registeredTheme?.sourcePath) {\n\t\tconst content = fs.readFileSync(registeredTheme.sourcePath, \"utf-8\");\n\t\treturn parseThemeJsonContent(registeredTheme.sourcePath, content);\n\t}\n\tif (registeredTheme) {\n\t\tthrow new Error(`Theme \"${name}\" does not have a source path for export`);\n\t}\n\tconst customThemesDir = getCustomThemesDir();\n\tconst themePath = path.join(customThemesDir, `${name}.json`);\n\tif (!fs.existsSync(themePath)) {\n\t\tthrow new Error(`Theme not found: ${name}`);\n\t}\n\tconst content = fs.readFileSync(themePath, \"utf-8\");\n\treturn parseThemeJsonContent(name, content);\n}\n\nconst BACKGROUND_TOKENS: ReadonlySet<string> = new Set<ThemeBg>([\n\t\"selectedBg\",\n\t\"searchMatchBg\",\n\t\"userMessageBg\",\n\t\"customMessageBg\",\n\t\"toolPendingBg\",\n\t\"toolSuccessBg\",\n\t\"toolErrorBg\",\n]);\n\nfunction splitThemeColors(colors: Record<string, string | number>): {\n\tfgColors: Record<ThemeColor, string | number>;\n\tbgColors: Record<ThemeBg, string | number>;\n} {\n\tconst fgColors = {} as Record<ThemeColor, string | number>;\n\tconst bgColors = {} as Record<ThemeBg, string | number>;\n\tfor (const [key, value] of Object.entries(colors)) {\n\t\tif (BACKGROUND_TOKENS.has(key)) {\n\t\t\tbgColors[key as ThemeBg] = value;\n\t\t} else {\n\t\t\tfgColors[key as ThemeColor] = value;\n\t\t}\n\t}\n\treturn { fgColors, bgColors };\n}\n\nfunction createTheme(themeJson: ThemeJson, mode?: TerminalColorMode, sourcePath?: string): Theme {\n\tconst colorMode = mode ?? getTerminalColorMode();\n\tconst resolvedColors = resolveThemeColors(withThemeColorFallbacks(themeJson.colors), themeJson.vars);\n\tconst { fgColors, bgColors } = splitThemeColors(resolvedColors);\n\treturn new Theme(fgColors, bgColors, colorMode, {\n\t\tname: themeJson.name,\n\t\tsourcePath,\n\t\tappearance: themeJson.appearance,\n\t});\n}\n\n/** Generate the system theme from the terminal's reported colors (grayscale while they are pending). */\nfunction createSystemTheme(mode?: TerminalColorMode): Theme {\n\tconst generated = generateSystemThemeColors({\n\t\t...terminalColors,\n\t\tsaturation: terminalColorsPending ? 0 : 1,\n\t\tappearanceHint: getTerminalTheme(),\n\t});\n\tconst { fgColors, bgColors } = splitThemeColors(generated.colors);\n\treturn new Theme(fgColors, bgColors, mode ?? getTerminalColorMode(), {\n\t\tname: SYSTEM_THEME_NAME,\n\t\tappearance: generated.appearance,\n\t\tdim: generated.dim,\n\t});\n}\n\nexport function loadThemeFromPath(themePath: string, mode?: TerminalColorMode): Theme {\n\tconst content = fs.readFileSync(themePath, \"utf-8\");\n\tconst themeJson = parseThemeJsonContent(themePath, content);\n\treturn createTheme(themeJson, mode, themePath);\n}\n\nfunction loadTheme(name: string, mode?: TerminalColorMode): Theme {\n\t// The system theme name is reserved: it takes precedence over custom themes of the same name.\n\tif (name === SYSTEM_THEME_NAME) return createSystemTheme(mode);\n\tconst registeredTheme = registeredThemes.get(name);\n\tif (registeredTheme) {\n\t\treturn registeredTheme;\n\t}\n\tconst themeJson = loadThemeJson(name);\n\treturn createTheme(themeJson, mode);\n}\n\nexport function getThemeByName(name: string): Theme | undefined {\n\ttry {\n\t\treturn loadTheme(name);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport type TerminalTheme = \"dark\" | \"light\";\n\nexport function parseAutoThemeSetting(\n\tthemeSetting: string | undefined,\n): { lightTheme: string; darkTheme: string } | undefined {\n\tif (!themeSetting) return undefined;\n\tconst slashIndex = themeSetting.indexOf(\"/\");\n\tif (slashIndex === -1 || themeSetting.indexOf(\"/\", slashIndex + 1) !== -1) {\n\t\treturn undefined;\n\t}\n\n\tconst lightTheme = themeSetting.slice(0, slashIndex).trim();\n\tconst darkTheme = themeSetting.slice(slashIndex + 1).trim();\n\tif (!lightTheme || !darkTheme) {\n\t\treturn undefined;\n\t}\n\treturn { lightTheme, darkTheme };\n}\n\nexport function resolveThemeSetting(\n\tthemeSetting: string | undefined,\n\tterminalTheme: TerminalTheme,\n): string | undefined {\n\tconst autoTheme = parseAutoThemeSetting(themeSetting);\n\tif (autoTheme) {\n\t\treturn terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme;\n\t}\n\tif (themeSetting?.includes(\"/\")) return undefined;\n\tif (typeof themeSetting === \"string\") return themeSetting;\n\treturn undefined;\n}\n\n/**\n * Dark or light from the `COLORFGBG` environment variable some terminals set, or undefined without a\n * usable background index. The value is `fg;bg` or `fg;xpm;bg` (rxvt), where a field is an ANSI color\n * index or `default` when the color is not in the palette. The index refers to the terminal's own palette,\n * whose colors are unknown here, so it is classified by index like Vim does: 0-6 and 8 (bright black, e.g.\n * Solarized Dark's background) are dark, 7 and 9-15 are light.\n */\nexport function detectColorFgBgTheme(env: NodeJS.ProcessEnv = process.env): TerminalTheme | undefined {\n\tconst bg = env.COLORFGBG?.split(\";\").at(-1)?.trim();\n\tif (!bg || !/^\\d{1,2}$/.test(bg)) return undefined;\n\tconst index = Number(bg);\n\tif (index > 15) return undefined;\n\treturn index <= 6 || index === 8 ? \"dark\" : \"light\";\n}\n\n/**\n * Whether the terminal is dark or light. The background it renders decides, classified the same way the\n * system theme does. Without a reported background: the terminal's light/dark report, then COLORFGBG,\n * then dark.\n */\nexport function detectTerminalTheme(\n\tcolors: TerminalColors = {},\n\treportedScheme?: TerminalTheme,\n\tenv: NodeJS.ProcessEnv = process.env,\n): TerminalTheme {\n\tconst { background, foreground } = colors;\n\tif (background) return terminalAppearance(background, foreground);\n\treturn reportedScheme ?? detectColorFgBgTheme(env) ?? \"dark\";\n}\n\n/** Whether the terminal is dark or light, from everything it reported so far. See `detectTerminalTheme()`. */\nexport function getTerminalTheme(): TerminalTheme {\n\treturn detectTerminalTheme(terminalColors, terminalColorScheme);\n}\n\n// ============================================================================\n// Global Theme Instance\n// ============================================================================\n\n// Use globalThis to share theme across module loaders (node + jiti in dev mode)\nconst THEME_KEY = Symbol.for(\"@earendil-works/pi-coding-agent:theme\");\nconst THEME_KEY_OLD = Symbol.for(\"@mariozechner/pi-coding-agent:theme\");\n\n// Export theme as a getter that reads from globalThis\n// This ensures all module instances (node, jiti) see the same theme\nexport const theme: Theme = new Proxy({} as Theme, {\n\tget(_target, prop) {\n\t\tconst t = (globalThis as Record<symbol, Theme>)[THEME_KEY];\n\t\tif (!t) throw new Error(\"Theme not initialized. Call initTheme() first.\");\n\t\treturn (t as unknown as Record<string | symbol, unknown>)[prop];\n\t},\n});\n\nfunction setGlobalTheme(t: Theme): void {\n\t(globalThis as Record<symbol, Theme>)[THEME_KEY] = t;\n\t(globalThis as Record<symbol, Theme>)[THEME_KEY_OLD] = t;\n}\n\nlet currentThemeName: string | undefined;\nlet themeWatcher: fs.FSWatcher | undefined;\nlet themeReloadTimer: NodeJS.Timeout | undefined;\nlet onThemeChangeCallback: (() => void) | undefined;\nconst registeredThemes = new Map<string, Theme>();\n\nexport function setRegisteredThemes(themes: Theme[]): void {\n\tregisteredThemes.clear();\n\tfor (const theme of themes) {\n\t\tif (theme.name) {\n\t\t\tassertThemeNameIsValid(theme.name);\n\t\t\tregisteredThemes.set(theme.name, theme);\n\t\t}\n\t}\n}\n\nexport function initTheme(themeName?: string, enableWatcher: boolean = false): void {\n\tconst name = themeName ?? SYSTEM_THEME_NAME;\n\tcurrentThemeName = name;\n\ttry {\n\t\tsetGlobalTheme(loadTheme(name));\n\t\tif (enableWatcher) {\n\t\t\tstartThemeWatcher();\n\t\t}\n\t} catch (_error) {\n\t\t// Theme is invalid - fall back to the system theme silently\n\t\tcurrentThemeName = SYSTEM_THEME_NAME;\n\t\tsetGlobalTheme(loadTheme(SYSTEM_THEME_NAME));\n\t\t// Don't start watcher for fallback theme\n\t}\n}\n\nexport function setTheme(name: string, enableWatcher: boolean = false): { success: boolean; error?: string } {\n\tcurrentThemeName = name;\n\ttry {\n\t\tsetGlobalTheme(loadTheme(name));\n\t\tif (enableWatcher) {\n\t\t\tstartThemeWatcher();\n\t\t}\n\t\tif (onThemeChangeCallback) {\n\t\t\tonThemeChangeCallback();\n\t\t}\n\t\treturn { success: true };\n\t} catch (error) {\n\t\t// Theme is invalid - fall back to the system theme\n\t\tcurrentThemeName = SYSTEM_THEME_NAME;\n\t\tsetGlobalTheme(loadTheme(SYSTEM_THEME_NAME));\n\t\t// Don't start watcher for fallback theme\n\t\treturn {\n\t\t\tsuccess: false,\n\t\t\terror: error instanceof Error ? error.message : String(error),\n\t\t};\n\t}\n}\n\nexport function setThemeInstance(themeInstance: Theme): void {\n\tsetGlobalTheme(themeInstance);\n\tcurrentThemeName = \"<in-memory>\";\n\tstopThemeWatcher(); // Can't watch a direct instance\n\tif (onThemeChangeCallback) {\n\t\tonThemeChangeCallback();\n\t}\n}\n\nexport function onThemeChange(callback: () => void): void {\n\tonThemeChangeCallback = callback;\n}\n\nfunction startThemeWatcher(): void {\n\tstopThemeWatcher();\n\n\t// Only watch if it's a custom theme (not built-in)\n\tif (\n\t\t!currentThemeName ||\n\t\tcurrentThemeName === \"dark\" ||\n\t\tcurrentThemeName === \"light\" ||\n\t\tcurrentThemeName === SYSTEM_THEME_NAME\n\t) {\n\t\treturn;\n\t}\n\n\tconst customThemesDir = getCustomThemesDir();\n\tconst watchedThemeName = currentThemeName;\n\tconst watchedFileName = `${watchedThemeName}.json`;\n\tconst themeFile = path.join(customThemesDir, watchedFileName);\n\n\t// Only watch if the file exists\n\tif (!fs.existsSync(themeFile)) {\n\t\treturn;\n\t}\n\n\tconst scheduleReload = () => {\n\t\tif (themeReloadTimer) {\n\t\t\tclearTimeout(themeReloadTimer);\n\t\t}\n\t\tthemeReloadTimer = setTimeout(() => {\n\t\t\tthemeReloadTimer = undefined;\n\n\t\t\t// Ignore stale timers after switching themes or stopping the watcher\n\t\t\tif (currentThemeName !== watchedThemeName) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Keep the last successfully loaded theme active if the file is temporarily missing\n\t\t\tif (!fs.existsSync(themeFile)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// Reload the theme from disk and refresh the registry cache\n\t\t\t\tconst reloadedTheme = loadThemeFromPath(themeFile);\n\t\t\t\tregisteredThemes.set(watchedThemeName, reloadedTheme);\n\t\t\t\tsetGlobalTheme(reloadedTheme);\n\t\t\t\t// Notify callback (to invalidate UI)\n\t\t\t\tif (onThemeChangeCallback) {\n\t\t\t\t\tonThemeChangeCallback();\n\t\t\t\t}\n\t\t\t} catch (_error) {\n\t\t\t\t// Ignore errors (file might be in invalid state while being edited)\n\t\t\t}\n\t\t}, 100);\n\t};\n\n\tthemeWatcher =\n\t\twatchWithErrorHandler(\n\t\t\tcustomThemesDir,\n\t\t\t(_eventType, filename) => {\n\t\t\t\tif (currentThemeName !== watchedThemeName) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (!filename) {\n\t\t\t\t\tscheduleReload();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (filename !== watchedFileName) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tscheduleReload();\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tcloseWatcher(themeWatcher);\n\t\t\t\tthemeWatcher = undefined;\n\t\t\t},\n\t\t) ?? undefined;\n}\n\nexport function stopThemeWatcher(): void {\n\tif (themeReloadTimer) {\n\t\tclearTimeout(themeReloadTimer);\n\t\tthemeReloadTimer = undefined;\n\t}\n\tcloseWatcher(themeWatcher);\n\tthemeWatcher = undefined;\n}\n\n// ============================================================================\n// HTML Export Helpers\n// ============================================================================\n\n/**\n * Get resolved theme colors as CSS-compatible hex strings.\n * Used by HTML export to generate CSS custom properties.\n */\nexport function getResolvedThemeColors(themeName?: string): Record<string, string> {\n\tconst colors = loadTheme(themeName ?? currentThemeName ?? SYSTEM_THEME_NAME).colors;\n\treturn Object.fromEntries(Object.entries(colors).map(([token, color]) => [token, colorToHex(color)]));\n}\n\n/**\n * Check if a theme is a \"light\" theme (for CSS that needs light/dark variants).\n */\nexport function isLightTheme(themeName?: string): boolean {\n\treturn loadTheme(themeName ?? currentThemeName ?? SYSTEM_THEME_NAME).appearance === \"light\";\n}\n\n/**\n * Get explicit export colors from theme JSON, if specified.\n * Returns undefined for each color that isn't explicitly set.\n */\nexport function getThemeExportColors(themeName?: string): {\n\tpageBg?: string;\n\tcardBg?: string;\n\tinfoBg?: string;\n} {\n\tconst name = themeName ?? currentThemeName ?? SYSTEM_THEME_NAME;\n\tif (name === SYSTEM_THEME_NAME) return {};\n\ttry {\n\t\tconst themeJson = loadThemeJson(name);\n\t\tconst exportSection = themeJson.export;\n\t\tif (!exportSection) return {};\n\n\t\tconst vars = themeJson.vars ?? {};\n\t\t// Export colors end up in CSS, which understands hex and oklch() values directly but not okhsl().\n\t\tconst resolve = (value: ColorValue | undefined): string | undefined => {\n\t\t\tif (value === undefined) return undefined;\n\t\t\tconst resolved = resolveVarRefs(value, vars);\n\t\t\tif (typeof resolved === \"number\") return colorToHex(indexedColor(resolved));\n\t\t\tif (resolved === \"\") return undefined;\n\t\t\tif (/^okhsl\\(/i.test(resolved)) return colorToHex(parseColor(resolved));\n\t\t\treturn resolved;\n\t\t};\n\n\t\treturn {\n\t\t\tpageBg: resolve(exportSection.pageBg),\n\t\t\tcardBg: resolve(exportSection.cardBg),\n\t\t\tinfoBg: resolve(exportSection.infoBg),\n\t\t};\n\t} catch {\n\t\treturn {};\n\t}\n}\n\n// ============================================================================\n// TUI Helpers\n// ============================================================================\n\ntype CliHighlightTheme = Record<string, (s: string) => string>;\n\nlet cachedHighlightThemeFor: Theme | undefined;\nlet cachedCliHighlightTheme: CliHighlightTheme | undefined;\n\nfunction buildCliHighlightTheme(t: Theme): CliHighlightTheme {\n\treturn {\n\t\tkeyword: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tbuilt_in: (s: string) => t.fg(\"syntaxType\", s),\n\t\tliteral: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tnumber: (s: string) => t.fg(\"syntaxNumber\", s),\n\t\tregexp: (s: string) => t.fg(\"syntaxString\", s),\n\t\tstring: (s: string) => t.fg(\"syntaxString\", s),\n\t\tsubst: (s: string) => t.fg(\"text\", s),\n\t\tcomment: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tdoctag: (s: string) => t.fg(\"syntaxComment\", s),\n\t\tmeta: (s: string) => t.fg(\"muted\", s),\n\t\tfunction: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\ttitle: (s: string) => t.fg(\"syntaxFunction\", s),\n\t\tclass: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttype: (s: string) => t.fg(\"syntaxType\", s),\n\t\ttag: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\tname: (s: string) => t.fg(\"syntaxKeyword\", s),\n\t\tattr: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tvariable: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\tparams: (s: string) => t.fg(\"syntaxVariable\", s),\n\t\toperator: (s: string) => t.fg(\"syntaxOperator\", s),\n\t\tpunctuation: (s: string) => t.fg(\"syntaxPunctuation\", s),\n\t\temphasis: (s: string) => t.italic(s),\n\t\tstrong: (s: string) => t.bold(s),\n\t\tlink: (s: string) => t.underline(s),\n\t\taddition: (s: string) => t.fg(\"toolDiffAdded\", s),\n\t\tdeletion: (s: string) => t.fg(\"toolDiffRemoved\", s),\n\t};\n}\n\nfunction getCliHighlightTheme(t: Theme): CliHighlightTheme {\n\tif (cachedHighlightThemeFor !== t || !cachedCliHighlightTheme) {\n\t\tcachedHighlightThemeFor = t;\n\t\tcachedCliHighlightTheme = buildCliHighlightTheme(t);\n\t}\n\treturn cachedCliHighlightTheme;\n}\n\n/**\n * Highlight code with syntax coloring based on file extension or language.\n * Returns array of highlighted lines.\n */\nexport function highlightCode(code: string, lang?: string): string[] {\n\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t// LiveCodeServer, etc., coloring random English words as keywords.\n\tif (!validLang) {\n\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t}\n\tconst opts = {\n\t\tlanguage: validLang,\n\t\tignoreIllegals: true,\n\t\ttheme: getCliHighlightTheme(theme),\n\t};\n\ttry {\n\t\treturn highlight(code, opts).split(\"\\n\");\n\t} catch {\n\t\treturn code.split(\"\\n\");\n\t}\n}\n\n/**\n * Get language identifier from file path extension.\n */\nexport function getLanguageFromPath(filePath: string): string | undefined {\n\tconst ext = filePath.split(\".\").pop()?.toLowerCase();\n\tif (!ext) return undefined;\n\n\tconst extToLang: Record<string, string> = {\n\t\tts: \"typescript\",\n\t\ttsx: \"typescript\",\n\t\tjs: \"javascript\",\n\t\tjsx: \"javascript\",\n\t\tmjs: \"javascript\",\n\t\tcjs: \"javascript\",\n\t\tpy: \"python\",\n\t\trb: \"ruby\",\n\t\trs: \"rust\",\n\t\tgo: \"go\",\n\t\tjava: \"java\",\n\t\tkt: \"kotlin\",\n\t\tswift: \"swift\",\n\t\tc: \"c\",\n\t\th: \"c\",\n\t\tcpp: \"cpp\",\n\t\tcc: \"cpp\",\n\t\tcxx: \"cpp\",\n\t\thpp: \"cpp\",\n\t\tcs: \"csharp\",\n\t\tphp: \"php\",\n\t\tsh: \"bash\",\n\t\tbash: \"bash\",\n\t\tzsh: \"bash\",\n\t\tfish: \"fish\",\n\t\tps1: \"powershell\",\n\t\tsql: \"sql\",\n\t\thtml: \"html\",\n\t\thtm: \"html\",\n\t\tcss: \"css\",\n\t\tscss: \"scss\",\n\t\tsass: \"sass\",\n\t\tless: \"less\",\n\t\tjson: \"json\",\n\t\tyaml: \"yaml\",\n\t\tyml: \"yaml\",\n\t\ttoml: \"toml\",\n\t\txml: \"xml\",\n\t\tmd: \"markdown\",\n\t\tmarkdown: \"markdown\",\n\t\tdockerfile: \"dockerfile\",\n\t\tmakefile: \"makefile\",\n\t\tcmake: \"cmake\",\n\t\tlua: \"lua\",\n\t\tperl: \"perl\",\n\t\tr: \"r\",\n\t\tscala: \"scala\",\n\t\tclj: \"clojure\",\n\t\tex: \"elixir\",\n\t\texs: \"elixir\",\n\t\terl: \"erlang\",\n\t\ths: \"haskell\",\n\t\tml: \"ocaml\",\n\t\tvim: \"vim\",\n\t\tgraphql: \"graphql\",\n\t\tproto: \"protobuf\",\n\t\ttf: \"hcl\",\n\t\thcl: \"hcl\",\n\t};\n\n\treturn extToLang[ext];\n}\n\nexport function getMarkdownTheme(): MarkdownTheme {\n\treturn {\n\t\theading: (text: string) => theme.fg(\"mdHeading\", text),\n\t\tlink: (text: string) => theme.fg(\"mdLink\", text),\n\t\tlinkUrl: (text: string) => theme.fg(\"mdLinkUrl\", text),\n\t\tcode: (text: string) => theme.fg(\"mdCode\", text),\n\t\tcodeBlock: (text: string) => theme.fg(\"mdCodeBlock\", text),\n\t\tcodeBlockBorder: (text: string) => theme.fg(\"mdCodeBlockBorder\", text),\n\t\tquote: (text: string) => theme.fg(\"mdQuote\", text),\n\t\tquoteBorder: (text: string) => theme.fg(\"mdQuoteBorder\", text),\n\t\thr: (text: string) => theme.fg(\"mdHr\", text),\n\t\tlistBullet: (text: string) => theme.fg(\"mdListBullet\", text),\n\t\tbold: (text: string) => theme.bold(text),\n\t\titalic: (text: string) => theme.italic(text),\n\t\tunderline: (text: string) => theme.underline(text),\n\t\tstrikethrough: (text: string) => theme.strikethrough(text),\n\t\thighlightCode: (code: string, lang?: string): string[] => {\n\t\t\t// Validate language before highlighting to avoid stderr spam from cli-highlight\n\t\t\tconst validLang = lang && supportsLanguage(lang) ? lang : undefined;\n\t\t\t// Skip highlighting when no valid language is specified. cli-highlight's\n\t\t\t// auto-detection is unreliable and can misidentify prose as AppleScript,\n\t\t\t// LiveCodeServer, etc., coloring random English words as keywords.\n\t\t\tif (!validLang) {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t\tconst opts = {\n\t\t\t\tlanguage: validLang,\n\t\t\t\tignoreIllegals: true,\n\t\t\t\ttheme: getCliHighlightTheme(theme),\n\t\t\t};\n\t\t\ttry {\n\t\t\t\treturn highlight(code, opts).split(\"\\n\");\n\t\t\t} catch {\n\t\t\t\treturn code.split(\"\\n\").map((line) => theme.fg(\"mdCodeBlock\", line));\n\t\t\t}\n\t\t},\n\t};\n}\n\nexport function getSelectListTheme(): SelectListTheme {\n\treturn {\n\t\tselectedPrefix: (text: string) => theme.fg(\"accent\", text),\n\t\tselectedText: (text: string) => theme.fg(\"accent\", text),\n\t\tdescription: (text: string) => theme.fg(\"muted\", text),\n\t\tscrollInfo: (text: string) => theme.fg(\"muted\", text),\n\t\tnoMatch: (text: string) => theme.fg(\"muted\", text),\n\t};\n}\n\nexport function getEditorTheme(): EditorTheme {\n\treturn {\n\t\tborderColor: (text: string) => theme.fg(\"borderMuted\", text),\n\t\tselectList: getSelectListTheme(),\n\t};\n}\n\nexport function getSettingsListTheme(): SettingsListTheme {\n\treturn {\n\t\tlabel: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : text),\n\t\tvalue: (text: string, selected: boolean) => (selected ? theme.fg(\"accent\", text) : theme.fg(\"muted\", text)),\n\t\tdescription: (text: string) => theme.fg(\"dim\", text),\n\t\tcursor: theme.fg(\"accent\", \"→ \"),\n\t\thint: (text: string) => theme.fg(\"dim\", text),\n\t};\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output files: files pi writes so the model can use output it was not shown in full, such as the
|
|
3
|
+
* full text of truncated tool output, binary MCP resources, and images shown by codemode scripts.
|
|
4
|
+
* Every output file is created here, so where they are stored can change in one place. Today they
|
|
5
|
+
* go to the OS temp directory.
|
|
6
|
+
*/
|
|
7
|
+
import { type WriteStream } from "node:fs";
|
|
8
|
+
/** Write `data` to a new output file and return its path. */
|
|
9
|
+
export declare function writeOutputFile(prefix: string, extension: string, data: string | Uint8Array): Promise<string>;
|
|
10
|
+
/** Open a new output file for streamed output. */
|
|
11
|
+
export declare function createOutputFileStream(prefix: string, extension: string): {
|
|
12
|
+
path: string;
|
|
13
|
+
stream: WriteStream;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=output-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-files.d.ts","sourceRoot":"","sources":["../../src/utils/output-files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC;AAa9D,6DAA6D;AAC7D,wBAAsB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAKnH;AAED,kDAAkD;AAClD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,WAAW,CAAA;CAAE,CAG/G"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Output files: files pi writes so the model can use output it was not shown in full, such as the
|
|
3
|
+
* full text of truncated tool output, binary MCP resources, and images shown by codemode scripts.
|
|
4
|
+
* Every output file is created here, so where they are stored can change in one place. Today they
|
|
5
|
+
* go to the OS temp directory.
|
|
6
|
+
*/
|
|
7
|
+
import { randomBytes } from "node:crypto";
|
|
8
|
+
import { createWriteStream } from "node:fs";
|
|
9
|
+
import { writeFile } from "node:fs/promises";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
/** Output can carry private data, so only the user may read the files. */
|
|
13
|
+
const OUTPUT_FILE_MODE = 0o600;
|
|
14
|
+
/** A new, unused path: `<dir>/<prefix>-<random hex><extension>`. `extension` includes the dot. */
|
|
15
|
+
function createOutputFilePath(prefix, extension) {
|
|
16
|
+
return join(tmpdir(), `${prefix}-${randomBytes(8).toString("hex")}${extension}`);
|
|
17
|
+
}
|
|
18
|
+
/** Write `data` to a new output file and return its path. */
|
|
19
|
+
export async function writeOutputFile(prefix, extension, data) {
|
|
20
|
+
const path = createOutputFilePath(prefix, extension);
|
|
21
|
+
// `wx` never follows a link someone else placed at the path.
|
|
22
|
+
await writeFile(path, data, { mode: OUTPUT_FILE_MODE, flag: "wx" });
|
|
23
|
+
return path;
|
|
24
|
+
}
|
|
25
|
+
/** Open a new output file for streamed output. */
|
|
26
|
+
export function createOutputFileStream(prefix, extension) {
|
|
27
|
+
const path = createOutputFilePath(prefix, extension);
|
|
28
|
+
return { path, stream: createWriteStream(path, { mode: OUTPUT_FILE_MODE, flags: "wx" }) };
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=output-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-files.js","sourceRoot":"","sources":["../../src/utils/output-files.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAoB,MAAM,SAAS,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,0EAA0E;AAC1E,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAE/B,kGAAkG;AAClG,SAAS,oBAAoB,CAAC,MAAc,EAAE,SAAiB;IAC9D,OAAO,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,MAAM,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC;AAClF,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,MAAc,EAAE,SAAiB,EAAE,IAAyB;IACjG,MAAM,IAAI,GAAG,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACrD,6DAA6D;IAC7D,MAAM,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACpE,OAAO,IAAI,CAAC;AACb,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,sBAAsB,CAAC,MAAc,EAAE,SAAiB;IACvE,MAAM,IAAI,GAAG,oBAAoB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACrD,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,iBAAiB,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;AAC3F,CAAC","sourcesContent":["/**\n * Output files: files pi writes so the model can use output it was not shown in full, such as the\n * full text of truncated tool output, binary MCP resources, and images shown by codemode scripts.\n * Every output file is created here, so where they are stored can change in one place. Today they\n * go to the OS temp directory.\n */\n\nimport { randomBytes } from \"node:crypto\";\nimport { createWriteStream, type WriteStream } from \"node:fs\";\nimport { writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\n\n/** Output can carry private data, so only the user may read the files. */\nconst OUTPUT_FILE_MODE = 0o600;\n\n/** A new, unused path: `<dir>/<prefix>-<random hex><extension>`. `extension` includes the dot. */\nfunction createOutputFilePath(prefix: string, extension: string): string {\n\treturn join(tmpdir(), `${prefix}-${randomBytes(8).toString(\"hex\")}${extension}`);\n}\n\n/** Write `data` to a new output file and return its path. */\nexport async function writeOutputFile(prefix: string, extension: string, data: string | Uint8Array): Promise<string> {\n\tconst path = createOutputFilePath(prefix, extension);\n\t// `wx` never follows a link someone else placed at the path.\n\tawait writeFile(path, data, { mode: OUTPUT_FILE_MODE, flag: \"wx\" });\n\treturn path;\n}\n\n/** Open a new output file for streamed output. */\nexport function createOutputFileStream(prefix: string, extension: string): { path: string; stream: WriteStream } {\n\tconst path = createOutputFilePath(prefix, extension);\n\treturn { path, stream: createWriteStream(path, { mode: OUTPUT_FILE_MODE, flags: \"wx\" }) };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syntax-highlight.d.ts","sourceRoot":"","sources":["../../src/utils/syntax-highlight.ts"],"names":[],"mappings":"AAsDA,wBAAgB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAezD;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,CAAC;CACvB;AAoED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,cAAmB,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"syntax-highlight.d.ts","sourceRoot":"","sources":["../../src/utils/syntax-highlight.ts"],"names":[],"mappings":"AAsDA,wBAAgB,yBAAyB,IAAI,OAAO,CAAC,IAAI,CAAC,CAezD;AAED,MAAM,MAAM,kBAAkB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;AAC1D,MAAM,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC,CAAC;AAEzE,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,CAAC;CACvB;AAoED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,cAAmB,GAAG,MAAM,CAyDtF;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,gBAAqB,GAAG,MAAM,CAQ9E;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEtD"}
|
|
@@ -126,7 +126,12 @@ export function renderHighlightedHtml(html, theme = {}) {
|
|
|
126
126
|
return;
|
|
127
127
|
}
|
|
128
128
|
const formatter = getActiveFormatter(scopes, theme);
|
|
129
|
-
output += formatter
|
|
129
|
+
output += formatter
|
|
130
|
+
? textBuffer
|
|
131
|
+
.split("\n")
|
|
132
|
+
.map((line) => (line ? formatter(line) : line))
|
|
133
|
+
.join("\n")
|
|
134
|
+
: textBuffer;
|
|
130
135
|
textBuffer = "";
|
|
131
136
|
};
|
|
132
137
|
let index = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"syntax-highlight.js","sourceRoot":"","sources":["../../src/utils/syntax-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,0BAA0B,CAAC;AAC5C,OAAO,IAAI,MAAM,oCAAoC,CAAC;AACtD,OAAO,CAAC,MAAM,iCAAiC,CAAC;AAChD,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,MAAM,MAAM,sCAAsC,CAAC;AAC1D,OAAO,IAAI,MAAM,oCAAoC,CAAC;AACtD,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAClD,OAAO,MAAM,MAAM,sCAAsC,CAAC;AAC1D,OAAO,IAAI,MAAM,oCAAoC,CAAC;AACtD,OAAO,UAAU,MAAM,0CAA0C,CAAC;AAClE,OAAO,IAAI,MAAM,oCAAoC,CAAC;AACtD,OAAO,MAAM,MAAM,sCAAsC,CAAC;AAC1D,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,IAAI,MAAM,oCAAoC,CAAC;AACtD,OAAO,GAAG,MAAM,mCAAmC,CAAC;AACpD,OAAO,MAAM,MAAM,sCAAsC,CAAC;AAC1D,OAAO,IAAI,MAAM,oCAAoC,CAA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AAM,CAAC;gBACxB,SAAS;YACV,CAAC;QACF,CAAC;QAED,UAAU,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,KAAK,EAAE,CAAC;IACT,CAAC;IAED,SAAS,EAAE,CAAC;IACZ,OAAO,MAAM,CAAC;AACf,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,OAAO,GAAqB,EAAE;IACrE,MAAM,IAAI,GAAG,OAAO,CAAC,QAAQ;QAC5B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE;YACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ;YAC1B,cAAc,EAAE,OAAO,CAAC,cAAc;SACtC,CAAC,CAAC,KAAK;QACT,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC;IAC1D,OAAO,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;AAC7C,CAAC","sourcesContent":["import hljs from \"highlight.js/lib/core.js\";\nimport bash from \"highlight.js/lib/languages/bash.js\";\nimport c from \"highlight.js/lib/languages/c.js\";\nimport cpp from \"highlight.js/lib/languages/cpp.js\";\nimport csharp from \"highlight.js/lib/languages/csharp.js\";\nimport dart from \"highlight.js/lib/languages/dart.js\";\nimport go from \"highlight.js/lib/languages/go.js\";\nimport groovy from \"highlight.js/lib/languages/groovy.js\";\nimport java from \"highlight.js/lib/languages/java.js\";\nimport javascript from \"highlight.js/lib/languages/javascript.js\";\nimport json from \"highlight.js/lib/languages/json.js\";\nimport kotlin from \"highlight.js/lib/languages/kotlin.js\";\nimport lua from \"highlight.js/lib/languages/lua.js\";\nimport nix from \"highlight.js/lib/languages/nix.js\";\nimport perl from \"highlight.js/lib/languages/perl.js\";\nimport php from \"highlight.js/lib/languages/php.js\";\nimport python from \"highlight.js/lib/languages/python.js\";\nimport ruby from \"highlight.js/lib/languages/ruby.js\";\nimport rust from \"highlight.js/lib/languages/rust.js\";\nimport scala from \"highlight.js/lib/languages/scala.js\";\nimport swift from \"highlight.js/lib/languages/swift.js\";\nimport typescript from \"highlight.js/lib/languages/typescript.js\";\nimport { decodeHtmlEntityAt } from \"./html.ts\";\n\nconst eagerLanguages = {\n\tpython,\n\tjava,\n\tgo,\n\tjavascript,\n\tjson,\n\tcpp,\n\ttypescript,\n\tphp,\n\truby,\n\tc,\n\tcsharp,\n\tnix,\n\tbash,\n\trust,\n\tscala,\n\tkotlin,\n\tswift,\n\tdart,\n\tgroovy,\n\tperl,\n\tlua,\n};\n\nfor (const [name, language] of Object.entries(eagerLanguages)) {\n\thljs.registerLanguage(name, language);\n}\n\nlet allLanguagesPromise: Promise<void> | undefined;\n\nexport function loadAllHighlightLanguages(): Promise<void> {\n\tif (!allLanguagesPromise) {\n\t\tallLanguagesPromise = new Promise((resolve) => {\n\t\t\tsetImmediate(() => {\n\t\t\t\tvoid import(\"highlight.js/lib/index.js\").then(\n\t\t\t\t\t() => resolve(),\n\t\t\t\t\t() => {\n\t\t\t\t\t\t// Eager languages and plaintext fallback remain available.\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t}\n\treturn allLanguagesPromise;\n}\n\nexport type HighlightFormatter = (text: string) => string;\nexport type HighlightTheme = Partial<Record<string, HighlightFormatter>>;\n\nexport interface HighlightOptions {\n\tlanguage?: string;\n\tignoreIllegals?: boolean;\n\tlanguageSubset?: string[];\n\ttheme?: HighlightTheme;\n}\n\nconst SPAN_CLOSE = \"</span>\";\nconst HIGHLIGHT_CLASS_PREFIX = \"hljs-\";\n\nfunction getScopeFromSpanTag(tag: string): string | undefined {\n\tconst match = /\\sclass\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/.exec(tag);\n\tconst classValue = match?.[1] ?? match?.[2];\n\tif (!classValue) {\n\t\treturn undefined;\n\t}\n\n\tfor (const className of classValue.split(/\\s+/)) {\n\t\tif (className.startsWith(HIGHLIGHT_CLASS_PREFIX)) {\n\t\t\treturn className.slice(HIGHLIGHT_CLASS_PREFIX.length);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction getScopeFormatter(scope: string, theme: HighlightTheme): HighlightFormatter | undefined {\n\tconst exact = theme[scope];\n\tif (exact) {\n\t\treturn exact;\n\t}\n\n\tconst dotIndex = scope.indexOf(\".\");\n\tif (dotIndex !== -1) {\n\t\tconst prefixFormatter = theme[scope.slice(0, dotIndex)];\n\t\tif (prefixFormatter) {\n\t\t\treturn prefixFormatter;\n\t\t}\n\t}\n\n\tconst dashIndex = scope.indexOf(\"-\");\n\tif (dashIndex !== -1) {\n\t\tconst prefixFormatter = theme[scope.slice(0, dashIndex)];\n\t\tif (prefixFormatter) {\n\t\t\treturn prefixFormatter;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction getActiveFormatter(scopes: Array<string | undefined>, theme: HighlightTheme): HighlightFormatter | undefined {\n\tfor (let i = scopes.length - 1; i >= 0; i--) {\n\t\tconst scope = scopes[i];\n\t\tif (!scope) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst formatter = getScopeFormatter(scope, theme);\n\t\tif (formatter) {\n\t\t\treturn formatter;\n\t\t}\n\t}\n\treturn theme.default;\n}\n\nfunction isSpanOpenTagStart(html: string, index: number): boolean {\n\tif (!html.startsWith(\"<span\", index)) {\n\t\treturn false;\n\t}\n\tconst nextChar = html[index + \"<span\".length];\n\treturn nextChar === \">\" || nextChar === \" \" || nextChar === \"\\t\" || nextChar === \"\\n\" || nextChar === \"\\r\";\n}\n\nexport function renderHighlightedHtml(html: string, theme: HighlightTheme = {}): string {\n\tlet output = \"\";\n\tlet textBuffer = \"\";\n\tconst scopes: Array<string | undefined> = [];\n\n\tconst flushText = () => {\n\t\tif (!textBuffer) {\n\t\t\treturn;\n\t\t}\n\t\tconst formatter = getActiveFormatter(scopes, theme);\n\t\toutput += formatter ? formatter(textBuffer) : textBuffer;\n\t\ttextBuffer = \"\";\n\t};\n\n\tlet index = 0;\n\twhile (index < html.length) {\n\t\tif (isSpanOpenTagStart(html, index)) {\n\t\t\tconst tagEndIndex = html.indexOf(\">\", index + 5);\n\t\t\tif (tagEndIndex !== -1) {\n\t\t\t\tflushText();\n\t\t\t\tconst tag = html.slice(index, tagEndIndex + 1);\n\t\t\t\tconst scope = getScopeFromSpanTag(tag);\n\t\t\t\tscopes.push(scope);\n\t\t\t\tindex = tagEndIndex + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tif (html.startsWith(SPAN_CLOSE, index)) {\n\t\t\tflushText();\n\t\t\tif (scopes.length > 0) {\n\t\t\t\tscopes.pop();\n\t\t\t}\n\t\t\tindex += SPAN_CLOSE.length;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (html[index] === \"&\") {\n\t\t\tconst decoded = decodeHtmlEntityAt(html, index);\n\t\t\tif (decoded) {\n\t\t\t\ttextBuffer += decoded.text;\n\t\t\t\tindex += decoded.length;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\ttextBuffer += html[index];\n\t\tindex++;\n\t}\n\n\tflushText();\n\treturn output;\n}\n\nexport function highlight(code: string, options: HighlightOptions = {}): string {\n\tconst html = options.language\n\t\t? hljs.highlight(code, {\n\t\t\t\tlanguage: options.language,\n\t\t\t\tignoreIllegals: options.ignoreIllegals,\n\t\t\t}).value\n\t\t: hljs.highlightAuto(code, options.languageSubset).value;\n\treturn renderHighlightedHtml(html, options.theme);\n}\n\nexport function supportsLanguage(name: string): boolean {\n\treturn hljs.getLanguage(name) !== undefined;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"syntax-highlight.js","sourceRoot":"","sources":["../../src/utils/syntax-highlight.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,0BAA0B,CAAC;A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c,EAAE,OAAO,CAAC,cAAc;SACtC,CAAC,CAAC,KAAK;QACT,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC;IAC1D,OAAO,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;AAC7C,CAAC","sourcesContent":["import hljs from \"highlight.js/lib/core.js\";\nimport bash from \"highlight.js/lib/languages/bash.js\";\nimport c from \"highlight.js/lib/languages/c.js\";\nimport cpp from \"highlight.js/lib/languages/cpp.js\";\nimport csharp from \"highlight.js/lib/languages/csharp.js\";\nimport dart from \"highlight.js/lib/languages/dart.js\";\nimport go from \"highlight.js/lib/languages/go.js\";\nimport groovy from \"highlight.js/lib/languages/groovy.js\";\nimport java from \"highlight.js/lib/languages/java.js\";\nimport javascript from \"highlight.js/lib/languages/javascript.js\";\nimport json from \"highlight.js/lib/languages/json.js\";\nimport kotlin from \"highlight.js/lib/languages/kotlin.js\";\nimport lua from \"highlight.js/lib/languages/lua.js\";\nimport nix from \"highlight.js/lib/languages/nix.js\";\nimport perl from \"highlight.js/lib/languages/perl.js\";\nimport php from \"highlight.js/lib/languages/php.js\";\nimport python from \"highlight.js/lib/languages/python.js\";\nimport ruby from \"highlight.js/lib/languages/ruby.js\";\nimport rust from \"highlight.js/lib/languages/rust.js\";\nimport scala from \"highlight.js/lib/languages/scala.js\";\nimport swift from \"highlight.js/lib/languages/swift.js\";\nimport typescript from \"highlight.js/lib/languages/typescript.js\";\nimport { decodeHtmlEntityAt } from \"./html.ts\";\n\nconst eagerLanguages = {\n\tpython,\n\tjava,\n\tgo,\n\tjavascript,\n\tjson,\n\tcpp,\n\ttypescript,\n\tphp,\n\truby,\n\tc,\n\tcsharp,\n\tnix,\n\tbash,\n\trust,\n\tscala,\n\tkotlin,\n\tswift,\n\tdart,\n\tgroovy,\n\tperl,\n\tlua,\n};\n\nfor (const [name, language] of Object.entries(eagerLanguages)) {\n\thljs.registerLanguage(name, language);\n}\n\nlet allLanguagesPromise: Promise<void> | undefined;\n\nexport function loadAllHighlightLanguages(): Promise<void> {\n\tif (!allLanguagesPromise) {\n\t\tallLanguagesPromise = new Promise((resolve) => {\n\t\t\tsetImmediate(() => {\n\t\t\t\tvoid import(\"highlight.js/lib/index.js\").then(\n\t\t\t\t\t() => resolve(),\n\t\t\t\t\t() => {\n\t\t\t\t\t\t// Eager languages and plaintext fallback remain available.\n\t\t\t\t\t\tresolve();\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t});\n\t\t});\n\t}\n\treturn allLanguagesPromise;\n}\n\nexport type HighlightFormatter = (text: string) => string;\nexport type HighlightTheme = Partial<Record<string, HighlightFormatter>>;\n\nexport interface HighlightOptions {\n\tlanguage?: string;\n\tignoreIllegals?: boolean;\n\tlanguageSubset?: string[];\n\ttheme?: HighlightTheme;\n}\n\nconst SPAN_CLOSE = \"</span>\";\nconst HIGHLIGHT_CLASS_PREFIX = \"hljs-\";\n\nfunction getScopeFromSpanTag(tag: string): string | undefined {\n\tconst match = /\\sclass\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)')/.exec(tag);\n\tconst classValue = match?.[1] ?? match?.[2];\n\tif (!classValue) {\n\t\treturn undefined;\n\t}\n\n\tfor (const className of classValue.split(/\\s+/)) {\n\t\tif (className.startsWith(HIGHLIGHT_CLASS_PREFIX)) {\n\t\t\treturn className.slice(HIGHLIGHT_CLASS_PREFIX.length);\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction getScopeFormatter(scope: string, theme: HighlightTheme): HighlightFormatter | undefined {\n\tconst exact = theme[scope];\n\tif (exact) {\n\t\treturn exact;\n\t}\n\n\tconst dotIndex = scope.indexOf(\".\");\n\tif (dotIndex !== -1) {\n\t\tconst prefixFormatter = theme[scope.slice(0, dotIndex)];\n\t\tif (prefixFormatter) {\n\t\t\treturn prefixFormatter;\n\t\t}\n\t}\n\n\tconst dashIndex = scope.indexOf(\"-\");\n\tif (dashIndex !== -1) {\n\t\tconst prefixFormatter = theme[scope.slice(0, dashIndex)];\n\t\tif (prefixFormatter) {\n\t\t\treturn prefixFormatter;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction getActiveFormatter(scopes: Array<string | undefined>, theme: HighlightTheme): HighlightFormatter | undefined {\n\tfor (let i = scopes.length - 1; i >= 0; i--) {\n\t\tconst scope = scopes[i];\n\t\tif (!scope) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst formatter = getScopeFormatter(scope, theme);\n\t\tif (formatter) {\n\t\t\treturn formatter;\n\t\t}\n\t}\n\treturn theme.default;\n}\n\nfunction isSpanOpenTagStart(html: string, index: number): boolean {\n\tif (!html.startsWith(\"<span\", index)) {\n\t\treturn false;\n\t}\n\tconst nextChar = html[index + \"<span\".length];\n\treturn nextChar === \">\" || nextChar === \" \" || nextChar === \"\\t\" || nextChar === \"\\n\" || nextChar === \"\\r\";\n}\n\nexport function renderHighlightedHtml(html: string, theme: HighlightTheme = {}): string {\n\tlet output = \"\";\n\tlet textBuffer = \"\";\n\tconst scopes: Array<string | undefined> = [];\n\n\tconst flushText = () => {\n\t\tif (!textBuffer) {\n\t\t\treturn;\n\t\t}\n\t\tconst formatter = getActiveFormatter(scopes, theme);\n\t\toutput += formatter\n\t\t\t? textBuffer\n\t\t\t\t\t.split(\"\\n\")\n\t\t\t\t\t.map((line) => (line ? formatter(line) : line))\n\t\t\t\t\t.join(\"\\n\")\n\t\t\t: textBuffer;\n\t\ttextBuffer = \"\";\n\t};\n\n\tlet index = 0;\n\twhile (index < html.length) {\n\t\tif (isSpanOpenTagStart(html, index)) {\n\t\t\tconst tagEndIndex = html.indexOf(\">\", index + 5);\n\t\t\tif (tagEndIndex !== -1) {\n\t\t\t\tflushText();\n\t\t\t\tconst tag = html.slice(index, tagEndIndex + 1);\n\t\t\t\tconst scope = getScopeFromSpanTag(tag);\n\t\t\t\tscopes.push(scope);\n\t\t\t\tindex = tagEndIndex + 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tif (html.startsWith(SPAN_CLOSE, index)) {\n\t\t\tflushText();\n\t\t\tif (scopes.length > 0) {\n\t\t\t\tscopes.pop();\n\t\t\t}\n\t\t\tindex += SPAN_CLOSE.length;\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (html[index] === \"&\") {\n\t\t\tconst decoded = decodeHtmlEntityAt(html, index);\n\t\t\tif (decoded) {\n\t\t\t\ttextBuffer += decoded.text;\n\t\t\t\tindex += decoded.length;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\ttextBuffer += html[index];\n\t\tindex++;\n\t}\n\n\tflushText();\n\treturn output;\n}\n\nexport function highlight(code: string, options: HighlightOptions = {}): string {\n\tconst html = options.language\n\t\t? hljs.highlight(code, {\n\t\t\t\tlanguage: options.language,\n\t\t\t\tignoreIllegals: options.ignoreIllegals,\n\t\t\t}).value\n\t\t: hljs.highlightAuto(code, options.languageSubset).value;\n\treturn renderHighlightedHtml(html, options.theme);\n}\n\nexport function supportsLanguage(name: string): boolean {\n\treturn hljs.getLanguage(name) !== undefined;\n}\n"]}
|
package/docs/cli.md
CHANGED
|
@@ -117,16 +117,26 @@ pi --tools read,grep,find,ls --print "Review this project"
|
|
|
117
117
|
See [Settings](settings.md#tools) for configuring the default tool selection.
|
|
118
118
|
|
|
119
119
|
- `-t`, `--tools <list>`<br>
|
|
120
|
-
Replaces the default selection with a comma-separated allowlist of built-in, extension, or custom tools.
|
|
120
|
+
Replaces the default selection with a comma-separated allowlist of built-in, extension, or custom tools. Entries are tool names or patterns where `*` matches any characters. MCP tools are kept unless an entry starts with `mcp__` (see [MCP tools](#mcp-tools)).
|
|
121
121
|
- `-xt`, `--exclude-tools <list>`<br>
|
|
122
|
-
Disables comma-separated tool names after all other selection options.
|
|
122
|
+
Disables comma-separated tool names or patterns after all other selection options, MCP tools included.
|
|
123
123
|
- `-nbt`, `--no-builtin-tools`<br>
|
|
124
124
|
Disables default built-in tools while retaining extension and custom tools.
|
|
125
125
|
- `-nt`, `--no-tools`<br>
|
|
126
|
-
Starts with all built-in, extension, and
|
|
126
|
+
Starts with all built-in, extension, custom, and MCP tools disabled.
|
|
127
127
|
|
|
128
128
|
Default enabled tools are `read`, `bash`, `edit`, and `write`, unless `defaultTools` changes them. `--tools` replaces the whole selection, so name every tool you want; `defaultTools` also accepts `+name` and `-name` to change the defaults instead.
|
|
129
129
|
|
|
130
|
+
<a id="mcp-tools"></a>
|
|
131
|
+
|
|
132
|
+
`--tools` selects the tools declared to the model. It does not remove MCP tools, whose reach is set by their [exposure](mcp.md#control-tool-exposure): `pi --tools read,codemode` keeps every MCP tool callable from codemode scripts. An MCP tool that no entry names or matches is never declared directly, whatever its exposure; only `tool_search`, if listed, can load it. Once an entry starts with `mcp__`, `--tools` filters MCP tools too, so this keeps only the tools of the `radius` server:
|
|
133
|
+
|
|
134
|
+
```sh
|
|
135
|
+
pi --tools read,bash,codemode,'mcp__radius__*'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The MCP resource tools (`list_mcp_resources`, `list_mcp_resource_templates`, `read_mcp_resource`) count as MCP tools. To remove MCP tools, use `--exclude-tools 'mcp__*'` or [`--no-mcp`](#resource-options).
|
|
139
|
+
|
|
130
140
|
| Built-in | Purpose |
|
|
131
141
|
|---|---|
|
|
132
142
|
| `read` | Read text files and supported images |
|
|
@@ -185,6 +195,8 @@ See [Configuration](configuration.md) for conventional directories and project t
|
|
|
185
195
|
Loads an extension file or directory, or a built-in extension such as `builtin:mcp`, and is repeatable.
|
|
186
196
|
- `-ne`, `--no-extensions`<br>
|
|
187
197
|
Disables discovered, configured, and built-in extensions. Explicit `-e` paths still load, so `pi -ne -e builtin:mcp` keeps only the built-in MCP support.
|
|
198
|
+
- `--no-mcp`<br>
|
|
199
|
+
Disables the built-in MCP support for this run: no servers connect, and there are no MCP tools or `/mcp`. It does not affect an extension that replaces the built-in MCP support.
|
|
188
200
|
- `--skill <path>`<br>
|
|
189
201
|
Loads a skill file or directory and is repeatable.
|
|
190
202
|
- `-ns`, `--no-skills`<br>
|