@infinity_cheng/dsh-prompt-editor 0.3.2 → 0.5.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/index.js CHANGED
@@ -11,12 +11,49 @@ export const inject = ['tools', 'llm', 'agentDefaultModel', 'fs', 'connection']
11
11
 
12
12
  /** User-editable defaults. */
13
13
  export const Config = Schema.object({
14
- defaultMode: Schema.union(MODE_IDS).default('intent-first'),
14
+ // Volatile: the settings service may update it in place; an ordinary field
15
+ // would force a plugin restart on every save.
16
+ defaultMode: Schema.union(MODE_IDS).default('intent-first').extra('volatile', true),
17
+ useCustomModel: Schema.boolean().default(false).extra('volatile', true),
18
+ enhanceProvider: Schema.string().default('').extra('volatile', true),
19
+ enhanceModel: Schema.string().default('').extra('volatile', true),
15
20
  maxDraftChars: Schema.number().default(20000),
16
21
  maxContextChars: Schema.number().default(4000),
17
22
  llmTimeoutMs: Schema.number().default(120000),
18
23
  maxLengthRatio: Schema.number().default(5.5),
19
24
  maxPromptChars: Schema.number().default(3000),
25
+ /**
26
+ * Optional per-model overrides, keyed by `provider/model`. Ordinary config:
27
+ * edit the profile patch and restart; settings-page preferences stay volatile.
28
+ */
29
+ modelProfiles: Schema.dict(Schema.object({
30
+ temperature: Schema.number().default(0.2),
31
+ maxTokens: Schema.number().default(0),
32
+ maxLengthRatio: Schema.number().default(4),
33
+ maxPromptChars: Schema.number().default(1800),
34
+ promptVariant: Schema.string().default('auto'),
35
+ retryOnLength: Schema.boolean().default(true),
36
+ reasoningEffort: Schema.string().default(''),
37
+ })).default({}),
38
+ })
39
+
40
+ /**
41
+ * A shipped profile for the Pro route. It is deliberately conservative: the
42
+ * normal intent-first prompt over-expands on this model, so use the concise
43
+ * variant and retry once if the result is still too long.
44
+ */
45
+ const BUILTIN_MODEL_PROFILES = Object.freeze({
46
+ 'deepseek-official/deepseek-v4-pro': Object.freeze({
47
+ temperature: 0.12,
48
+ // 0 means "use the provider default": Pro spends part of this budget on
49
+ // reasoning, so a small cap can end the stream before any text arrives.
50
+ maxTokens: 0,
51
+ maxLengthRatio: 4,
52
+ maxPromptChars: 1800,
53
+ promptVariant: 'auto',
54
+ retryOnLength: true,
55
+ reasoningEffort: '',
56
+ }),
20
57
  })
21
58
 
22
59
  /**
@@ -25,7 +62,11 @@ export const Config = Schema.object({
25
62
  * @param {{ defaultMode: string, maxDraftChars: number, maxContextChars: number, llmTimeoutMs: number, maxLengthRatio: number }} config
26
63
  */
