hummin-cli 1.0.3 → 1.0.5

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +5788 -0
  2. package/LICENSE +21 -0
  3. package/README.md +129 -0
  4. package/dist/bundle/chunks/{chunk-LNNEJ7WT.js → chunk-RGARQVSZ.js} +1 -1
  5. package/dist/bundle/cli.js +1 -1
  6. package/dist/bundle/index.js +1 -1
  7. package/dist/bundle/rpc-entry.js +1 -1
  8. package/dist/core/export-html/ansi-to-html.d.ts +22 -0
  9. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  10. package/dist/core/export-html/ansi-to-html.js +249 -0
  11. package/dist/core/export-html/ansi-to-html.js.map +1 -0
  12. package/dist/core/export-html/index.d.ts +37 -0
  13. package/dist/core/export-html/index.d.ts.map +1 -0
  14. package/dist/core/export-html/index.js +226 -0
  15. package/dist/core/export-html/index.js.map +1 -0
  16. package/dist/core/export-html/template.css +1066 -0
  17. package/dist/core/export-html/template.html +55 -0
  18. package/dist/core/export-html/template.js +1864 -0
  19. package/dist/core/export-html/tool-renderer.d.ts +34 -0
  20. package/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  21. package/dist/core/export-html/tool-renderer.js +108 -0
  22. package/dist/core/export-html/tool-renderer.js.map +1 -0
  23. package/dist/core/export-html/vendor/highlight.min.js +1213 -0
  24. package/dist/core/export-html/vendor/marked.min.js +78 -0
  25. package/dist/modes/interactive/assets/clankolas.png +0 -0
  26. package/dist/modes/interactive/theme/dark.json +91 -0
  27. package/dist/modes/interactive/theme/hummin-dark.json +93 -0
  28. package/dist/modes/interactive/theme/light.json +90 -0
  29. package/dist/modes/interactive/theme/theme-controller.d.ts +41 -0
  30. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -0
  31. package/dist/modes/interactive/theme/theme-controller.js +130 -0
  32. package/dist/modes/interactive/theme/theme-controller.js.map +1 -0
  33. package/dist/modes/interactive/theme/theme-json.d.ts +84 -0
  34. package/dist/modes/interactive/theme/theme-json.d.ts.map +1 -0
  35. package/dist/modes/interactive/theme/theme-json.js +130 -0
  36. package/dist/modes/interactive/theme/theme-json.js.map +1 -0
  37. package/dist/modes/interactive/theme/theme-schema.json +356 -0
  38. package/dist/modes/interactive/theme/theme.d.ts +131 -0
  39. package/dist/modes/interactive/theme/theme.d.ts.map +1 -0
  40. package/dist/modes/interactive/theme/theme.js +993 -0
  41. package/dist/modes/interactive/theme/theme.js.map +1 -0
  42. package/package.json +61 -38
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-controller.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-controller.ts"],"names":[],"mappings":"AAEA,OAAO,EACN,+BAA+B,EAC/B,6BAA6B,EAC7B,0BAA0B,EAC1B,SAAS,EACT,qBAAqB,EACrB,mBAAmB,EACnB,QAAQ,EACR,gBAAgB,GAGhB,MAAM,YAAY,CAAC;AAIpB,MAAM,OAAO,0BAA0B;IACrB,EAAE,CAAM;IACR,kBAAkB,CAAwB;IAC1C,SAAS,CAA4B;IACrC,SAAS,CAAa;IAC/B,mBAAmB,CAAqB;IACxC,aAAa,GAAkB,+BAA+B,EAAE,CAAC,KAAK,CAAC;IACvE,eAAe,CAAqB;IACpC,eAAe,GAAG,KAAK,CAAC;IACxB,8BAA8B,CAA2B;IAEjE,YACC,EAAO,EACP,OAKC,EACA;QACD,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,mBAAmB,GAAG,OAAO,CAAC,mBAAmB,CAAC;QACvD,IAAI,CAAC,eAAe,GAAG,mBAAmB,CACzC,IAAI,CAAC,mBAAmB,IAAI,IAAI,CAAC,kBAAkB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AAA,CACjB;IAEO,WAAW,CAAC,OAAgB,EAAQ;QAC3C,IAAI,IAAI,CAAC,eAAe,KAAK,OAAO;YAAE,OAAO;QAC7C,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;QAC/B,IAAI,CAAC,EAAE,CAAC,mCAAmC,CAAC,OAAO,CAAC,CAAC;IAAA,CACrD;IAEO,+BAA+B,GAAS;QAC/C,IAAI,CAAC,8BAA8B,GAAG,IAAI,CAAC,EAAE,CAAC,2BAA2B,CAAC,CAAC,aAAa,EAAE,EAAE,CAC3F,IAAI,CAAC,kBAAkB,CAAC,aAAa,CAAC,CACtC,CAAC;IAAA,CACF;IAEO,kBAAkB,CAAC,aAA4B,EAAQ;QAC9D,IAAI,CAAC,IAAI,CAAC,eAAe;YAAE,OAAO;QAClC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,MAAM,SAAS,GAAG,qBAAqB,CAAC,IAAI,CAAC,mBAAmB,IAAI,IAAI,CAAC,kBAAkB,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC;QACjH,IAAI,CAAC,SAAS,EAAE,CAAC;YAChB,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACxB,OAAO;QACR,CAAC;QACD,MAAM,SAAS,GAAG,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC;QACzF,IAAI,SAAS,KAAK,IAAI,CAAC,eAAe,EAAE,CAAC;YACxC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QAChC,CAAC;IAAA,CACD;CACD","sourcesContent":["import type { TUI } from \"@earendil-works/pi-tui\";\nimport type { SettingsManager } from \"../../../core/settings-manager.ts\";\nimport {\n\tdetectTerminalBackgroundFromEnv,\n\tdetectTerminalBackgroundTheme,\n\tdetectTerminalThemeForAuto,\n\tinitTheme,\n\tparseAutoThemeSetting,\n\tresolveThemeSetting,\n\tsetTheme,\n\tsetThemeInstance,\n\ttype TerminalTheme,\n\ttype Theme,\n} from \"./theme.ts\";\n\ntype ThemeResult = { success: boolean; error?: string };\n\nexport class InteractiveThemeController {\n\tprivate readonly ui: TUI;\n\tprivate readonly getSettingsManager: () => SettingsManager;\n\tprivate readonly showError: (message: string) => void;\n\tprivate readonly onChanged: () => void;\n\tprivate currentThemeSetting: string | undefined;\n\tprivate terminalTheme: TerminalTheme = detectTerminalBackgroundFromEnv().theme;\n\tprivate activeThemeName: string | undefined;\n\tprivate autoSyncEnabled = false;\n\tprivate terminalColorSchemeUnsubscribe: (() => void) | undefined;\n\n\tconstructor(\n\t\tui: TUI,\n\t\toptions: {\n\t\t\tgetSettingsManager: () => SettingsManager;\n\t\t\tshowError: (message: string) => void;\n\t\t\tonChanged: () => void;\n\t\t\tinitialThemeSetting?: string;\n\t\t},\n\t) {\n\t\tthis.ui = ui;\n\t\tthis.getSettingsManager = options.getSettingsManager;\n\t\tthis.showError = options.showError;\n\t\tthis.onChanged = options.onChanged;\n\t\tthis.currentThemeSetting = options.initialThemeSetting;\n\t\tthis.activeThemeName = resolveThemeSetting(\n\t\t\tthis.currentThemeSetting ?? this.getSettingsManager().getThemeSetting(),\n\t\t\tthis.terminalTheme,\n\t\t);\n\t\tinitTheme(this.activeThemeName, true);\n\t\tthis.bindTerminalColorSchemeListener();\n\t}\n\n\trebindTui(): void {\n\t\tthis.terminalColorSchemeUnsubscribe?.();\n\t\tthis.bindTerminalColorSchemeListener();\n\t\tthis.ui.setTerminalColorSchemeNotifications(this.autoSyncEnabled);\n\t}\n\n\tasync applyFromSettings(): Promise<void> {\n\t\tconst settingsManager = this.getSettingsManager();\n\t\tconst themeSetting = this.currentThemeSetting ?? settingsManager.getThemeSetting();\n\t\tconst autoTheme = parseAutoThemeSetting(themeSetting);\n\t\tif (autoTheme) {\n\t\t\tthis.terminalTheme = await detectTerminalThemeForAuto({ ui: this.ui, timeoutMs: 100 });\n\t\t\tthis.setAutoSync(true);\n\t\t\tthis.applyThemeName(this.terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme, true);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setAutoSync(false);\n\t\tif (themeSetting !== undefined) {\n\t\t\tthis.applyThemeName(themeSetting, true);\n\t\t\treturn;\n\t\t}\n\n\t\tconst detection = await detectTerminalBackgroundTheme({ ui: this.ui, timeoutMs: 100 });\n\t\tthis.terminalTheme = detection.theme;\n\t\tif (!this.applyThemeName(detection.theme).success) return;\n\t\tif (detection.confidence === \"high\") {\n\t\t\tsettingsManager.setTheme(detection.theme);\n\t\t\tawait settingsManager.flush();\n\t\t}\n\t}\n\n\tgetThemeSelection(): string | undefined {\n\t\treturn this.currentThemeSetting ?? this.getSettingsManager().getThemeSetting() ?? this.activeThemeName;\n\t}\n\n\tsetThemeName(themeName: string, showError = false): ThemeResult {\n\t\tthis.setAutoSync(false);\n\t\tconst result = this.applyThemeName(themeName, showError);\n\t\tif (result.success) {\n\t\t\tthis.currentThemeSetting = themeName;\n\t\t}\n\t\treturn result;\n\t}\n\n\tasync setThemeSetting(themeSetting: string): Promise<void> {\n\t\tthis.currentThemeSetting = themeSetting;\n\t\tawait this.applyFromSettings();\n\t}\n\n\tsetThemeInstance(themeInstance: Theme): ThemeResult {\n\t\tthis.setAutoSync(false);\n\t\tsetThemeInstance(themeInstance);\n\t\tthis.activeThemeName = \"<in-memory>\";\n\t\tthis.notifyChanged();\n\t\treturn { success: true };\n\t}\n\n\tpreview(themeSettingOrName: string): void {\n\t\tconst themeName = resolveThemeSetting(themeSettingOrName, this.terminalTheme) ?? this.activeThemeName;\n\t\tif (!themeName) return;\n\t\tif (setTheme(themeName, true).success) {\n\t\t\tthis.ui.invalidate();\n\t\t\tthis.ui.requestRender();\n\t\t}\n\t}\n\n\tdisableAutoSync(): void {\n\t\tthis.setAutoSync(false);\n\t}\n\n\tdispose(): void {\n\t\tthis.setAutoSync(false);\n\t\tthis.terminalColorSchemeUnsubscribe?.();\n\t\tthis.terminalColorSchemeUnsubscribe = undefined;\n\t}\n\n\tgetTerminalTheme(): TerminalTheme {\n\t\treturn this.terminalTheme;\n\t}\n\n\tprivate applyThemeName(themeName: string, showError = false): ThemeResult {\n\t\tconst result = setTheme(themeName, true);\n\t\tthis.activeThemeName = result.success ? themeName : \"dark\";\n\t\tthis.notifyChanged();\n\t\tif (!result.success && showError) {\n\t\t\tthis.showError(`Failed to load theme \"${themeName}\": ${result.error}\\nFell back to dark theme.`);\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate notifyChanged(): void {\n\t\tthis.ui.invalidate();\n\t\tthis.onChanged();\n\t}\n\n\tprivate setAutoSync(enabled: boolean): void {\n\t\tif (this.autoSyncEnabled === enabled) return;\n\t\tthis.autoSyncEnabled = enabled;\n\t\tthis.ui.setTerminalColorSchemeNotifications(enabled);\n\t}\n\n\tprivate bindTerminalColorSchemeListener(): void {\n\t\tthis.terminalColorSchemeUnsubscribe = this.ui.onTerminalColorSchemeChange((terminalTheme) =>\n\t\t\tthis.applyTerminalTheme(terminalTheme),\n\t\t);\n\t}\n\n\tprivate applyTerminalTheme(terminalTheme: TerminalTheme): void {\n\t\tif (!this.autoSyncEnabled) return;\n\t\tthis.terminalTheme = terminalTheme;\n\t\tconst autoTheme = parseAutoThemeSetting(this.currentThemeSetting ?? this.getSettingsManager().getThemeSetting());\n\t\tif (!autoTheme) {\n\t\t\tthis.setAutoSync(false);\n\t\t\treturn;\n\t\t}\n\t\tconst themeName = terminalTheme === \"light\" ? autoTheme.lightTheme : autoTheme.darkTheme;\n\t\tif (themeName !== this.activeThemeName) {\n\t\t\tthis.applyThemeName(themeName);\n\t\t}\n\t}\n}\n"]}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Theme JSON validation, kept out of `theme.ts` on purpose.
3
+ *
4
+ * Validating user-authored theme files needs typebox, which costs ~17 MB of module graph to import.
5
+ * Palette lookup does not, so a presentation that only uses built-in themes should never pay for it.
6
+ * `interactive-mode.ts` installs this validator; anything that does not simply skips validation, as
7
+ * built-in themes already do.
8
+ */
9
+ import { type Static, Type } from "typebox";
10
+ declare const ColorValueSchema: Type.TUnion<[Type.TString, Type.TInteger]>;
11
+ declare const ThemeJsonSchema: Type.TObject<{
12
+ $schema: Type.TOptional<Type.TString>;
13
+ name: Type.TString;
14
+ vars: Type.TOptional<Type.TRecord<"^.*$", Type.TUnion<[Type.TString, Type.TInteger]>>>;
15
+ colors: Type.TObject<{
16
+ accent: Type.TUnion<[Type.TString, Type.TInteger]>;
17
+ border: Type.TUnion<[Type.TString, Type.TInteger]>;
18
+ borderAccent: Type.TUnion<[Type.TString, Type.TInteger]>;
19
+ borderMuted: Type.TUnion<[Type.TString, Type.TInteger]>;
20
+ success: Type.TUnion<[Type.TString, Type.TInteger]>;
21
+ error: Type.TUnion<[Type.TString, Type.TInteger]>;
22
+ warning: Type.TUnion<[Type.TString, Type.TInteger]>;
23
+ muted: Type.TUnion<[Type.TString, Type.TInteger]>;
24
+ dim: Type.TUnion<[Type.TString, Type.TInteger]>;
25
+ text: Type.TUnion<[Type.TString, Type.TInteger]>;
26
+ thinkingText: Type.TUnion<[Type.TString, Type.TInteger]>;
27
+ scrollbarTrack: Type.TOptional<Type.TUnion<[Type.TString, Type.TInteger]>>;
28
+ scrollbarThumb: Type.TOptional<Type.TUnion<[Type.TString, Type.TInteger]>>;
29
+ selectedBg: Type.TUnion<[Type.TString, Type.TInteger]>;
30
+ searchMatchBg: Type.TOptional<Type.TUnion<[Type.TString, Type.TInteger]>>;
31
+ searchMatchText: Type.TOptional<Type.TUnion<[Type.TString, Type.TInteger]>>;
32
+ userMessageBg: Type.TUnion<[Type.TString, Type.TInteger]>;
33
+ userMessageText: Type.TUnion<[Type.TString, Type.TInteger]>;
34
+ customMessageBg: Type.TUnion<[Type.TString, Type.TInteger]>;
35
+ customMessageText: Type.TUnion<[Type.TString, Type.TInteger]>;
36
+ customMessageLabel: Type.TUnion<[Type.TString, Type.TInteger]>;
37
+ toolPendingBg: Type.TUnion<[Type.TString, Type.TInteger]>;
38
+ toolSuccessBg: Type.TUnion<[Type.TString, Type.TInteger]>;
39
+ toolErrorBg: Type.TUnion<[Type.TString, Type.TInteger]>;
40
+ toolTitle: Type.TUnion<[Type.TString, Type.TInteger]>;
41
+ toolOutput: Type.TUnion<[Type.TString, Type.TInteger]>;
42
+ mdHeading: Type.TUnion<[Type.TString, Type.TInteger]>;
43
+ mdLink: Type.TUnion<[Type.TString, Type.TInteger]>;
44
+ mdLinkUrl: Type.TUnion<[Type.TString, Type.TInteger]>;
45
+ mdCode: Type.TUnion<[Type.TString, Type.TInteger]>;
46
+ mdCodeBlock: Type.TUnion<[Type.TString, Type.TInteger]>;
47
+ mdCodeBlockBorder: Type.TUnion<[Type.TString, Type.TInteger]>;
48
+ mdQuote: Type.TUnion<[Type.TString, Type.TInteger]>;
49
+ mdQuoteBorder: Type.TUnion<[Type.TString, Type.TInteger]>;
50
+ mdHr: Type.TUnion<[Type.TString, Type.TInteger]>;
51
+ mdListBullet: Type.TUnion<[Type.TString, Type.TInteger]>;
52
+ toolDiffAdded: Type.TUnion<[Type.TString, Type.TInteger]>;
53
+ toolDiffRemoved: Type.TUnion<[Type.TString, Type.TInteger]>;
54
+ toolDiffContext: Type.TUnion<[Type.TString, Type.TInteger]>;
55
+ syntaxComment: Type.TUnion<[Type.TString, Type.TInteger]>;
56
+ syntaxKeyword: Type.TUnion<[Type.TString, Type.TInteger]>;
57
+ syntaxFunction: Type.TUnion<[Type.TString, Type.TInteger]>;
58
+ syntaxVariable: Type.TUnion<[Type.TString, Type.TInteger]>;
59
+ syntaxString: Type.TUnion<[Type.TString, Type.TInteger]>;
60
+ syntaxNumber: Type.TUnion<[Type.TString, Type.TInteger]>;
61
+ syntaxType: Type.TUnion<[Type.TString, Type.TInteger]>;
62
+ syntaxOperator: Type.TUnion<[Type.TString, Type.TInteger]>;
63
+ syntaxPunctuation: Type.TUnion<[Type.TString, Type.TInteger]>;
64
+ thinkingOff: Type.TUnion<[Type.TString, Type.TInteger]>;
65
+ thinkingMinimal: Type.TUnion<[Type.TString, Type.TInteger]>;
66
+ thinkingLow: Type.TUnion<[Type.TString, Type.TInteger]>;
67
+ thinkingMedium: Type.TUnion<[Type.TString, Type.TInteger]>;
68
+ thinkingHigh: Type.TUnion<[Type.TString, Type.TInteger]>;
69
+ thinkingXhigh: Type.TUnion<[Type.TString, Type.TInteger]>;
70
+ thinkingMax: Type.TOptional<Type.TUnion<[Type.TString, Type.TInteger]>>;
71
+ bashMode: Type.TUnion<[Type.TString, Type.TInteger]>;
72
+ }>;
73
+ export: Type.TOptional<Type.TObject<{
74
+ pageBg: Type.TOptional<Type.TUnion<[Type.TString, Type.TInteger]>>;
75
+ cardBg: Type.TOptional<Type.TUnion<[Type.TString, Type.TInteger]>>;
76
+ infoBg: Type.TOptional<Type.TUnion<[Type.TString, Type.TInteger]>>;
77
+ }>>;
78
+ }>;
79
+ export type ThemeColorValue = Static<typeof ColorValueSchema>;
80
+ export type ValidatedThemeJson = Static<typeof ThemeJsonSchema>;
81
+ /** Validate one theme document, throwing a message that names the offending tokens. */
82
+ export declare function validateThemeJson(label: string, json: unknown): ValidatedThemeJson;
83
+ export {};
84
+ //# sourceMappingURL=theme-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-json.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-json.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAG5C,QAAA,MAAM,gBAAgB,4CAGpB,CAAC;AAEH,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6EnB,CAAC;AAIH,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC9D,MAAM,MAAM,kBAAkB,GAAG,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAEhE,uFAAuF;AACvF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,kBAAkB,CA2ClF","sourcesContent":["/**\n * Theme JSON validation, kept out of `theme.ts` on purpose.\n *\n * Validating user-authored theme files needs typebox, which costs ~17 MB of module graph to import.\n * Palette lookup does not, so a presentation that only uses built-in themes should never pay for it.\n * `interactive-mode.ts` installs this validator; anything that does not simply skips validation, as\n * built-in themes already do.\n */\n\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\n\nconst ColorValueSchema = Type.Union([\n\tType.String(), // hex \"#ff0000\", var ref \"primary\", or empty \"\"\n\tType.Integer({ minimum: 0, maximum: 255 }), // 256-color index\n]);\n\nconst ThemeJsonSchema = Type.Object({\n\t$schema: Type.Optional(Type.String()),\n\tname: Type.String(),\n\tvars: Type.Optional(Type.Record(Type.String(), ColorValueSchema)),\n\tcolors: Type.Object({\n\t\t// Core UI (11 colors)\n\t\taccent: ColorValueSchema,\n\t\tborder: ColorValueSchema,\n\t\tborderAccent: ColorValueSchema,\n\t\tborderMuted: ColorValueSchema,\n\t\tsuccess: ColorValueSchema,\n\t\terror: ColorValueSchema,\n\t\twarning: ColorValueSchema,\n\t\tmuted: ColorValueSchema,\n\t\tdim: ColorValueSchema,\n\t\ttext: ColorValueSchema,\n\t\tthinkingText: ColorValueSchema,\n\t\t// Scrollbar (2 optional colors)\n\t\tscrollbarTrack: Type.Optional(ColorValueSchema),\n\t\tscrollbarThumb: Type.Optional(ColorValueSchema),\n\t\t// Backgrounds & Content Text (11 required, 2 optional)\n\t\tselectedBg: ColorValueSchema,\n\t\tsearchMatchBg: Type.Optional(ColorValueSchema),\n\t\tsearchMatchText: Type.Optional(ColorValueSchema),\n\t\tuserMessageBg: ColorValueSchema,\n\t\tuserMessageText: ColorValueSchema,\n\t\tcustomMessageBg: ColorValueSchema,\n\t\tcustomMessageText: ColorValueSchema,\n\t\tcustomMessageLabel: ColorValueSchema,\n\t\ttoolPendingBg: ColorValueSchema,\n\t\ttoolSuccessBg: ColorValueSchema,\n\t\ttoolErrorBg: ColorValueSchema,\n\t\ttoolTitle: ColorValueSchema,\n\t\ttoolOutput: ColorValueSchema,\n\t\t// Markdown (10 colors)\n\t\tmdHeading: ColorValueSchema,\n\t\tmdLink: ColorValueSchema,\n\t\tmdLinkUrl: ColorValueSchema,\n\t\tmdCode: ColorValueSchema,\n\t\tmdCodeBlock: ColorValueSchema,\n\t\tmdCodeBlockBorder: ColorValueSchema,\n\t\tmdQuote: ColorValueSchema,\n\t\tmdQuoteBorder: ColorValueSchema,\n\t\tmdHr: ColorValueSchema,\n\t\tmdListBullet: ColorValueSchema,\n\t\t// Tool Diffs (3 colors)\n\t\ttoolDiffAdded: ColorValueSchema,\n\t\ttoolDiffRemoved: ColorValueSchema,\n\t\ttoolDiffContext: ColorValueSchema,\n\t\t// Syntax Highlighting (9 colors)\n\t\tsyntaxComment: ColorValueSchema,\n\t\tsyntaxKeyword: ColorValueSchema,\n\t\tsyntaxFunction: ColorValueSchema,\n\t\tsyntaxVariable: ColorValueSchema,\n\t\tsyntaxString: ColorValueSchema,\n\t\tsyntaxNumber: ColorValueSchema,\n\t\tsyntaxType: ColorValueSchema,\n\t\tsyntaxOperator: ColorValueSchema,\n\t\tsyntaxPunctuation: ColorValueSchema,\n\t\t// Thinking Level Borders (6 colors)\n\t\tthinkingOff: ColorValueSchema,\n\t\tthinkingMinimal: ColorValueSchema,\n\t\tthinkingLow: ColorValueSchema,\n\t\tthinkingMedium: ColorValueSchema,\n\t\tthinkingHigh: ColorValueSchema,\n\t\tthinkingXhigh: ColorValueSchema,\n\t\tthinkingMax: Type.Optional(ColorValueSchema),\n\t\t// Bash Mode (1 color)\n\t\tbashMode: ColorValueSchema,\n\t}),\n\texport: Type.Optional(\n\t\tType.Object({\n\t\t\tpageBg: Type.Optional(ColorValueSchema),\n\t\t\tcardBg: Type.Optional(ColorValueSchema),\n\t\t\tinfoBg: Type.Optional(ColorValueSchema),\n\t\t}),\n\t),\n});\n\nconst compiledThemeSchema = Compile(ThemeJsonSchema);\n\nexport type ThemeColorValue = Static<typeof ColorValueSchema>;\nexport type ValidatedThemeJson = Static<typeof ThemeJsonSchema>;\n\n/** Validate one theme document, throwing a message that names the offending tokens. */\nexport function validateThemeJson(label: string, json: unknown): ValidatedThemeJson {\n\tif (!compiledThemeSchema.Check(json)) {\n\t\tconst errors = Array.from(compiledThemeSchema.Errors(json));\n\t\tconst missingColors = new Set<string>();\n\t\tconst otherErrors: string[] = [];\n\n\t\tfor (const error of errors) {\n\t\t\tif (error.keyword === \"required\" && error.instancePath === \"/colors\") {\n\t\t\t\tconst requiredProperties = (error.params as { requiredProperties?: string[] }).requiredProperties;\n\t\t\t\tfor (const requiredProperty of requiredProperties ?? []) {\n\t\t\t\t\tmissingColors.add(requiredProperty);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst path = error.instancePath || \"/\";\n\t\t\totherErrors.push(` - ${path}: ${error.message}`);\n\t\t}\n\n\t\tlet errorMessage = `Invalid theme \"${label}\":\\n`;\n\t\tif (missingColors.size > 0) {\n\t\t\terrorMessage += \"\\nMissing required color tokens:\\n\";\n\t\t\terrorMessage += Array.from(missingColors)\n\t\t\t\t.sort()\n\t\t\t\t.map((color) => ` - ${color}`)\n\t\t\t\t.join(\"\\n\");\n\t\t\terrorMessage += '\\n\\nPlease add these colors to your theme\\'s \"colors\" object.';\n\t\t\terrorMessage += \"\\nSee the built-in themes (dark.json, light.json) for reference values.\";\n\t\t}\n\t\tif (otherErrors.length > 0) {\n\t\t\terrorMessage += `\\n\\nOther errors:\\n${otherErrors.join(\"\\n\")}`;\n\t\t}\n\n\t\tthrow new Error(errorMessage);\n\t}\n\n\tconst themeJson = json as ValidatedThemeJson;\n\tif (themeJson.name.includes(\"/\")) {\n\t\tthrow new Error(\n\t\t\t`Invalid theme name \"${themeJson.name}\": theme names cannot contain \"/\" because it is reserved for automatic light/dark theme settings.`,\n\t\t);\n\t}\n\treturn themeJson;\n}\n"]}
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Theme JSON validation, kept out of `theme.ts` on purpose.
3
+ *
4
+ * Validating user-authored theme files needs typebox, which costs ~17 MB of module graph to import.
5
+ * Palette lookup does not, so a presentation that only uses built-in themes should never pay for it.
6
+ * `interactive-mode.ts` installs this validator; anything that does not simply skips validation, as
7
+ * built-in themes already do.
8
+ */
9
+ import { Type } from "typebox";
10
+ import { Compile } from "typebox/compile";
11
+ const ColorValueSchema = Type.Union([
12
+ Type.String(), // hex "#ff0000", var ref "primary", or empty ""
13
+ Type.Integer({ minimum: 0, maximum: 255 }), // 256-color index
14
+ ]);
15
+ const ThemeJsonSchema = Type.Object({
16
+ $schema: Type.Optional(Type.String()),
17
+ name: Type.String(),
18
+ vars: Type.Optional(Type.Record(Type.String(), ColorValueSchema)),
19
+ colors: Type.Object({
20
+ // Core UI (11 colors)
21
+ accent: ColorValueSchema,
22
+ border: ColorValueSchema,
23
+ borderAccent: ColorValueSchema,
24
+ borderMuted: ColorValueSchema,
25
+ success: ColorValueSchema,
26
+ error: ColorValueSchema,
27
+ warning: ColorValueSchema,
28
+ muted: ColorValueSchema,
29
+ dim: ColorValueSchema,
30
+ text: ColorValueSchema,
31
+ thinkingText: ColorValueSchema,
32
+ // Scrollbar (2 optional colors)
33
+ scrollbarTrack: Type.Optional(ColorValueSchema),
34
+ scrollbarThumb: Type.Optional(ColorValueSchema),
35
+ // Backgrounds & Content Text (11 required, 2 optional)
36
+ selectedBg: ColorValueSchema,
37
+ searchMatchBg: Type.Optional(ColorValueSchema),
38
+ searchMatchText: Type.Optional(ColorValueSchema),
39
+ userMessageBg: ColorValueSchema,
40
+ userMessageText: ColorValueSchema,
41
+ customMessageBg: ColorValueSchema,
42
+ customMessageText: ColorValueSchema,
43
+ customMessageLabel: ColorValueSchema,
44
+ toolPendingBg: ColorValueSchema,
45
+ toolSuccessBg: ColorValueSchema,
46
+ toolErrorBg: ColorValueSchema,
47
+ toolTitle: ColorValueSchema,
48
+ toolOutput: ColorValueSchema,
49
+ // Markdown (10 colors)
50
+ mdHeading: ColorValueSchema,
51
+ mdLink: ColorValueSchema,
52
+ mdLinkUrl: ColorValueSchema,
53
+ mdCode: ColorValueSchema,
54
+ mdCodeBlock: ColorValueSchema,
55
+ mdCodeBlockBorder: ColorValueSchema,
56
+ mdQuote: ColorValueSchema,
57
+ mdQuoteBorder: ColorValueSchema,
58
+ mdHr: ColorValueSchema,
59
+ mdListBullet: ColorValueSchema,
60
+ // Tool Diffs (3 colors)
61
+ toolDiffAdded: ColorValueSchema,
62
+ toolDiffRemoved: ColorValueSchema,
63
+ toolDiffContext: ColorValueSchema,
64
+ // Syntax Highlighting (9 colors)
65
+ syntaxComment: ColorValueSchema,
66
+ syntaxKeyword: ColorValueSchema,
67
+ syntaxFunction: ColorValueSchema,
68
+ syntaxVariable: ColorValueSchema,
69
+ syntaxString: ColorValueSchema,
70
+ syntaxNumber: ColorValueSchema,
71
+ syntaxType: ColorValueSchema,
72
+ syntaxOperator: ColorValueSchema,
73
+ syntaxPunctuation: ColorValueSchema,
74
+ // Thinking Level Borders (6 colors)
75
+ thinkingOff: ColorValueSchema,
76
+ thinkingMinimal: ColorValueSchema,
77
+ thinkingLow: ColorValueSchema,
78
+ thinkingMedium: ColorValueSchema,
79
+ thinkingHigh: ColorValueSchema,
80
+ thinkingXhigh: ColorValueSchema,
81
+ thinkingMax: Type.Optional(ColorValueSchema),
82
+ // Bash Mode (1 color)
83
+ bashMode: ColorValueSchema,
84
+ }),
85
+ export: Type.Optional(Type.Object({
86
+ pageBg: Type.Optional(ColorValueSchema),
87
+ cardBg: Type.Optional(ColorValueSchema),
88
+ infoBg: Type.Optional(ColorValueSchema),
89
+ })),
90
+ });
91
+ const compiledThemeSchema = Compile(ThemeJsonSchema);
92
+ /** Validate one theme document, throwing a message that names the offending tokens. */
93
+ export function validateThemeJson(label, json) {
94
+ if (!compiledThemeSchema.Check(json)) {
95
+ const errors = Array.from(compiledThemeSchema.Errors(json));
96
+ const missingColors = new Set();
97
+ const otherErrors = [];
98
+ for (const error of errors) {
99
+ if (error.keyword === "required" && error.instancePath === "/colors") {
100
+ const requiredProperties = error.params.requiredProperties;
101
+ for (const requiredProperty of requiredProperties ?? []) {
102
+ missingColors.add(requiredProperty);
103
+ }
104
+ continue;
105
+ }
106
+ const path = error.instancePath || "/";
107
+ otherErrors.push(` - ${path}: ${error.message}`);
108
+ }
109
+ let errorMessage = `Invalid theme "${label}":\n`;
110
+ if (missingColors.size > 0) {
111
+ errorMessage += "\nMissing required color tokens:\n";
112
+ errorMessage += Array.from(missingColors)
113
+ .sort()
114
+ .map((color) => ` - ${color}`)
115
+ .join("\n");
116
+ errorMessage += '\n\nPlease add these colors to your theme\'s "colors" object.';
117
+ errorMessage += "\nSee the built-in themes (dark.json, light.json) for reference values.";
118
+ }
119
+ if (otherErrors.length > 0) {
120
+ errorMessage += `\n\nOther errors:\n${otherErrors.join("\n")}`;
121
+ }
122
+ throw new Error(errorMessage);
123
+ }
124
+ const themeJson = json;
125
+ if (themeJson.name.includes("/")) {
126
+ throw new Error(`Invalid theme name "${themeJson.name}": theme names cannot contain "/" because it is reserved for automatic light/dark theme settings.`);
127
+ }
128
+ return themeJson;
129
+ }
130
+ //# sourceMappingURL=theme-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-json.js","sourceRoot":"","sources":["../../../../src/modes/interactive/theme/theme-json.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,CAAC;IACnC,IAAI,CAAC,MAAM,EAAE,EAAE,gDAAgD;IAC/D,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE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AI,+DAA+D,CAAC;YAChF,YAAY,IAAI,yEAAyE,CAAC;QAC3F,CAAC;QACD,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,YAAY,IAAI,sBAAsB,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAChE,CAAC;QAED,MAAM,IAAI,KAAK,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC;IAED,MAAM,SAAS,GAAG,IAA0B,CAAC;IAC7C,IAAI,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACd,uBAAuB,SAAS,CAAC,IAAI,mGAAmG,CACxI,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AAAA,CACjB","sourcesContent":["/**\n * Theme JSON validation, kept out of `theme.ts` on purpose.\n *\n * Validating user-authored theme files needs typebox, which costs ~17 MB of module graph to import.\n * Palette lookup does not, so a presentation that only uses built-in themes should never pay for it.\n * `interactive-mode.ts` installs this validator; anything that does not simply skips validation, as\n * built-in themes already do.\n */\n\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\n\nconst ColorValueSchema = Type.Union([\n\tType.String(), // hex \"#ff0000\", var ref \"primary\", or empty \"\"\n\tType.Integer({ minimum: 0, maximum: 255 }), // 256-color index\n]);\n\nconst ThemeJsonSchema = Type.Object({\n\t$schema: Type.Optional(Type.String()),\n\tname: Type.String(),\n\tvars: Type.Optional(Type.Record(Type.String(), ColorValueSchema)),\n\tcolors: Type.Object({\n\t\t// Core UI (11 colors)\n\t\taccent: ColorValueSchema,\n\t\tborder: ColorValueSchema,\n\t\tborderAccent: ColorValueSchema,\n\t\tborderMuted: ColorValueSchema,\n\t\tsuccess: ColorValueSchema,\n\t\terror: ColorValueSchema,\n\t\twarning: ColorValueSchema,\n\t\tmuted: ColorValueSchema,\n\t\tdim: ColorValueSchema,\n\t\ttext: ColorValueSchema,\n\t\tthinkingText: ColorValueSchema,\n\t\t// Scrollbar (2 optional colors)\n\t\tscrollbarTrack: Type.Optional(ColorValueSchema),\n\t\tscrollbarThumb: Type.Optional(ColorValueSchema),\n\t\t// Backgrounds & Content Text (11 required, 2 optional)\n\t\tselectedBg: ColorValueSchema,\n\t\tsearchMatchBg: Type.Optional(ColorValueSchema),\n\t\tsearchMatchText: Type.Optional(ColorValueSchema),\n\t\tuserMessageBg: ColorValueSchema,\n\t\tuserMessageText: ColorValueSchema,\n\t\tcustomMessageBg: ColorValueSchema,\n\t\tcustomMessageText: ColorValueSchema,\n\t\tcustomMessageLabel: ColorValueSchema,\n\t\ttoolPendingBg: ColorValueSchema,\n\t\ttoolSuccessBg: ColorValueSchema,\n\t\ttoolErrorBg: ColorValueSchema,\n\t\ttoolTitle: ColorValueSchema,\n\t\ttoolOutput: ColorValueSchema,\n\t\t// Markdown (10 colors)\n\t\tmdHeading: ColorValueSchema,\n\t\tmdLink: ColorValueSchema,\n\t\tmdLinkUrl: ColorValueSchema,\n\t\tmdCode: ColorValueSchema,\n\t\tmdCodeBlock: ColorValueSchema,\n\t\tmdCodeBlockBorder: ColorValueSchema,\n\t\tmdQuote: ColorValueSchema,\n\t\tmdQuoteBorder: ColorValueSchema,\n\t\tmdHr: ColorValueSchema,\n\t\tmdListBullet: ColorValueSchema,\n\t\t// Tool Diffs (3 colors)\n\t\ttoolDiffAdded: ColorValueSchema,\n\t\ttoolDiffRemoved: ColorValueSchema,\n\t\ttoolDiffContext: ColorValueSchema,\n\t\t// Syntax Highlighting (9 colors)\n\t\tsyntaxComment: ColorValueSchema,\n\t\tsyntaxKeyword: ColorValueSchema,\n\t\tsyntaxFunction: ColorValueSchema,\n\t\tsyntaxVariable: ColorValueSchema,\n\t\tsyntaxString: ColorValueSchema,\n\t\tsyntaxNumber: ColorValueSchema,\n\t\tsyntaxType: ColorValueSchema,\n\t\tsyntaxOperator: ColorValueSchema,\n\t\tsyntaxPunctuation: ColorValueSchema,\n\t\t// Thinking Level Borders (6 colors)\n\t\tthinkingOff: ColorValueSchema,\n\t\tthinkingMinimal: ColorValueSchema,\n\t\tthinkingLow: ColorValueSchema,\n\t\tthinkingMedium: ColorValueSchema,\n\t\tthinkingHigh: ColorValueSchema,\n\t\tthinkingXhigh: ColorValueSchema,\n\t\tthinkingMax: Type.Optional(ColorValueSchema),\n\t\t// Bash Mode (1 color)\n\t\tbashMode: ColorValueSchema,\n\t}),\n\texport: Type.Optional(\n\t\tType.Object({\n\t\t\tpageBg: Type.Optional(ColorValueSchema),\n\t\t\tcardBg: Type.Optional(ColorValueSchema),\n\t\t\tinfoBg: Type.Optional(ColorValueSchema),\n\t\t}),\n\t),\n});\n\nconst compiledThemeSchema = Compile(ThemeJsonSchema);\n\nexport type ThemeColorValue = Static<typeof ColorValueSchema>;\nexport type ValidatedThemeJson = Static<typeof ThemeJsonSchema>;\n\n/** Validate one theme document, throwing a message that names the offending tokens. */\nexport function validateThemeJson(label: string, json: unknown): ValidatedThemeJson {\n\tif (!compiledThemeSchema.Check(json)) {\n\t\tconst errors = Array.from(compiledThemeSchema.Errors(json));\n\t\tconst missingColors = new Set<string>();\n\t\tconst otherErrors: string[] = [];\n\n\t\tfor (const error of errors) {\n\t\t\tif (error.keyword === \"required\" && error.instancePath === \"/colors\") {\n\t\t\t\tconst requiredProperties = (error.params as { requiredProperties?: string[] }).requiredProperties;\n\t\t\t\tfor (const requiredProperty of requiredProperties ?? []) {\n\t\t\t\t\tmissingColors.add(requiredProperty);\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst path = error.instancePath || \"/\";\n\t\t\totherErrors.push(` - ${path}: ${error.message}`);\n\t\t}\n\n\t\tlet errorMessage = `Invalid theme \"${label}\":\\n`;\n\t\tif (missingColors.size > 0) {\n\t\t\terrorMessage += \"\\nMissing required color tokens:\\n\";\n\t\t\terrorMessage += Array.from(missingColors)\n\t\t\t\t.sort()\n\t\t\t\t.map((color) => ` - ${color}`)\n\t\t\t\t.join(\"\\n\");\n\t\t\terrorMessage += '\\n\\nPlease add these colors to your theme\\'s \"colors\" object.';\n\t\t\terrorMessage += \"\\nSee the built-in themes (dark.json, light.json) for reference values.\";\n\t\t}\n\t\tif (otherErrors.length > 0) {\n\t\t\terrorMessage += `\\n\\nOther errors:\\n${otherErrors.join(\"\\n\")}`;\n\t\t}\n\n\t\tthrow new Error(errorMessage);\n\t}\n\n\tconst themeJson = json as ValidatedThemeJson;\n\tif (themeJson.name.includes(\"/\")) {\n\t\tthrow new Error(\n\t\t\t`Invalid theme name \"${themeJson.name}\": theme names cannot contain \"/\" because it is reserved for automatic light/dark theme settings.`,\n\t\t);\n\t}\n\treturn themeJson;\n}\n"]}
@@ -0,0 +1,356 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "title": "Pi Coding Agent Theme",
4
+ "description": "Theme schema for Pi coding agent",
5
+ "type": "object",
6
+ "required": ["name", "colors"],
7
+ "properties": {
8
+ "$schema": {
9
+ "type": "string",
10
+ "description": "JSON schema reference"
11
+ },
12
+ "name": {
13
+ "type": "string",
14
+ "pattern": "^[^/]+$",
15
+ "description": "Theme name. Must not contain '/' because it is reserved for automatic light/dark theme settings."
16
+ },
17
+ "vars": {
18
+ "type": "object",
19
+ "description": "Reusable color variables",
20
+ "additionalProperties": {
21
+ "oneOf": [
22
+ {
23
+ "type": "string",
24
+ "description": "Hex color (#RRGGBB), variable reference, or empty string for terminal default"
25
+ },
26
+ {
27
+ "type": "integer",
28
+ "minimum": 0,
29
+ "maximum": 255,
30
+ "description": "256-color palette index (0-255)"
31
+ }
32
+ ]
33
+ }
34
+ },
35
+ "colors": {
36
+ "type": "object",
37
+ "description": "Theme color definitions (scrollbar, thinkingMax, and search highlight colors are optional and use compatible fallbacks)",
38
+ "required": [
39
+ "accent",
40
+ "border",
41
+ "borderAccent",
42
+ "borderMuted",
43
+ "success",
44
+ "error",
45
+ "warning",
46
+ "muted",
47
+ "dim",
48
+ "text",
49
+ "thinkingText",
50
+ "selectedBg",
51
+ "userMessageBg",
52
+ "userMessageText",
53
+ "customMessageBg",
54
+ "customMessageText",
55
+ "customMessageLabel",
56
+ "toolPendingBg",
57
+ "toolSuccessBg",
58
+ "toolErrorBg",
59
+ "toolTitle",
60
+ "toolOutput",
61
+ "mdHeading",
62
+ "mdLink",
63
+ "mdLinkUrl",
64
+ "mdCode",
65
+ "mdCodeBlock",
66
+ "mdCodeBlockBorder",
67
+ "mdQuote",
68
+ "mdQuoteBorder",
69
+ "mdHr",
70
+ "mdListBullet",
71
+ "toolDiffAdded",
72
+ "toolDiffRemoved",
73
+ "toolDiffContext",
74
+ "syntaxComment",
75
+ "syntaxKeyword",
76
+ "syntaxFunction",
77
+ "syntaxVariable",
78
+ "syntaxString",
79
+ "syntaxNumber",
80
+ "syntaxType",
81
+ "syntaxOperator",
82
+ "syntaxPunctuation",
83
+ "thinkingOff",
84
+ "thinkingMinimal",
85
+ "thinkingLow",
86
+ "thinkingMedium",
87
+ "thinkingHigh",
88
+ "thinkingXhigh",
89
+ "bashMode"
90
+ ],
91
+ "properties": {
92
+ "accent": {
93
+ "$ref": "#/$defs/colorValue",
94
+ "description": "Primary accent color (logo, selected items, cursor)"
95
+ },
96
+ "border": {
97
+ "$ref": "#/$defs/colorValue",
98
+ "description": "Normal borders"
99
+ },
100
+ "borderAccent": {
101
+ "$ref": "#/$defs/colorValue",
102
+ "description": "Highlighted borders"
103
+ },
104
+ "borderMuted": {
105
+ "$ref": "#/$defs/colorValue",
106
+ "description": "Subtle borders"
107
+ },
108
+ "success": {
109
+ "$ref": "#/$defs/colorValue",
110
+ "description": "Success states"
111
+ },
112
+ "error": {
113
+ "$ref": "#/$defs/colorValue",
114
+ "description": "Error states"
115
+ },
116
+ "warning": {
117
+ "$ref": "#/$defs/colorValue",
118
+ "description": "Warning states"
119
+ },
120
+ "muted": {
121
+ "$ref": "#/$defs/colorValue",
122
+ "description": "Secondary/dimmed text"
123
+ },
124
+ "dim": {
125
+ "$ref": "#/$defs/colorValue",
126
+ "description": "Very dimmed text (more subtle than muted)"
127
+ },
128
+ "text": {
129
+ "$ref": "#/$defs/colorValue",
130
+ "description": "Default text color (usually empty string)"
131
+ },
132
+ "thinkingText": {
133
+ "$ref": "#/$defs/colorValue",
134
+ "description": "Thinking block text color"
135
+ },
136
+ "selectedBg": {
137
+ "$ref": "#/$defs/colorValue",
138
+ "description": "Selected item background"
139
+ },
140
+ "scrollbarTrack": {
141
+ "$ref": "#/$defs/colorValue",
142
+ "description": "Fullscreen scrollbar track foreground (falls back to muted when omitted)"
143
+ },
144
+ "scrollbarThumb": {
145
+ "$ref": "#/$defs/colorValue",
146
+ "description": "Fullscreen scrollbar thumb foreground (falls back to text when omitted)"
147
+ },
148
+ "searchMatchBg": {
149
+ "$ref": "#/$defs/colorValue",
150
+ "description": "Transcript search match background and current-match text (falls back to selectedBg when omitted)"
151
+ },
152
+ "searchMatchText": {
153
+ "$ref": "#/$defs/colorValue",
154
+ "description": "Transcript search match text and current-match background (falls back to text when omitted)"
155
+ },
156
+ "userMessageBg": {
157
+ "$ref": "#/$defs/colorValue",
158
+ "description": "User message background"
159
+ },
160
+ "userMessageText": {
161
+ "$ref": "#/$defs/colorValue",
162
+ "description": "User message text color"
163
+ },
164
+ "customMessageBg": {
165
+ "$ref": "#/$defs/colorValue",
166
+ "description": "Custom message background (hook-injected messages)"
167
+ },
168
+ "customMessageText": {
169
+ "$ref": "#/$defs/colorValue",
170
+ "description": "Custom message text color"
171
+ },
172
+ "customMessageLabel": {
173
+ "$ref": "#/$defs/colorValue",
174
+ "description": "Custom message type label color"
175
+ },
176
+ "toolPendingBg": {
177
+ "$ref": "#/$defs/colorValue",
178
+ "description": "Tool execution box (pending state)"
179
+ },
180
+ "toolSuccessBg": {
181
+ "$ref": "#/$defs/colorValue",
182
+ "description": "Tool execution box (success state)"
183
+ },
184
+ "toolErrorBg": {
185
+ "$ref": "#/$defs/colorValue",
186
+ "description": "Tool execution box (error state)"
187
+ },
188
+ "toolTitle": {
189
+ "$ref": "#/$defs/colorValue",
190
+ "description": "Tool execution box title color"
191
+ },
192
+ "toolOutput": {
193
+ "$ref": "#/$defs/colorValue",
194
+ "description": "Tool execution box output text color"
195
+ },
196
+ "mdHeading": {
197
+ "$ref": "#/$defs/colorValue",
198
+ "description": "Markdown heading text"
199
+ },
200
+ "mdLink": {
201
+ "$ref": "#/$defs/colorValue",
202
+ "description": "Markdown link text"
203
+ },
204
+ "mdLinkUrl": {
205
+ "$ref": "#/$defs/colorValue",
206
+ "description": "Markdown link URL"
207
+ },
208
+ "mdCode": {
209
+ "$ref": "#/$defs/colorValue",
210
+ "description": "Markdown inline code"
211
+ },
212
+ "mdCodeBlock": {
213
+ "$ref": "#/$defs/colorValue",
214
+ "description": "Markdown code block content"
215
+ },
216
+ "mdCodeBlockBorder": {
217
+ "$ref": "#/$defs/colorValue",
218
+ "description": "Markdown code block fences"
219
+ },
220
+ "mdQuote": {
221
+ "$ref": "#/$defs/colorValue",
222
+ "description": "Markdown blockquote text"
223
+ },
224
+ "mdQuoteBorder": {
225
+ "$ref": "#/$defs/colorValue",
226
+ "description": "Markdown blockquote border"
227
+ },
228
+ "mdHr": {
229
+ "$ref": "#/$defs/colorValue",
230
+ "description": "Markdown horizontal rule"
231
+ },
232
+ "mdListBullet": {
233
+ "$ref": "#/$defs/colorValue",
234
+ "description": "Markdown list bullets/numbers"
235
+ },
236
+ "toolDiffAdded": {
237
+ "$ref": "#/$defs/colorValue",
238
+ "description": "Added lines in tool diffs"
239
+ },
240
+ "toolDiffRemoved": {
241
+ "$ref": "#/$defs/colorValue",
242
+ "description": "Removed lines in tool diffs"
243
+ },
244
+ "toolDiffContext": {
245
+ "$ref": "#/$defs/colorValue",
246
+ "description": "Context lines in tool diffs"
247
+ },
248
+ "syntaxComment": {
249
+ "$ref": "#/$defs/colorValue",
250
+ "description": "Syntax highlighting: comments"
251
+ },
252
+ "syntaxKeyword": {
253
+ "$ref": "#/$defs/colorValue",
254
+ "description": "Syntax highlighting: keywords"
255
+ },
256
+ "syntaxFunction": {
257
+ "$ref": "#/$defs/colorValue",
258
+ "description": "Syntax highlighting: function names"
259
+ },
260
+ "syntaxVariable": {
261
+ "$ref": "#/$defs/colorValue",
262
+ "description": "Syntax highlighting: variable names"
263
+ },
264
+ "syntaxString": {
265
+ "$ref": "#/$defs/colorValue",
266
+ "description": "Syntax highlighting: string literals"
267
+ },
268
+ "syntaxNumber": {
269
+ "$ref": "#/$defs/colorValue",
270
+ "description": "Syntax highlighting: number literals"
271
+ },
272
+ "syntaxType": {
273
+ "$ref": "#/$defs/colorValue",
274
+ "description": "Syntax highlighting: type names"
275
+ },
276
+ "syntaxOperator": {
277
+ "$ref": "#/$defs/colorValue",
278
+ "description": "Syntax highlighting: operators"
279
+ },
280
+ "syntaxPunctuation": {
281
+ "$ref": "#/$defs/colorValue",
282
+ "description": "Syntax highlighting: punctuation"
283
+ },
284
+ "thinkingOff": {
285
+ "$ref": "#/$defs/colorValue",
286
+ "description": "Thinking level border: off"
287
+ },
288
+ "thinkingMinimal": {
289
+ "$ref": "#/$defs/colorValue",
290
+ "description": "Thinking level border: minimal"
291
+ },
292
+ "thinkingLow": {
293
+ "$ref": "#/$defs/colorValue",
294
+ "description": "Thinking level border: low"
295
+ },
296
+ "thinkingMedium": {
297
+ "$ref": "#/$defs/colorValue",
298
+ "description": "Thinking level border: medium"
299
+ },
300
+ "thinkingHigh": {
301
+ "$ref": "#/$defs/colorValue",
302
+ "description": "Thinking level border: high"
303
+ },
304
+ "thinkingXhigh": {
305
+ "$ref": "#/$defs/colorValue",
306
+ "description": "Thinking level border: xhigh"
307
+ },
308
+ "thinkingMax": {
309
+ "$ref": "#/$defs/colorValue",
310
+ "description": "Thinking level border: max (falls back to thinkingXhigh when omitted)"
311
+ },
312
+ "bashMode": {
313
+ "$ref": "#/$defs/colorValue",
314
+ "description": "Editor border color in bash mode"
315
+ }
316
+ },
317
+ "additionalProperties": false
318
+ },
319
+ "export": {
320
+ "type": "object",
321
+ "description": "Optional colors for HTML export (defaults derived from userMessageBg if not specified)",
322
+ "properties": {
323
+ "pageBg": {
324
+ "$ref": "#/$defs/colorValue",
325
+ "description": "Page background color"
326
+ },
327
+ "cardBg": {
328
+ "$ref": "#/$defs/colorValue",
329
+ "description": "Card/container background color"
330
+ },
331
+ "infoBg": {
332
+ "$ref": "#/$defs/colorValue",
333
+ "description": "Info sections background (system prompt, notices)"
334
+ }
335
+ },
336
+ "additionalProperties": false
337
+ }
338
+ },
339
+ "additionalProperties": false,
340
+ "$defs": {
341
+ "colorValue": {
342
+ "oneOf": [
343
+ {
344
+ "type": "string",
345
+ "description": "Hex color (#RRGGBB), variable reference, or empty string for terminal default"
346
+ },
347
+ {
348
+ "type": "integer",
349
+ "minimum": 0,
350
+ "maximum": 255,
351
+ "description": "256-color palette index (0-255)"
352
+ }
353
+ ]
354
+ }
355
+ }
356
+ }