@toddzheng024/dscode-bundle 0.7.11 → 0.7.13

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 (154) hide show
  1. package/THIRD_PARTY_NOTICES.md +3 -3
  2. package/cordis.patch.yml +1 -1
  3. package/package.json +5 -4
  4. package/plugins/i18n/messages.mjs +6 -6
  5. package/plugins/session-metrics/view.mjs +16 -5
  6. package/plugins/tui-tools/index.mjs +14 -1
  7. package/vendor/tui/lib/app.mjs +6674 -0
  8. package/vendor/tui/lib/approval.mjs +122 -0
  9. package/vendor/tui/lib/attachments.mjs +218 -0
  10. package/vendor/tui/lib/authorization-panel.mjs +242 -0
  11. package/vendor/tui/lib/authorization.mjs +111 -0
  12. package/vendor/tui/lib/commands.mjs +123 -0
  13. package/vendor/tui/lib/dscode/chat.mjs +64 -0
  14. package/vendor/tui/lib/dscode/flags.mjs +32 -0
  15. package/vendor/tui/lib/dscode/model-search.mjs +68 -0
  16. package/vendor/tui/lib/dscode/paste.mjs +87 -0
  17. package/vendor/tui/lib/dscode/telemetry.mjs +82 -0
  18. package/vendor/tui/lib/dscode/welcome.mjs +100 -0
  19. package/vendor/tui/lib/editor-keys.mjs +346 -0
  20. package/vendor/tui/lib/editor.mjs +50 -0
  21. package/vendor/tui/lib/fork.mjs +24 -0
  22. package/vendor/tui/lib/git-workflow.mjs +278 -0
  23. package/vendor/tui/{types/history.d.ts → lib/history.mjs} +69 -26
  24. package/vendor/tui/{types/i18n.d.ts → lib/i18n.mjs} +23 -15
  25. package/vendor/tui/lib/index.mjs +2198 -0
  26. package/vendor/tui/lib/input-split.mjs +170 -0
  27. package/vendor/tui/lib/internals.mjs +90 -0
  28. package/vendor/tui/lib/invariant.mjs +22 -0
  29. package/vendor/tui/lib/kernel-panels.mjs +1265 -0
  30. package/vendor/tui/lib/keyboard.mjs +283 -0
  31. package/vendor/tui/lib/language-panel.mjs +41 -0
  32. package/vendor/tui/lib/locales/en.mjs +495 -0
  33. package/vendor/tui/lib/locales/zh.mjs +495 -0
  34. package/vendor/tui/lib/mentions.mjs +150 -0
  35. package/vendor/tui/lib/model-capabilities.mjs +245 -0
  36. package/vendor/tui/lib/models.mjs +215 -0
  37. package/vendor/tui/{types/panel-accent.d.ts → lib/panel-accent.mjs} +11 -7
  38. package/vendor/tui/lib/permissions.mjs +45 -0
  39. package/vendor/tui/lib/plugin-inventory.mjs +27 -0
  40. package/vendor/tui/lib/presets.mjs +46 -0
  41. package/vendor/tui/lib/provider-settings.mjs +600 -0
  42. package/vendor/tui/lib/questions.mjs +116 -0
  43. package/vendor/tui/lib/rainbow.mjs +181 -0
  44. package/vendor/tui/lib/render/animations.mjs +665 -0
  45. package/vendor/tui/lib/render/editor.mjs +437 -0
  46. package/vendor/tui/lib/render/export.mjs +119 -0
  47. package/vendor/tui/lib/render/fuzzy.mjs +79 -0
  48. package/vendor/tui/lib/render/ime-cursor.mjs +135 -0
  49. package/vendor/tui/lib/render/inspector.mjs +93 -0
  50. package/vendor/tui/lib/render/lines.mjs +538 -0
  51. package/vendor/tui/lib/render/markdown.mjs +592 -0
  52. package/vendor/tui/lib/render/projection.mjs +1862 -0
  53. package/vendor/tui/lib/render/status.mjs +591 -0
  54. package/vendor/tui/lib/render/text.mjs +157 -0
  55. package/vendor/tui/lib/render/tool-detail.mjs +187 -0
  56. package/vendor/tui/lib/render/tool-preview.mjs +79 -0
  57. package/vendor/tui/lib/render/usage.mjs +336 -0
  58. package/vendor/tui/lib/render/width.mjs +191 -0
  59. package/vendor/tui/lib/session-directory.mjs +329 -0
  60. package/vendor/tui/lib/session-query.mjs +184 -0
  61. package/vendor/tui/lib/session-switch.mjs +51 -0
  62. package/vendor/tui/lib/settings-file.mjs +75 -0
  63. package/vendor/tui/lib/skills.mjs +119 -0
  64. package/vendor/tui/lib/startup.mjs +111 -0
  65. package/vendor/tui/lib/store.mjs +129 -0
  66. package/vendor/tui/lib/subagents.mjs +200 -0
  67. package/vendor/tui/lib/terminal-title.mjs +186 -0
  68. package/vendor/tui/lib/theme-panel.mjs +60 -0
  69. package/vendor/tui/lib/theme.mjs +379 -0
  70. package/vendor/tui/lib/update-panel.mjs +239 -0
  71. package/vendor/tui/lib/update.mjs +101 -0
  72. package/vendor/tui/lib/version.mjs +105 -0
  73. package/vendor/tui/lib/whale-glyph.mjs +20 -0
  74. package/vendor/tui/LICENSE +0 -21
  75. package/vendor/tui/devtools-CdTl3MNy.mjs +0 -3643
  76. package/vendor/tui/dscode-email/cli.mjs +0 -32
  77. package/vendor/tui/dscode-email/contacts.mjs +0 -36
  78. package/vendor/tui/dscode-email/gmail-oauth.mjs +0 -69
  79. package/vendor/tui/dscode-email/gmail-store.mjs +0 -2
  80. package/vendor/tui/dscode-email/gmail.mjs +0 -194
  81. package/vendor/tui/dscode-email/imap.mjs +0 -136
  82. package/vendor/tui/dscode-email/inbox.d.mts +0 -25
  83. package/vendor/tui/dscode-email/inbox.mjs +0 -76
  84. package/vendor/tui/dscode-email/smtp.mjs +0 -69
  85. package/vendor/tui/dscode-email/store.mjs +0 -32
  86. package/vendor/tui/dscode-providers/catalog.mjs +0 -136
  87. package/vendor/tui/dscode-providers/effort.mjs +0 -35
  88. package/vendor/tui/dscode-providers/openrouter-account.mjs +0 -171
  89. package/vendor/tui/index.mjs +0 -44483
  90. package/vendor/tui/invariant.mjs +0 -21
  91. package/vendor/tui/rolldown-runtime-CMFfr-1z.mjs +0 -26
  92. package/vendor/tui/session-query.mjs +0 -150
  93. package/vendor/tui/startup.mjs +0 -109
  94. package/vendor/tui/theme-7u5Qo3dF.mjs +0 -1265
  95. package/vendor/tui/types/app.d.ts +0 -348
  96. package/vendor/tui/types/approval.d.ts +0 -59
  97. package/vendor/tui/types/attachments.d.ts +0 -52
  98. package/vendor/tui/types/authorization-panel.d.ts +0 -22
  99. package/vendor/tui/types/authorization.d.ts +0 -36
  100. package/vendor/tui/types/commands.d.ts +0 -52
  101. package/vendor/tui/types/editor-keys.d.ts +0 -105
  102. package/vendor/tui/types/editor.d.ts +0 -6
  103. package/vendor/tui/types/fork.d.ts +0 -8
  104. package/vendor/tui/types/git-workflow.d.ts +0 -121
  105. package/vendor/tui/types/index.d.ts +0 -223
  106. package/vendor/tui/types/input-split.d.ts +0 -54
  107. package/vendor/tui/types/internals.d.ts +0 -26
  108. package/vendor/tui/types/invariant.d.ts +0 -15
  109. package/vendor/tui/types/kernel-panels.d.ts +0 -245
  110. package/vendor/tui/types/keyboard.d.ts +0 -80
  111. package/vendor/tui/types/language-panel.d.ts +0 -12
  112. package/vendor/tui/types/locales/en.d.ts +0 -450
  113. package/vendor/tui/types/locales/zh.d.ts +0 -9
  114. package/vendor/tui/types/mentions.d.ts +0 -85
  115. package/vendor/tui/types/model-capabilities.d.ts +0 -82
  116. package/vendor/tui/types/models.d.ts +0 -133
  117. package/vendor/tui/types/permissions.d.ts +0 -27
  118. package/vendor/tui/types/plugin-inventory.d.ts +0 -11
  119. package/vendor/tui/types/presets.d.ts +0 -22
  120. package/vendor/tui/types/provider-settings.d.ts +0 -239
  121. package/vendor/tui/types/questions.d.ts +0 -54
  122. package/vendor/tui/types/rainbow.d.ts +0 -69
  123. package/vendor/tui/types/render/animations.d.ts +0 -307
  124. package/vendor/tui/types/render/editor.d.ts +0 -163
  125. package/vendor/tui/types/render/export.d.ts +0 -9
  126. package/vendor/tui/types/render/fuzzy.d.ts +0 -21
  127. package/vendor/tui/types/render/ime-cursor.d.ts +0 -60
  128. package/vendor/tui/types/render/inspector.d.ts +0 -62
  129. package/vendor/tui/types/render/lines.d.ts +0 -86
  130. package/vendor/tui/types/render/markdown.d.ts +0 -29
  131. package/vendor/tui/types/render/projection.d.ts +0 -587
  132. package/vendor/tui/types/render/status.d.ts +0 -196
  133. package/vendor/tui/types/render/text.d.ts +0 -64
  134. package/vendor/tui/types/render/tool-detail.d.ts +0 -94
  135. package/vendor/tui/types/render/tool-preview.d.ts +0 -28
  136. package/vendor/tui/types/render/usage.d.ts +0 -113
  137. package/vendor/tui/types/render/width.d.ts +0 -29
  138. package/vendor/tui/types/session-directory.d.ts +0 -190
  139. package/vendor/tui/types/session-query.d.ts +0 -92
  140. package/vendor/tui/types/session-switch.d.ts +0 -17
  141. package/vendor/tui/types/settings-file.d.ts +0 -41
  142. package/vendor/tui/types/skills.d.ts +0 -47
  143. package/vendor/tui/types/startup.d.ts +0 -65
  144. package/vendor/tui/types/store.d.ts +0 -58
  145. package/vendor/tui/types/subagents.d.ts +0 -70
  146. package/vendor/tui/types/terminal-title.d.ts +0 -66
  147. package/vendor/tui/types/theme-panel.d.ts +0 -24
  148. package/vendor/tui/types/theme.d.ts +0 -434
  149. package/vendor/tui/types/update-panel.d.ts +0 -49
  150. package/vendor/tui/types/update.d.ts +0 -75
  151. package/vendor/tui/types/version.d.ts +0 -19
  152. package/vendor/tui/types/whale-glyph.d.ts +0 -6
  153. /package/vendor/tui/{dscode-clipboard-image → lib/dscode/clipboard-image}/clipboard-image.swift +0 -0
  154. /package/vendor/tui/{dscode-clipboard-image → lib/dscode/clipboard-image}/index.mjs +0 -0