27
64
  export function apply(ctx, config) {
28
- if (!MODE_IDS.includes(config.defaultMode)) {
65
+ const initialMode = config.defaultMode !== null && typeof config.defaultMode === 'object'
66
+ && typeof config.defaultMode.get === 'function'
67
+ ? config.defaultMode.get()
68
+ : config.defaultMode
69
+ if (!MODE_IDS.includes(initialMode)) {
29
70
  throw new Error(`defaultMode must be one of: ${MODE_IDS.join(', ')}`)
30
71
  }
31
72
  if (!Number.isSafeInteger(config.maxDraftChars) || config.maxDraftChars < 1000 || config.maxDraftChars > 100000) {
@@ -69,6 +110,14 @@ export function apply(ctx, config) {
69
110
  type: 'string',
70
111
  description: 'Optional file whose contents are used as context.',
71
112
  },
113
+ provider: {
114
+ type: 'string',
115
+ description: 'Advanced: provider override for this call only. Requires model; omit to use the configured enhancement model.',
116
+ },
117
+ model: {
118
+ type: 'string',
119
+ description: 'Advanced: model override for this call only. Requires provider; used for model comparisons and diagnostics.',
120
+ },
72
121
  },
73
122
  output: {
74
123
  schema: {
@@ -111,6 +160,8 @@ export function apply(ctx, config) {
111
160
  mode: args.mode,
112
161
  language: args.language,
113
162
  context: [args.context, contextPathText].filter((part) => typeof part === 'string' && part.trim() !== '').join('\n\n'),
163
+ provider: args.provider,
164
+ model: args.model,
114
165
  signal: exec.signal,
115
166
  })
116
167
  },
@@ -119,12 +170,9 @@ export function apply(ctx, config) {
119
170
  ctx.effect(
120
171
  () => ctx.connection.fetch.register({
121
172
  path: SETTINGS_PATH,
122
- methods: ['GET'],
173
+ methods: ['GET', 'POST'],
123
174
  requestBody: 'buffered',
124
- fetch: () => Response.json({
125
- ok: true,
126
- values: { defaultMode: config.defaultMode },
127
- }),
175
+ fetch: (request) => handleSettingsRoute(ctx, config, request),
128
176
  }),
129
177
  'prompt-editor: settings route',
130
178
  )
@@ -143,9 +191,192 @@ export function apply(ctx, config) {
143
191
  /** Browser route for the composer button. */
144
192
  const ENHANCE_PATH = '/api/prompt-editor/enhance'
145
193
 
146
- /** Read-only settings route for the settings page. */
194
+ /** Settings route for the settings page. */
147
195
  const SETTINGS_PATH = '/api/prompt-editor/settings'
148
196
 
197
+ /**
198
+ * Live config view. A volatile write mutates the loader entry; the config
199
+ * captured at activation is only the fallback.
200
+ * @param {any} ctx
201
+ * @param {any} config
202
+ */
203
+ function liveConfig(ctx, config) {
204
+ const live = ctx.fiber?.entry?.options?.config
205
+ return live !== null && typeof live === 'object' ? { ...config, ...live } : config
206
+ }
207
+
208
+ /**
209
+ * Resolve the current default mode.
210
+ * @param {any} ctx
211
+ * @param {any} config
212
+ */
213
+ function readRef(value, fallback) {
214
+ return value !== null && typeof value === 'object' && typeof value.get === 'function'
215
+ ? value.get()
216
+ : value ?? fallback
217
+ }
218
+
219
+ function readModeRef(value, fallback) {
220
+ const current = readRef(value, fallback)
221
+ return MODE_IDS.includes(current) ? current : fallback
222
+ }
223
+
224
+ function readSettings(ctx, config) {
225
+ const live = liveConfig(ctx, config)
226
+ return {
227
+ defaultMode: readModeRef(live.defaultMode, readModeRef(config.defaultMode, 'intent-first')),
228
+ useCustomModel: readRef(live.useCustomModel, false) === true,
229
+ enhanceProvider: typeof readRef(live.enhanceProvider, '') === 'string' ? readRef(live.enhanceProvider, '') : '',
230
+ enhanceModel: typeof readRef(live.enhanceModel, '') === 'string' ? readRef(live.enhanceModel, '') : '',
231
+ }
232
+ }
233
+
234
+ /**
235
+ * A rough complexity classifier. Complex drafts get the balanced prompt;
236
+ * short/simple drafts keep the concise one. This is deterministic and local,
237
+ * so it costs no extra model call.
238
+ * @param {string} draft
239
+ * @param {string | undefined} context
240
+ */
241
+ export function isComplexDraft(draft, context) {
242
+ if (typeof context === 'string' && context.trim() !== '') return true
243
+ const text = String(draft)
244
+ const high = /(重构|拆|迁移|升级|并发|监控|告警|鉴权|权限|性能|安全|接口|导出|批量|多步|工作流|重试|超时|日志|脱敏|打码)/i.test(text)
245
+ const code = /```|src\/|\.(?:ts|tsx|js|jsx|json|yaml|yml)|https?:\/\/|npm |package\.json/i.test(text)
246
+ const constraints = /(不要|只改|保持|不得|必须|至少|最多|以内|超过|兼容|回归|测试)/i.test(text)
247
+ const clauses = (text.match(/[,,;;。]/g) ?? []).length >= 2
248
+ let score = 0
249
+ if (text.trim().length >= 120) score += 1
250
+ if (high) score += 1
251
+ if (code) score += 1
252
+ if (constraints) score += 1
253
+ if (clauses) score += 1
254
+ return high || code || text.trim().length >= 120 || score >= 2
255
+ }
256
+
257
+ function promptVariantFor(profile, draft, context) {
258
+ if (profile === null || profile === undefined) return undefined
259
+ if (profile.promptVariant === 'concise' || profile.promptVariant === 'balanced' || profile.promptVariant === 'normal') {
260
+ return profile.promptVariant
261
+ }
262
+ if (profile.promptVariant !== 'auto') return undefined
263
+ return isComplexDraft(draft, context) ? 'balanced' : 'concise'
264
+ }
265
+
266
+ function liveDefaultMode(ctx, config) {
267
+ return readSettings(ctx, config).defaultMode
268
+ }
269
+
270
+ /**
271
+ * Resolve the optional profile for the currently selected custom model.
272
+ * @param {any} ctx
273
+ * @param {any} config
274
+ */
275
+ function resolveModelProfile(config, selection) {
276
+ if (selection?.provider === undefined || selection?.model === undefined) return null
277
+ const key = `${selection.provider}/${selection.model}`
278
+ const configured = config.modelProfiles?.[key]
279
+ const builtin = BUILTIN_MODEL_PROFILES[key]
280
+ if (configured === undefined && builtin === undefined) return null
281
+ return { ...builtin, ...configured, key }
282
+ }
283
+
284
+ /**
285
+ * A per-call override wins; otherwise the stored custom model applies when the
286
+ * switch is on; otherwise the session default is used.
287
+ */
288
+ function resolveModelSelection(ctx, config, override) {
289
+ if (override?.provider !== undefined && override.provider !== ''
290
+ && override?.model !== undefined && override.model !== '') {
291
+ return { provider: override.provider, model: override.model }
292
+ }
293
+ const settings = readSettings(ctx, config)
294
+ if (settings.useCustomModel && settings.enhanceProvider !== '' && settings.enhanceModel !== '') {
295
+ return { provider: settings.enhanceProvider, model: settings.enhanceModel }
296
+ }
297
+ return ctx.agentDefaultModel.currentSelection()
298
+ }
299
+
300
+ /**
301
+ * Namespace settings.write() expects: the loader row's short id.
302
+ * @param {any} ctx
303
+ */
304
+ function settingsNamespace(ctx) {
305
+ const shortId = ctx.fiber?.entry?.options?.id
306
+ if (typeof shortId === 'string' && shortId.length > 0) return shortId
307
+ const reported = ctx.get('profileContext')?.entryId
308
+ if (typeof reported === 'string' && reported.length > 0) {
309
+ const parts = reported.split(':')
310
+ return parts[parts.length - 1]
311
+ }
312
+ return undefined
313
+ }
314
+
315
+ /**
316
+ * Read or write the default rule through the profile settings service.
317
+ * @param {any} ctx
318
+ * @param {any} config
319
+ * @param {Request} request
320
+ */
321
+ async function handleSettingsRoute(ctx, config, request) {
322
+ if (request.method === 'GET') {
323
+ return Response.json({ ok: true, values: readSettings(ctx, config) })
324
+ }
325
+
326
+ let payload
327
+ try {
328
+ payload = await request.json()
329
+ } catch {
330
+ return Response.json({ ok: false, error: 'invalid JSON body' }, { status: 400 })
331
+ }
332
+ if (payload === null || typeof payload !== 'object') {
333
+ return Response.json({ ok: false, error: 'invalid settings body' }, { status: 400 })
334
+ }
335
+
336
+ const patch = {}
337
+ if (payload.defaultMode !== undefined) {
338
+ if (!MODE_IDS.includes(payload.defaultMode)) {
339
+ return Response.json({ ok: false, error: `defaultMode must be one of: ${MODE_IDS.join(', ')}` }, { status: 400 })
340
+ }
341
+ patch.defaultMode = payload.defaultMode
342
+ }
343
+ if (payload.useCustomModel !== undefined) {
344
+ if (typeof payload.useCustomModel !== 'boolean') {
345
+ return Response.json({ ok: false, error: 'useCustomModel must be a boolean' }, { status: 400 })
346
+ }
347
+ patch.useCustomModel = payload.useCustomModel
348
+ }
349
+ for (const key of ['enhanceProvider', 'enhanceModel']) {
350
+ if (payload[key] === undefined) continue
351
+ if (typeof payload[key] !== 'string' || payload[key].length > 200) {
352
+ return Response.json({ ok: false, error: `${key} must be a string of at most 200 characters` }, { status: 400 })
353
+ }
354
+ patch[key] = payload[key].trim()
355
+ }
356
+ if (Object.keys(patch).length === 0) {
357
+ return Response.json({ ok: false, error: 'no settings to update' }, { status: 400 })
358
+ }
359
+
360
+ const settings = ctx.get('settings')
361
+ if (settings === undefined || typeof settings.update !== 'function') {
362
+ return Response.json({ ok: false, error: 'settings service is unavailable' }, { status: 503 })
363
+ }
364
+ const ns = settingsNamespace(ctx)
365
+ if (ns === undefined) {
366
+ return Response.json({ ok: false, error: 'cannot locate the plugin settings entry' }, { status: 503 })
367
+ }
368
+
369
+ try {
370
+ await settings.update(ns, patch)
371
+ return Response.json({ ok: true, values: readSettings(ctx, config) })
372
+ } catch (error) {
373
+ return Response.json({
374
+ ok: false,
375
+ error: error instanceof Error ? error.message : String(error),
376
+ }, { status: 500 })
377
+ }
378
+ }
379
+
149
380
  /**
150
381
  * Stream one enhancement to the browser as Server-Sent Events.
151
382
  * `delta` carries raw model text; `done` carries the validated result.
@@ -222,22 +453,36 @@ async function handleEnhanceRoute(ctx, config, request) {
222
453
 
223
454
  /**
224
455
  * Enhance a draft end to end.
225
- * @param {{ ctx: any, config: any, draft: string, mode?: string, language?: string, context?: string, signal?: AbortSignal, onDelta?: (text: string) => void, onReset?: () => void }} request
456
+ * @param {{ ctx: any, config: any, draft: string, mode?: string, language?: string, context?: string, provider?: string, model?: string, signal?: AbortSignal, onDelta?: (text: string) => void, onReset?: () => void }} request
226
457
  */
227
458
  export async function enhance(request) {
228
459
  const { ctx, config, signal, onDelta, onReset } = request
229
460
  const draft = normalizeDraft(request.draft, config.maxDraftChars)
230
- const mode = resolveMode(request.mode ?? config.defaultMode)
461
+ const selection = resolveModelSelection(ctx, config, {
462
+ provider: request.provider,
463
+ model: request.model,
464
+ })
465
+ const profile = resolveModelProfile(config, selection)
466
+ const variant = promptVariantFor(profile, draft, request.context)
467
+ const mode = resolveMode(request.mode ?? liveDefaultMode(ctx, config), variant)
231
468
  const language = normalizeLanguage(request.language)
232
469
  const context = (request.context ?? '').trim().slice(0, config.maxContextChars)
233
- const baseUser = buildUserMessage({ draft, context, language }) + completenessHint(draft)
470
+ const kindHint = taskKindHint(draft)
471
+ const codeTask = isCodeChangeDraft(draft)
472
+ const effectiveMode = codeTask
473
+ ? {
474
+ ...mode,
475
+ system: `${mode.system}\n\n<task_kind>CODE_CHANGE</task_kind>\nThis draft is a code/config change to logging or telemetry, not a request to process a supplied sample. Do not ask for logs; do not output a redacted sample. Rewrite it as an instruction to modify the producer code.${isRedactionDraft(draft) ? ' The rewritten prompt must require a fixed placeholder, preserve field names and log structure, cover every log level and output path, and define acceptance as no plaintext values of the named sensitive fields while request id remains.' : ''}`,
476
+ }
477
+ : mode
478
+ const baseUser = (kindHint === '' ? '' : `${kindHint}\n\n`) + buildUserMessage({ draft, context, language }) + completenessHint(draft)
234
479
 
235
480
  let userMessage = baseUser
236
481
  let lastWarnings = []
237
482
 
238
483
  for (let attempt = 0; attempt < 2; attempt += 1) {
239
484
  if (attempt > 0) onReset?.()
240
- const raw = await callModel({ ctx, config, mode, userMessage, signal, onDelta })
485
+ const raw = await callModel({ ctx, config, mode: effectiveMode, profile, selection, userMessage, signal, onDelta })
241
486
  const parsed = parseModelOutput(raw)
242
487
 
243
488
  if (parsed.kind === 'unchanged') {
@@ -251,12 +496,16 @@ export async function enhance(request) {
251
496
  mode: mode.id,
252
497
  tagged: parsed.tagged,
253
498
  language,
254
- maxLengthRatio: config.maxLengthRatio,
255
- maxPromptChars: config.maxPromptChars,
499
+ maxLengthRatio: profile?.maxLengthRatio ?? config.maxLengthRatio,
500
+ maxPromptChars: profile?.maxPromptChars ?? config.maxPromptChars,
256
501
  })
257
502
  const hard = warnings.filter(isHardWarning)
503
+ const lengthWarnings = profile?.retryOnLength === true
504
+ ? warnings.filter((warning) => warning.startsWith('too_long'))
505
+ : []
506
+ const retryWarnings = [...hard, ...lengthWarnings]
258
507
 
259
- if (hard.length === 0) {
508
+ if (retryWarnings.length === 0) {
260
509
  return {
261
510
  prompt: parsed.prompt,
262
511
  changed: parsed.prompt.trim() !== draft.trim(),
@@ -267,6 +516,17 @@ export async function enhance(request) {
267
516
  }
268
517
 
269
518
  if (attempt === 1) {
519
+ // A still-too-long result is usable; preserve it with the warning rather
520
+ // than discarding a valid rewrite. Hard semantic failures still fallback.
521
+ if (hard.length === 0) {
522
+ return {
523
+ prompt: parsed.prompt,
524
+ changed: parsed.prompt.trim() !== draft.trim(),
525
+ mode: mode.id,
526
+ warnings,
527
+ status: parsed.prompt.trim() !== draft.trim() ? 'changed' : 'unchanged',
528
+ }
529
+ }
270
530
  return {
271
531
  prompt: draft,
272
532
  changed: false,
@@ -277,7 +537,7 @@ export async function enhance(request) {
277
537
  }
278
538
 
279
539
  lastWarnings = warnings
280
- userMessage = withCorrection(baseUser, warnings, parsed.prompt)
540
+ userMessage = withCorrection(baseUser, retryWarnings, parsed.prompt)
281
541
  continue
282
542
  }
283
543
 
@@ -294,8 +554,8 @@ export async function enhance(request) {
294
554
  * @param {{ ctx: any, config: any, mode: any, userMessage: string, signal?: AbortSignal, onDelta?: (text: string) => void }} request
295
555
  */
296
556
  async function callModel(request) {
297
- const { ctx, config, mode, userMessage, signal, onDelta } = request
298
- const selection = ctx.agentDefaultModel.currentSelection()
557
+ const { ctx, config, mode, profile, userMessage, signal, onDelta } = request
558
+ const selection = request.selection ?? resolveModelSelection(ctx, config)
299
559
  if (selection?.provider === undefined || selection?.model === undefined) {
300
560
  throw new Error('no default model selection is available')
301
561
  }
@@ -304,7 +564,7 @@ async function callModel(request) {
304
564
  const timeout = AbortSignal.timeout(config.llmTimeoutMs)
305
565
  const llmSignal = signal === undefined ? timeout : AbortSignal.any([signal, timeout])
306
566
 
307
- for await (const chunk of ctx.llm.stream({
567
+ const options = {
308
568
  provider: selection.provider,
309
569
  model: selection.model,
310
570
  sessionId: 'dsh-prompt-editor',
@@ -313,9 +573,15 @@ async function callModel(request) {
313
573
  content: [{ type: 'text', text: userMessage }],
314
574
  source: { kind: 'user' },
315
575
  })],
316
- temperature: mode.temperature,
576
+ temperature: profile?.temperature ?? mode.temperature,
317
577
  signal: llmSignal,
318
- })) {
578
+ }
579
+ if (typeof profile?.maxTokens === 'number' && profile.maxTokens > 0) options.maxTokens = profile.maxTokens
580
+ if (typeof profile?.reasoningEffort === 'string' && profile.reasoningEffort !== '') {
581
+ options.reasoningEffort = profile.reasoningEffort
582
+ }
583
+
584
+ for await (const chunk of ctx.llm.stream(options)) {
319
585
  assembler.push(chunk)
320
586
  if (chunk.type === 'text-delta' && typeof chunk.text === 'string' && onDelta !== undefined) {
321
587
  onDelta(chunk.text)
@@ -394,6 +660,7 @@ export function validatePrompt(input) {
394
660
 
395
661
  const lost = lostFacts(draft, prompt)
396
662
  if (lost.length > 0) warnings.push(`lost_facts: ${lost.join(', ')}`)
663
+ if (isCodeChangeDraft(draft) && isSampleProcessing(prompt)) warnings.push('wrong_task_kind')
397
664
 
398
665
  if (!tagged) warnings.push('missing_tags')
399
666
 
@@ -424,6 +691,7 @@ function isHardWarning(warning) {
424
691
  return warning.startsWith('refusal') ||
425
692
  warning.startsWith('asks_user') ||
426
693
  warning.startsWith('lost_facts') ||
694
+ warning.startsWith('wrong_task_kind') ||
427
695
  warning.startsWith('placeholder') ||
428
696
  warning.startsWith('empty_output')
429
697
  }
@@ -443,6 +711,12 @@ function withCorrection(baseUser, warnings, previous) {
443
711
  'Your previous answer was rejected because:',
444
712
  reasons,
445
713
  'Rewrite the draft again. Preserve all facts verbatim, do not ask the user anything, and follow the output contract exactly.',
714
+ ...(warnings.some((warning) => warning.startsWith('too_long'))
715
+ ? ['The previous answer was too long. Compress it and remove any section, example, or acceptance criterion the draft did not ask for.']
716
+ : []),
717
+ ...(warnings.includes('wrong_task_kind')
718
+ ? ['This draft is a code/config change. Do not process a supplied log or data sample; rewrite it as an instruction to change the code that produces them.']
719
+ : []),
446
720
  `The rejected answer began with: ${String(previous).slice(0, 500)}`,
447
721
  '</correction>',
448
722
  ].join('\n')
@@ -465,6 +739,31 @@ function asksUser(text) {
465
739
  return /(?:你|您)(?:希望|想要|需要|是否|要不要|更倾向|倾向于)|(?:需要|要)我(?:来|帮|先)|(?:请|能否|可以)(?:确认|告诉我|选择)|(?:would you like|do you want me|should i|can you confirm|please confirm|let me know which)/i.test(text)
466
740
  }
467
741
 
742
+ /**
743
+ * Keep code-shaped log/data work from being reinterpreted as processing a
744
+ * supplied sample. This is a hint, not a validator; the model still decides.
745
+ * @param {string} draft
746
+ */
747
+ function isCodeChangeDraft(draft) {
748
+ const domain = /(日志|log|数据|data|请求|request)/i.test(draft)
749
+ const mutation = /(字段|field|打码|脱敏|掩码|mask|redact|过滤|filter|格式化|format)/i.test(draft)
750
+ const sample = /(这段|这份|如下|以下|附件|attached|provided|上面的).{0,16}(日志|数据|文本|log|data|text)|\[附件/i.test(draft)
751
+ return domain && mutation && !sample
752
+ }
753
+
754
+ function isRedactionDraft(draft) {
755
+ return isCodeChangeDraft(draft) && /(打码|脱敏|掩码|mask|redact)/i.test(draft)
756
+ }
757
+
758
+ function taskKindHint(draft) {
759
+ if (!isCodeChangeDraft(draft)) return ''
760
+ return '<task_kind_hint>This draft is a CODE CHANGE to logging/telemetry code, not a request to process a supplied sample. Rewrite it as an instruction to modify the code that produces the logs. Do not write "provided logs", do not ask for a log sample, and do not output a redacted log.</task_kind_hint>'
761
+ }
762
+
763
+ function isSampleProcessing(prompt) {
764
+ return /(?:随请求提供的|提供的|这段|这份)(?:日志|数据|文本)|输出(?:脱敏|打码|处理)后的(?:完整)?(?:日志|数据|文本)|处理(?:随请求提供的)?(?:日志|数据|文本)/i.test(prompt)
765
+ }
766
+
468
767
  /**
469
768
  * Suggest UNCHANGED when a long draft already looks like a complete brief.
470
769
  * This is a hint, not a hard rule; the model still decides.
package/locale/en.json CHANGED
@@ -32,13 +32,38 @@
32
32
  "done": "Rewrite complete ({count} checks)",
33
33
  "hostMissing": "Host route is not loaded (HTTP 404). Fully quit and reopen DeepSeek Harness so the Host loads 0.2.x.",
34
34
  "chipsSelect": "This draft has reference chips. Select a passage that contains no chip, then enhance.",
35
- "chipsOverlap": "The selection contains a reference chip. Select a passage without chips; chips are preserved."
35
+ "chipsOverlap": "The selection contains a reference chip. Select a passage without chips; chips are preserved.",
36
+ "view": "View",
37
+ "viewDiff": "Diff",
38
+ "viewSide": "Side by side",
39
+ "diffTitle": "Original → rewritten",
40
+ "diffLegend": "removed / added",
41
+ "copy": "Copy",
42
+ "copied": "Copied",
43
+ "stop": "Stop",
44
+ "stopped": "Stopped"
36
45
  },
37
46
  "settings": {
38
47
  "nav": "Prompt editor",
39
48
  "title": "Prompt editor",
40
- "intro": "Choose the default rule for the composer button. It only rewrites; it never sends.",
49
+ "intro": "The default rule is saved in the current DSH profile and shared by the composer button and the Agent tool.",
41
50
  "mode": "Default rule",
42
- "modeHint": "Intent-first expands a thin draft; strict only removes ambiguity."
51
+ "modeHint": "Intent-first expands a thin draft; strict only removes ambiguity.",
52
+ "persisted": "Saved into this profile, so it survives browser changes and cache clears.",
53
+ "saving": "Saving…",
54
+ "saveError": "Save failed: {message}",
55
+ "modelTitle": "Enhancement model",
56
+ "modelHint": "When off, the current session model is used; when on, the model below is fixed.",
57
+ "useCustomModel": "Use a dedicated enhancement model",
58
+ "modelLoading": "Loading models…",
59
+ "modelLoadError": "Could not load the model catalog",
60
+ "modelPlaceholder": "Follow the session model",
61
+ "modelChoose": "Choose a model",
62
+ "savedModel": "Saved: {model} (currently disabled)"
63
+ },
64
+ "undo": {
65
+ "done": "Replaced",
66
+ "action": "Undo",
67
+ "close": "Dismiss undo"
43
68
  }
44
69
  }
package/locale/zh.json CHANGED
@@ -32,13 +32,38 @@
32
32
  "done": "改写完成({count} 条提示)",
33
33
  "hostMissing": "Host 路由未加载(HTTP 404)。请完全退出并重新打开 DeepSeek Harness,让 Host 加载 0.2.x。",
34
34
  "chipsSelect": "草稿含引用块。请先选中一段不含引用块的文字,再点增强。",
35
- "chipsOverlap": "选区包含引用块。请重新选择不含引用块的一段;引用块会原样保留。"
35
+ "chipsOverlap": "选区包含引用块。请重新选择不含引用块的一段;引用块会原样保留。",
36
+ "view": "显示方式",
37
+ "viewDiff": "差异",
38
+ "viewSide": "对照",
39
+ "diffTitle": "原文 → 改写",
40
+ "diffLegend": "删除 / 新增",
41
+ "copy": "复制",
42
+ "copied": "已复制",
43
+ "stop": "停止",
44
+ "stopped": "已停止生成"
36
45
  },
37
46
  "settings": {
38
47
  "nav": "提示词增强",
39
48
  "title": "提示词增强",
40
- "intro": "设置输入框按钮使用的默认规则。规则只影响改写,不会发送消息。",
49
+ "intro": "默认规则保存到当前 DSH profile,输入框按钮和 Agent 工具共用。",
41
50
  "mode": "默认规则",
42
- "modeHint": "意图优先会补全成任务说明;最小改动只消除歧义。"
51
+ "modeHint": "意图优先会补全成任务说明;最小改动只消除歧义。",
52
+ "persisted": "保存后写入当前 profile 的插件配置,换浏览器或清缓存都不会丢。",
53
+ "saving": "保存中…",
54
+ "saveError": "保存失败:{message}",
55
+ "modelTitle": "增强模型",
56
+ "modelHint": "关闭时跟随当前会话模型;开启后固定使用下面的模型。",
57
+ "useCustomModel": "使用增强专用模型",
58
+ "modelLoading": "正在读取模型…",
59
+ "modelLoadError": "模型目录读取失败",
60
+ "modelPlaceholder": "跟随当前会话模型",
61
+ "modelChoose": "请选择模型",
62
+ "savedModel": "已保存:{model}(当前未启用)"
63
+ },
64
+ "undo": {
65
+ "done": "已替换",
66
+ "action": "撤销",
67
+ "close": "关闭撤销提示"
43
68
  }
44
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infinity_cheng/dsh-prompt-editor",
3
- "version": "0.3.2",
3
+ "version": "0.5.0",
4
4
  "description": "Rewrite a rough prompt draft into a clear, executable prompt in DeepSeek Harness: streaming preview, selection-aware replace, and fact-preservation checks.",
5
5
  "icon": "icon.svg",
6
6
  "type": "module",