@surfishs/dsh-prompt-enhance 0.0.7 → 0.0.8
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/README.en.md +3 -0
- package/README.md +3 -0
- package/cordis.patch.yml +1 -1
- package/lib/client.js +341 -383
- package/lib/index.js +67 -56
- package/lib/index.js.map +3 -3
- package/package.json +23 -15
- package/src/client/ActionIcons.tsx +4 -17
- package/src/client/EnhanceButton.tsx +52 -48
- package/src/client/ResultDock.tsx +22 -9
- package/src/client/ResultPanel.tsx +83 -52
- package/src/client/SparkleFishIcon.tsx +3 -13
- package/src/client/SparkleIcon.tsx +2 -12
- package/src/client/UndoBar.tsx +11 -6
- package/src/client/enhance-client.ts +44 -40
- package/src/client/index.tsx +3 -12
- package/src/client/llm-catalog.ts +14 -16
- package/src/client/locales.ts +18 -4
- package/src/client/reasoning-options.ts +7 -15
- package/src/client/settings-page-controls.tsx +449 -0
- package/src/client/settings-page-copy.ts +112 -0
- package/src/client/settings-page-spec.ts +330 -0
- package/src/client/settings-page-styles.ts +161 -0
- package/src/client/settings-page.tsx +113 -1110
- package/src/client/settings-source.ts +41 -31
- package/src/client/settings.ts +17 -12
- package/src/client/shortcut.ts +7 -6
- package/src/client/useDockAlignment.ts +5 -15
- package/src/config.ts +84 -27
- package/src/context.ts +1 -5
- package/src/enhance-routes.ts +8 -8
- package/src/enhancer.ts +43 -34
- package/src/orchestrate.ts +19 -23
- package/src/prompts.ts +4 -4
- package/src/provider-catalog.ts +1 -1
- package/src/reasoning-cache.ts +4 -4
- package/src/reasoning-efforts.ts +4 -9
- package/src/settings-source.ts +37 -23
- package/src/shared/limits.ts +38 -0
- package/src/shared/normalize.ts +4 -1
- package/src/shared/protocol.ts +27 -23
- package/src/shared/reasoning.ts +1 -7
- package/src/shared/stream-text.ts +0 -6
- package/src/shared/validate.ts +3 -9
- package/docs/code-review-2026-09.md +0 -211
- package/docs/handoff-settings-page.md +0 -195
- package/docs/release-0.2.3.md +0 -47
- package/docs/release-0.2.4.md +0 -20
- package/docs/release-0.2.5.md +0 -28
- package/docs/release-0.2.6.md +0 -33
- package/docs/release-0.2.7.md +0 -22
- package/docs/release-0.3.0.md +0 -36
- package/docs/release-0.3.1.md +0 -50
- package/docs/release-0.3.2.md +0 -41
- package/docs/release-0.3.3.md +0 -53
- package/docs/release-0.3.4.md +0 -43
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The settings model both configuration surfaces share: the row table, its
|
|
3
|
+
* schemastery descriptors, the staged form, and the projection types the
|
|
4
|
+
* renderer reads.
|
|
5
|
+
*
|
|
6
|
+
* Split out of `settings-page` so the row table can be edited without opening
|
|
7
|
+
* the rendering code, and so the copy and styles tables can be edited without
|
|
8
|
+
* opening this one.
|
|
9
|
+
* @module dsh-prompt-enhance/client/settings-page-spec
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { SettingsFormModel, settingsNumberField, settingsTextField } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
13
|
+
import type { SettingsFieldDescriptor } from '@deepseek-ai/dsh-client-ui-primitives'
|
|
14
|
+
import { DEFAULT_VALUES } from '../shared/defaults'
|
|
15
|
+
import type { PromptEnhanceKey } from './locales'
|
|
16
|
+
import type { RowCopy, Translate } from './settings-page-copy'
|
|
17
|
+
|
|
18
|
+
/** The settings dialog's navigation slot. */
|
|
19
|
+
export const SETTINGS_SECTION_SLOT = 'settings.section'
|
|
20
|
+
|
|
21
|
+
/** Cell id of the settings-dialog page, and the locale namespace its label uses. */
|
|
22
|
+
export const SETTINGS_SECTION_ID = 'dsh-prompt-enhance'
|
|
23
|
+
|
|
24
|
+
/** Where the page sits among the dialog's sections. */
|
|
25
|
+
export const SETTINGS_SECTION_ORDER = 70
|
|
26
|
+
|
|
27
|
+
/** The settings-dialog row's title, used when no locale service is mounted. */
|
|
28
|
+
export const SETTINGS_SECTION_LABEL = '提示词增强'
|
|
29
|
+
|
|
30
|
+
/** The plugin manager's keyed slot for one row's configuration page. */
|
|
31
|
+
export const SETTINGS_ROW_CONFIG_SLOT = 'plugins.row.config'
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Settings namespace the host half registers. Spelled here rather than
|
|
35
|
+
* imported from `../config`: a client package must not depend on a host
|
|
36
|
+
* package, whose module would drag the schema runtime into the browser
|
|
37
|
+
* bundle.
|
|
38
|
+
*/
|
|
39
|
+
export const SETTINGS_NAMESPACE = 'dsh-prompt-enhance'
|
|
40
|
+
|
|
41
|
+
/** The bundle whose patch declares the row, and that row's id. */
|
|
42
|
+
export const SETTINGS_BUNDLE = '@surfishs/dsh-prompt-enhance'
|
|
43
|
+
export const SETTINGS_ROW_ID = 'dsh-prompt-enhance'
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Key of the Plugins-page entry: the plugin manager keys a row as
|
|
47
|
+
* `<bundle package name>#<row id>`, so this must stay in step with
|
|
48
|
+
* `cordis.patch.yml`'s `id` for the row.
|
|
49
|
+
*/
|
|
50
|
+
export const SETTINGS_ROW_CONFIG_KEY = `${SETTINGS_BUNDLE}#${SETTINGS_ROW_ID}`
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A boolean descriptor: `true`/`false` in text form, and a real boolean back
|
|
54
|
+
* out of `parse`, so a switch writes the JSON type the schema declares.
|
|
55
|
+
* Blank text means "clear", matching the bundled helpers' convention.
|
|
56
|
+
* @param key - the config key the row edits.
|
|
57
|
+
* @returns the descriptor for that key.
|
|
58
|
+
*/
|
|
59
|
+
export function settingsBooleanField(key: string): SettingsFieldDescriptor {
|
|
60
|
+
return {
|
|
61
|
+
field: key,
|
|
62
|
+
format: (value) => (typeof value === 'boolean' ? String(value) : ''),
|
|
63
|
+
parse: (text) => {
|
|
64
|
+
const trimmed = text.trim()
|
|
65
|
+
if (trimmed === '') return { kind: 'clear' }
|
|
66
|
+
if (trimmed === 'true') return { kind: 'set', value: true }
|
|
67
|
+
if (trimmed === 'false') return { kind: 'set', value: false }
|
|
68
|
+
return undefined
|
|
69
|
+
},
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* An enum descriptor over a fixed set of strings. Text outside the set is
|
|
75
|
+
* staged as invalid instead of being written, so a stale stored value cannot
|
|
76
|
+
* be saved back by an accidental edit.
|
|
77
|
+
* @param key - the config key the row edits.
|
|
78
|
+
* @param options - the accepted values, in display order.
|
|
79
|
+
* @returns the descriptor for that key.
|
|
80
|
+
*/
|
|
81
|
+
export function settingsEnumField(key: string, options: readonly string[]): SettingsFieldDescriptor {
|
|
82
|
+
return {
|
|
83
|
+
field: key,
|
|
84
|
+
format: (value) => (typeof value === 'string' ? value : ''),
|
|
85
|
+
parse: (text) => {
|
|
86
|
+
const trimmed = text.trim()
|
|
87
|
+
if (trimmed === '') return { kind: 'clear' }
|
|
88
|
+
return options.includes(trimmed) ? { kind: 'set', value: trimmed } : undefined
|
|
89
|
+
},
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/** Choices of `strategyMode`, by dictionary key. */
|
|
94
|
+
export const STRATEGY_OPTIONS: readonly { value: string; label: PromptEnhanceKey }[] = [
|
|
95
|
+
{ value: 'replace-default', label: 'settings.strategy.replace' },
|
|
96
|
+
{ value: 'extend-default', label: 'settings.strategy.extend' },
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
/** How one row is edited, which picks both its control and its descriptor. */
|
|
100
|
+
export type RowKind = 'text' | 'number' | 'boolean' | 'strategy' | 'reasoning' | 'provider' | 'model'
|
|
101
|
+
|
|
102
|
+
/** One row of both pages, in display order. */
|
|
103
|
+
export interface Row {
|
|
104
|
+
/** The config key; the form reads and writes it by this name. */
|
|
105
|
+
readonly key: string
|
|
106
|
+
/** Which control renders it. */
|
|
107
|
+
readonly kind: RowKind
|
|
108
|
+
/** Dictionary key of the row's name. */
|
|
109
|
+
readonly label: PromptEnhanceKey
|
|
110
|
+
/** Dictionary key of the hint under the row. */
|
|
111
|
+
readonly hint: PromptEnhanceKey
|
|
112
|
+
/**
|
|
113
|
+
* Dictionary key of an example shown greyed out while the input is empty.
|
|
114
|
+
* It teaches the expected format without writing any value into the config.
|
|
115
|
+
*/
|
|
116
|
+
readonly placeholder?: PromptEnhanceKey
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Every row both pages edit, in display order: the master switch and the two
|
|
121
|
+
* display/context switches first, then routing and generation, then the
|
|
122
|
+
* context window, then the host-side resource caps, and the shortcut last.
|
|
123
|
+
*/
|
|
124
|
+
export const BASIC_ROWS: readonly Row[] = [
|
|
125
|
+
{ key: 'enabled', kind: 'boolean', label: 'settings.row.enabled.label', hint: 'settings.row.enabled.hint' },
|
|
126
|
+
{ key: 'provider', kind: 'provider', label: 'settings.row.provider.label', hint: 'settings.row.provider.hint' },
|
|
127
|
+
{ key: 'model', kind: 'model', label: 'settings.row.model.label', hint: 'settings.row.model.hint' },
|
|
128
|
+
{ key: 'reasoningEffort', kind: 'reasoning', label: 'settings.row.reasoningEffort.label', hint: 'settings.row.reasoningEffort.hint' },
|
|
129
|
+
{ key: 'temperature', kind: 'number', label: 'settings.row.temperature.label', hint: 'settings.row.temperature.hint' },
|
|
130
|
+
{ key: 'contextAware', kind: 'boolean', label: 'settings.row.contextAware.label', hint: 'settings.row.contextAware.hint' },
|
|
131
|
+
{ key: 'streaming', kind: 'boolean', label: 'settings.row.streaming.label', hint: 'settings.row.streaming.hint' },
|
|
132
|
+
{ key: 'systemPrompt', kind: 'text', label: 'settings.row.systemPrompt.label', hint: 'settings.row.systemPrompt.hint', placeholder: 'settings.row.systemPrompt.placeholder' },
|
|
133
|
+
{ key: 'shortcut', kind: 'text', label: 'settings.row.shortcut.label', hint: 'settings.row.shortcut.hint', placeholder: 'settings.row.shortcut.placeholder' },
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
/** Tuning and deployment limits, hidden behind the Advanced disclosure by default. */
|
|
137
|
+
export const ADVANCED_ROWS: readonly Row[] = [
|
|
138
|
+
{ key: 'strategyMode', kind: 'strategy', label: 'settings.row.strategyMode.label', hint: 'settings.row.strategyMode.hint' },
|
|
139
|
+
{ key: 'maxInputChars', kind: 'number', label: 'settings.row.maxInputChars.label', hint: 'settings.row.maxInputChars.hint' },
|
|
140
|
+
{ key: 'maxOutputTokens', kind: 'number', label: 'settings.row.maxOutputTokens.label', hint: 'settings.row.maxOutputTokens.hint' },
|
|
141
|
+
{ key: 'timeoutMs', kind: 'number', label: 'settings.row.timeoutMs.label', hint: 'settings.row.timeoutMs.hint' },
|
|
142
|
+
{ key: 'contextMaxMessages', kind: 'number', label: 'settings.row.contextMaxMessages.label', hint: 'settings.row.contextMaxMessages.hint' },
|
|
143
|
+
{ key: 'contextMaxChars', kind: 'number', label: 'settings.row.contextMaxChars.label', hint: 'settings.row.contextMaxChars.hint' },
|
|
144
|
+
{ key: 'maxConcurrent', kind: 'number', label: 'settings.row.maxConcurrent.label', hint: 'settings.row.maxConcurrent.hint' },
|
|
145
|
+
{ key: 'rateLimitPerMinute', kind: 'number', label: 'settings.row.rateLimitPerMinute.label', hint: 'settings.row.rateLimitPerMinute.hint' },
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
/** Every row both pages edit; the renderer splits it at the Advanced boundary. */
|
|
149
|
+
export const ROWS: readonly Row[] = [...BASIC_ROWS, ...ADVANCED_ROWS]
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* The staged form's descriptor for one row.
|
|
153
|
+
* @param row - the row to describe.
|
|
154
|
+
* @returns its field descriptor.
|
|
155
|
+
*/
|
|
156
|
+
export function descriptorOf(row: Row): SettingsFieldDescriptor {
|
|
157
|
+
switch (row.kind) {
|
|
158
|
+
case 'number':
|
|
159
|
+
return settingsNumberField(row.key)
|
|
160
|
+
case 'boolean':
|
|
161
|
+
return settingsBooleanField(row.key)
|
|
162
|
+
case 'strategy':
|
|
163
|
+
return settingsEnumField(
|
|
164
|
+
row.key,
|
|
165
|
+
STRATEGY_OPTIONS.map((option) => option.value),
|
|
166
|
+
)
|
|
167
|
+
case 'reasoning':
|
|
168
|
+
// Effort ids are adapter-owned and discovered at render time, so the
|
|
169
|
+
// descriptor cannot enumerate them; the segmented control is the only
|
|
170
|
+
// writer, and the host validates the id against the route's declaration.
|
|
171
|
+
return settingsTextField(row.key)
|
|
172
|
+
default:
|
|
173
|
+
return settingsTextField(row.key)
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Descriptors in display order; the form model holds one per row. */
|
|
178
|
+
export const FIELD_SPECS: readonly SettingsFieldDescriptor[] = ROWS.map((row) => descriptorOf(row))
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Build the staged form these pages render over one settings scope.
|
|
182
|
+
*
|
|
183
|
+
* Exported so a test can drive the same descriptors the pages use — the
|
|
184
|
+
* boolean and enum rows exist precisely because their staged text must parse
|
|
185
|
+
* back into a JSON boolean and a known enum string, and that contract is worth
|
|
186
|
+
* holding down outside the minified shell.
|
|
187
|
+
* @param scope - the settings scope of the plugin's entry.
|
|
188
|
+
* @returns the staged form over every row.
|
|
189
|
+
*/
|
|
190
|
+
export function createSettingsForm(scope: unknown): SettingsFormModel {
|
|
191
|
+
return new SettingsFormModel(scope, FIELD_SPECS)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/** One projection of the pages' form store. */
|
|
195
|
+
export interface SettingsSnapshot {
|
|
196
|
+
writable?: boolean
|
|
197
|
+
[key: string]: unknown
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** One row's projection inside that snapshot. */
|
|
201
|
+
export interface FieldView {
|
|
202
|
+
text: string
|
|
203
|
+
overridden: boolean
|
|
204
|
+
invalid: boolean
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** The staged form's actions, as both slots hand them over. */
|
|
208
|
+
export interface FormProps {
|
|
209
|
+
/**
|
|
210
|
+
* The store hook, named after the `inject()` hook key (`promptEnhance`).
|
|
211
|
+
* Absent when the host does not project hooks for this slot; the component
|
|
212
|
+
* renders the explanation instead of throwing, because a throwing page
|
|
213
|
+
* blanks the pane.
|
|
214
|
+
*/
|
|
215
|
+
usePromptEnhance?: (selector: (snapshot: SettingsSnapshot) => SettingsSnapshot) => SettingsSnapshot
|
|
216
|
+
edit?: (key: string, text: string) => void
|
|
217
|
+
resetField?: (key: string) => void
|
|
218
|
+
save?: () => void
|
|
219
|
+
discard?: () => void
|
|
220
|
+
writeField?: (key: string, text: string) => Promise<'saved' | 'invalid' | 'failed'>
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** One locale snapshot, as the client locale service exposes it. */
|
|
224
|
+
export interface LocaleSnapshotLike {
|
|
225
|
+
/** Active locale id, e.g. `zh` or `en`. */
|
|
226
|
+
active?: string
|
|
227
|
+
/** Monotonic revision; changes on locale switches and dictionary registration. */
|
|
228
|
+
revision?: number
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** The client locale service, reached structurally so no package type is needed. */
|
|
232
|
+
export interface LocaleFaceLike {
|
|
233
|
+
bind(namespace: string): Translate
|
|
234
|
+
getSnapshot(): LocaleSnapshotLike
|
|
235
|
+
subscribe(listener: () => void): () => void
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Props of the settings-dialog page. */
|
|
239
|
+
export type SectionProps = FormProps & {
|
|
240
|
+
/** The locale-bound translate seat this plugin projects into the page. */
|
|
241
|
+
translate?: Translate
|
|
242
|
+
/** Locale snapshot selector hook; re-renders the page when the language changes. */
|
|
243
|
+
usePromptEnhanceLocale?: (selector: (snapshot: LocaleSnapshotLike) => LocaleSnapshotLike) => LocaleSnapshotLike
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** Props the plugin manager hands a configuration page. */
|
|
247
|
+
export interface PageProps extends FormProps {
|
|
248
|
+
/** Translate seat of this page's locale namespace, injected by the slot. */
|
|
249
|
+
t?: Translate
|
|
250
|
+
/** Which view the manager asks for: the form, or the one-line summary. */
|
|
251
|
+
view?: 'page' | 'summary'
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** Props shared by every row component: the row, its copy, its state, its actions. */
|
|
255
|
+
export interface RowProps {
|
|
256
|
+
/** The DOM id of the row's control. */
|
|
257
|
+
id: string
|
|
258
|
+
/** The row's title, already resolved. */
|
|
259
|
+
label: string
|
|
260
|
+
/** The hint under the row, already resolved. */
|
|
261
|
+
hint: string
|
|
262
|
+
/** The frame's copy, for the overridden badge and its reset button. */
|
|
263
|
+
copy: RowCopy
|
|
264
|
+
/** The row's staged state. */
|
|
265
|
+
view: FieldView
|
|
266
|
+
/** Whether writes are refused by this deployment. */
|
|
267
|
+
disabled: boolean
|
|
268
|
+
/** Stage new text for this row. */
|
|
269
|
+
onEdit: (text: string) => void
|
|
270
|
+
/** Clear the stored value so the row re-inherits the composition default. */
|
|
271
|
+
onReset: () => void
|
|
272
|
+
/** Commit the current text now, e.g. on blur or Enter. */
|
|
273
|
+
onCommit?: () => void
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Read one row's projection out of the page snapshot.
|
|
278
|
+
*
|
|
279
|
+
* A row the host schema does not declare is absent from the projection; it
|
|
280
|
+
* renders as an empty, non-overridden field rather than throwing.
|
|
281
|
+
* @param snapshot - the page's current snapshot.
|
|
282
|
+
* @param key - the row's config key.
|
|
283
|
+
* @returns the row's text form and staging flags.
|
|
284
|
+
*/
|
|
285
|
+
export function viewOf(snapshot: SettingsSnapshot, key: string): FieldView {
|
|
286
|
+
const value = snapshot[key]
|
|
287
|
+
if (value === null || typeof value !== 'object') return { text: '', overridden: false, invalid: false }
|
|
288
|
+
const field = value as { text?: unknown; overridden?: unknown; invalid?: unknown }
|
|
289
|
+
return {
|
|
290
|
+
text: typeof field.text === 'string' ? field.text : '',
|
|
291
|
+
overridden: field.overridden === true,
|
|
292
|
+
invalid: field.invalid === true,
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Whether one row's current text equals its shipped default.
|
|
298
|
+
*
|
|
299
|
+
* The host form reports `overridden` as "this field was written explicitly"
|
|
300
|
+
* (stored value or a staged set), which stays true even when the user edits
|
|
301
|
+
* the value back to the default. The badge and its reset action only make
|
|
302
|
+
* sense while there is something to reset, so visibility is derived from this
|
|
303
|
+
* comparison instead — for text/number/enum rows alike.
|
|
304
|
+
* @param key - the config key.
|
|
305
|
+
* @param text - the row's current staged text.
|
|
306
|
+
* @returns true when editing can no longer change anything from the default.
|
|
307
|
+
*/
|
|
308
|
+
/** The display text a reset row falls back to, from the shared defaults. */
|
|
309
|
+
export function defaultTextOf(key: string): string {
|
|
310
|
+
const descriptor = FIELD_SPECS.find((item) => item.field === key)
|
|
311
|
+
const fallback = (DEFAULT_VALUES as Record<string, unknown>)[key]
|
|
312
|
+
if (descriptor === undefined || fallback === undefined) return ''
|
|
313
|
+
try {
|
|
314
|
+
return descriptor.format(fallback)
|
|
315
|
+
} catch {
|
|
316
|
+
return ''
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export function atDefaultValue(key: string, text: string): boolean {
|
|
321
|
+
const fallback = (DEFAULT_VALUES as Record<string, unknown>)[key]
|
|
322
|
+
// provider/model are absent from the defaults on purpose: empty means follow.
|
|
323
|
+
if (fallback === undefined) return text.trim() === ''
|
|
324
|
+
if (typeof fallback === 'boolean') return text.trim() === String(fallback)
|
|
325
|
+
if (typeof fallback === 'number') {
|
|
326
|
+
const parsed = Number(text.trim())
|
|
327
|
+
return Number.isFinite(parsed) && parsed === fallback
|
|
328
|
+
}
|
|
329
|
+
return text.trim() === String(fallback)
|
|
330
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inline styles and the header constants of the configuration pages.
|
|
3
|
+
*
|
|
4
|
+
* Kept apart from the components on purpose: a visual tweak should not have to
|
|
5
|
+
* open the row table or the renderer, and the values here are pure data.
|
|
6
|
+
* @module dsh-prompt-enhance/client/settings-page-styles
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { CSSProperties } from 'react'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Inline copies of the host form's row metrics (the shell's `181ew` styles
|
|
13
|
+
* module), so a switch or segmented row lines up with the text rows the
|
|
14
|
+
* primitives render instead of looking like a foreign control.
|
|
15
|
+
*/
|
|
16
|
+
export const ROW_STYLE: CSSProperties = { display: 'flex', flexDirection: 'column', gap: 6, padding: '12px 0' }
|
|
17
|
+
export const HEAD_STYLE: CSSProperties = { display: 'flex', alignItems: 'center', gap: 8 }
|
|
18
|
+
export const LABEL_STYLE: CSSProperties = {
|
|
19
|
+
flex: 1,
|
|
20
|
+
minWidth: 0,
|
|
21
|
+
fontSize: 13,
|
|
22
|
+
fontWeight: 500,
|
|
23
|
+
lineHeight: 1.5,
|
|
24
|
+
color: 'var(--dsw-alias-label-primary, inherit)',
|
|
25
|
+
}
|
|
26
|
+
export const HINT_STYLE: CSSProperties = {
|
|
27
|
+
margin: 0,
|
|
28
|
+
fontSize: 12,
|
|
29
|
+
lineHeight: 1.5,
|
|
30
|
+
color: 'var(--dsw-alias-label-tertiary, inherit)',
|
|
31
|
+
}
|
|
32
|
+
/** Dynamic-tier status line under the reasoning control. */
|
|
33
|
+
export const STATUS_STYLE: CSSProperties = {
|
|
34
|
+
margin: 0,
|
|
35
|
+
fontSize: 12,
|
|
36
|
+
lineHeight: 1.5,
|
|
37
|
+
color: 'var(--dsw-alias-label-secondary, inherit)',
|
|
38
|
+
}
|
|
39
|
+
/** The neutral chip surface shared by the row's quiet actions. */
|
|
40
|
+
export const CHIP_STYLE: CSSProperties = {
|
|
41
|
+
display: 'inline-flex',
|
|
42
|
+
alignItems: 'center',
|
|
43
|
+
padding: '1px 8px',
|
|
44
|
+
border: 'none',
|
|
45
|
+
borderRadius: 999,
|
|
46
|
+
background: 'var(--pe-chip-bg, var(--dsw-alias-bg-module-platform, rgba(128, 128, 128, 0.12)))',
|
|
47
|
+
fontFamily: 'inherit',
|
|
48
|
+
fontSize: 11,
|
|
49
|
+
fontWeight: 500,
|
|
50
|
+
lineHeight: '17px',
|
|
51
|
+
color: 'var(--pe-chip-color, var(--dsw-alias-label-secondary, inherit))',
|
|
52
|
+
textDecoration: 'underline',
|
|
53
|
+
textUnderlineOffset: 2,
|
|
54
|
+
cursor: 'pointer',
|
|
55
|
+
}
|
|
56
|
+
/** The tier refetch action, in the same chip surface. */
|
|
57
|
+
export const REFRESH_STYLE: CSSProperties = { ...CHIP_STYLE, flex: 'none' }
|
|
58
|
+
/** The reset action: the neutral chip surface, with an underline for affordance. */
|
|
59
|
+
export const RESET_STYLE: CSSProperties = CHIP_STYLE
|
|
60
|
+
/** One border for every form control, so focus never changes the outline width. */
|
|
61
|
+
export const FIELD_BORDER = '1px solid rgba(128, 128, 128, 0.38)'
|
|
62
|
+
/** The form input, mirroring the host's `input` metrics for a native control. */
|
|
63
|
+
export const INPUT_STYLE: CSSProperties = {
|
|
64
|
+
boxSizing: 'border-box',
|
|
65
|
+
width: '100%',
|
|
66
|
+
height: 34,
|
|
67
|
+
padding: '0 12px',
|
|
68
|
+
border: FIELD_BORDER,
|
|
69
|
+
borderRadius: 'var(--dsw-radius-md, 8px)',
|
|
70
|
+
background: 'var(--dsw-alias-bg-layer-3, transparent)',
|
|
71
|
+
font: 'inherit',
|
|
72
|
+
fontSize: 13,
|
|
73
|
+
lineHeight: 1.5,
|
|
74
|
+
color: 'var(--dsw-alias-label-primary, inherit)',
|
|
75
|
+
outline: 'none',
|
|
76
|
+
}
|
|
77
|
+
/** The error line under an invalid numeric row. */
|
|
78
|
+
export const INVALID_STYLE: CSSProperties = {
|
|
79
|
+
margin: 0,
|
|
80
|
+
fontSize: 12,
|
|
81
|
+
lineHeight: 1.5,
|
|
82
|
+
color: 'var(--dsw-alias-state-error-primary, #f85149)',
|
|
83
|
+
}
|
|
84
|
+
/** The warning line under the routing rows; saves are not blocked by it. */
|
|
85
|
+
export const WARN_STYLE: CSSProperties = {
|
|
86
|
+
margin: 0,
|
|
87
|
+
fontSize: 12,
|
|
88
|
+
lineHeight: 1.5,
|
|
89
|
+
color: 'var(--dsw-alias-state-error-primary, #f85149)',
|
|
90
|
+
}
|
|
91
|
+
/** The provider/model select, sharing the value input's metrics. */
|
|
92
|
+
export const SELECT_STYLE: CSSProperties = {
|
|
93
|
+
...INPUT_STYLE,
|
|
94
|
+
cursor: 'pointer',
|
|
95
|
+
}
|
|
96
|
+
export const SEPARATOR_STYLE: CSSProperties = {
|
|
97
|
+
borderTop: '0.5px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.24))',
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Public repository behind this build, linked from the page header. */
|
|
101
|
+
export const REPOSITORY_URL = 'https://github.com/surfishs/dsh-prompt-enhance'
|
|
102
|
+
|
|
103
|
+
/** Public npm package page, linked from the page header next to the repository. */
|
|
104
|
+
export const NPM_URL = 'https://www.npmjs.com/package/@surfishs/dsh-prompt-enhance'
|
|
105
|
+
|
|
106
|
+
/** The GitHub mark (16×16), painted with the current text color. */
|
|
107
|
+
export const GITHUB_MARK =
|
|
108
|
+
'M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82a7.6 7.6 0 0 1 2-.27c.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0 0 16 8c0-4.42-3.58-8-8-8z'
|
|
109
|
+
|
|
110
|
+
/** The npm mark (24×24), painted with the current text color. */
|
|
111
|
+
export const NPM_MARK =
|
|
112
|
+
'M1.763 0C.786 0 0 .786 0 1.763v20.474C0 23.214.786 24 1.763 24h20.474c.977 0 1.763-.786 1.763-1.763V1.763C24 .786 23.214 0 22.237 0zM5.13 5.323l13.837.019-.009 13.836h-3.464l.01-10.382h-3.456L12.04 19.17H5.113z'
|
|
113
|
+
|
|
114
|
+
/** The version this bundle was built from; guarded for environments without the define. */
|
|
115
|
+
export const PLUGIN_VERSION = typeof __PLUGIN_VERSION__ === 'string' ? __PLUGIN_VERSION__ : '0.0.0'
|
|
116
|
+
|
|
117
|
+
/** Header block: title, repository link, version, and one description line. */
|
|
118
|
+
export const HEADER_STYLE: CSSProperties = { display: 'flex', flexDirection: 'column', gap: 12, padding: '2px 0' }
|
|
119
|
+
export const HEADER_ROW_STYLE: CSSProperties = { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' }
|
|
120
|
+
export const HEADER_TITLE_STYLE: CSSProperties = {
|
|
121
|
+
fontSize: 18,
|
|
122
|
+
fontWeight: 600,
|
|
123
|
+
letterSpacing: '-0.012em',
|
|
124
|
+
lineHeight: 1.3,
|
|
125
|
+
color: 'var(--dsw-alias-label-primary, inherit)',
|
|
126
|
+
}
|
|
127
|
+
export const HEADER_LINK_STYLE: CSSProperties = {
|
|
128
|
+
display: 'inline-flex',
|
|
129
|
+
alignItems: 'center',
|
|
130
|
+
gap: 3,
|
|
131
|
+
height: 18,
|
|
132
|
+
padding: '0 7px',
|
|
133
|
+
border: '1px solid var(--dsw-alias-border-l4, rgba(128, 128, 128, 0.35))',
|
|
134
|
+
borderRadius: 999,
|
|
135
|
+
background: 'var(--dsw-alias-bg-layer-3, transparent)',
|
|
136
|
+
fontSize: 10.5,
|
|
137
|
+
fontWeight: 500,
|
|
138
|
+
lineHeight: 1,
|
|
139
|
+
color: 'var(--dsw-alias-label-secondary, inherit)',
|
|
140
|
+
textDecoration: 'none',
|
|
141
|
+
}
|
|
142
|
+
export const HEADER_VERSION_STYLE: CSSProperties = {
|
|
143
|
+
display: 'inline-flex',
|
|
144
|
+
alignItems: 'center',
|
|
145
|
+
height: 18,
|
|
146
|
+
padding: '0 7px',
|
|
147
|
+
borderRadius: 999,
|
|
148
|
+
background: 'var(--dsw-alias-bg-layer-4, transparent)',
|
|
149
|
+
fontSize: 10.5,
|
|
150
|
+
lineHeight: 1,
|
|
151
|
+
color: 'var(--dsw-alias-label-tertiary, inherit)',
|
|
152
|
+
fontVariantNumeric: 'tabular-nums',
|
|
153
|
+
}
|
|
154
|
+
export const HEADER_DESCRIPTION_STYLE: CSSProperties = {
|
|
155
|
+
margin: 0,
|
|
156
|
+
fontSize: 13,
|
|
157
|
+
lineHeight: 1.65,
|
|
158
|
+
color: 'var(--dsw-alias-label-tertiary, inherit)',
|
|
159
|
+
textWrap: 'pretty',
|
|
160
|
+
maxWidth: '72ch',
|
|
161
|
+
}
|