@restregular/dsh-powerup 0.9.0 → 0.9.1

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 (3) hide show
  1. package/README.md +14 -7
  2. package/client.js +77 -29
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -374,15 +374,22 @@ fiber is unloaded. The panel closes; refresh the page when the install finishes.
374
374
  ### Conversation rendering enhancements
375
375
 
376
376
  A feature set for more readable conversations, toggled as a whole on the
377
- Power-Up page. Its first sub-feature is **reply masking**: each rule is a regular
378
- expression; matching fragments in Agent reply prose are replaced with a
379
- placeholder (`[已屏蔽]` by default, or a custom replacement). Reasoning blocks,
380
- tool calls and user messages are never touched — only the assistant's answer
381
- text, including the final task summary.
377
+ Power-Up page. Its first sub-feature is **reply masking**: each rule matches
378
+ Agent reply prose and replaces matching fragments. Reasoning blocks, tool calls
379
+ and user messages are never touched — only the assistant's answer text,
380
+ including the final task summary.
381
+
382
+ Each rule has:
383
+ - a pattern, with a per-rule **Regex** toggle (on = regular expression with
384
+ `g/u/m/s` flags so `^`/`$` match line boundaries and `.` crosses newlines;
385
+ off = plain literal text),
386
+ - a replacement (blank removes the match; a **Default** button fills in
387
+ `[已屏蔽]`),
388
+ - an enable switch.
382
389
 
383
390
  Global rules are managed on the Power-Up page's **Masking** tab. Workspace rules
384
- are managed from the **Power-Up settings** tab in any conversation header (it
385
- appears after Trajectory), and are stored in the workspace's
391
+ are managed from the **PowerUp** tab in any conversation header (it appears
392
+ after Trajectory), and are stored in the workspace's
386
393
  `.dsh/dsh-powerup/mask-rules.json` through a local Host route.
387
394
 
388
395
  ### Dual send buttons
package/client.js CHANGED
@@ -83,7 +83,7 @@
83
83
  const promptCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
84
84
  /** Fallback bucket when the hero cannot resolve an owning workspace yet. */
85
85
  const UNSCOPED_WORKSPACE = '__unscoped__';
86
- const VERSION = '0.9.0';
86
+ const VERSION = '0.9.1';
87
87
  const MENU_GAP = 8;
88
88
  const MENU_WIDTH = 248;
89
89
  /** Reference scheme understood by the Host's `powerup_step_read` tool. */
@@ -137,7 +137,7 @@
137
137
  'scrollToTop.hint': '将左侧边栏滚动回最顶部',
138
138
  'page.renderingTitle': '会话内容渲染增强',
139
139
  'page.renderingDesc': '一组让会话内容更好读的增强,当前包含「回复内容屏蔽」:按正则表达式把 Agent 回复正文中匹配的片段替换成占位符,例如隐藏内部标签、水印或重复前缀。思考过程与工具调用不会被动到,只有发给你的回复正文(含最终总结)会被处理。',
140
- 'page.renderingHow': '在 Power-Up 设置页的「内容屏蔽」标签页管理全局规则;也可以在会话顶部的「Power-Up 设置」标签页管理当前工作区的规则。每条规则填一个正则表达式和替换文本,可不填替换文本(默认 [已屏蔽])。',
140
+ 'page.renderingHow': '在 Power-Up 设置页的「内容屏蔽」标签页管理全局规则;也可以在会话顶部的 PowerUp 标签页管理当前工作区的规则。每条规则填一个正则表达式和替换文本;替换文本留空表示直接删除匹配内容,也可点「默认值」按钮填入 [已屏蔽]。正则支持多行匹配(^/$ 匹配行首行尾,. 可跨行)。',
141
141
  'page.dualSendTitle': '双发送按钮',
142
142
  'page.dualSendDesc': '在输入框右侧增加两个发送按钮:普通发送(等待/排队)与插话发送(立即打断当前生成)。快捷键 Enter 固定为等待发送、Ctrl+Shift+Enter 固定为插话发送,不受系统「繁忙时发送行为」设置影响。',
143
143
  'page.dualSendHow': '启用后输入框里会出现两个按钮,鼠标悬停可看到各自说明;输入文字后按 Enter 排队发送,按 Ctrl+Shift+Enter 立即插话发送。',
