@restregular/dsh-powerup 0.8.19 → 0.9.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/README.md CHANGED
@@ -371,6 +371,33 @@ fiber is unloaded. The panel closes; refresh the page when the install finishes.
371
371
  fixed-position popovers anchored to their triggers, so they never grow the
372
372
  dialog or get clipped by its scroll area.
373
373
 
374
+ ### Conversation rendering enhancements
375
+
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.
382
+
383
+ 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
386
+ `.dsh/dsh-powerup/mask-rules.json` through a local Host route.
387
+
388
+ ### Dual send buttons
389
+
390
+ When enabled on the Power-Up page, two compact controls appear at the right of
391
+ the composer: a queued send and an interrupt (steer) send. They bypass the
392
+ system "busy Enter" preference:
393
+
394
+ - **Enter** always queues the message as a next turn.
395
+ - **Ctrl+Shift+Enter** (Cmd+Shift+Enter on macOS) always interrupts the running
396
+ turn with the message.
397
+
398
+ Plain Shift+Enter still inserts a newline, IME composition and slash/mention
399
+ menus are left to the host, and an empty draft keeps the host's retry behavior.
400
+
374
401
  ## Development
375
402
 
376
403
  ```bash
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.8.19';
86
+ const VERSION = '0.9.0';
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. */
@@ -135,6 +135,36 @@
135
135
  'page.scrollToTopHow': '在左侧边栏向下滚动工作区列表,顶部的「新会话」旁会出现向上箭头按钮,点击即可回到顶部。',
136
136
  'scrollToTop.label': '回到顶部',
137
137
  'scrollToTop.hint': '将左侧边栏滚动回最顶部',
138
+ 'page.renderingTitle': '会话内容渲染增强',
139
+ 'page.renderingDesc': '一组让会话内容更好读的增强,当前包含「回复内容屏蔽」:按正则表达式把 Agent 回复正文中匹配的片段替换成占位符,例如隐藏内部标签、水印或重复前缀。思考过程与工具调用不会被动到,只有发给你的回复正文(含最终总结)会被处理。',
140
+ 'page.renderingHow': '在 Power-Up 设置页的「内容屏蔽」标签页管理全局规则;也可以在会话顶部的「Power-Up 设置」标签页管理当前工作区的规则。每条规则填一个正则表达式和替换文本,可不填替换文本(默认 [已屏蔽])。',
141
+ 'page.dualSendTitle': '双发送按钮',
142
+ 'page.dualSendDesc': '在输入框右侧增加两个发送按钮:普通发送(等待/排队)与插话发送(立即打断当前生成)。快捷键 Enter 固定为等待发送、Ctrl+Shift+Enter 固定为插话发送,不受系统「繁忙时发送行为」设置影响。',
143
+ 'page.dualSendHow': '启用后输入框里会出现两个按钮,鼠标悬停可看到各自说明;输入文字后按 Enter 排队发送,按 Ctrl+Shift+Enter 立即插话发送。',
144
+ 'mask.tab': '内容屏蔽',
145
+ 'mask.tabFeatures': '功能',
146
+ 'mask.tabWorkspace': '工作区设置',
147
+ 'mask.globalTitle': '全局屏蔽规则',
148
+ 'mask.workspaceTitle': '工作区屏蔽规则',
149
+ 'mask.hint': '每条规则是一个正则表达式;命中的片段会被替换为占位符。思考过程与工具调用不会被处理。',
150
+ 'mask.pattern': '正则表达式',
151
+ 'mask.patternPlaceholder': '例如:\\[内部[^\\]]*\\]',
152
+ 'mask.replacement': '替换为',
153
+ 'mask.replacementPlaceholder': '留空则显示 [已屏蔽]',
154
+ 'mask.enabled': '启用',
155
+ 'mask.add': '添加规则',
156
+ 'mask.delete': '删除',
157
+ 'mask.empty': '还没有规则。',
158
+ 'mask.invalid': '正则表达式无效',
159
+ 'mask.scopeGlobal': '全局',
160
+ 'mask.scopeWorkspace': '当前工作区',
161
+ 'mask.sessionTitle': 'Power-Up 设置',
162
+ 'mask.sessionDesc': '管理当前工作区的 Power-Up 功能设置与内容屏蔽规则。',
163
+ 'send.wait': '等待发送',
164
+ 'send.waitHint': '排队发送(Enter)',
165
+ 'send.interrupt': '插话发送',
166
+ 'send.interruptHint': '立即打断并发送(Ctrl+Shift+Enter)',
167
+ 'send.empty': '输入为空',
138
168
  'launcher.groupDefault': '分组',
139
169
  'launcher.count': '{count} 个面板',
140
170
  'launcher.renameHint': '点击重命名',
@@ -392,6 +422,36 @@
392
422
  'page.scrollToTopHow': 'Scroll the workspace list down in the left sidebar; an up-arrow button appears beside New Session — click it to return to the top.',
393
423
  'scrollToTop.label': 'Back to top',
394
424
  'scrollToTop.hint': 'Scroll the left sidebar back to the top',
425
+ 'page.renderingTitle': 'Conversation rendering enhancements',
426
+ '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]).',
428
+ 'page.dualSendTitle': 'Dual send buttons',
429
+ '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
+ '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.',
431
+ 'mask.tab': 'Masking',
432
+ 'mask.tabFeatures': 'Features',
433
+ 'mask.tabWorkspace': 'Workspace settings',
434
+ 'mask.globalTitle': 'Global masking rules',
435
+ 'mask.workspaceTitle': 'Workspace masking rules',
436
+ 'mask.hint': 'Each rule is a regular expression; matching fragments are replaced with a placeholder. Reasoning and tool calls are never touched.',
437
+ 'mask.pattern': 'Regular expression',
438
+ 'mask.patternPlaceholder': 'e.g. \\[internal[^\\]]*\\]',
439
+ 'mask.replacement': 'Replace with',
440
+ 'mask.replacementPlaceholder': 'Blank shows [masked]',
441
+ 'mask.enabled': 'Enabled',
442
+ 'mask.add': 'Add rule',
443
+ 'mask.delete': 'Delete',
444
+ 'mask.empty': 'No rules yet.',
445
+ 'mask.invalid': 'Invalid regular expression',
446
+ 'mask.scopeGlobal': 'Global',
447
+ 'mask.scopeWorkspace': 'This workspace',
448
+ 'mask.sessionTitle': 'Power-Up settings',
449
+ 'mask.sessionDesc': 'Manage Power-Up settings and masking rules for this workspace.',
450
+ 'send.wait': 'Send (queued)',
451
+ 'send.waitHint': 'Queue to send (Enter)',
452
+ 'send.interrupt': 'Send (interrupt)',
453
+ 'send.interruptHint': 'Interrupt and send now (Ctrl+Shift+Enter)',
454
+ 'send.empty': 'Empty input',
395
455
  'launcher.groupDefault': 'Group',
396
456
  'launcher.count': '{count} panels',
397
457
  'launcher.renameHint': 'Click to rename',
@@ -646,6 +706,8 @@
646
706
  update: true,
647
707
  locateSession: true,
648
708
  scrollToTop: true,
709
+ contentRendering: true,
710
+ dualSend: false,
649
711
  workspacePrompts: true,
650
712
  oneClickEnable: true,
651
713
  oneClickRestart: true,
@@ -666,6 +728,8 @@
666
728
  update: parsed.update !== false,
667
729
  locateSession: parsed.locateSession !== false,
668
730
  scrollToTop: parsed.scrollToTop !== false,
731
+ contentRendering: parsed.contentRendering !== false,
732
+ dualSend: parsed.dualSend === true,
669
733
  workspacePrompts: parsed.workspacePrompts !== false,
670
734
  oneClickEnable: parsed.oneClickEnable !== false,
671
735
  oneClickRestart: parsed.oneClickRestart !== false,
@@ -798,6 +862,125 @@
798
862
  }
799
863
  }
800
864
 
865
+ // ------------------------------------------------------------------
866
+ // Mask rules for the content-rendering enhancement.
867
+ // Global rules live in localStorage; workspace rules live in the
868
+ // workspace's `.dsh/dsh-powerup/mask-rules.json` via a Host route, exactly
869
+ // like prompts. Both lists share one normalize/compile helper.
870
+ // ------------------------------------------------------------------
871
+ const MASK_RULES_KEY = 'dsh-powerup:mask-rules:v1';
872
+ const MASK_RULES_API = '/dsh-powerup/api/mask-rules';
873
+ const MASK_PLACEHOLDER = '[已屏蔽]';
874
+ let globalMaskRules = readGlobalMaskRules();
875
+ let workspaceMaskRules = [];
876
+ let maskRulesWorkspace = '';
877
+ const maskRulesListeners = new Set();
878
+
879
+ /** Normalize one stored rule; invalid regex is kept but never compiled. */
880
+ function normalizeMaskRule(item) {
881
+ if (item === null || typeof item !== 'object') return null;
882
+ return {
883
+ id: typeof item.id === 'string' && item.id !== '' ? item.id : newId(),
884
+ pattern: typeof item.pattern === 'string' ? item.pattern : '',
885
+ replacement: typeof item.replacement === 'string' ? item.replacement : '',
886
+ enabled: item.enabled !== false,
887
+ scope: item.scope === 'workspace' ? 'workspace' : 'global',
888
+ };
889
+ }
890
+
891
+ function readGlobalMaskRules() {
892
+ try {
893
+ const parsed = JSON.parse(localStorage.getItem(MASK_RULES_KEY) || '[]');
894
+ return Array.isArray(parsed) ? parsed.map(normalizeMaskRule).filter(Boolean) : [];
895
+ } catch {
896
+ return [];
897
+ }
898
+ }
899
+
900
+ function writeGlobalMaskRules(list) {
901
+ globalMaskRules = (Array.isArray(list) ? list : []).map(normalizeMaskRule).filter(Boolean);
902
+ try {
903
+ localStorage.setItem(MASK_RULES_KEY, JSON.stringify(globalMaskRules));
904
+ } catch {
905
+ /* Private mode: the in-memory list still works this page. */
906
+ }
907
+ emitMaskRules();
908
+ }
909
+
910
+ async function loadWorkspaceMaskRules(workspaceId) {
911
+ const id = typeof workspaceId === 'string' ? workspaceId : '';
912
+ maskRulesWorkspace = id;
913
+ try {
914
+ const response = await fetch(MASK_RULES_API + '?workspaceId=' + encodeURIComponent(id), {
915
+ headers: { accept: 'application/json' },
916
+ });
917
+ const data = response.ok ? await response.json() : null;
918
+ const rules = data !== null && Array.isArray(data.rules) ? data.rules : [];
919
+ workspaceMaskRules = rules.map(normalizeMaskRule).filter(Boolean)
920
+ .map((rule) => ({ ...rule, scope: 'workspace' }));
921
+ } catch {
922
+ /* Host unavailable: keep the last known list. */
923
+ }
924
+ emitMaskRules();
925
+ return workspaceMaskRules;
926
+ }
927
+
928
+ function writeWorkspaceMaskRules(list) {
929
+ workspaceMaskRules = (Array.isArray(list) ? list : []).map(normalizeMaskRule).filter(Boolean)
930
+ .map((rule) => ({ ...rule, scope: 'workspace' }));
931
+ emitMaskRules();
932
+ fetch(MASK_RULES_API, {
933
+ method: 'POST',
934
+ headers: { 'content-type': 'application/json', accept: 'application/json' },
935
+ body: JSON.stringify({ workspaceId: maskRulesWorkspace, rules: workspaceMaskRules }),
936
+ }).catch(() => {
937
+ /* The in-memory list still works this page. */
938
+ });
939
+ }
940
+
941
+ function subscribeMaskRules(listener) {
942
+ maskRulesListeners.add(listener);
943
+ return () => maskRulesListeners.delete(listener);
944
+ }
945
+ function emitMaskRules() {
946
+ for (const listener of [...maskRulesListeners]) {
947
+ try { listener(); } catch { /* one listener must not break the rest */ }
948
+ }
949
+ }
950
+
951
+ /** Rules that apply to the current workspace: global plus its own. */
952
+ function activeMaskRules() {
953
+ return [...globalMaskRules, ...workspaceMaskRules].filter((rule) => rule.enabled && rule.pattern !== '');
954
+ }
955
+
956
+ /** Compile rules once per change into reusable RegExp objects. */
957
+ function compileMaskRules(list) {
958
+ const compiled = [];
959
+ for (const rule of Array.isArray(list) ? list : []) {
960
+ if (rule === null || rule.enabled === false || typeof rule.pattern !== 'string' || rule.pattern === '') continue;
961
+ try {
962
+ compiled.push({
963
+ re: new RegExp(rule.pattern, 'gu'),
964
+ replacement: typeof rule.replacement === 'string' && rule.replacement !== ''
965
+ ? rule.replacement : MASK_PLACEHOLDER,
966
+ });
967
+ } catch {
968
+ /* Invalid regex is skipped, never throws into rendering. */
969
+ }
970
+ }
971
+ return compiled;
972
+ }
973
+
974
+ /** Apply compiled rules to one text fragment; safe for any string. */
975
+ function applyMaskRules(text, compiled) {
976
+ if (typeof text !== 'string' || text === '' || compiled.length === 0) return text;
977
+ let out = text;
978
+ for (const rule of compiled) {
979
+ out = out.replace(rule.re, rule.replacement);
980
+ }
981
+ return out;
982
+ }
983
+
801
984
  /**
802
985
  * A prompt is visible in a workspace when it is global ('') or scoped to
803
986
  * that exact workspace. The dropdown never shows prompts of other workspaces.
@@ -2528,6 +2711,17 @@
2528
2711
  bridge.sessionId = sessionId;
2529
2712
  bridge.trajectory = snapshot;
2530
2713
  bridge.inputActions = inputActions;
2714
+ // Keep workspace masking rules loaded for the active session so the
2715
+ // DOM mask observer can use them without the settings tab being open.
2716
+ if (typeof sessionId === 'string' && sessionId !== '') {
2717
+ const workspaces = ctxRef.current?.get?.('workspaces');
2718
+ const wsId = typeof workspaces?.list?.getSnapshot === 'function'
2719
+ ? resolveWorkspaceIdFromSnapshot(workspaces.list.getSnapshot(), sessionId)
2720
+ : '';
2721
+ if (typeof wsId === 'string' && wsId !== '' && wsId !== maskRulesWorkspace) {
2722
+ void loadWorkspaceMaskRules(wsId);
2723
+ }
2724
+ }
2531
2725
  return () => {
2532
2726
  if (bridge.token === token) {
2533
2727
  bridge.token = null;
@@ -3653,6 +3847,25 @@ default; shown only while the sidebar workspace list is scrolled down. */
3653
3847
  html[data-platform="darwin"] .dsh-powerup-scrolltop{background:var(--dsw-specific-sidebar-glass-fill)}
3654
3848
  html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-specific-sidebar-glass-hover)}
3655
3849
  @media (prefers-reduced-motion:reduce){.dsh-powerup-scrolltop{transition:none}}
3850
+ `;
3851
+
3852
+ const RENDERING_CSS = `
3853
+ /* Masked fragments get a subtle marker so the reader knows text was hidden. */
3854
+ .dsh-powerup-masked{color:var(--dsw-alias-label-caption);font-style:italic;opacity:.72}
3855
+ /* Dual send buttons injected into the composer's right slot. */
3856
+ .dsh-powerup-send{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;padding:0;box-sizing:border-box;border:.5px solid var(--dsw-alias-border-l3);border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-secondary);font:inherit;cursor:pointer;transition:background .12s ease,color .12s ease,border-color .12s ease}
3857
+ .dsh-powerup-send:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l3)}
3858
+ .dsh-powerup-send:disabled{opacity:.45;cursor:not-allowed}
3859
+ .dsh-powerup-send:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
3860
+ .dsh-powerup-send[data-kind="interrupt"]{color:var(--dsw-alias-state-warn-label,var(--dsw-alias-label-secondary))}
3861
+ .dsh-powerup-send svg{width:16px;height:16px}
3862
+ .dsh-powerup-dual-send{display:inline-flex;align-items:center;gap:4px}
3863
+ .dsh-powerup-mask-editor{display:flex;flex-direction:column;gap:10px}
3864
+ .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)}
3865
+ .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
+ .dsh-powerup-mask-input.invalid{border-color:var(--dsw-alias-state-error-primary)}
3867
+ .dsh-powerup-mask-empty{color:var(--dsw-alias-label-secondary);font-size:12px}
3868
+ @media (max-width:680px){.dsh-powerup-mask-row{grid-template-columns:minmax(0,1fr)}}
3656
3869
  `;
