@toddzheng024/dscode-bundle 0.7.12 → 0.7.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. package/THIRD_PARTY_NOTICES.md +3 -3
  2. package/cordis.patch.yml +6 -2
  3. package/package.json +7 -5
  4. package/plugins/code-review/index.mjs +5 -2
  5. package/plugins/compaction/threshold.mjs +12 -0
  6. package/plugins/credentials/index.mjs +13 -0
  7. package/plugins/grok/adapter.mjs +114 -0
  8. package/plugins/grok/auth.mjs +76 -0
  9. package/plugins/grok/billing.mjs +146 -0
  10. package/plugins/grok/index.mjs +118 -0
  11. package/plugins/grok/models.mjs +129 -0
  12. package/plugins/grok/status.mjs +28 -0
  13. package/plugins/grok/wire.mjs +268 -0
  14. package/plugins/i18n/messages.mjs +6 -6
  15. package/plugins/providers/catalog.mjs +2 -0
  16. package/plugins/session-metrics/view.mjs +34 -3
  17. package/vendor/compaction-basic/index.js +91 -1
  18. package/vendor/persistent/index.js +10 -9
  19. package/vendor/terminal/index.js +5 -0
  20. package/vendor/tui/lib/app.mjs +6711 -0
  21. package/vendor/tui/lib/approval.mjs +122 -0
  22. package/vendor/tui/lib/attachments.mjs +218 -0
  23. package/vendor/tui/lib/authorization-panel.mjs +242 -0
  24. package/vendor/tui/lib/authorization.mjs +111 -0
  25. package/vendor/tui/lib/commands.mjs +123 -0
  26. package/vendor/tui/lib/dscode/chat.mjs +84 -0
  27. package/vendor/tui/lib/dscode/flags.mjs +32 -0
  28. package/vendor/tui/lib/dscode/model-search.mjs +68 -0
  29. package/vendor/tui/lib/dscode/paste.mjs +87 -0
  30. package/vendor/tui/lib/dscode/telemetry.mjs +82 -0
  31. package/vendor/tui/lib/dscode/welcome.mjs +100 -0
  32. package/vendor/tui/lib/editor-keys.mjs +346 -0
  33. package/vendor/tui/lib/editor.mjs +50 -0
  34. package/vendor/tui/lib/fork.mjs +24 -0
  35. package/vendor/tui/lib/git-workflow.mjs +278 -0
  36. package/vendor/tui/{types/history.d.ts → lib/history.mjs} +69 -26
  37. package/vendor/tui/{types/i18n.d.ts → lib/i18n.mjs} +23 -15
  38. package/vendor/tui/lib/index.mjs +2200 -0
  39. package/vendor/tui/lib/input-split.mjs +170 -0
  40. package/vendor/tui/lib/internals.mjs +90 -0
  41. package/vendor/tui/lib/invariant.mjs +22 -0
  42. package/vendor/tui/lib/kernel-panels.mjs +1265 -0
  43. package/vendor/tui/lib/keyboard.mjs +283 -0
  44. package/vendor/tui/lib/language-panel.mjs +41 -0
  45. package/vendor/tui/lib/locales/en.mjs +495 -0
  46. package/vendor/tui/lib/locales/zh.mjs +495 -0
  47. package/vendor/tui/lib/mentions.mjs +150 -0
  48. package/vendor/tui/lib/model-capabilities.mjs +245 -0
  49. package/vendor/tui/lib/models.mjs +215 -0
  50. package/vendor/tui/{types/panel-accent.d.ts → lib/panel-accent.mjs} +11 -7
  51. package/vendor/tui/lib/permissions.mjs +45 -0
  52. package/vendor/tui/lib/plugin-inventory.mjs +27 -0
  53. package/vendor/tui/lib/presets.mjs +46 -0
  54. package/vendor/tui/lib/provider-settings.mjs +600 -0
  55. package/vendor/tui/lib/questions.mjs +116 -0
  56. package/vendor/tui/lib/rainbow.mjs +181 -0
  57. package/vendor/tui/lib/render/animations.mjs +665 -0
  58. package/vendor/tui/lib/render/editor.mjs +437 -0
  59. package/vendor/tui/lib/render/export.mjs +119 -0
  60. package/vendor/tui/lib/render/fuzzy.mjs +79 -0
  61. package/vendor/tui/lib/render/ime-cursor.mjs +135 -0
  62. package/vendor/tui/lib/render/inspector.mjs +93 -0
  63. package/vendor/tui/lib/render/lines.mjs +538 -0
  64. package/vendor/tui/lib/render/markdown.mjs +592 -0
  65. package/vendor/tui/lib/render/projection.mjs +1864 -0
  66. package/vendor/tui/lib/render/status.mjs +591 -0
  67. package/vendor/tui/lib/render/text.mjs +157 -0
  68. package/vendor/tui/lib/render/tool-detail.mjs +187 -0
  69. package/vendor/tui/lib/render/tool-preview.mjs +79 -0
  70. package/vendor/tui/lib/render/usage.mjs +336 -0
  71. package/vendor/tui/lib/render/width.mjs +191 -0
  72. package/vendor/tui/lib/session-directory.mjs +329 -0
  73. package/vendor/tui/lib/session-query.mjs +184 -0
  74. package/vendor/tui/lib/session-switch.mjs +51 -0
  75. package/vendor/tui/lib/settings-file.mjs +75 -0
  76. package/vendor/tui/lib/skills.mjs +119 -0
  77. package/vendor/tui/lib/startup.mjs +111 -0
  78. package/vendor/tui/lib/store.mjs +129 -0
  79. package/vendor/tui/lib/subagents.mjs +200 -0
  80. package/vendor/tui/lib/terminal-title.mjs +186 -0
  81. package/vendor/tui/lib/theme-panel.mjs +60 -0
  82. package/vendor/tui/lib/theme.mjs +379 -0
  83. package/vendor/tui/lib/update-panel.mjs +239 -0
  84. package/vendor/tui/lib/update.mjs +101 -0
  85. package/vendor/tui/lib/version.mjs +105 -0
  86. package/vendor/tui/lib/whale-glyph.mjs +20 -0
  87. package/vendor/tui/LICENSE +0 -21
  88. package/vendor/tui/devtools-CdTl3MNy.mjs +0 -3643
  89. package/vendor/tui/dscode-email/cli.mjs +0 -32
  90. package/vendor/tui/dscode-email/contacts.mjs +0 -36
  91. package/vendor/tui/dscode-email/gmail-oauth.mjs +0 -69
  92. package/vendor/tui/dscode-email/gmail-store.mjs +0 -2
  93. package/vendor/tui/dscode-email/gmail.mjs +0 -194
  94. package/vendor/tui/dscode-email/imap.mjs +0 -136
  95. package/vendor/tui/dscode-email/inbox.d.mts +0 -25
  96. package/vendor/tui/dscode-email/inbox.mjs +0 -76
  97. package/vendor/tui/dscode-email/smtp.mjs +0 -69
  98. package/vendor/tui/dscode-email/store.mjs +0 -32
  99. package/vendor/tui/dscode-providers/catalog.mjs +0 -136
  100. package/vendor/tui/dscode-providers/effort.mjs +0 -35
  101. package/vendor/tui/dscode-providers/openrouter-account.mjs +0 -171
  102. package/vendor/tui/index.mjs +0 -44441
  103. package/vendor/tui/invariant.mjs +0 -21
  104. package/vendor/tui/rolldown-runtime-CMFfr-1z.mjs +0 -26
  105. package/vendor/tui/session-query.mjs +0 -150
  106. package/vendor/tui/startup.mjs +0 -109
  107. package/vendor/tui/theme-7u5Qo3dF.mjs +0 -1265
  108. package/vendor/tui/types/app.d.ts +0 -348
  109. package/vendor/tui/types/approval.d.ts +0 -59
  110. package/vendor/tui/types/attachments.d.ts +0 -52
  111. package/vendor/tui/types/authorization-panel.d.ts +0 -22
  112. package/vendor/tui/types/authorization.d.ts +0 -36
  113. package/vendor/tui/types/commands.d.ts +0 -52
  114. package/vendor/tui/types/editor-keys.d.ts +0 -105
  115. package/vendor/tui/types/editor.d.ts +0 -6
  116. package/vendor/tui/types/fork.d.ts +0 -8
  117. package/vendor/tui/types/git-workflow.d.ts +0 -121
  118. package/vendor/tui/types/index.d.ts +0 -223
  119. package/vendor/tui/types/input-split.d.ts +0 -54
  120. package/vendor/tui/types/internals.d.ts +0 -26
  121. package/vendor/tui/types/invariant.d.ts +0 -15
  122. package/vendor/tui/types/kernel-panels.d.ts +0 -245
  123. package/vendor/tui/types/keyboard.d.ts +0 -80
  124. package/vendor/tui/types/language-panel.d.ts +0 -12
  125. package/vendor/tui/types/locales/en.d.ts +0 -450
  126. package/vendor/tui/types/locales/zh.d.ts +0 -9
  127. package/vendor/tui/types/mentions.d.ts +0 -85
  128. package/vendor/tui/types/model-capabilities.d.ts +0 -82
  129. package/vendor/tui/types/models.d.ts +0 -133
  130. package/vendor/tui/types/permissions.d.ts +0 -27
  131. package/vendor/tui/types/plugin-inventory.d.ts +0 -11
  132. package/vendor/tui/types/presets.d.ts +0 -22
  133. package/vendor/tui/types/provider-settings.d.ts +0 -239
  134. package/vendor/tui/types/questions.d.ts +0 -54
  135. package/vendor/tui/types/rainbow.d.ts +0 -69
  136. package/vendor/tui/types/render/animations.d.ts +0 -307
  137. package/vendor/tui/types/render/editor.d.ts +0 -163
  138. package/vendor/tui/types/render/export.d.ts +0 -9
  139. package/vendor/tui/types/render/fuzzy.d.ts +0 -21
  140. package/vendor/tui/types/render/ime-cursor.d.ts +0 -60
  141. package/vendor/tui/types/render/inspector.d.ts +0 -62
  142. package/vendor/tui/types/render/lines.d.ts +0 -86
  143. package/vendor/tui/types/render/markdown.d.ts +0 -29
  144. package/vendor/tui/types/render/projection.d.ts +0 -587
  145. package/vendor/tui/types/render/status.d.ts +0 -196
  146. package/vendor/tui/types/render/text.d.ts +0 -64
  147. package/vendor/tui/types/render/tool-detail.d.ts +0 -94
  148. package/vendor/tui/types/render/tool-preview.d.ts +0 -28
  149. package/vendor/tui/types/render/usage.d.ts +0 -113
  150. package/vendor/tui/types/render/width.d.ts +0 -29
  151. package/vendor/tui/types/session-directory.d.ts +0 -190
  152. package/vendor/tui/types/session-query.d.ts +0 -92
  153. package/vendor/tui/types/session-switch.d.ts +0 -17
  154. package/vendor/tui/types/settings-file.d.ts +0 -41
  155. package/vendor/tui/types/skills.d.ts +0 -47
  156. package/vendor/tui/types/startup.d.ts +0 -65
  157. package/vendor/tui/types/store.d.ts +0 -58
  158. package/vendor/tui/types/subagents.d.ts +0 -70
  159. package/vendor/tui/types/terminal-title.d.ts +0 -66
  160. package/vendor/tui/types/theme-panel.d.ts +0 -24
  161. package/vendor/tui/types/theme.d.ts +0 -434
  162. package/vendor/tui/types/update-panel.d.ts +0 -49
  163. package/vendor/tui/types/update.d.ts +0 -75
  164. package/vendor/tui/types/version.d.ts +0 -19
  165. package/vendor/tui/types/whale-glyph.d.ts +0 -6
  166. /package/vendor/tui/{dscode-clipboard-image → lib/dscode/clipboard-image}/clipboard-image.swift +0 -0
  167. /package/vendor/tui/{dscode-clipboard-image → lib/dscode/clipboard-image}/index.mjs +0 -0