@@ -150,7 +150,11 @@
150
150
  'mask.pattern': '正则表达式',
151
151
  'mask.patternPlaceholder': '例如:\\[内部[^\\]]*\\]',
152
152
  'mask.replacement': '替换为',
153
- 'mask.replacementPlaceholder': '留空则显示 [已屏蔽]',
153
+ 'mask.replacementPlaceholder': '留空则删除匹配内容',
154
+ 'mask.useDefault': '默认值',
155
+ 'mask.useDefaultHint': '填入 [已屏蔽]',
156
+ 'mask.regex': '正则',
157
+ 'mask.regexHint': '关闭后按纯文本匹配',
154
158
  'mask.enabled': '启用',
155
159
  'mask.add': '添加规则',
156
160
  'mask.delete': '删除',
@@ -159,6 +163,7 @@
159
163
  'mask.scopeGlobal': '全局',
160
164
  'mask.scopeWorkspace': '当前工作区',
161
165
  'mask.sessionTitle': 'Power-Up 设置',
166
+ 'mask.viewTabLabel': 'PowerUp',
162
167
  'mask.sessionDesc': '管理当前工作区的 Power-Up 功能设置与内容屏蔽规则。',
163
168
  'send.wait': '等待发送',
164
169
  'send.waitHint': '排队发送(Enter)',
@@ -424,7 +429,7 @@
424
429
  'scrollToTop.hint': 'Scroll the left sidebar back to the top',
425
430
  'page.renderingTitle': 'Conversation rendering enhancements',
426
431
  'page.renderingDesc': 'A feature set for more readable conversations. Its first sub-feature is reply masking: regular expressions replace matching fragments in Agent reply text with a placeholder, for example to hide internal tags, watermarks or repeated prefixes. Reasoning and tool calls are untouched; only reply prose (including the final summary) is processed.',
427
- 'page.renderingHow': 'Manage global rules on the Power-Up page\'s Masking tab, or workspace rules from the Power-Up Settings tab in a session header. Each rule has a regular expression and a replacement (blank defaults to [masked]).',
432
+ 'page.renderingHow': 'Manage global rules on the Power-Up page\'s Masking tab, or workspace rules from the PowerUp tab in a session header. Each rule has a regular expression and a replacement text; a blank replacement removes the match, or click the Default button to fill in [masked]. Regex supports multiline matching (^/$ match line boundaries, . matches newlines).',
428
433
  'page.dualSendTitle': 'Dual send buttons',
429
434
  'page.dualSendDesc': 'Adds two send buttons beside the composer: a normal (queued) send and an interrupt (steer) send. Enter always queues and Ctrl+Shift+Enter always interrupts, overriding the system busy-time send behavior.',
430
435
  'page.dualSendHow': 'Once enabled, two buttons appear in the composer with hover labels. Press Enter to queue a message, or Ctrl+Shift+Enter to interrupt the running turn with it.',
@@ -437,7 +442,11 @@
437
442
  'mask.pattern': 'Regular expression',
438
443
  'mask.patternPlaceholder': 'e.g. \\[internal[^\\]]*\\]',
439
444
  'mask.replacement': 'Replace with',
440
- 'mask.replacementPlaceholder': 'Blank shows [masked]',
445
+ 'mask.replacementPlaceholder': 'Blank removes the match',
446
+ 'mask.useDefault': 'Default',
447
+ 'mask.useDefaultHint': 'Fill in [masked]',
448
+ 'mask.regex': 'Regex',
449
+ 'mask.regexHint': 'Off means plain-text match',
441
450
  'mask.enabled': 'Enabled',
442
451
  'mask.add': 'Add rule',
443
452
  'mask.delete': 'Delete',
@@ -446,6 +455,7 @@
446
455
  'mask.scopeGlobal': 'Global',
447
456
  'mask.scopeWorkspace': 'This workspace',
448
457
  'mask.sessionTitle': 'Power-Up settings',
458
+ 'mask.viewTabLabel': 'PowerUp',
449
459
  'mask.sessionDesc': 'Manage Power-Up settings and masking rules for this workspace.',
450
460
  'send.wait': 'Send (queued)',