@@ -0,0 +1,116 @@
1
+ /**
2
+ * The terminal ask_user_question answerer: one `user-questions/request`
3
+ * waterfall listener that drives a FIFO queue — one question request on
4
+ * screen at a time, everything else waiting — then resolves the collected
5
+ * answers back into the waterfall. Mirrors the approval answerer's claim/
6
+ * defer split: only agents this TUI owns are answered, every other request
7
+ * falls through to the next answerer.
8
+ *
9
+ * Plan reviews (`exit_plan_mode`) arrive through the same waterfall with an
10
+ * `intent: { kind: 'plan-review' }` — the renderer highlights the approve
11
+ * option; the answer encoding is identical either way.
12
+ *
13
+ * @module @deepseek-ai/dsh-code/questions
14
+ */
15
+ import { UserQuestionError, } from '@deepseek-ai/dsh-user-questions';
16
+ const ABORT_ERROR = new UserQuestionError('ask_user_question was interrupted before the user answered', 'ASK_ABORTED');
17
+ /**
18
+ * Mount the `user-questions/request` answerer over a FIFO queue.
19
+ * @param ctx - plugin context whose event bus carries the waterfall.
20
+ * @param owns - agents this terminal answers for; every other request is
21
+ * deferred back into the waterfall (`next()`), so sibling answerers stay
22
+ * usable. Agent-less asks are claimed: this TUI is the only human surface
23
+ * in the process.
24
+ * @returns the store the renderer subscribes to.
25
+ */
26
+ export function mountQuestionProvider(ctx, owns) {
27
+ let snapshot = { pending: undefined };
28
+ let active;
29
+ const queue = [];
30
+ const listeners = new Set();
31
+ const set = (next) => {
32
+ snapshot = next;
33
+ for (const listener of listeners)
34
+ listener();
35
+ };
36
+ /** Settle the active request and show the next queued one, if any. */
37
+ const advance = () => {
38
+ const next = queue.shift();
39
+ active = next;
40
+ set({ pending: next });
41
+ };
42
+ ctx.on('user-questions/request', (request, next) => {
43
+ if (request.agent !== undefined && !owns(request.agent))
44
+ return next();
45
+ return new Promise((resolve, reject) => {
46
+ // Abort settles through the same channel as an Esc cancel: the
47
+ // owning tool/step died, so the answer must not linger.
48
+ const onAbort = () => {
49
+ if (active === pending) {
50
+ active = undefined;
51
+ set({ pending: undefined });
52
+ advance();
53
+ }
54
+ else {
55
+ const at = queue.indexOf(pending);
56
+ if (at >= 0)
57
+ queue.splice(at, 1);
58
+ }
59
+ reject(ABORT_ERROR);
60
+ };
61
+ // Detach on every settle so an answered/cancelled question never
62
+ // retains a listener on the owning tool call's signal.
63
+ const detachAbort = () => {
64
+ if (request.signal !== undefined)
65
+ request.signal.removeEventListener('abort', onAbort);
66
+ };
67
+ const pending = {
68
+ request,
69
+ resolve,
70
+ reject,
71
+ detachAbort,
72
+ };
73
+ if (request.signal?.aborted === true) {
74
+ reject(ABORT_ERROR);
75
+ return;
76
+ }
77
+ request.signal?.addEventListener('abort', onAbort, { once: true });
78
+ if (active === undefined) {
79
+ active = pending;
80
+ set({ pending });
81
+ }
82
+ else {
83
+ queue.push(pending);
84
+ }
85
+ });
86
+ });
87
+ return {
88
+ subscribe(listener) {
89
+ listeners.add(listener);
90
+ return () => {
91
+ listeners.delete(listener);
92
+ };
93
+ },
94
+ getSnapshot() {
95
+ return snapshot;
96
+ },
97
+ submit(pending, answers) {
98
+ if (active !== pending)
99
+ return;
100
+ active = undefined;
101
+ set({ pending: undefined });
102
+ pending.detachAbort?.();
103
+ pending.resolve(answers);
104
+ advance();
105
+ },
106
+ cancel(pending) {
107
+ if (active !== pending)
108
+ return;
109
+ active = undefined;
110
+ set({ pending: undefined });
111
+ pending.detachAbort?.();
112
+ pending.reject(ABORT_ERROR);
113
+ advance();
114
+ },
115
+ };
116
+ }
@@ -0,0 +1,181 @@
1
+ /**
2
+ * The rainbow theme's per-launch roll: a seeded shuffle over a twelve-color
3
+ * bright-tier spectrum that fills every palette role, the status-bar tone map
4
+ * (adjacent tones in canonical on-screen order never share a color, the
5
+ * row1/row2 boundary included), the panel accent ring, and full-spectrum
6
+ * flow anchors with a random phase. The roll happens once per launch and
7
+ * stays stable for the whole run; setting RAINBOW_SEED=<uint32> pins it for
8
+ * reproduction (the /theme notification prints the seed of the current roll).
9
+ *
10
+ * All pool colors clear AA body text (≥4.5:1) on a black terminal by a wide
11
+ * margin (11-17:1); diff rows pair a bright hue with its own 22% dark tint
12
+ * so the foreground stays 7.7-10.2:1 on its background.
13
+ *
14
+ * @module @deepseek-ai/dsh-tui/rainbow
15
+ */
16
+ /**
17
+ * The bright-tier spectrum: twelve Tailwind *-300 hues covering red through
18
+ * fuchsia, every one ≥11:1 on black. The roll samples this pool by shuffle;
19
+ * nothing outside it is ever painted.
20
+ */
21
+ export const RAINBOW_POOL = [
22
+ [252, 165, 165],
23
+ [253, 186, 116],
24
+ [253, 230, 138],
25
+ [253, 224, 71],
26
+ [190, 242, 100],
27
+ [134, 239, 172],
28
+ [94, 234, 212],
29
+ [103, 232, 249],
30
+ [125, 211, 252],
31
+ [147, 197, 253],
32
+ [196, 181, 253],
33
+ [240, 171, 252],
34
+ ];
35
+ /**
36
+ * Status tones in canonical on-screen order (row one left-to-right, then row
37
+ * two): consecutive entries here are the pairs the "adjacent spans differ"
38
+ * guarantee covers, including the accent→value step across the row boundary.
39
+ */
40
+ const TONE_ORDER = [
41
+ 'live', 'model', 'path', 'branch', 'accent',
42
+ 'value', 'label', 'meta', 'ctxFill', 'success', 'plan', 'warn', 'error',
43
+ ];
44
+ /** Parse a RAINBOW_SEED value: a non-negative decimal uint32, else nothing. */
45
+ export function parseRainbowSeed(value) {
46
+ if (value === undefined || !/^\d{1,10}$/.test(value.trim()))
47
+ return undefined;
48
+ const parsed = Number(value.trim());
49
+ return Number.isSafeInteger(parsed) ? parsed >>> 0 : undefined;
50
+ }
51
+ /**
52
+ * One parsed `/rainbow` argument: empty means a fresh random roll; a
53
+ * decimal uint32 pins that seed; anything else is a usage error.
54
+ * @param argument - the raw text after `/rainbow`.
55
+ * @returns `{ seed }`, `'random'`, or `'usage'`.
56
+ */
57
+ export function parseRainbowArgument(argument) {
58
+ const trimmed = argument.trim();
59
+ if (trimmed === '')
60
+ return 'random';
61
+ const parsed = parseRainbowSeed(trimmed);
62
+ return parsed === undefined ? 'usage' : { seed: parsed };
63
+ }
64
+ /** Deterministic 32-bit RNG (mulberry32) — one roll, one stream. */
65
+ function mulberry32(seed) {
66
+ let state = seed >>> 0;
67
+ return () => {
68
+ state = (state + 0x6d2b79f5) | 0;
69
+ let t = Math.imul(state ^ (state >>> 15), 1 | state);
70
+ t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
71
+ return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
72
+ };
73
+ }
74
+ /** Fisher–Yates shuffle over a copy, driven by the roll's RNG. */
75
+ function shuffle(items, rng) {
76
+ const out = [...items];
77
+ for (let i = out.length - 1; i > 0; i -= 1) {
78
+ const j = Math.floor(rng() * (i + 1));
79
+ [out[i], out[j]] = [out[j], out[i]];
80
+ }
81
+ return out;
82
+ }
83
+ /** Approximate HSL hue of one RGB triple, degrees in [0, 360). */
84
+ function hueOf([r, g, b]) {
85
+ const max = Math.max(r, g, b);
86
+ const min = Math.min(r, g, b);
87
+ if (max === min)
88
+ return 0;
89
+ const span = max - min;
90
+ if (max === r)
91
+ return (60 * (g - b) / span + 360) % 360;
92
+ if (max === g)
93
+ return (60 * (b - r) / span + 120) % 360;
94
+ return (60 * (r - g) / span + 240) % 360;
95
+ }
96
+ /** A dark row tint for diff backgrounds: the hue at 22% strength over black. */
97
+ function darkTint(hue) {
98
+ return [Math.round(hue[0] * 0.22), Math.round(hue[1] * 0.22), Math.round(hue[2] * 0.22)];
99
+ }
100
+ /** Readability anchors shared by every roll: captions, text, band stay calm. */
101
+ const DIM = [166, 163, 184];
102
+ const TEXT = [240, 238, 249];
103
+ const BAND = [46, 46, 52];
104
+ /**
105
+ * Build the roll for one seed: pure and deterministic, so tests pin exact
106
+ * outcomes and RAINBOW_SEED reproduces a lucky launch exactly.
107
+ * @param seed - the uint32 seed to roll from.
108
+ * @returns the complete carnival roll.
109
+ */
110
+ export function rollRainbow(seed) {
111
+ const rng = mulberry32(seed);
112
+ const pool = shuffle(RAINBOW_POOL, rng);
113
+ const [brand, brandBright, brandMid, brandDeep, code, success, error, warn, addHue, delHue] = pool;
114
+ const palette = {
115
+ brand: brand,
116
+ brandBright: brandBright,
117
+ brandMid: brandMid,
118
+ brandDeep: brandDeep,
119
+ dim: DIM,
120
+ success: success,
121
+ error: error,
122
+ warn: warn,
123
+ text: TEXT,
124
+ code: code,
125
+ composerBand: BAND,
126
+ diffAdd: darkTint(addHue),
127
+ diffDel: darkTint(delHue),
128
+ diffAddFg: addHue,
129
+ diffDelFg: delHue,
130
+ // Prompt-row bars ride the roll's own colors: the bright brand hue for an
131
+ // ordinary prompt, the rolled warning hue for a queued one, and the rolled
132
+ // code hue for a steered one. Each bar is that color over the surface.
133
+ surface: [0, 0, 0],
134
+ prompt: brandBright,
135
+ queued: warn,
136
+ steered: code,
137
+ };
138
+ const ring = shuffle(RAINBOW_POOL, rng).slice(0, 4);
139
+ // Adjacency by construction: consecutive tones take consecutive slots of a
140
+ // 12-distinct shuffle, so neighbors can never match (13 tones wrap the
141
+ // first color onto 'error', which is never adjacent to 'live' on screen).
142
+ const offset = Math.floor(rng() * RAINBOW_POOL.length);
143
+ const toneColors = {};
144
+ TONE_ORDER.forEach((tone, index) => {
145
+ toneColors[tone] = pool[(offset + index) % pool.length];
146
+ });
147
+ const flowAnchors = [...RAINBOW_POOL].sort((a, b) => hueOf(a) - hueOf(b));
148
+ const flowPhaseMs = Math.floor(rng() * 2400);
149
+ return { seed, palette, ring, toneColors, flowAnchors, flowPhaseMs };
150
+ }
151
+ /** The launch seed: RAINBOW_SEED when parseable, else a fresh random roll. */
152
+ function launchSeed() {
153
+ const pinned = parseRainbowSeed(process.env.RAINBOW_SEED);
154
+ if (pinned !== undefined)
155
+ return pinned;
156
+ return (Date.now() ^ Math.floor(Math.random() * 0x100000000)) >>> 0;
157
+ }
158
+ let rolled;
159
+ /** The memoized per-launch roll; computed once, stable for the whole run. */
160
+ export function rainbowRoll() {
161
+ if (rolled === undefined)
162
+ rolled = rollRainbow(launchSeed());
163
+ return rolled;
164
+ }
165
+ /**
166
+ * Replace the memoized roll: omit the seed for a fresh random one, or pass
167
+ * a uint32 to pin it. `/rainbow` uses this so a mid-session reroll actually
168
+ * recolors; {@link setTheme}(`'rainbow'`) must run afterwards so the
169
+ * palette accessor picks the new values up.
170
+ * @param seed - the seed to pin, or undefined for a new random roll.
171
+ * @returns the roll now in force.
172
+ */
173
+ export function rerollRainbow(seed) {
174
+ const next = seed ?? ((Date.now() ^ Math.floor(Math.random() * 0x100000000)) >>> 0);
175
+ rolled = rollRainbow(next);
176
+ return rolled;
177
+ }
178
+ /** The current roll's seed as display copy (also the RAINBOW_SEED value). */
179
+ export function rainbowSeedLabel() {
180
+ return String(rainbowRoll().seed);
181
+ }