@@ -1,1265 +0,0 @@
1
- import os from "node:os";
2
- import process$1 from "node:process";
3
- import tty from "node:tty";
4
- //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
5
- const ANSI_BACKGROUND_OFFSET = 10;
6
- const wrapAnsi16 = (offset = 0) => (code) => `\u001B[${code + offset}m`;
7
- const wrapAnsi256 = (offset = 0) => (code) => `\u001B[${38 + offset};5;${code}m`;
8
- const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
9
- const styles$1 = {
10
- modifier: {
11
- reset: [0, 0],
12
- bold: [1, 22],
13
- dim: [2, 22],
14
- italic: [3, 23],
15
- underline: [4, 24],
16
- overline: [53, 55],
17
- inverse: [7, 27],
18
- hidden: [8, 28],
19
- strikethrough: [9, 29]
20
- },
21
- color: {
22
- black: [30, 39],
23
- red: [31, 39],
24
- green: [32, 39],
25
- yellow: [33, 39],
26
- blue: [34, 39],
27
- magenta: [35, 39],
28
- cyan: [36, 39],
29
- white: [37, 39],
30
- blackBright: [90, 39],
31
- gray: [90, 39],
32
- grey: [90, 39],
33
- redBright: [91, 39],
34
- greenBright: [92, 39],
35
- yellowBright: [93, 39],
36
- blueBright: [94, 39],
37
- magentaBright: [95, 39],
38
- cyanBright: [96, 39],
39
- whiteBright: [97, 39]
40
- },
41
- bgColor: {
42
- bgBlack: [40, 49],
43
- bgRed: [41, 49],
44
- bgGreen: [42, 49],
45
- bgYellow: [43, 49],
46
- bgBlue: [44, 49],
47
- bgMagenta: [45, 49],
48
- bgCyan: [46, 49],
49
- bgWhite: [47, 49],
50
- bgBlackBright: [100, 49],
51
- bgGray: [100, 49],
52
- bgGrey: [100, 49],
53
- bgRedBright: [101, 49],
54
- bgGreenBright: [102, 49],
55
- bgYellowBright: [103, 49],
56
- bgBlueBright: [104, 49],
57
- bgMagentaBright: [105, 49],
58
- bgCyanBright: [106, 49],
59
- bgWhiteBright: [107, 49]
60
- }
61
- };
62
- Object.keys(styles$1.modifier);
63
- const foregroundColorNames = Object.keys(styles$1.color);
64
- const backgroundColorNames = Object.keys(styles$1.bgColor);
65
- [...foregroundColorNames, ...backgroundColorNames];
66
- function assembleStyles() {
67
- const codes = /* @__PURE__ */ new Map();
68
- for (const [groupName, group] of Object.entries(styles$1)) {
69
- for (const [styleName, style] of Object.entries(group)) {
70
- styles$1[styleName] = {
71
- open: `\u001B[${style[0]}m`,
72
- close: `\u001B[${style[1]}m`
73
- };
74
- group[styleName] = styles$1[styleName];
75
- codes.set(style[0], style[1]);
76
- }
77
- Object.defineProperty(styles$1, groupName, {
78
- value: group,
79
- enumerable: false
80
- });
81
- }
82
- Object.defineProperty(styles$1, "codes", {
83
- value: codes,
84
- enumerable: false
85
- });
86
- styles$1.color.close = "\x1B[39m";
87
- styles$1.bgColor.close = "\x1B[49m";
88
- styles$1.color.ansi = wrapAnsi16();
89
- styles$1.color.ansi256 = wrapAnsi256();
90
- styles$1.color.ansi16m = wrapAnsi16m();
91
- styles$1.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
92
- styles$1.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
93
- styles$1.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
94
- Object.defineProperties(styles$1, {
95
- rgbToAnsi256: {
96
- value(red, green, blue) {
97
- if (red === green && green === blue) {
98
- if (red < 8) return 16;
99
- if (red > 248) return 231;
100
- return Math.round((red - 8) / 247 * 24) + 232;
101
- }
102
- return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
103
- },
104
- enumerable: false
105
- },
106
- hexToRgb: {
107
- value(hex) {
108
- const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
109
- if (!matches) return [
110
- 0,
111
- 0,
112
- 0
113
- ];
114
- let [colorString] = matches;
115
- if (colorString.length === 3) colorString = [...colorString].map((character) => character + character).join("");
116
- const integer = Number.parseInt(colorString, 16);
117
- return [
118
- integer >> 16 & 255,
119
- integer >> 8 & 255,
120
- integer & 255
121
- ];
122
- },
123
- enumerable: false
124
- },
125
- hexToAnsi256: {
126
- value: (hex) => styles$1.rgbToAnsi256(...styles$1.hexToRgb(hex)),
127
- enumerable: false
128
- },
129
- ansi256ToAnsi: {
130
- value(code) {
131
- if (code < 8) return 30 + code;
132
- if (code < 16) return 90 + (code - 8);
133
- let red;
134
- let green;
135
- let blue;
136
- if (code >= 232) {
137
- red = ((code - 232) * 10 + 8) / 255;
138
- green = red;
139
- blue = red;
140
- } else {
141
- code -= 16;
142
- const remainder = code % 36;
143
- red = Math.floor(code / 36) / 5;
144
- green = Math.floor(remainder / 6) / 5;
145
- blue = remainder % 6 / 5;
146
- }
147
- const value = Math.max(red, green, blue) * 2;
148
- if (value === 0) return 30;
149
- let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
150
- if (value === 2) result += 60;
151
- return result;
152
- },
153
- enumerable: false
154
- },
155
- rgbToAnsi: {
156
- value: (red, green, blue) => styles$1.ansi256ToAnsi(styles$1.rgbToAnsi256(red, green, blue)),
157
- enumerable: false
158
- },
159
- hexToAnsi: {
160
- value: (hex) => styles$1.ansi256ToAnsi(styles$1.hexToAnsi256(hex)),
161
- enumerable: false
162
- }
163
- });
164
- return styles$1;
165
- }
166
- const ansiStyles = assembleStyles();
167
- //#endregion
168
- //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
169
- function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process$1.argv) {
170
- const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
171
- const position = argv.indexOf(prefix + flag);
172
- const terminatorPosition = argv.indexOf("--");
173
- return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
174
- }
175
- const { env: env$1 } = process$1;
176
- let flagForceColor;
177
- if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) flagForceColor = 0;
178
- else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) flagForceColor = 1;
179
- function envForceColor() {
180
- if ("FORCE_COLOR" in env$1) {
181
- if (env$1.FORCE_COLOR === "true") return 1;
182
- if (env$1.FORCE_COLOR === "false") return 0;
183
- return env$1.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env$1.FORCE_COLOR, 10), 3);
184
- }
185
- }
186
- function translateLevel(level) {
187
- if (level === 0) return false;
188
- return {
189
- level,
190
- hasBasic: true,
191
- has256: level >= 2,
192
- has16m: level >= 3
193
- };
194
- }
195
- function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
196
- const noFlagForceColor = envForceColor();
197
- if (noFlagForceColor !== void 0) flagForceColor = noFlagForceColor;
198
- const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
199
- if (forceColor === 0) return 0;
200
- if (sniffFlags) {
201
- if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) return 3;
202
- if (hasFlag("color=256")) return 2;
203
- }
204
- if ("TF_BUILD" in env$1 && "AGENT_NAME" in env$1) return 1;
205
- if (haveStream && !streamIsTTY && forceColor === void 0) return 0;
206
- const min = forceColor || 0;
207
- if (env$1.TERM === "dumb") return min;
208
- if (process$1.platform === "win32") {
209
- const osRelease = os.release().split(".");
210
- if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
211
- return 1;
212
- }
213
- if ("CI" in env$1) {
214
- if ([
215
- "GITHUB_ACTIONS",
216
- "GITEA_ACTIONS",
217
- "CIRCLECI"
218
- ].some((key) => key in env$1)) return 3;
219
- if ([
220
- "TRAVIS",
221
- "APPVEYOR",
222
- "GITLAB_CI",
223
- "BUILDKITE",
224
- "DRONE"
225
- ].some((sign) => sign in env$1) || env$1.CI_NAME === "codeship") return 1;
226
- return min;
227
- }
228
- if ("TEAMCITY_VERSION" in env$1) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env$1.TEAMCITY_VERSION) ? 1 : 0;
229
- if (env$1.COLORTERM === "truecolor") return 3;
230
- if (env$1.TERM === "xterm-kitty") return 3;
231
- if (env$1.TERM === "xterm-ghostty") return 3;
232
- if (env$1.TERM === "wezterm") return 3;
233
- if ("TERM_PROGRAM" in env$1) {
234
- const version = Number.parseInt((env$1.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
235
- switch (env$1.TERM_PROGRAM) {
236
- case "iTerm.app": return version >= 3 ? 3 : 2;
237
- case "Apple_Terminal": return 2;
238
- }
239
- }
240
- if (/-256(color)?$/i.test(env$1.TERM)) return 2;
241
- if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env$1.TERM)) return 1;
242
- if ("COLORTERM" in env$1) return 1;
243
- return min;
244
- }
245
- function createSupportsColor(stream, options = {}) {
246
- return translateLevel(_supportsColor(stream, {
247
- streamIsTTY: stream && stream.isTTY,
248
- ...options
249
- }));
250
- }
251
- const supportsColor = {
252
- stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
253
- stderr: createSupportsColor({ isTTY: tty.isatty(2) })
254
- };
255
- //#endregion
256
- //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
257
- function stringReplaceAll(string, substring, replacer) {
258
- let index = string.indexOf(substring);
259
- if (index === -1) return string;
260
- const substringLength = substring.length;
261
- let endIndex = 0;
262
- let returnValue = "";
263
- do {
264
- returnValue += string.slice(endIndex, index) + substring + replacer;
265
- endIndex = index + substringLength;
266
- index = string.indexOf(substring, endIndex);
267
- } while (index !== -1);
268
- returnValue += string.slice(endIndex);
269
- return returnValue;
270
- }
271
- function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
272
- let endIndex = 0;
273
- let returnValue = "";
274
- do {
275
- const gotCR = string[index - 1] === "\r";
276
- returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
277
- endIndex = index + 1;
278
- index = string.indexOf("\n", endIndex);
279
- } while (index !== -1);
280
- returnValue += string.slice(endIndex);
281
- return returnValue;
282
- }
283
- //#endregion
284
- //#region node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
285
- const { stdout: stdoutColor, stderr: stderrColor } = supportsColor;
286
- const GENERATOR = Symbol("GENERATOR");
287
- const STYLER = Symbol("STYLER");
288
- const IS_EMPTY = Symbol("IS_EMPTY");
289
- const levelMapping = [
290
- "ansi",
291
- "ansi",
292
- "ansi256",
293
- "ansi16m"
294
- ];
295
- const styles = Object.create(null);
296
- const applyOptions = (object, options = {}) => {
297
- if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) throw new Error("The `level` option should be an integer from 0 to 3");
298
- const colorLevel = stdoutColor ? stdoutColor.level : 0;
299
- object.level = options.level === void 0 ? colorLevel : options.level;
300
- };
301
- const chalkFactory = (options) => {
302
- const chalk = (...strings) => strings.join(" ");
303
- applyOptions(chalk, options);
304
- Object.setPrototypeOf(chalk, createChalk.prototype);
305
- return chalk;
306
- };
307
- function createChalk(options) {
308
- return chalkFactory(options);
309
- }
310
- Object.setPrototypeOf(createChalk.prototype, Function.prototype);
311
- for (const [styleName, style] of Object.entries(ansiStyles)) styles[styleName] = { get() {
312
- const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
313
- Object.defineProperty(this, styleName, { value: builder });
314
- return builder;
315
- } };
316
- styles.visible = { get() {
317
- const builder = createBuilder(this, this[STYLER], true);
318
- Object.defineProperty(this, "visible", { value: builder });
319
- return builder;
320
- } };
321
- const getModelAnsi = (model, level, type, ...arguments_) => {
322
- if (model === "rgb") {
323
- if (level === "ansi16m") return ansiStyles[type].ansi16m(...arguments_);
324
- if (level === "ansi256") return ansiStyles[type].ansi256(ansiStyles.rgbToAnsi256(...arguments_));
325
- return ansiStyles[type].ansi(ansiStyles.rgbToAnsi(...arguments_));
326
- }
327
- if (model === "hex") return getModelAnsi("rgb", level, type, ...ansiStyles.hexToRgb(...arguments_));
328
- return ansiStyles[type][model](...arguments_);
329
- };
330
- for (const model of [
331
- "rgb",
332
- "hex",
333
- "ansi256"
334
- ]) {
335
- styles[model] = { get() {
336
- const { level } = this;
337
- return function(...arguments_) {
338
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansiStyles.color.close, this[STYLER]);
339
- return createBuilder(this, styler, this[IS_EMPTY]);
340
- };
341
- } };
342
- const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
343
- styles[bgModel] = { get() {
344
- const { level } = this;
345
- return function(...arguments_) {
346
- const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansiStyles.bgColor.close, this[STYLER]);
347
- return createBuilder(this, styler, this[IS_EMPTY]);
348
- };
349
- } };
350
- }
351
- const proto = Object.defineProperties(() => {}, {
352
- ...styles,
353
- level: {
354
- enumerable: true,
355
- get() {
356
- return this[GENERATOR].level;
357
- },
358
- set(level) {
359
- this[GENERATOR].level = level;
360
- }
361
- }
362
- });
363
- const createStyler = (open, close, parent) => {
364
- let openAll;
365
- let closeAll;
366
- if (parent === void 0) {
367
- openAll = open;
368
- closeAll = close;
369
- } else {
370
- openAll = parent.openAll + open;
371
- closeAll = close + parent.closeAll;
372
- }
373
- return {
374
- open,
375
- close,
376
- openAll,
377
- closeAll,
378
- parent
379
- };
380
- };
381
- const createBuilder = (self, _styler, _isEmpty) => {
382
- const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
383
- Object.setPrototypeOf(builder, proto);
384
- builder[GENERATOR] = self;
385
- builder[STYLER] = _styler;
386
- builder[IS_EMPTY] = _isEmpty;
387
- return builder;
388
- };
389
- const applyStyle = (self, string) => {
390
- if (self.level <= 0 || !string) return self[IS_EMPTY] ? "" : string;
391
- let styler = self[STYLER];
392
- if (styler === void 0) return string;
393
- const { openAll, closeAll } = styler;
394
- if (string.includes("\x1B")) while (styler !== void 0) {
395
- string = stringReplaceAll(string, styler.close, styler.open);
396
- styler = styler.parent;
397
- }
398
- const lfIndex = string.indexOf("\n");
399
- if (lfIndex !== -1) string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
400
- return openAll + string + closeAll;
401
- };
402
- Object.defineProperties(createChalk.prototype, styles);
403
- const chalk = createChalk();
404
- createChalk({ level: stderrColor ? stderrColor.level : 0 });
405
- //#endregion
406
- //#region src/rainbow.ts
407
- /**
408
- * The bright-tier spectrum: twelve Tailwind *-300 hues covering red through
409
- * fuchsia, every one ≥11:1 on black. The roll samples this pool by shuffle;
410
- * nothing outside it is ever painted.
411
- */
412
- const RAINBOW_POOL = [
413
- [
414
- 252,
415
- 165,
416
- 165
417
- ],
418
- [
419
- 253,
420
- 186,
421
- 116
422
- ],
423
- [
424
- 253,
425
- 230,
426
- 138
427
- ],
428
- [
429
- 253,
430
- 224,
431
- 71
432
- ],
433
- [
434
- 190,
435
- 242,
436
- 100
437
- ],
438
- [
439
- 134,
440
- 239,
441
- 172
442
- ],
443
- [
444
- 94,
445
- 234,
446
- 212
447
- ],
448
- [
449
- 103,
450
- 232,
451
- 249
452
- ],
453
- [
454
- 125,
455
- 211,
456
- 252
457
- ],
458
- [
459
- 147,
460
- 197,
461
- 253
462
- ],
463
- [
464
- 196,
465
- 181,
466
- 253
467
- ],
468
- [
469
- 240,
470
- 171,
471
- 252
472
- ]
473
- ];
474
- /**
475
- * Status tones in canonical on-screen order (row one left-to-right, then row
476
- * two): consecutive entries here are the pairs the "adjacent spans differ"
477
- * guarantee covers, including the accent→value step across the row boundary.
478
- */
479
- const TONE_ORDER = [
480
- "live",
481
- "model",
482
- "path",
483
- "branch",
484
- "accent",
485
- "value",
486
- "label",
487
- "meta",
488
- "ctxFill",
489
- "success",
490
- "plan",
491
- "warn",
492
- "error"
493
- ];
494
- /** Parse a RAINBOW_SEED value: a non-negative decimal uint32, else nothing. */
495
- function parseRainbowSeed(value) {
496
- if (value === void 0 || !/^\d{1,10}$/.test(value.trim())) return void 0;
497
- const parsed = Number(value.trim());
498
- return Number.isSafeInteger(parsed) ? parsed >>> 0 : void 0;
499
- }
500
- /**
501
- * One parsed `/rainbow` argument: empty means a fresh random roll; a
502
- * decimal uint32 pins that seed; anything else is a usage error.
503
- * @param argument - the raw text after `/rainbow`.
504
- * @returns `{ seed }`, `'random'`, or `'usage'`.
505
- */
506
- function parseRainbowArgument(argument) {
507
- const trimmed = argument.trim();
508
- if (trimmed === "") return "random";
509
- const parsed = parseRainbowSeed(trimmed);
510
- return parsed === void 0 ? "usage" : { seed: parsed };
511
- }
512
- /** Deterministic 32-bit RNG (mulberry32) — one roll, one stream. */
513
- function mulberry32(seed) {
514
- let state = seed >>> 0;
515
- return () => {
516
- state = state + 1831565813 | 0;
517
- let t = Math.imul(state ^ state >>> 15, 1 | state);
518
- t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
519
- return ((t ^ t >>> 14) >>> 0) / 4294967296;
520
- };
521
- }
522
- /** Fisher–Yates shuffle over a copy, driven by the roll's RNG. */
523
- function shuffle(items, rng) {
524
- const out = [...items];
525
- for (let i = out.length - 1; i > 0; i -= 1) {
526
- const j = Math.floor(rng() * (i + 1));
527
- [out[i], out[j]] = [out[j], out[i]];
528
- }
529
- return out;
530
- }
531
- /** Approximate HSL hue of one RGB triple, degrees in [0, 360). */
532
- function hueOf([r, g, b]) {
533
- const max = Math.max(r, g, b);
534
- const min = Math.min(r, g, b);
535
- if (max === min) return 0;
536
- const span = max - min;
537
- if (max === r) return (60 * (g - b) / span + 360) % 360;
538
- if (max === g) return (60 * (b - r) / span + 120) % 360;
539
- return (60 * (r - g) / span + 240) % 360;
540
- }
541
- /** A dark row tint for diff backgrounds: the hue at 22% strength over black. */
542
- function darkTint(hue) {
543
- return [
544
- Math.round(hue[0] * .22),
545
- Math.round(hue[1] * .22),
546
- Math.round(hue[2] * .22)
547
- ];
548
- }
549
- /** Readability anchors shared by every roll: captions, text, band stay calm. */
550
- const DIM = [
551
- 166,
552
- 163,
553
- 184
554
- ];
555
- const TEXT = [
556
- 240,
557
- 238,
558
- 249
559
- ];
560
- const BAND = [
561
- 46,
562
- 46,
563
- 52
564
- ];
565
- /**
566
- * Build the roll for one seed: pure and deterministic, so tests pin exact
567
- * outcomes and RAINBOW_SEED reproduces a lucky launch exactly.
568
- * @param seed - the uint32 seed to roll from.
569
- * @returns the complete carnival roll.
570
- */
571
- function rollRainbow(seed) {
572
- const rng = mulberry32(seed);
573
- const pool = shuffle(RAINBOW_POOL, rng);
574
- const [brand, brandBright, brandMid, brandDeep, code, success, error, warn, addHue, delHue] = pool;
575
- const palette = {
576
- brand,
577
- brandBright,
578
- brandMid,
579
- brandDeep,
580
- dim: DIM,
581
- success,
582
- error,
583
- warn,
584
- text: TEXT,
585
- code,
586
- composerBand: BAND,
587
- diffAdd: darkTint(addHue),
588
- diffDel: darkTint(delHue),
589
- diffAddFg: addHue,
590
- diffDelFg: delHue,
591
- surface: [
592
- 0,
593
- 0,
594
- 0
595
- ],
596
- prompt: brandBright,
597
- queued: warn,
598
- steered: code
599
- };
600
- const ring = shuffle(RAINBOW_POOL, rng).slice(0, 4);
601
- const offset = Math.floor(rng() * RAINBOW_POOL.length);
602
- const toneColors = {};
603
- TONE_ORDER.forEach((tone, index) => {
604
- toneColors[tone] = pool[(offset + index) % pool.length];
605
- });
606
- return {
607
- seed,
608
- palette,
609
- ring,
610
- toneColors,
611
- flowAnchors: [...RAINBOW_POOL].sort((a, b) => hueOf(a) - hueOf(b)),
612
- flowPhaseMs: Math.floor(rng() * 2400)
613
- };
614
- }
615
- /** The launch seed: RAINBOW_SEED when parseable, else a fresh random roll. */
616
- function launchSeed() {
617
- const pinned = parseRainbowSeed(process.env.RAINBOW_SEED);
618
- if (pinned !== void 0) return pinned;
619
- return (Date.now() ^ Math.floor(Math.random() * 4294967296)) >>> 0;
620
- }
621
- let rolled;
622
- /** The memoized per-launch roll; computed once, stable for the whole run. */
623
- function rainbowRoll() {
624
- if (rolled === void 0) rolled = rollRainbow(launchSeed());
625
- return rolled;
626
- }
627
- /**
628
- * Replace the memoized roll: omit the seed for a fresh random one, or pass
629
- * a uint32 to pin it. `/rainbow` uses this so a mid-session reroll actually
630
- * recolors; {@link setTheme}(`'rainbow'`) must run afterwards so the
631
- * palette accessor picks the new values up.
632
- * @param seed - the seed to pin, or undefined for a new random roll.
633
- * @returns the roll now in force.
634
- */
635
- function rerollRainbow(seed) {
636
- rolled = rollRainbow(seed ?? (Date.now() ^ Math.floor(Math.random() * 4294967296)) >>> 0);
637
- return rolled;
638
- }
639
- /** The current roll's seed as display copy (also the RAINBOW_SEED value). */
640
- function rainbowSeedLabel() {
641
- return String(rainbowRoll().seed);
642
- }
643
- //#endregion
644
- //#region src/theme.ts
645
- /**
646
- * Terminal color tokens for the dsh TUI, mapped from the product design
647
- * platform's DeepSeek palette
648
- * (`packages/client/ui-theme/src/styles/design-platform.css`). Truecolor RGB
649
- * rides chalk, which degrades automatically on terminals without truecolor.
650
- *
651
- * Three palettes — `dark` (the default), `light`, and `prismatic` (the
652
- * neon synthwave skin) — share the same token keys with different values.
653
- * Painters and the palette accessor read the ACTIVE
654
- * palette selected through {@link setTheme}, so a theme switch recolors every
655
- * painted surface on the next render without touching call sites; consumers
656
- * read colors through {@link getPalette} or the painters below only.
657
- *
658
- * @module @deepseek-ai/dsh-tui/theme
659
- */
660
- /** Valid theme names in canonical picker order. */
661
- const THEME_NAMES = [
662
- "dark",
663
- "light",
664
- "prismatic",
665
- "rainbow",
666
- "auto"
667
- ];
668
- /**
669
- * Every theme's picker metadata in canonical order — the single source the
670
- * /theme panel rows derive from; {@link THEME_NAMES} stays the validation
671
- * list. Adding a theme means adding its palette plus one row here.
672
- */
673
- const THEMES = [
674
- {
675
- id: "dark",
676
- label: "dark",
677
- description: "DeepSeek dark palette (default)"
678
- },
679
- {
680
- id: "light",
681
- label: "light",
682
- description: "light palette for bright terminals"
683
- },
684
- {
685
- id: "prismatic",
686
- label: "prismatic",
687
- description: "neon synthwave palette (violet/magenta/cyan)"
688
- },
689
- {
690
- id: "rainbow",
691
- label: "rainbow",
692
- description: "randomized carnival palette (/rainbow to reroll)"
693
- },
694
- {
695
- id: "auto",
696
- label: "auto",
697
- description: "follow the terminal; dark until detection lands"
698
- }
699
- ];
700
- /**
701
- * DeepSeek dark palette: the original TUI colors, one entry per
702
- * design-platform token in use. Keep names and values in sync with the CSS
703
- * custom properties cited inline.
704
- */
705
- const DARK_PALETTE = {
706
- /** Primary brand blue — `--dsw-static-deepseek-500`. */
707
- brand: [
708
- 65,
709
- 118,
710
- 230
711
- ],
712
- /** Brighter brand blue for live/streaming emphasis — `--dsw-static-deepseek-400`. */
713
- brandBright: [
714
- 103,
715
- 158,
716
- 254
717
- ],
718
- /** Intermediate brand blue between brand and brandBright — `--dsw-static-deepseek-450`. */
719
- brandMid: [
720
- 86,
721
- 134,
722
- 254
723
- ],
724
- /** Deep brand blue for secondary chrome — `--dsw-static-deepseek-600`. */
725
- brandDeep: [
726
- 72,
727
- 104,
728
- 178
729
- ],
730
- /** Muted caption gray — `--dsw-static-neutral-bluish-600`. */
731
- dim: [
732
- 129,
733
- 133,
734
- 140
735
- ],
736
- /** Success green — `--dsw-static-green-500`. */
737
- success: [
738
- 34,
739
- 197,
740
- 94
741
- ],
742
- /** Error red — `--dsw-static-red-500`. */
743
- error: [
744
- 239,
745
- 68,
746
- 68
747
- ],
748
- /** Warning amber — `--dsw-static-amber-500`. */
749
- warn: [
750
- 245,
751
- 158,
752
- 11
753
- ],
754
- /** Default foreground text — `--dsw-static-neutral-50`. */
755
- text: [
756
- 236,
757
- 240,
758
- 246
759
- ],
760
- /** Inline/fenced code — soft sky blue, distinct from brand accents. */
761
- code: [
762
- 125,
763
- 211,
764
- 252
765
- ],
766
- /** Composer three-row band base — neutral light gray, hue-free so wave tints read on it. */
767
- composerBand: [
768
- 46,
769
- 48,
770
- 52
771
- ],
772
- /** Diff added-line background — Codex's muted dark green tint (#213A2B). */
773
- diffAdd: [
774
- 33,
775
- 58,
776
- 43
777
- ],
778
- /** Diff removed-line background — Codex's muted dark red tint (#4A221D). */
779
- diffDel: [
780
- 74,
781
- 34,
782
- 29
783
- ],
784
- /** Diff added-line foreground — green-500, 5.4:1 on the diffAdd tint. */
785
- diffAddFg: [
786
- 34,
787
- 197,
788
- 94
789
- ],
790
- /** Diff removed-line foreground — red-400, 4.9:1 on the diffDel tint (error's red-500 sinks to 3.6:1 on it). */
791
- diffDelFg: [
792
- 248,
793
- 113,
794
- 113
795
- ],
796
- /** Terminal background this palette is designed against; row tints blend toward it. */
797
- surface: [
798
- 0,
799
- 0,
800
- 0
801
- ],
802
- /**
803
- * The three prompt-row colors, one per delivery kind. They are the palette's
804
- * own accents (bright brand, warning amber, violet) rather than fixed RGBs,
805
- * and every row's bar is these colors laid over {@link surface}.
806
- */
807
- prompt: [
808
- 103,
809
- 158,
810
- 254
811
- ],
812
- queued: [
813
- 245,
814
- 158,
815
- 11
816
- ],
817
- steered: [
818
- 167,
819
- 139,
820
- 250
821
- ]
822
- };
823
- /**
824
- * Every STATIC palette by theme name; auto resolves through {@link resolveTheme}
825
- * and rainbow is rolled per launch ({@link rainbowRoll}), so neither lives
826
- * here — {@link setTheme} resolves both through the same key space.
827
- */
828
- const PALETTES = {
829
- dark: DARK_PALETTE,
830
- light: {
831
- /** Primary brand blue — unchanged design-platform value; ≈4.2:1 on white, so bold/accent spans only (body-size brand text uses brandBright). */
832
- brand: [
833
- 65,
834
- 118,
835
- 230
836
- ],
837
- /** Brighter brand blue deepened for white backgrounds (was 2.7:1). */
838
- brandBright: [
839
- 72,
840
- 104,
841
- 178
842
- ],
843
- /** Intermediate brand blue — Tailwind blue-500. */
844
- brandMid: [
845
- 59,
846
- 130,
847
- 246
848
- ],
849
- /** Deep brand blue for secondary chrome — `--dsw-static-deepseek-700`. */
850
- brandDeep: [
851
- 47,
852
- 76,
853
- 143
854
- ],
855
- /** Muted caption gray deepened for white backgrounds. */
856
- dim: [
857
- 101,
858
- 103,
859
- 107
860
- ],
861
- /** Success green — Tailwind green-700. */
862
- success: [
863
- 21,
864
- 128,
865
- 61
866
- ],
867
- /** Error red — Tailwind red-600. */
868
- error: [
869
- 236,
870
- 19,
871
- 19
872
- ],
873
- /** Warning amber — Tailwind amber-700. */
874
- warn: [
875
- 180,
876
- 83,
877
- 9
878
- ],
879
- /** Default foreground text — near-black. */
880
- text: [
881
- 21,
882
- 21,
883
- 23
884
- ],
885
- /** Inline/fenced code — Tailwind cyan-700, distinct from brand accents. */
886
- code: [
887
- 14,
888
- 116,
889
- 144
890
- ],
891
- /** Composer three-row band base — neutral light gray, hue-free so wave tints read on it. */
892
- composerBand: [
893
- 229,
894
- 231,
895
- 235
896
- ],
897
- /** Diff added-line background — GitHub's pastel green (#dafbe1), Codex's light pick. */
898
- diffAdd: [
899
- 218,
900
- 251,
901
- 225
902
- ],
903
- /** Diff removed-line background — GitHub's pastel red (#ffebe9), Codex's light pick. */
904
- diffDel: [
905
- 255,
906
- 235,
907
- 233
908
- ],
909
- /** Diff added-line foreground — green-800, 6.4:1 on the pastel tint (green-700 clears 4.5:1 by a hair). */
910
- diffAddFg: [
911
- 22,
912
- 101,
913
- 52
914
- ],
915
- /** Diff removed-line foreground — red-700, 5.6:1 on the pastel tint (error's red-600 is 3.9:1). */
916
- diffDelFg: [
917
- 185,
918
- 28,
919
- 28
920
- ],
921
- /** Terminal background this palette is designed against; row tints blend toward it. */
922
- surface: [
923
- 255,
924
- 255,
925
- 255
926
- ],
927
- /**
928
- * Prompt-row colors deepened for white: the amber and violet the dark theme
929
- * uses sit at the AA edge on their own pastel bars, so each kind carries a
930
- * value that clears 4.5:1 both on the bar and on plain white.
931
- */
932
- prompt: [
933
- 47,
934
- 76,
935
- 143
936
- ],
937
- queued: [
938
- 124,
939
- 53,
940
- 10
941
- ],
942
- steered: [
943
- 109,
944
- 40,
945
- 217
946
- ]
947
- },
948
- prismatic: {
949
- /** Primary electric purple — violet-500 (#8B5CF6), 5.0:1 on black. */
950
- brand: [
951
- 139,
952
- 92,
953
- 246
954
- ],
955
- /** Live/streaming emphasis — neon fuchsia-300 (#F0ABFC), 11.9:1 on black. */
956
- brandBright: [
957
- 240,
958
- 171,
959
- 252
960
- ],
961
- /** Intermediate violet — violet-400 (#A78BFA), 7.7:1 on black. */
962
- brandMid: [
963
- 167,
964
- 139,
965
- 250
966
- ],
967
- /** Deep secondary chrome — violet-600 (#7C3AED), 3.7:1 on black (violet-700 misses 3:1). */
968
- brandDeep: [
969
- 124,
970
- 58,
971
- 237
972
- ],
973
- /** Muted captions — lavender gray (#A6A3B8), 8.6:1 on black. */
974
- dim: [
975
- 166,
976
- 163,
977
- 184
978
- ],
979
- /** Success green — unchanged from dark. */
980
- success: [
981
- 34,
982
- 197,
983
- 94
984
- ],
985
- /** Error red — unchanged from dark. */
986
- error: [
987
- 239,
988
- 68,
989
- 68
990
- ],
991
- /** Warning amber — unchanged from dark. */
992
- warn: [
993
- 245,
994
- 158,
995
- 11
996
- ],
997
- /** Default foreground text — white with a lavender cast (#F0EEF9). */
998
- text: [
999
- 240,
1000
- 238,
1001
- 249
1002
- ],
1003
- /** Inline/fenced code — neon cyan-300 (#67E8F9), 14.5:1 on black. */
1004
- code: [
1005
- 103,
1006
- 232,
1007
- 249
1008
- ],
1009
- /** Composer three-row band base — neutral dark gray, hue-free so wave tints read on it. */
1010
- composerBand: [
1011
- 46,
1012
- 46,
1013
- 52
1014
- ],
1015
- /** Diff added-line background — unchanged from dark. */
1016
- diffAdd: [
1017
- 33,
1018
- 58,
1019
- 43
1020
- ],
1021
- /** Diff removed-line background — unchanged from dark. */
1022
- diffDel: [
1023
- 74,
1024
- 34,
1025
- 29
1026
- ],
1027
- /** Diff added-line foreground — unchanged from dark. */
1028
- diffAddFg: [
1029
- 34,
1030
- 197,
1031
- 94
1032
- ],
1033
- /** Diff removed-line foreground — unchanged from dark. */
1034
- diffDelFg: [
1035
- 248,
1036
- 113,
1037
- 113
1038
- ],
1039
- /** Terminal background this palette is designed against; row tints blend toward it. */
1040
- surface: [
1041
- 0,
1042
- 0,
1043
- 0
1044
- ],
1045
- /** Prompt rows in the skin's own neon: fuchsia, amber, cyan. */
1046
- prompt: [
1047
- 240,
1048
- 171,
1049
- 252
1050
- ],
1051
- queued: [
1052
- 245,
1053
- 158,
1054
- 11
1055
- ],
1056
- steered: [
1057
- 103,
1058
- 232,
1059
- 249
1060
- ]
1061
- }
1062
- };
1063
- /** The theme name in force (the requested name; 'auto' included). */
1064
- let activeName = "dark";
1065
- /** The palette painters and {@link getPalette} read for the active theme. */
1066
- let activePalette = DARK_PALETTE;
1067
- /**
1068
- * Resolve a theme name to the palette actually in use. `auto` detection
1069
- * (OSC 11 terminal background query) is a later enhancement; until it lands,
1070
- * auto falls back to the dark palette (prismatic and rainbow are always
1071
- * explicit choices, never auto-resolved).
1072
- * @param name - the requested theme name.
1073
- * @returns 'dark', 'light', 'prismatic', or 'rainbow' — the palette key.
1074
- */
1075
- function resolveTheme(name) {
1076
- return name === "light" ? "light" : name === "prismatic" ? "prismatic" : name === "rainbow" ? "rainbow" : "dark";
1077
- }
1078
- /**
1079
- * Switch the active theme: painters and {@link getPalette} reflect the new
1080
- * palette from the next render onward. The default is dark, so a process
1081
- * that never calls this paints exactly as before.
1082
- * @param name - the theme to activate ('auto' resolves to dark for now).
1083
- */
1084
- function setTheme(name) {
1085
- activeName = name;
1086
- const resolved = resolveTheme(name);
1087
- activePalette = resolved === "rainbow" ? rainbowRoll().palette : PALETTES[resolved];
1088
- }
1089
- /**
1090
- * The theme name in force. Returns the requested name ('auto' included) so
1091
- * the /theme picker and persistence can round-trip the user's choice; the
1092
- * palette actually used is {@link getPalette}.
1093
- */
1094
- function getTheme() {
1095
- return activeName;
1096
- }
1097
- /** The palette in force; theme-aware call sites read colors through it. */
1098
- function getPalette() {
1099
- return activePalette;
1100
- }
1101
- /**
1102
- * Parse a persisted theme name: only names in {@link THEME_NAMES} survive;
1103
- * anything else (missing, corrupt, or unknown) falls back to the dark default.
1104
- * @param value - the raw parsed JSON value (expected string).
1105
- * @returns a valid theme name.
1106
- */
1107
- function parseThemeName(value) {
1108
- return typeof value === "string" && THEME_NAMES.includes(value) ? value : "dark";
1109
- }
1110
- /** Ink `color` string for one RGB triple. */
1111
- function inkColor(triple) {
1112
- return `rgb(${triple[0]}, ${triple[1]}, ${triple[2]})`;
1113
- }
1114
- /**
1115
- * Diff-line background as an Ink `backgroundColor` string, theme-aware and
1116
- * depth-gated (the Codex diff renderer's rule): 16-color terminals paint
1117
- * backgrounds from the saturated system palette, which drowns the text, so
1118
- * they keep the foreground-only look; 256-color and truecolor terminals get
1119
- * the palette's tint (chalk quantizes the RGB form down automatically).
1120
- * @param token - which diff background, added or removed lines.
1121
- * @returns the Ink background color, or undefined to paint foreground-only.
1122
- */
1123
- function diffBackground(token) {
1124
- if (chalk.level < 2) return void 0;
1125
- return inkColor(activePalette[token]);
1126
- }
1127
- /** How far one prompt-row tint leans toward its color, over the surface. */
1128
- const PROMPT_ROW_TINT = .22;
1129
- /**
1130
- * The color family one prompt row wears, chosen by how it was delivered: the
1131
- * ordinary brand accent, the warning amber for a queued prompt, and the
1132
- * palette's own third accent for a steered one. The bar behind it is derived
1133
- * from that same color, so every theme — including a freshly rolled rainbow —
1134
- * carries its own look instead of a fixed triple.
1135
- * @param delivery - how the prompt was delivered; undefined is an ordinary one.
1136
- * @returns the palette token whose color paints the row.
1137
- */
1138
- function promptRowTokens(delivery) {
1139
- if (delivery === "queued") return { fg: "queued" };
1140
- if (delivery === "steered") return { fg: "steered" };
1141
- return { fg: "prompt" };
1142
- }
1143
- /**
1144
- * Blended prompt-row background for one row color: the palette color laid
1145
- * over the surface the palette is designed for (dark themes over black, light
1146
- * over white), depth-gated exactly like {@link diffBackground} — a 16-color
1147
- * terminal keeps the foreground-only look rather than painting a saturated
1148
- * system background behind the text.
1149
- * @param color - the row's palette token.
1150
- * @returns the Ink background color, or undefined to paint foreground-only.
1151
- */
1152
- function rowBackground(color) {
1153
- if (chalk.level < 2) return void 0;
1154
- const surface = activePalette.surface;
1155
- const tint = activePalette[color];
1156
- const blend = (index) => Math.round(surface[index] + (tint[index] - surface[index]) * PROMPT_ROW_TINT);
1157
- return inkColor([
1158
- blend(0),
1159
- blend(1),
1160
- blend(2)
1161
- ]);
1162
- }
1163
- /**
1164
- * The prismatic surface ring: four neon accents panels cycle through by
1165
- * mount order (cyan → fuchsia → violet → lime), all ≥3:1 on black. Dark and
1166
- * light ignore the ring — {@link surfaceAccent} falls back to the passed-in
1167
- * base color so those themes stay pixel-identical.
1168
- */
1169
- const ACCENT_RING = [
1170
- [
1171
- 34,
1172
- 211,
1173
- 238
1174
- ],
1175
- [
1176
- 232,
1177
- 121,
1178
- 249
1179
- ],
1180
- [
1181
- 167,
1182
- 139,
1183
- 250
1184
- ],
1185
- [
1186
- 163,
1187
- 230,
1188
- 53
1189
- ]
1190
- ];
1191
- /**
1192
- * The prismatic flow anchors: brand violet → neon fuchsia → neon cyan. All
1193
- * three clear 4.5:1 on black, so a flowing foreground stays AA throughout
1194
- * the oscillation (render/animations.ts walks the triangle).
1195
- */
1196
- const FLOW_ANCHORS = [
1197
- [
1198
- 139,
1199
- 92,
1200
- 246
1201
- ],
1202
- [
1203
- 232,
1204
- 121,
1205
- 249
1206
- ],
1207
- [
1208
- 34,
1209
- 211,
1210
- 238
1211
- ]
1212
- ];
1213
- /**
1214
- * Whether the active theme is prismatic (the neon skin with surface rings
1215
- * and flowing accents).
1216
- */
1217
- function isPrismatic() {
1218
- return activeName === "prismatic";
1219
- }
1220
- /** Whether the active theme is rainbow (the per-launch carnival roll). */
1221
- function isRainbow() {
1222
- return activeName === "rainbow";
1223
- }
1224
- /**
1225
- * The flowing theme's anchor walk: prismatic rides the fixed violet→fuchsia→
1226
- * cyan triangle; rainbow rides its rolled full-spectrum anchors with a random
1227
- * phase; dark and light have no flow (undefined) and keep static accents.
1228
- */
1229
- function themeFlow() {
1230
- if (isPrismatic()) return {
1231
- anchors: FLOW_ANCHORS,
1232
- phaseMs: 0
1233
- };
1234
- if (isRainbow()) {
1235
- const roll = rainbowRoll();
1236
- return {
1237
- anchors: roll.flowAnchors,
1238
- phaseMs: roll.flowPhaseMs
1239
- };
1240
- }
1241
- }
1242
- /**
1243
- * The accent for one surface slot: prismatic rotates the {@link ACCENT_RING}
1244
- * by slot index; every other theme gets the caller's base color back.
1245
- * @param index - the slot's position in the mount-order sequence.
1246
- * @param base - the color to use outside prismatic (the surface's usual one).
1247
- * @returns the accent to paint the surface's border/title with.
1248
- */
1249
- function surfaceAccent(index, base) {
1250
- if (isPrismatic()) {
1251
- const ring = ACCENT_RING;
1252
- return ring[(index % ring.length + ring.length) % ring.length];
1253
- }
1254
- if (isRainbow()) {
1255
- const ring = rainbowRoll().ring;
1256
- return ring[(index % ring.length + ring.length) % ring.length];
1257
- }
1258
- return base;
1259
- }
1260
- /** Paint muted captions, hints, and meta lines. */
1261
- function dim(text) {
1262
- return chalk.rgb(...activePalette.dim)(text);
1263
- }
1264
- //#endregion
1265
- export { parseRainbowArgument as _, dim as a, rerollRainbow as b, inkColor as c, parseThemeName as d, promptRowTokens as f, themeFlow as g, surfaceAccent as h, diffBackground as i, isPrismatic as l, setTheme as m, THEMES as n, getPalette as o, rowBackground as p, THEME_NAMES as r, getTheme as s, FLOW_ANCHORS as t, isRainbow as u, rainbowRoll as v, chalk as x, rainbowSeedLabel as y };