451
461
  'send.waitHint': 'Queue to send (Enter)',
@@ -884,6 +894,8 @@
884
894
  pattern: typeof item.pattern === 'string' ? item.pattern : '',
885
895
  replacement: typeof item.replacement === 'string' ? item.replacement : '',
886
896
  enabled: item.enabled !== false,
897
+ // Existing rules predate this flag and were regexes, so default true.
898
+ regex: item.regex !== false,
887
899
  scope: item.scope === 'workspace' ? 'workspace' : 'global',
888
900
  };
889
901
  }
@@ -953,16 +965,26 @@
953
965
  return [...globalMaskRules, ...workspaceMaskRules].filter((rule) => rule.enabled && rule.pattern !== '');
954
966
  }
955
967
 
956
- /** Compile rules once per change into reusable RegExp objects. */
968
+ /** Escape a literal string so it can be used as an exact regex source. */
969
+ function escapeRegExp(text) {
970
+ return text.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
971
+ }
972
+
973
+ /**
974
+ * Compile rules once per change into reusable RegExp objects. Regex mode
975
+ * uses 'g' (all), 'u' (unicode), 'm' (^/$ per line) and 's' (dot crosses
976
+ * newlines); plain-text mode escapes the pattern for a literal match.
977
+ */
957
978
  function compileMaskRules(list) {
958
979
  const compiled = [];
959
980
  for (const rule of Array.isArray(list) ? list : []) {
960
981
  if (rule === null || rule.enabled === false || typeof rule.pattern !== 'string' || rule.pattern === '') continue;
982
+ const isRegex = rule.regex !== false;
961
983
  try {
962
984
  compiled.push({
963
- re: new RegExp(rule.pattern, 'gu'),
964
- replacement: typeof rule.replacement === 'string' && rule.replacement !== ''
965
- ? rule.replacement : MASK_PLACEHOLDER,
985
+ re: isRegex ? new RegExp(rule.pattern, 'gums') : new RegExp(escapeRegExp(rule.pattern), 'gu'),
986
+ // A blank replacement is intentional: remove the matched text.
987
+ replacement: typeof rule.replacement === 'string' ? rule.replacement : '',
966
988
  });
967
989
  } catch {
968
990
  /* Invalid regex is skipped, never throws into rendering. */
@@ -3862,8 +3884,14 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
3862
3884
  .dsh-powerup-dual-send{display:inline-flex;align-items:center;gap:4px}
3863
3885
  .dsh-powerup-mask-editor{display:flex;flex-direction:column;gap:10px}
3864
3886
  .dsh-powerup-mask-row{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr) auto auto;gap:8px;align-items:center;padding:8px;border:.5px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1)}
3887
+ .dsh-powerup-mask-default.on{background:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-layer-1);border-color:var(--dsw-alias-brand-primary)}
3865
3888
  .dsh-powerup-mask-input{width:100%;box-sizing:border-box;padding:6px 8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px;line-height:18px}
3866
3889
  .dsh-powerup-mask-input.invalid{border-color:var(--dsw-alias-state-error-primary)}
3890
+ .dsh-powerup-mask-replacement{display:flex;align-items:center;gap:4px;min-width:0}
3891
+ .dsh-powerup-mask-replacement .dsh-powerup-mask-input{flex:1 1 auto;min-width:0}
3892
+ .dsh-powerup-mask-default{flex:none;padding:5px 8px;border:.5px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm,6px);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;line-height:18px;white-space:nowrap;cursor:pointer;transition:background .12s ease,color .12s ease}
3893
+ .dsh-powerup-mask-default:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
3894
+ .dsh-powerup-mask-default:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
3867
3895
  .dsh-powerup-mask-empty{color:var(--dsw-alias-label-secondary);font-size:12px}
3868
3896
  @media (max-width:680px){.dsh-powerup-mask-row{grid-template-columns:minmax(0,1fr)}}