3657
3870
 
3658
3871
  const PROMPTS_CSS = `
@@ -4841,11 +5054,138 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4841
5054
  return core;
4842
5055
  }
4843
5056
 
5057
+ /**
5058
+ * DOM-based masking for assistant reply prose. We observe the Chat view's
5059
+ * assistant reply rows and replace matching text fragments in place. The
5060
+ * original text of each text node is cached in a WeakMap so a re-render
5061
+ * that restores it can be masked again, and a re-render that produces a
5062
+ * new node is picked up by the MutationObserver. Only reply rows
5063
+ * (`data-chat-flow-kind="assistant-step"` with `group-part="response"`)
5064
+ * are touched; reasoning disclosures and tool calls are left alone.
5065
+ * @param {{isEnabled?: Function, rules?: Function}} deps
5066
+ */
5067
+ function createReplyMaskCore(deps) {
5068
+ const options = deps ?? {};
5069
+ const isEnabled = typeof options.isEnabled === 'function' ? options.isEnabled : () => true;
5070
+ const rulesOf = typeof options.rules === 'function' ? options.rules : () => [];
5071
+ const originals = new WeakMap();
5072
+ let observer = null;
5073
+ let timer = null;
5074
+ let started = false;
5075
+ let compiled = [];
5076
+ let sweeping = false;
5077
+
5078
+ function hasDocument() {
5079
+ return typeof document !== 'undefined' && document !== null
5080
+ && typeof document.querySelectorAll === 'function' && document.body !== null;
5081
+ }
5082
+
5083
+ function refreshRules() {
5084
+ compiled = compileMaskRules(rulesOf());
5085
+ }
5086
+
5087
+ function maskTextNode(node) {
5088
+ if (node.nodeType !== 3) return; // Node.TEXT_NODE
5089
+ const current = node.nodeValue ?? '';
5090
+ const original = originals.get(node);
5091
+ if (original !== undefined) {
5092
+ const maskedFromOriginal = applyMaskRules(original, compiled);
5093
+ if (current === maskedFromOriginal) return; // still our masked output
5094
+ }
5095
+ // Either a fresh node, React restored the original, or streaming grew
5096
+ // the text. Treat what is on screen now as the source of truth.
5097
+ originals.set(node, current);
5098
+ const masked = applyMaskRules(current, compiled);
5099
+ if (masked !== current) node.nodeValue = masked;
5100
+ }
5101
+
5102
+ function maskRow(row) {
5103
+ // Only the assistant's answer prose; skip reasoning / tool rows.
5104
+ const kind = row.getAttribute('data-chat-flow-kind');
5105
+ const part = row.getAttribute('data-chat-group-part');
5106
+ if (kind !== 'assistant-step' || (part !== null && part !== 'response')) return;
5107
+ const body = row.querySelector('[data-streaming], .dsh-powerup-mask-root') ?? row;
5108
+ const walker = document.createTreeWalker(body, 4 /* NodeFilter.SHOW_TEXT */, null);
5109
+ let node;
5110
+ while ((node = walker.nextNode()) !== null) {
5111
+ maskTextNode(node);
5112
+ }
5113
+ }
5114
+
5115
+ function sweep() {
5116
+ if (!started || !isEnabled() || compiled.length === 0 || sweeping) return;
5117
+ // Changing nodeValue fires our own characterData observer; the flag
5118
+ // keeps that from cascading into another full sweep.
5119
+ sweeping = true;
5120
+ try {
5121
+ const rows = document.querySelectorAll('[data-chat-flow-kind="assistant-step"]');
5122
+ for (const row of rows) maskRow(row);
5123
+ } finally {
5124
+ setTimeout(() => { sweeping = false; }, 0);
5125
+ }
5126
+ }
5127
+
5128
+ function schedule() {
5129
+ if (timer !== null) return;
5130
+ timer = setTimeout(() => {
5131
+ timer = null;
5132
+ sweep();
5133
+ }, 40);
5134
+ }
5135
+
5136
+ function start() {
5137
+ if (started || !hasDocument()) return;
5138
+ started = true;
5139
+ refreshRules();
5140
+ sweep();
5141
+ if (typeof MutationObserver === 'function') {
5142
+ observer = new MutationObserver(() => schedule());
5143
+ observer.observe(document.body, { childList: true, subtree: true, characterData: true });
5144
+ }
5145
+ }
5146
+
5147
+ function stop() {
5148
+ started = false;
5149
+ if (observer !== null) observer.disconnect();
5150
+ observer = null;
5151
+ if (timer !== null) clearTimeout(timer);
5152
+ timer = null;
5153
+ }
5154
+
5155
+ return { start, stop, sweep, refreshRules, maskRow, applyMaskRules, compileMaskRules };
5156
+ }
5157
+
5158
+ /** Install the reply-mask observer and keep its compiled rules in sync. */
5159
+ function installReplyMask(ctx) {
5160
+ const core = createReplyMaskCore({
5161
+ isEnabled: () => getSettings().contentRendering,
5162
+ rules: () => activeMaskRules(),
5163
+ });
5164
+ const enabled = () => getSettings().contentRendering;
5165
+ ctx.effect(() => {
5166
+ if (enabled()) core.start();
5167
+ const offSettings = subscribeSettings(() => {
5168
+ if (enabled()) { core.refreshRules(); core.start(); core.sweep(); }
5169
+ else core.stop();
5170
+ });
5171
+ const offRules = subscribeMaskRules(() => {
5172
+ core.refreshRules();
5173
+ if (enabled()) core.sweep();
5174
+ });
5175
+ return () => {
5176
+ offSettings();
5177
+ offRules();
5178
+ core.stop();
5179
+ };
5180
+ }, 'dsh-powerup: reply mask');
5181
+ return core;
5182
+ }
5183
+
4844
5184
  function installStyles(ctx) {
4845
5185
  try {
4846
5186
  const style = document.createElement('style');
4847
5187
  style.setAttribute('data-dsh-powerup', '');
4848
- style.textContent = CSS + '\n' + LAUNCHER_CSS + '\n' + SESSION_SWITCH_CSS + '\n' + LOCATE_CSS + '\n' + SCROLL_TOP_CSS + '\n' + PROMPTS_CSS;
5188
+ style.textContent = CSS + '\n' + LAUNCHER_CSS + '\n' + SESSION_SWITCH_CSS + '\n' + LOCATE_CSS + '\n' + SCROLL_TOP_CSS + '\n' + RENDERING_CSS + '\n' + PROMPTS_CSS;
4849
5189
  document.head.appendChild(style);
4850
5190
  ctx.effect(() => () => style.remove(), 'dsh-powerup: styles');
4851
5191
  } catch (error) {
@@ -7852,6 +8192,225 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
7852
8192
  );
7853
8193
  }
7854
8194
 
8195
+ /**
8196
+ * Shared editor for a list of mask rules. `scope` is 'global' or
8197
+ * 'workspace'; writes go through the matching store functions.
8198
+ */
8199
+ function MaskRuleEditor({ scope, t }) {
8200
+ const rules = useMaskRules();
8201
+ const visible = rules.filter((rule) => (rule.scope || 'global') === scope);
8202
+ const commit = (next) => {
8203
+ if (scope === 'workspace') writeWorkspaceMaskRules(next);
8204
+ else writeGlobalMaskRules(next);
8205
+ };
8206
+ const update = (id, patch) => {
8207
+ commit(visible.map((rule) => (rule.id === id ? { ...rule, ...patch } : rule)));
8208
+ };
8209
+ const remove = (id) => {
8210
+ commit(visible.filter((rule) => rule.id !== id));
8211
+ };
8212
+ const add = () => {
8213
+ commit([...visible, { id: newId(), pattern: '', replacement: '', enabled: true, scope }]);
8214
+ };
8215
+ const title = scope === 'workspace' ? t('mask.workspaceTitle') : t('mask.globalTitle');
8216
+ return h('div', { className: 'dsh-powerup-mask-editor' },
8217
+ h('h3', { className: 'dsh-powerup-section-title' }, title),
8218
+ h('p', { className: 'dsh-powerup-card-desc' }, t('mask.hint')),
8219
+ ...visible.map((rule) => {
8220
+ let invalid = false;
8221
+ if (rule.pattern !== '') {
8222
+ try { new RegExp(rule.pattern); } catch { invalid = true; }
8223
+ }
8224
+ 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
+ }),
8242
+ h('button', {
8243
+ type: 'button',
8244
+ role: 'switch',
8245
+ 'aria-checked': rule.enabled ? 'true' : 'false',
8246
+ className: 'dsh-powerup-switch',
8247
+ onClick: () => update(rule.id, { enabled: !rule.enabled }),
8248
+ }, invalid ? t('mask.invalid') : (rule.enabled ? t('page.enabled') : t('page.disabled'))),
8249
+ h('button', {
8250
+ type: 'button',
8251
+ className: 'dsh-powerup-prompt-new',
8252
+ onClick: () => remove(rule.id),
8253
+ }, t('mask.delete')),
8254
+ );
8255
+ }),
8256
+ visible.length === 0 ? h('p', { className: 'dsh-powerup-mask-empty' }, t('mask.empty')) : null,
8257
+ h('button', {
8258
+ type: 'button',
8259
+ className: 'dsh-powerup-prompt-new',
8260
+ onClick: add,
8261
+ }, t('mask.add')),
8262
+ );
8263
+ }
8264
+
8265
+ function useMaskRules() {
8266
+ const [revision, setRevision] = useState(0);
8267
+ useEffect(() => subscribeMaskRules(() => setRevision((v) => v + 1)), []);
8268
+ void revision;
8269
+ return [...globalMaskRules, ...workspaceMaskRules];
8270
+ }
8271
+
8272
+ /**
8273
+ * Two send buttons injected into the composer's right slot. Enter / the
8274
+ * host primary button keep their own behavior; we add explicit queued and
8275
+ * interrupt controls that bypass the system busy-time setting.
8276
+ */
8277
+ function DualSendButtons({ sessionId, useInput, inputActions, ctx, t }) {
8278
+ const settings = useSettings();
8279
+ const draft = typeof useInput === 'function' ? useInput((s) => s.draft) : '';
8280
+ // Session-scope slots usually pass sessionId; fall back to the DOM
8281
+ // contract the rest of this plugin already relies on.
8282
+ const ownerId = () => {
8283
+ if (typeof sessionId === 'string' && sessionId !== '') return sessionId;
8284
+ try {
8285
+ const el = document.querySelector('[data-conversation-session]');
8286
+ const id = el === null ? null : el.getAttribute('data-conversation-session');
8287
+ return typeof id === 'string' && id !== '' ? id : '';
8288
+ } catch {
8289
+ return '';
8290
+ }
8291
+ };
8292
+ const trimmed = typeof draft === 'string' ? draft.trim() : '';
8293
+ const currentDraft = { trimmed, sessionId, inputActions, ctx };
8294
+ const send = (mode, text) => {
8295
+ const value = typeof text === 'string' ? text.trim() : trimmed;
8296
+ const id = ownerId();
8297
+ if (value === '' || id === '') return;
8298
+ try {
8299
+ const sessions = ctx.get('sessions');
8300
+ const binding = sessions?.binding?.(id);
8301
+ const session = binding?.session;
8302
+ if (session === undefined || typeof session.prompt !== 'function') return;
8303
+ const handle = typeof session.beginSubmission === 'function'
8304
+ ? session.beginSubmission({ mode, text: value, attachments: [] })
8305
+ : null;
8306
+ void session.prompt([{ type: 'text', text: value }], mode, undefined, handle?.requestId);
8307
+ if (typeof inputActions?.setDraft === 'function') inputActions.setDraft('');
8308
+ } catch (error) {
8309
+ console.warn('[dsh-powerup] dual send failed:', error?.message ?? error);
8310
+ }
8311
+ };
8312
+ // Capture-phase keymap overrides the host's busy-time send behavior:
8313
+ // Enter always queues, Ctrl/Cmd+Shift+Enter always interrupts. Plain
8314
+ // Shift+Enter (newline), IME composition, and an open command listbox
8315
+ // are left to the host.
8316
+ useEffect(() => {
8317
+ if (!settings.dualSend || typeof document === 'undefined' || document === null) return undefined;
8318
+ const onKeyDown = (event) => {
8319
+ if (event.key !== 'Enter' || event.isComposing === true || event.repeat === true) return;
8320
+ const target = event.target;
8321
+ const editor = target !== null && typeof target.closest === 'function'
8322
+ ? target.closest('[data-composer-input]')
8323
+ : null;
8324
+ if (editor === null) return;
8325
+ if (editor.hasAttribute('data-composer-composing')) return;
8326
+ // An empty draft is the host's retry gesture; leave it alone.
8327
+ if (trimmed === '') return;
8328
+ // Let the host resolve Enter while a / or @ menu (or a selected
8329
+ // command chip) is open — the menu can be portaled outside the card.
8330
+ const openMenu = document.querySelector?.(
8331
+ '[aria-haspopup="listbox"][aria-expanded="true"], [aria-haspopup="menu"][aria-expanded="true"], [role="listbox"]:not([hidden]), [role="menu"]:not([hidden])',
8332
+ );
8333
+ if (openMenu !== null && openMenu !== undefined) return;
8334
+ if (editor.hasAttribute('data-composer-chip-selected')) return;
8335
+ const interrupt = event.shiftKey && (event.ctrlKey || event.metaKey);
8336
+ if (event.shiftKey && !interrupt) return; // plain Shift+Enter = newline
8337
+ if (!interrupt && (event.ctrlKey || event.metaKey || event.altKey)) return;
8338
+ event.preventDefault();
8339
+ event.stopPropagation();
8340
+ send(interrupt ? 'steer' : 'queue');
8341
+ };
8342
+ document.addEventListener('keydown', onKeyDown, true);
8343
+ return () => document.removeEventListener('keydown', onKeyDown, true);
8344
+ }, [settings.dualSend, sessionId, draft, ctx, inputActions]);
8345
+ void currentDraft;
8346
+ if (!settings.dualSend) return null;
8347
+ return h('div', { className: 'dsh-powerup-dual-send' },
8348
+ h('button', {
8349
+ type: 'button',
8350
+ className: 'dsh-powerup-send',
8351
+ 'data-kind': 'wait',
8352
+ 'aria-label': t('send.waitHint'),
8353
+ title: t('send.waitHint'),
8354
+ disabled: trimmed === '',
8355
+ onMouseDown: (event) => event.preventDefault(),
8356
+ onClick: () => send('queue'),
8357
+ }, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
8358
+ h('path', { d: 'M3 8h9M8.5 4.5 12 8l-3.5 3.5', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' }))),
8359
+ h('button', {
8360
+ type: 'button',
8361
+ className: 'dsh-powerup-send',
8362
+ 'data-kind': 'interrupt',
8363
+ 'aria-label': t('send.interruptHint'),
8364
+ title: t('send.interruptHint'),
8365
+ disabled: trimmed === '',
8366
+ onMouseDown: (event) => event.preventDefault(),
8367
+ onClick: () => send('steer'),
8368
+ }, h('svg', { viewBox: '0 0 16 16', width: 16, height: 16, 'aria-hidden': 'true' },
8369
+ h('path', { d: 'M8 2v12M3 6l5-4 5 4', fill: 'none', stroke: 'currentColor', strokeWidth: 1.4, strokeLinecap: 'round', strokeLinejoin: 'round' }))),
8370
+ );
8371
+ }
8372
+
8373
+ /**
8374
+ * Conversation View tab for per-workspace Power-Up settings. Registered
8375
+ * after Trajectory so it appears last in the header tab row.
8376
+ */
8377
+ function WorkspaceSettingsView({ ctx, sessionId, useWorkspaces }) {
8378
+ const settings = useSettings();
8379
+ const rules = useMaskRules();
8380
+ const [, forceLocale] = useState(0);
8381
+ const t = useCallback((key, params) => translateCurrent(key, params), []);
8382
+ useEffect(() => {
8383
+ const off = ctx.locale?.subscribe?.(() => forceLocale((v) => v + 1));
8384
+ return typeof off === 'function' ? off : undefined;
8385
+ }, [ctx]);
8386
+ // Prefer the slot's sessionId; fall back to the live DOM contract.
8387
+ let ownerId = sessionId;
8388
+ if (typeof ownerId !== 'string' || ownerId === '') {
8389
+ try {
8390
+ const el = document.querySelector('[data-conversation-session]');
8391
+ const id = el === null ? null : el.getAttribute('data-conversation-session');
8392
+ if (typeof id === 'string' && id !== '') ownerId = id;
8393
+ } catch { /* keep the empty id */ }
8394
+ }
8395
+ const workspaceSelector = useMemo(() => (snapshot) => resolveWorkspaceIdFromSnapshot(snapshot, ownerId), [ownerId]);
8396
+ const workspaceId = typeof useWorkspaces === 'function' ? useWorkspaces(workspaceSelector) ?? '' : '';
8397
+ useEffect(() => {
8398
+ if (typeof workspaceId === 'string' && workspaceId !== '') void loadWorkspaceMaskRules(workspaceId);
8399
+ }, [workspaceId]);
8400
+ void rules; void settings;
8401
+ return h('div', { className: 'dsh-powerup-page' },
8402
+ h('div', { className: 'dsh-powerup-shell' },
8403
+ h('header', { className: 'dsh-powerup-hero' },
8404
+ h('div', { className: 'dsh-powerup-hero-copy' },
8405
+ h('h1', null, t('mask.sessionTitle')),
8406
+ h('p', null, t('mask.sessionDesc')),
8407
+ ),
8408
+ ),
8409
+ h(MaskRuleEditor, { scope: 'workspace', t }),
8410
+ ),
8411
+ );
8412
+ }
8413
+
7855
8414
  function PromptManager({ ctx }) {
7856
8415
  const prompts = usePrompts();
7857
8416
  const [, forceLocale] = useState(0);
@@ -8094,7 +8653,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8094
8653
  }, []);
8095
8654
  useEffect(() => {
8096
8655
  if (settings.workspacePrompts === false && tab === 'prompts') setTab('features');
8097
- }, [settings.workspacePrompts, tab]);
8656
+ if (settings.contentRendering === false && tab === 'mask') setTab('features');
8657
+ }, [settings.workspacePrompts, settings.contentRendering, tab]);
8098
8658
  const t = (key, params) => translateCurrent(key, params);
8099
8659
  const actions = [
8100
8660
  { id: 'copy', icon: CopyIcon, name: t('action.copy'), hint: t('action.copyHint') },
@@ -8176,6 +8736,15 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8176
8736
  className: 'dsh-powerup-tab' + (tab === 'features' ? ' on' : ''),
8177
8737
  onClick: () => setTab('features'),
8178
8738
  }, t('prompts.tabFeatures')),
8739
+ settings.contentRendering !== false
8740
+ ? h('button', {
8741
+ type: 'button',
8742
+ role: 'tab',
8743
+ 'aria-selected': tab === 'mask' ? 'true' : 'false',
8744
+ className: 'dsh-powerup-tab' + (tab === 'mask' ? ' on' : ''),
8745
+ onClick: () => setTab('mask'),
8746
+ }, t('mask.tab'))
8747
+ : null,
8179
8748
  settings.workspacePrompts !== false
8180
8749
  ? h('button', {
8181
8750
  type: 'button',
@@ -8197,6 +8766,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8197
8766
  featureCard('sessionSwitch', QuickIcon, 'page.sessionSwitchTitle', 'page.sessionSwitchDesc', 'page.sessionSwitchHow'),
8198
8767
  featureCard('locateSession', LocateIcon, 'page.locateTitle', 'page.locateDesc', 'page.locateHow'),
8199
8768
  featureCard('scrollToTop', ScrollTopIcon, 'page.scrollToTopTitle', 'page.scrollToTopDesc', 'page.scrollToTopHow'),
8769
+ featureCard('contentRendering', PowerUpLineIcon, 'page.renderingTitle', 'page.renderingDesc', 'page.renderingHow'),
8770
+ featureCard('dualSend', LauncherIcon, 'page.dualSendTitle', 'page.dualSendDesc', 'page.dualSendHow'),
8200
8771
  featureCard('workspacePrompts', TagIcon, 'page.promptsTitle', 'page.promptsDesc', 'page.promptsHow'),
8201
8772
  featureCard('jobStop', StopIcon, 'page.jobStopTitle', 'page.jobStopDesc', 'page.jobStopHow'),
8202
8773
  featureCard('update', UpdateIcon, 'page.updateTitle', 'page.updateDesc', 'page.updateHow', oneClickDetail),
@@ -8212,9 +8783,11 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8212
8783
  ),
8213
8784
  ),
8214
8785
  tabs,
8215
- tab === 'prompts' && settings.workspacePrompts !== false
8216
- ? h(PromptManager, { ctx })
8217
- : featuresContent,
8786
+ tab === 'mask' && settings.contentRendering !== false
8787
+ ? h(MaskRuleEditor, { scope: 'global', t })
8788
+ : tab === 'prompts' && settings.workspacePrompts !== false
8789
+ ? h(PromptManager, { ctx })
8790
+ : featuresContent,
8218
8791
  h('footer', { className: 'dsh-powerup-foot' },
8219
8792
  h('span', null, format(t('page.footer'), { version: VERSION })),
8220
8793
  h('span', { className: 'dsh-powerup-dot' }),
@@ -8262,6 +8835,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8262
8835
  installSessionSwitcher(ctx);
8263
8836
  installLocateSession(ctx);
8264
8837
  installScrollToTop(ctx);
8838
+ installReplyMask(ctx);
8265
8839
 
8266
8840
  const slots = ctx.get('slots');
8267
8841
  if (slots === undefined || typeof slots.inject !== 'function' || typeof slots.register !== 'function') {
@@ -8303,6 +8877,26 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8303
8877
  order: 60,
8304
8878
  }, HeroPromptsControl, 'dsh-powerup: prompt picker');
8305
8879
 
8880
+ // Session-scope composer controls. These receive sessionId/useInput/
8881
+ // inputActions from the host's conversation slot wiring; the t() locale
8882
+ // seat is provided by the slot, so we wrap to use the plugin dictionary.
8883
+ register('conversation.input.right', {
8884
+ id: 'powerup-dual-send',
8885
+ order: 80,
8886
+ }, (props) => h(DualSendButtons, {
8887
+ ...props,
8888
+ ctx,
8889
+ t: (key, params) => translateCurrent(key, params),
8890
+ }), 'dsh-powerup: dual send buttons');
8891
+
8892
+ // Per-workspace Power-Up settings as a Conversation View tab, ordered
8893
+ // after the host's Trajectory view (order 10).
8894
+ register('conversation.view', {
8895
+ id: 'powerup-settings',
8896
+ order: 20,
8897
+ label: () => translateCurrent('mask.sessionTitle'),
8898
+ }, (props) => h(WorkspaceSettingsView, { ...props, ctx }), 'dsh-powerup: workspace settings view');
8899
+
8306
8900
  // The update control drives the built-in plugin manager through its
8307
8901
  // `remote.pluginManager` namespace. Register it in a nested inject scope
8308
8902
  // so a late-provided service is observed instead of sampled once.
@@ -8361,6 +8955,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8361
8955
  SESSION_SWITCH_CSS,
8362
8956
  LOCATE_CSS,
8363
8957
  SCROLL_TOP_CSS,
8958
+ RENDERING_CSS,
8364
8959
  PROMPTS_CSS,
8365
8960
  PROMPTS_LAST_KEY,
8366
8961
  promptCreateDraft,
@@ -8441,6 +9036,18 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8441
9036
  operationReason,
8442
9037
  restorePreviousBundle,
8443
9038
  runOneClickUpdate,
9039
+ MASK_RULES_KEY,
9040
+ MASK_PLACEHOLDER,
9041
+ readGlobalMaskRules,
9042
+ writeGlobalMaskRules,
9043
+ normalizeMaskRule,
9044
+ activeMaskRules,
9045
+ compileMaskRules,
9046
+ applyMaskRules,
9047
+ createReplyMaskCore,
9048
+ DualSendButtons,
9049
+ MaskRuleEditor,
9050
+ WorkspaceSettingsView,
8444
9051
  },
8445
9052
  };
8446
9053
  },
package/index.js CHANGED
@@ -50,9 +50,11 @@ const SELF_UPDATE_DELAY_MS = 600;
50
50
  /** Request body bound for the small JSON commands. */
51
51
  const BODY_LIMIT = 16 * 1024;
52
52
 
53
- /** Per-workspace prompts live under the workspace's own .dsh directory. */
53
+ /** Per-workspace state files live under the workspace's own .dsh directory. */
54
54
  const PROMPTS_DIR = join('.dsh', 'dsh-powerup');
55
55
  const PROMPTS_FILE = 'prompts.json';
56
+ /** Per-workspace mask rules used by the content-rendering enhancement. */
57
+ const MASK_RULES_FILE = 'mask-rules.json';
56
58
 
57
59
  /** The moment this Host process started; a profile file newer than it may await a restart. */
58
60
  const HOST_STARTED_AT = Date.now() - process.uptime() * 1000;
@@ -348,14 +350,15 @@ export async function performSelfUpdate(ctx, version, registry, options = {}) {
348
350
  }
349
351
 
350
352
  /**
351
- * Absolute path of one workspace's prompt store. The workspace path is
353
+ * Absolute path of one workspace's state file. The workspace path is
352
354
  * canonical (realpath) and the id is a uuid, so a stray id can never escape
353
355
  * into an arbitrary directory.
354
356
  * @param {import('@deepseek-ai/cordis').Context} ctx
355
357
  * @param {string} workspaceId
358
+ * @param {string} fileName
356
359
  * @returns {string | undefined}
357
360
  */
358
- function promptStorePath(ctx, workspaceId) {
361
+ function workspaceStorePath(ctx, workspaceId, fileName) {
359
362
  if (typeof workspaceId !== 'string' || workspaceId === '') return undefined;
360
363
  const registry = ctx?.get?.('workspaceRegistry');
361
364
  const workspace = registry?.get?.(workspaceId);
@@ -363,15 +366,20 @@ function promptStorePath(ctx, workspaceId) {
363
366
  return undefined;
364
367
  }
365
368
  const root = resolvePath(workspace.path);
366
- const target = resolvePath(root, PROMPTS_DIR, PROMPTS_FILE);
369
+ const target = resolvePath(root, PROMPTS_DIR, fileName);
367
370
  // The store must stay inside the workspace, whatever the registry returned.
368
371
  const prefix = root.endsWith(sep) ? root : root + sep;
369
372
  if (!target.startsWith(prefix)) return undefined;
370
373
  return target;
371
374
  }
372
375
 
373
- /** Read one workspace's prompts from disk; a missing file is an empty list. */
374
- function readPromptStore(filePath) {
376
+ /** One workspace's prompt store path. */
377
+ function promptStorePath(ctx, workspaceId) {
378
+ return workspaceStorePath(ctx, workspaceId, PROMPTS_FILE);
379
+ }
380
+
381
+ /** Read one workspace's JSON list from disk; a missing file is an empty list. */
382
+ function readJsonStore(filePath) {
375
383
  try {
376
384
  const parsed = JSON.parse(readFileSync(filePath, 'utf8'));
377
385
  return Array.isArray(parsed) ? parsed : [];
@@ -381,6 +389,11 @@ function readPromptStore(filePath) {
381
389
  }
382
390
  }
383
391
 
392
+ /** Read one workspace's prompts from disk; a missing file is an empty list. */
393
+ function readPromptStore(filePath) {
394
+ return readJsonStore(filePath);
395
+ }
396
+
384
397
  /**
385
398
  * @param {import('node:http').IncomingMessage} req
386
399
  * @param {import('node:http').ServerResponse} res
@@ -394,11 +407,51 @@ async function handle(req, res, ctx) {
394
407
 
395
408
  const url = new URL(req.url ?? ROUTE, 'http://localhost');
396
409
  const op = url.pathname.slice(ROUTE.length).replace(/^\/+/u, '') || url.searchParams.get('op') || '';
397
- if (op !== '' && op !== 'restart' && op !== 'close' && op !== 'self-update' && op !== 'audit' && op !== 'job-kill' && op !== 'prompts') {
410
+ if (op !== '' && op !== 'restart' && op !== 'close' && op !== 'self-update' && op !== 'audit' && op !== 'job-kill' && op !== 'prompts' && op !== 'mask-rules') {
398
411
  sendJson(res, { ok: false, error: 'not-found' }, 404);
399
412
  return;
400
413
  }
401
414
 
415
+ if (op === 'mask-rules') {
416
+ const targetId = req.method === 'GET'
417
+ ? (url.searchParams.get('workspaceId') ?? '')
418
+ : '';
419
+ let workspaceId = targetId;
420
+ if (req.method === 'POST') {
421
+ try {
422
+ const body = await readJsonBody(req);
423
+ workspaceId = typeof body?.workspaceId === 'string' ? body.workspaceId.trim() : '';
424
+ const filePath = workspaceStorePath(ctx, workspaceId, MASK_RULES_FILE);
425
+ if (filePath === undefined) {
426
+ sendJson(res, { ok: false, code: 'workspace-not-found', error: 'workspace not found' }, 404);
427
+ return;
428
+ }
429
+ const rules = Array.isArray(body?.rules) ? body.rules : [];
430
+ mkdirSync(dirname(filePath), { recursive: true });
431
+ writeFileSync(filePath, JSON.stringify(rules, null, 2) + '\n', 'utf8');
432
+ sendJson(res, { ok: true, workspaceId, rules });
433
+ } catch (error) {
434
+ sendJson(res, { ok: false, error: String(error?.message ?? error) }, 500);
435
+ }
436
+ return;
437
+ }
438
+ if (req.method !== 'GET') {
439
+ sendJson(res, { ok: false, error: 'method-not-allowed' }, 405);
440
+ return;
441
+ }
442
+ try {
443
+ const filePath = workspaceStorePath(ctx, workspaceId, MASK_RULES_FILE);
444
+ if (filePath === undefined) {
445
+ sendJson(res, { ok: false, code: 'workspace-not-found', error: 'workspace not found' }, 404);
446
+ return;
447
+ }
448
+ sendJson(res, { ok: true, workspaceId, rules: readJsonStore(filePath) });
449
+ } catch (error) {
450
+ sendJson(res, { ok: false, error: String(error?.message ?? error) }, 500);
451
+ }
452
+ return;
453
+ }
454
+
402
455
  if (op === 'prompts') {
403
456
  // The active workspace's directory holds the whole prompt store, including
404
457
  // prompts scoped to other workspaces and the "all workspaces" ones.
@@ -591,6 +644,9 @@ export const __test = {
591
644
  profileDirectory,
592
645
  promptStorePath,
593
646
  readPromptStore,
647
+ workspaceStorePath,
648
+ readJsonStore,
649
+ MASK_RULES_FILE,
594
650
  HOST_STARTED_AT,
595
651
  SELF_VERSION,
596
652
  ROUTE,
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Power-Up",
4
- "description": "A set of small, independently toggleable upgrades for DeepSeek Harness on the Power-Up page: trajectory context menu and step references, job stop reasons, one-click plugin install, sidebar icon grid and back-to-top, session switching and locating, and workspace prompts."
4
+ "description": "Independently toggleable upgrades for DeepSeek Harness on the Power-Up page: trajectory context menu and step references, job stop reasons, one-click plugin install, sidebar icon grid and back-to-top, session switching and locating, workspace prompts, plus conversation rendering enhancements (regex reply masking) and dual send buttons (queued/interrupt)."
5
5
  }
6
6
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Power-Up",
4
- "description": "为 DeepSeek Harness 提供一组可在 Power-Up 页面独立开关的小型增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格与回到顶部、会话切换与定位、工作区提示词。"
4
+ "description": "为 DeepSeek Harness 提供一组可在 Power-Up 页面独立开关的增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格与回到顶部、会话切换与定位、工作区提示词,以及会话内容渲染增强(回复内容正则屏蔽)和双发送按钮(等待/插话)。"
5
5
  }
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.8.19",
3
+ "version": "0.9.0",
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",