@toddzheng024/dscode-bundle 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +5 -0
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/bin/apply_patch +4 -0
- package/bootstrap.mjs +21 -0
- package/cordis.patch.yml +756 -0
- package/package.json +327 -0
- package/plugins/auto-review/audit.mjs +20 -0
- package/plugins/auto-review/index.mjs +181 -0
- package/plugins/auto-review/policy.mjs +59 -0
- package/plugins/dscode/index.mjs +35 -0
- package/plugins/session-metrics/index.mjs +44 -0
- package/plugins/session-metrics/pricing.mjs +18 -0
- package/plugins/session-metrics/store.mjs +24 -0
- package/plugins/session-metrics/view.mjs +58 -0
- package/plugins/tui-tools/hooks.mjs +23 -0
- package/plugins/tui-tools/index.mjs +164 -0
- package/plugins/ultra/policy.mjs +11 -0
- package/presets/dscode/agent.cordis.yml +288 -0
- package/presets/dscode/preset.yml +3 -0
- package/vendor/bash/LICENSE +21 -0
- package/vendor/bash/index.js +449 -0
- package/vendor/bash/types/background.d.ts +19 -0
- package/vendor/bash/types/index.d.ts +22 -0
- package/vendor/bash/types/render.d.ts +38 -0
- package/vendor/deepseek/LICENSE +21 -0
- package/vendor/deepseek/index.js +2102 -0
- package/vendor/deepseek/types/adapter.d.ts +163 -0
- package/vendor/deepseek/types/file-id.d.ts +19 -0
- package/vendor/deepseek/types/file-store.d.ts +83 -0
- package/vendor/deepseek/types/files-api.d.ts +103 -0
- package/vendor/deepseek/types/image-tokens.d.ts +19 -0
- package/vendor/deepseek/types/index.d.ts +106 -0
- package/vendor/deepseek/types/request-pricing.d.ts +48 -0
- package/vendor/deepseek/types/serialize.d.ts +85 -0
- package/vendor/deepseek/types/sse.d.ts +24 -0
- package/vendor/deepseek/types/translate.d.ts +37 -0
- package/vendor/deepseek/types/types.d.ts +178 -0
- package/vendor/deepseek/types/upload-index.d.ts +68 -0
- package/vendor/persistent/LICENSE +21 -0
- package/vendor/persistent/index.js +386 -0
- package/vendor/persistent/types/index.d.ts +24 -0
- package/vendor/tui/LICENSE +21 -0
- package/vendor/tui/devtools-CdTl3MNy.mjs +3643 -0
- package/vendor/tui/index.mjs +39105 -0
- package/vendor/tui/invariant.mjs +21 -0
- package/vendor/tui/rolldown-runtime-CMFfr-1z.mjs +26 -0
- package/vendor/tui/startup.mjs +109 -0
- package/vendor/tui/theme-DCT8Y2xf.mjs +628 -0
- package/vendor/tui/types/app.d.ts +304 -0
- package/vendor/tui/types/approval.d.ts +59 -0
- package/vendor/tui/types/attachments.d.ts +52 -0
- package/vendor/tui/types/authorization-panel.d.ts +22 -0
- package/vendor/tui/types/authorization.d.ts +36 -0
- package/vendor/tui/types/commands.d.ts +52 -0
- package/vendor/tui/types/editor-keys.d.ts +105 -0
- package/vendor/tui/types/editor.d.ts +6 -0
- package/vendor/tui/types/fork.d.ts +8 -0
- package/vendor/tui/types/git-workflow.d.ts +32 -0
- package/vendor/tui/types/history.d.ts +97 -0
- package/vendor/tui/types/index.d.ts +124 -0
- package/vendor/tui/types/input-split.d.ts +54 -0
- package/vendor/tui/types/internals.d.ts +26 -0
- package/vendor/tui/types/invariant.d.ts +15 -0
- package/vendor/tui/types/kernel-panels.d.ts +167 -0
- package/vendor/tui/types/keyboard.d.ts +80 -0
- package/vendor/tui/types/mentions.d.ts +81 -0
- package/vendor/tui/types/model-capabilities.d.ts +82 -0
- package/vendor/tui/types/models.d.ts +119 -0
- package/vendor/tui/types/permissions.d.ts +27 -0
- package/vendor/tui/types/plugin-inventory.d.ts +11 -0
- package/vendor/tui/types/presets.d.ts +22 -0
- package/vendor/tui/types/provider-settings.d.ts +239 -0
- package/vendor/tui/types/questions.d.ts +54 -0
- package/vendor/tui/types/render/animations.d.ts +265 -0
- package/vendor/tui/types/render/editor.d.ts +162 -0
- package/vendor/tui/types/render/export.d.ts +9 -0
- package/vendor/tui/types/render/fuzzy.d.ts +21 -0
- package/vendor/tui/types/render/inspector.d.ts +36 -0
- package/vendor/tui/types/render/lines.d.ts +66 -0
- package/vendor/tui/types/render/markdown.d.ts +29 -0
- package/vendor/tui/types/render/projection.d.ts +461 -0
- package/vendor/tui/types/render/status.d.ts +196 -0
- package/vendor/tui/types/render/text.d.ts +58 -0
- package/vendor/tui/types/render/tool-detail.d.ts +94 -0
- package/vendor/tui/types/render/tool-preview.d.ts +28 -0
- package/vendor/tui/types/render/width.d.ts +29 -0
- package/vendor/tui/types/session-directory.d.ts +173 -0
- package/vendor/tui/types/session-switch.d.ts +17 -0
- package/vendor/tui/types/settings-file.d.ts +41 -0
- package/vendor/tui/types/skills.d.ts +47 -0
- package/vendor/tui/types/startup.d.ts +65 -0
- package/vendor/tui/types/store.d.ts +58 -0
- package/vendor/tui/types/subagents.d.ts +70 -0
- package/vendor/tui/types/theme-panel.d.ts +24 -0
- package/vendor/tui/types/theme.d.ts +215 -0
- package/vendor/tui/types/version.d.ts +18 -0
- package/vendor/tui/types/whale-glyph.d.ts +6 -0
|
@@ -0,0 +1,628 @@
|
|
|
1
|
+
import os from "node:os";
|
|
2
|
+
import process 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.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;
|
|
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.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/theme.ts
|
|
407
|
+
/**
|
|
408
|
+
* Terminal color tokens for the dsh TUI, mapped from the product design
|
|
409
|
+
* platform's DeepSeek palette
|
|
410
|
+
* (`packages/client/ui-theme/src/styles/design-platform.css`). Truecolor RGB
|
|
411
|
+
* rides chalk, which degrades automatically on terminals without truecolor.
|
|
412
|
+
*
|
|
413
|
+
* Two palettes — `dark` (the default) and `light` — share the same token keys
|
|
414
|
+
* with different values. Painters and the palette accessor read the ACTIVE
|
|
415
|
+
* palette selected through {@link setTheme}, so a theme switch recolors every
|
|
416
|
+
* painted surface on the next render without touching call sites. Raw token
|
|
417
|
+
* consumers keep reading {@link TUI_RGB} (the dark values) until the
|
|
418
|
+
* theme-aware integration replaces those call sites with
|
|
419
|
+
* `inkColor(getPalette().token)`.
|
|
420
|
+
*
|
|
421
|
+
* @module @deepseek-ai/dsh-tui/theme
|
|
422
|
+
*/
|
|
423
|
+
/** Valid theme names in canonical picker order. */
|
|
424
|
+
const THEME_NAMES = [
|
|
425
|
+
"dark",
|
|
426
|
+
"light",
|
|
427
|
+
"auto"
|
|
428
|
+
];
|
|
429
|
+
/**
|
|
430
|
+
* DeepSeek dark palette: the original TUI colors, one entry per
|
|
431
|
+
* design-platform token in use. Keep names and values in sync with the CSS
|
|
432
|
+
* custom properties cited inline.
|
|
433
|
+
*/
|
|
434
|
+
const DARK_PALETTE = {
|
|
435
|
+
/** Primary brand blue — `--dsw-static-deepseek-500`. */
|
|
436
|
+
brand: [
|
|
437
|
+
65,
|
|
438
|
+
118,
|
|
439
|
+
230
|
|
440
|
+
],
|
|
441
|
+
/** Brighter brand blue for live/streaming emphasis — `--dsw-static-deepseek-400`. */
|
|
442
|
+
brandBright: [
|
|
443
|
+
103,
|
|
444
|
+
158,
|
|
445
|
+
254
|
|
446
|
+
],
|
|
447
|
+
/** Intermediate brand blue between brand and brandBright — `--dsw-static-deepseek-450`. */
|
|
448
|
+
brandMid: [
|
|
449
|
+
86,
|
|
450
|
+
134,
|
|
451
|
+
254
|
|
452
|
+
],
|
|
453
|
+
/** Deep brand blue for secondary chrome — `--dsw-static-deepseek-600`. */
|
|
454
|
+
brandDeep: [
|
|
455
|
+
72,
|
|
456
|
+
104,
|
|
457
|
+
178
|
|
458
|
+
],
|
|
459
|
+
/** Muted caption gray — `--dsw-static-neutral-bluish-600`. */
|
|
460
|
+
dim: [
|
|
461
|
+
129,
|
|
462
|
+
133,
|
|
463
|
+
140
|
|
464
|
+
],
|
|
465
|
+
/** Success green — `--dsw-static-green-500`. */
|
|
466
|
+
success: [
|
|
467
|
+
34,
|
|
468
|
+
197,
|
|
469
|
+
94
|
|
470
|
+
],
|
|
471
|
+
/** Error red — `--dsw-static-red-500`. */
|
|
472
|
+
error: [
|
|
473
|
+
239,
|
|
474
|
+
68,
|
|
475
|
+
68
|
|
476
|
+
],
|
|
477
|
+
/** Warning amber — `--dsw-static-amber-500`. */
|
|
478
|
+
warn: [
|
|
479
|
+
245,
|
|
480
|
+
158,
|
|
481
|
+
11
|
|
482
|
+
],
|
|
483
|
+
/** Default foreground text — `--dsw-static-neutral-50`. */
|
|
484
|
+
text: [
|
|
485
|
+
236,
|
|
486
|
+
240,
|
|
487
|
+
246
|
|
488
|
+
],
|
|
489
|
+
/** Inline/fenced code — soft sky blue, distinct from brand accents. */
|
|
490
|
+
code: [
|
|
491
|
+
125,
|
|
492
|
+
211,
|
|
493
|
+
252
|
|
494
|
+
],
|
|
495
|
+
/** Composer three-row band base — neutral light gray, hue-free so wave tints read on it. */
|
|
496
|
+
composerBand: [
|
|
497
|
+
46,
|
|
498
|
+
48,
|
|
499
|
+
52
|
|
500
|
+
]
|
|
501
|
+
};
|
|
502
|
+
/** Every palette by theme name; auto resolves through {@link resolveTheme}. */
|
|
503
|
+
const PALETTES = {
|
|
504
|
+
dark: DARK_PALETTE,
|
|
505
|
+
light: {
|
|
506
|
+
/** Primary brand blue — unchanged, ≈4.9:1 AA on white. */
|
|
507
|
+
brand: [
|
|
508
|
+
65,
|
|
509
|
+
118,
|
|
510
|
+
230
|
|
511
|
+
],
|
|
512
|
+
/** Brighter brand blue deepened for white backgrounds (was 2.7:1). */
|
|
513
|
+
brandBright: [
|
|
514
|
+
72,
|
|
515
|
+
104,
|
|
516
|
+
178
|
|
517
|
+
],
|
|
518
|
+
/** Intermediate brand blue — Tailwind blue-500. */
|
|
519
|
+
brandMid: [
|
|
520
|
+
59,
|
|
521
|
+
130,
|
|
522
|
+
246
|
|
523
|
+
],
|
|
524
|
+
/** Deep brand blue for secondary chrome — `--dsw-static-deepseek-700`. */
|
|
525
|
+
brandDeep: [
|
|
526
|
+
47,
|
|
527
|
+
76,
|
|
528
|
+
143
|
|
529
|
+
],
|
|
530
|
+
/** Muted caption gray deepened for white backgrounds. */
|
|
531
|
+
dim: [
|
|
532
|
+
101,
|
|
533
|
+
103,
|
|
534
|
+
107
|
|
535
|
+
],
|
|
536
|
+
/** Success green — Tailwind green-700. */
|
|
537
|
+
success: [
|
|
538
|
+
21,
|
|
539
|
+
128,
|
|
540
|
+
61
|
|
541
|
+
],
|
|
542
|
+
/** Error red — Tailwind red-600. */
|
|
543
|
+
error: [
|
|
544
|
+
236,
|
|
545
|
+
19,
|
|
546
|
+
19
|
|
547
|
+
],
|
|
548
|
+
/** Warning amber — Tailwind amber-700. */
|
|
549
|
+
warn: [
|
|
550
|
+
180,
|
|
551
|
+
83,
|
|
552
|
+
9
|
|
553
|
+
],
|
|
554
|
+
/** Default foreground text — near-black. */
|
|
555
|
+
text: [
|
|
556
|
+
21,
|
|
557
|
+
21,
|
|
558
|
+
23
|
|
559
|
+
],
|
|
560
|
+
/** Inline/fenced code — Tailwind cyan-700, distinct from brand accents. */
|
|
561
|
+
code: [
|
|
562
|
+
14,
|
|
563
|
+
116,
|
|
564
|
+
144
|
|
565
|
+
],
|
|
566
|
+
/** Composer three-row band base — neutral light gray, hue-free so wave tints read on it. */
|
|
567
|
+
composerBand: [
|
|
568
|
+
229,
|
|
569
|
+
231,
|
|
570
|
+
235
|
|
571
|
+
]
|
|
572
|
+
}
|
|
573
|
+
};
|
|
574
|
+
/** The theme name in force (the requested name; 'auto' included). */
|
|
575
|
+
let activeName = "dark";
|
|
576
|
+
/** The palette painters and {@link getPalette} read for the active theme. */
|
|
577
|
+
let activePalette = DARK_PALETTE;
|
|
578
|
+
/**
|
|
579
|
+
* Resolve a theme name to the palette actually in use. `auto` detection
|
|
580
|
+
* (OSC 11 terminal background query) is a later enhancement; until it lands,
|
|
581
|
+
* auto falls back to the dark palette.
|
|
582
|
+
* @param name - the requested theme name.
|
|
583
|
+
* @returns 'dark' or 'light' — the palette key to paint with.
|
|
584
|
+
*/
|
|
585
|
+
function resolveTheme(name) {
|
|
586
|
+
return name === "light" ? "light" : "dark";
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* Switch the active theme: painters and {@link getPalette} reflect the new
|
|
590
|
+
* palette from the next render onward. The default is dark, so a process
|
|
591
|
+
* that never calls this paints exactly as before.
|
|
592
|
+
* @param name - the theme to activate ('auto' resolves to dark for now).
|
|
593
|
+
*/
|
|
594
|
+
function setTheme(name) {
|
|
595
|
+
activeName = name;
|
|
596
|
+
activePalette = PALETTES[resolveTheme(name)];
|
|
597
|
+
}
|
|
598
|
+
/**
|
|
599
|
+
* The theme name in force. Returns the requested name ('auto' included) so
|
|
600
|
+
* the /theme picker and persistence can round-trip the user's choice; the
|
|
601
|
+
* palette actually used is {@link getPalette}.
|
|
602
|
+
*/
|
|
603
|
+
function getTheme() {
|
|
604
|
+
return activeName;
|
|
605
|
+
}
|
|
606
|
+
/** The palette in force; theme-aware call sites read colors through it. */
|
|
607
|
+
function getPalette() {
|
|
608
|
+
return activePalette;
|
|
609
|
+
}
|
|
610
|
+
/**
|
|
611
|
+
* Parse a persisted theme name: only 'light' and 'auto' survive; anything
|
|
612
|
+
* else (missing, corrupt, or unknown) falls back to the dark default.
|
|
613
|
+
* @param value - the raw parsed JSON value (expected string).
|
|
614
|
+
* @returns a valid theme name.
|
|
615
|
+
*/
|
|
616
|
+
function parseThemeName(value) {
|
|
617
|
+
return value === "light" || value === "auto" ? value : "dark";
|
|
618
|
+
}
|
|
619
|
+
/** Ink `color` string for one RGB triple. */
|
|
620
|
+
function inkColor(triple) {
|
|
621
|
+
return `rgb(${triple[0]}, ${triple[1]}, ${triple[2]})`;
|
|
622
|
+
}
|
|
623
|
+
/** Paint muted captions, hints, and meta lines. */
|
|
624
|
+
function dim(text) {
|
|
625
|
+
return chalk.rgb(...activePalette.dim)(text);
|
|
626
|
+
}
|
|
627
|
+
//#endregion
|
|
628
|
+
export { inkColor as a, chalk as c, getTheme as i, dim as n, parseThemeName as o, getPalette as r, setTheme as s, THEME_NAMES as t };
|