3869
3897
  `;
@@ -8218,27 +8246,47 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8218
8246
  h('p', { className: 'dsh-powerup-card-desc' }, t('mask.hint')),
8219
8247
  ...visible.map((rule) => {
8220
8248
  let invalid = false;
8221
- if (rule.pattern !== '') {
8222
- try { new RegExp(rule.pattern); } catch { invalid = true; }
8249
+ if (rule.pattern !== '' && rule.regex !== false) {
8250
+ try { new RegExp(rule.pattern, 'gums'); } catch { invalid = true; }
8223
8251
  }
8224
8252
  return h('div', { key: rule.id, className: 'dsh-powerup-mask-row' },
8225
- h('input', {
8226
- type: 'text',
8227
- className: 'dsh-powerup-mask-input' + (invalid ? ' invalid' : ''),
8228
- value: rule.pattern,
8229
- placeholder: t('mask.patternPlaceholder'),
8230
- 'aria-label': t('mask.pattern'),
8231
- title: invalid ? t('mask.invalid') : t('mask.pattern'),
8232
- onChange: (event) => update(rule.id, { pattern: event.target.value }),
8233
- }),
8234
- h('input', {
8235
- type: 'text',
8236
- className: 'dsh-powerup-mask-input',
8237
- value: rule.replacement,
8238
- placeholder: t('mask.replacementPlaceholder'),
8239
- 'aria-label': t('mask.replacement'),
8240
- onChange: (event) => update(rule.id, { replacement: event.target.value }),
8241
- }),
8253
+ h('div', { className: 'dsh-powerup-mask-replacement' },
8254
+ h('input', {
8255
+ type: 'text',
8256
+ className: 'dsh-powerup-mask-input' + (invalid ? ' invalid' : ''),
8257
+ value: rule.pattern,
8258
+ placeholder: t('mask.patternPlaceholder'),
8259
+ 'aria-label': t('mask.pattern'),
8260
+ title: invalid ? t('mask.invalid') : t('mask.pattern'),
8261
+ onChange: (event) => update(rule.id, { pattern: event.target.value }),
8262
+ }),
8263
+ h('button', {
8264
+ type: 'button',
8265
+ role: 'switch',
8266
+ 'aria-checked': rule.regex !== false ? 'true' : 'false',
8267
+ className: 'dsh-powerup-mask-default' + (rule.regex !== false ? ' on' : ''),
8268
+ title: t('mask.regexHint'),
8269
+ 'aria-label': t('mask.regexHint'),
8270
+ onClick: () => update(rule.id, { regex: rule.regex === false }),
8271
+ }, t('mask.regex')),
8272
+ ),
8273
+ h('div', { className: 'dsh-powerup-mask-replacement' },
8274
+ h('input', {
8275
+ type: 'text',
8276
+ className: 'dsh-powerup-mask-input',
8277
+ value: rule.replacement,
8278
+ placeholder: t('mask.replacementPlaceholder'),
8279
+ 'aria-label': t('mask.replacement'),
8280
+ onChange: (event) => update(rule.id, { replacement: event.target.value }),
8281
+ }),
8282
+ h('button', {
8283
+ type: 'button',
8284
+ className: 'dsh-powerup-mask-default',
8285
+ title: t('mask.useDefaultHint'),
8286
+ 'aria-label': t('mask.useDefaultHint'),
8287
+ onClick: () => update(rule.id, { replacement: MASK_PLACEHOLDER }),
8288
+ }, t('mask.useDefault')),
8289
+ ),
8242
8290
  h('button', {
8243
8291
  type: 'button',
8244
8292
  role: 'switch',
@@ -8894,7 +8942,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8894
8942
  register('conversation.view', {
8895
8943
  id: 'powerup-settings',
8896
8944
  order: 20,
8897
- label: () => translateCurrent('mask.sessionTitle'),
8945
+ label: () => translateCurrent('mask.viewTabLabel'),
8898
8946
  }, (props) => h(WorkspaceSettingsView, { ...props, ctx }), 'dsh-powerup: workspace settings view');
8899
8947
 
8900
8948
  // The update control drives the built-in plugin manager through its
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "description": "为 DeepSeek Harness 提供一组可选的小型增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格、会话切换、定位当前会话、工作区提示词;所有功能均可在 Power-Up 页面独立开关。 · Opt-in upgrades for DeepSeek Harness: Trajectory context menu and step references, job stop reasons, one-click plugin install, an adaptive sidebar launcher, session switching, locating the current session, and workspace prompts — each toggled independently on the Power-Up page.",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",