@restregular/dsh-powerup 0.9.0 → 0.9.2
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 +18 -8
- package/client.js +153 -85
- package/index.js +68 -65
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -374,16 +374,26 @@ 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
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
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 **
|
|
385
|
-
|
|
386
|
-
|
|
391
|
+
are managed from the **PowerUp** tab in any conversation header (it appears
|
|
392
|
+
after Trajectory). Both prompts and workspace rules live in ONE central store
|
|
393
|
+
under `~/.dsh/dsh-powerup/` (`prompts.json` / `mask-rules.json`), with each
|
|
394
|
+
record carrying its own workspace id, so the settings page can manage every
|
|
395
|
+
workspace together. Older per-workspace files are migrated automatically on
|
|
396
|
+
first access.
|
|
387
397
|
|
|
388
398
|
### Dual send buttons
|
|
389
399
|
|
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.
|
|
86
|
+
const VERSION = '0.9.2';
|
|
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
|
|
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
|
|
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
|
|
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)',
|
|
@@ -776,14 +786,15 @@
|
|
|
776
786
|
}
|
|
777
787
|
|
|
778
788
|
// ------------------------------------------------------------------
|
|
779
|
-
// Workspace prompts store.
|
|
780
|
-
//
|
|
781
|
-
//
|
|
782
|
-
//
|
|
789
|
+
// Workspace prompts store. All workspaces' prompts live in ONE central
|
|
790
|
+
// file (~/.dsh/dsh-powerup/prompts.json) through a Host route; each
|
|
791
|
+
// record carries its own workspaceId ('' = global). The browser keeps an
|
|
792
|
+
// in-memory cache of the whole list so the hero dropdown and the
|
|
793
|
+
// management tab see every workspace together.
|
|
783
794
|
// ------------------------------------------------------------------
|
|
784
795
|
const PROMPTS_API = '/dsh-powerup/api/prompts';
|
|
785
796
|
let promptsCache = [];
|
|
786
|
-
let
|
|
797
|
+
let promptsLoaded = false;
|
|
787
798
|
|
|
788
799
|
/** Normalize an arbitrary value into a clean prompt record. */
|
|
789
800
|
function normalizePrompt(item) {
|
|
@@ -802,17 +813,14 @@
|
|
|
802
813
|
}
|
|
803
814
|
|
|
804
815
|
/**
|
|
805
|
-
* Load the
|
|
806
|
-
*
|
|
807
|
-
* open provides the file; a missing file is simply an empty store.
|
|
816
|
+
* Load the whole central store once. The list includes every workspace's
|
|
817
|
+
* prompts; callers filter by workspaceId through `promptsForWorkspace`.
|
|
808
818
|
*/
|
|
809
|
-
async function loadPrompts(
|
|
810
|
-
|
|
811
|
-
|
|
819
|
+
async function loadPrompts() {
|
|
820
|
+
if (promptsLoaded) return promptsCache;
|
|
821
|
+
promptsLoaded = true;
|
|
812
822
|
try {
|
|
813
|
-
const response = await fetch(PROMPTS_API
|
|
814
|
-
headers: { accept: 'application/json' },
|
|
815
|
-
});
|
|
823
|
+
const response = await fetch(PROMPTS_API, { headers: { accept: 'application/json' } });
|
|
816
824
|
const data = response.ok ? await response.json() : null;
|
|
817
825
|
const list = data !== null && Array.isArray(data.prompts) ? data.prompts : [];
|
|
818
826
|
promptsCache = list.map(normalizePrompt).filter(Boolean);
|
|
@@ -826,12 +834,12 @@
|
|
|
826
834
|
function writePrompts(list) {
|
|
827
835
|
const next = (Array.isArray(list) ? list : []).map(normalizePrompt).filter(Boolean);
|
|
828
836
|
promptsCache = next;
|
|
837
|
+
promptsLoaded = true;
|
|
829
838
|
emitPrompts();
|
|
830
|
-
const id = promptStoreWorkspace;
|
|
831
839
|
fetch(PROMPTS_API, {
|
|
832
840
|
method: 'POST',
|
|
833
841
|
headers: { 'content-type': 'application/json', accept: 'application/json' },
|
|
834
|
-
body: JSON.stringify({
|
|
842
|
+
body: JSON.stringify({ prompts: next }),
|
|
835
843
|
}).catch(() => {
|
|
836
844
|
/* The in-memory list still works for this page. */
|
|
837
845
|
});
|
|
@@ -864,15 +872,18 @@
|
|
|
864
872
|
|
|
865
873
|
// ------------------------------------------------------------------
|
|
866
874
|
// Mask rules for the content-rendering enhancement.
|
|
867
|
-
// Global rules live in localStorage
|
|
868
|
-
//
|
|
869
|
-
//
|
|
875
|
+
// Global rules live in localStorage (already shared by every workspace
|
|
876
|
+
// in this browser). Workspace rules live in ONE central file
|
|
877
|
+
// (~/.dsh/dsh-powerup/mask-rules.json) via a Host route, together with
|
|
878
|
+
// every other workspace's rules; the client filters by workspaceId.
|
|
879
|
+
// Both lists share one normalize/compile helper.
|
|
870
880
|
// ------------------------------------------------------------------
|
|
871
881
|
const MASK_RULES_KEY = 'dsh-powerup:mask-rules:v1';
|
|
872
882
|
const MASK_RULES_API = '/dsh-powerup/api/mask-rules';
|
|
873
883
|
const MASK_PLACEHOLDER = '[已屏蔽]';
|
|
874
884
|
let globalMaskRules = readGlobalMaskRules();
|
|
875
|
-
let
|
|
885
|
+
let allWorkspaceMaskRules = [];
|
|
886
|
+
let maskRulesLoaded = false;
|
|
876
887
|
let maskRulesWorkspace = '';
|
|
877
888
|
const maskRulesListeners = new Set();
|
|
878
889
|
|
|
@@ -884,6 +895,9 @@
|
|
|
884
895
|
pattern: typeof item.pattern === 'string' ? item.pattern : '',
|
|
885
896
|
replacement: typeof item.replacement === 'string' ? item.replacement : '',
|
|
886
897
|
enabled: item.enabled !== false,
|
|
898
|
+
// Existing rules predate this flag and were regexes, so default true.
|
|
899
|
+
regex: item.regex !== false,
|
|
900
|
+
workspaceId: typeof item.workspaceId === 'string' ? item.workspaceId : '',
|
|
887
901
|
scope: item.scope === 'workspace' ? 'workspace' : 'global',
|
|
888
902
|
};
|
|
889
903
|
}
|
|
@@ -907,32 +921,44 @@
|
|
|
907
921
|
emitMaskRules();
|
|
908
922
|
}
|
|
909
923
|
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
924
|
+
/** Workspace rules belonging to one workspace id. */
|
|
925
|
+
function workspaceRulesFor(id) {
|
|
926
|
+
const ws = typeof id === 'string' ? id : '';
|
|
927
|
+
return allWorkspaceMaskRules.filter((rule) => rule.workspaceId === ws);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
/** Load the whole central rules file once (all workspaces). */
|
|
931
|
+
async function loadWorkspaceMaskRules() {
|
|
932
|
+
if (maskRulesLoaded) return allWorkspaceMaskRules;
|
|
933
|
+
maskRulesLoaded = true;
|
|
913
934
|
try {
|
|
914
|
-
const response = await fetch(MASK_RULES_API
|
|
915
|
-
headers: { accept: 'application/json' },
|
|
916
|
-
});
|
|
935
|
+
const response = await fetch(MASK_RULES_API, { headers: { accept: 'application/json' } });
|
|
917
936
|
const data = response.ok ? await response.json() : null;
|
|
918
937
|
const rules = data !== null && Array.isArray(data.rules) ? data.rules : [];
|
|
919
|
-
|
|
920
|
-
.map((rule) => ({ ...rule, scope: 'workspace' }));
|
|
938
|
+
allWorkspaceMaskRules = rules.map(normalizeMaskRule).filter(Boolean)
|
|
939
|
+
.map((rule) => ({ ...rule, scope: 'workspace', workspaceId: rule.workspaceId ?? '' }));
|
|
921
940
|
} catch {
|
|
922
941
|
/* Host unavailable: keep the last known list. */
|
|
923
942
|
}
|
|
924
943
|
emitMaskRules();
|
|
925
|
-
return
|
|
944
|
+
return allWorkspaceMaskRules;
|
|
926
945
|
}
|
|
927
946
|
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
947
|
+
/** Replace the rules of one workspace, leaving other workspaces intact. */
|
|
948
|
+
function writeWorkspaceMaskRules(list, workspaceId) {
|
|
949
|
+
const ws = typeof workspaceId === 'string' ? workspaceId : maskRulesWorkspace;
|
|
950
|
+
const next = (Array.isArray(list) ? list : []).map(normalizeMaskRule).filter(Boolean)
|
|
951
|
+
.map((rule) => ({ ...rule, scope: 'workspace', workspaceId: ws }));
|
|
952
|
+
allWorkspaceMaskRules = [
|
|
953
|
+
...allWorkspaceMaskRules.filter((rule) => rule.workspaceId !== ws),
|
|
954
|
+
...next,
|
|
955
|
+
];
|
|
956
|
+
maskRulesLoaded = true;
|
|
931
957
|
emitMaskRules();
|
|
932
958
|
fetch(MASK_RULES_API, {
|
|
933
959
|
method: 'POST',
|
|
934
960
|
headers: { 'content-type': 'application/json', accept: 'application/json' },
|
|
935
|
-
body: JSON.stringify({
|
|
961
|
+
body: JSON.stringify({ rules: allWorkspaceMaskRules }),
|
|
936
962
|
}).catch(() => {
|
|
937
963
|
/* The in-memory list still works this page. */
|
|
938
964
|
});
|
|
@@ -950,19 +976,31 @@
|
|
|
950
976
|
|
|
951
977
|
/** Rules that apply to the current workspace: global plus its own. */
|
|
952
978
|
function activeMaskRules() {
|
|
953
|
-
|
|
979
|
+
const ws = typeof maskRulesWorkspace === 'string' ? maskRulesWorkspace : '';
|
|
980
|
+
return [...globalMaskRules, ...workspaceRulesFor(ws)]
|
|
981
|
+
.filter((rule) => rule.enabled && rule.pattern !== '');
|
|
954
982
|
}
|
|
955
983
|
|
|
956
|
-
/**
|
|
984
|
+
/** Escape a literal string so it can be used as an exact regex source. */
|
|
985
|
+
function escapeRegExp(text) {
|
|
986
|
+
return text.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* Compile rules once per change into reusable RegExp objects. Regex mode
|
|
991
|
+
* uses 'g' (all), 'u' (unicode), 'm' (^/$ per line) and 's' (dot crosses
|
|
992
|
+
* newlines); plain-text mode escapes the pattern for a literal match.
|
|
993
|
+
*/
|
|
957
994
|
function compileMaskRules(list) {
|
|
958
995
|
const compiled = [];
|
|
959
996
|
for (const rule of Array.isArray(list) ? list : []) {
|
|
960
997
|
if (rule === null || rule.enabled === false || typeof rule.pattern !== 'string' || rule.pattern === '') continue;
|
|
998
|
+
const isRegex = rule.regex !== false;
|
|
961
999
|
try {
|
|
962
1000
|
compiled.push({
|
|
963
|
-
re: new RegExp(rule.pattern, 'gu'),
|
|
964
|
-
|
|
965
|
-
|
|
1001
|
+
re: isRegex ? new RegExp(rule.pattern, 'gums') : new RegExp(escapeRegExp(rule.pattern), 'gu'),
|
|
1002
|
+
// A blank replacement is intentional: remove the matched text.
|
|
1003
|
+
replacement: typeof rule.replacement === 'string' ? rule.replacement : '',
|
|
966
1004
|
});
|
|
967
1005
|
} catch {
|
|
968
1006
|
/* Invalid regex is skipped, never throws into rendering. */
|
|
@@ -1000,14 +1038,10 @@
|
|
|
1000
1038
|
return t('prompts.summaryFallback');
|
|
1001
1039
|
}
|
|
1002
1040
|
|
|
1003
|
-
function usePrompts(
|
|
1041
|
+
function usePrompts() {
|
|
1004
1042
|
const [value, setValue] = useState(readPrompts);
|
|
1005
1043
|
useEffect(() => subscribePrompts(() => setValue(readPrompts())), []);
|
|
1006
|
-
useEffect(() => {
|
|
1007
|
-
if (typeof workspaceId === 'string' && workspaceId !== '') {
|
|
1008
|
-
void loadPrompts(workspaceId);
|
|
1009
|
-
}
|
|
1010
|
-
}, [workspaceId]);
|
|
1044
|
+
useEffect(() => { void loadPrompts(); }, []);
|
|
1011
1045
|
return value;
|
|
1012
1046
|
}
|
|
1013
1047
|
|
|
@@ -2719,7 +2753,8 @@
|
|
|
2719
2753
|
? resolveWorkspaceIdFromSnapshot(workspaces.list.getSnapshot(), sessionId)
|
|
2720
2754
|
: '';
|
|
2721
2755
|
if (typeof wsId === 'string' && wsId !== '' && wsId !== maskRulesWorkspace) {
|
|
2722
|
-
|
|
2756
|
+
maskRulesWorkspace = wsId;
|
|
2757
|
+
void loadWorkspaceMaskRules();
|
|
2723
2758
|
}
|
|
2724
2759
|
}
|
|
2725
2760
|
return () => {
|
|
@@ -3862,8 +3897,14 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
3862
3897
|
.dsh-powerup-dual-send{display:inline-flex;align-items:center;gap:4px}
|
|
3863
3898
|
.dsh-powerup-mask-editor{display:flex;flex-direction:column;gap:10px}
|
|
3864
3899
|
.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)}
|
|
3900
|
+
.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
3901
|
.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
3902
|
.dsh-powerup-mask-input.invalid{border-color:var(--dsw-alias-state-error-primary)}
|
|
3903
|
+
.dsh-powerup-mask-replacement{display:flex;align-items:center;gap:4px;min-width:0}
|
|
3904
|
+
.dsh-powerup-mask-replacement .dsh-powerup-mask-input{flex:1 1 auto;min-width:0}
|
|
3905
|
+
.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}
|
|
3906
|
+
.dsh-powerup-mask-default:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
3907
|
+
.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
3908
|
.dsh-powerup-mask-empty{color:var(--dsw-alias-label-secondary);font-size:12px}
|
|
3868
3909
|
@media (max-width:680px){.dsh-powerup-mask-row{grid-template-columns:minmax(0,1fr)}}
|
|
3869
3910
|
`;
|
|
@@ -3878,20 +3919,20 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
3878
3919
|
.dsh-powerup-prompt-trigger-label{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
3879
3920
|
.dsh-powerup-prompt-trigger-chevron{flex:none;display:inline-flex;color:var(--dsw-alias-label-tertiary);transition:transform .15s ease}
|
|
3880
3921
|
.dsh-powerup-prompt-trigger[aria-expanded=true] .dsh-powerup-prompt-trigger-chevron{transform:rotate(180deg)}
|
|
3881
|
-
.dsh-powerup-prompt-pop{position:fixed;z-index:1600;box-sizing:border-box;display:flex;flex-direction:column;overflow:hidden;border:0;border-radius:
|
|
3922
|
+
.dsh-powerup-prompt-pop{position:fixed;z-index:1600;box-sizing:border-box;display:flex;flex-direction:column;overflow:hidden;overflow-x:hidden;border:0;border-radius:10px;background:var(--dsw-alias-bg-layer-2);box-shadow:var(--dsw-elevation-prominent);--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:1.5;opacity:0;transform:translateY(-4px);transition:opacity .12s ease,transform .12s ease;pointer-events:auto;--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2)}
|
|
3882
3923
|
.dsh-powerup-prompt-pop.is-open{opacity:1;transform:none}
|
|
3883
|
-
.dsh-powerup-prompt-pop-head{display:flex;align-items:center;gap:6px;padding:8px 11px 7px;color:var(--dsw-alias-label-tertiary);font-size:10.5px;font-weight:600;letter-spacing:.03em}
|
|
3884
|
-
.dsh-powerup-prompt-pop-list{display:flex;flex-direction:column;gap:1px;padding:4px;overflow-y:auto}
|
|
3885
|
-
.dsh-powerup-prompt-pop-item{display:flex;align-items:center;gap:4px;width:100%;min-height:34px;padding:2px 4px 2px 7px;border:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;text-align:left}
|
|
3924
|
+
.dsh-powerup-prompt-pop-head{flex:none;display:flex;align-items:center;gap:6px;padding:8px 11px 7px;color:var(--dsw-alias-label-tertiary);font-size:10.5px;font-weight:600;letter-spacing:.03em}
|
|
3925
|
+
.dsh-powerup-prompt-pop-list{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;gap:1px;padding:4px;overflow-y:auto;overflow-x:hidden}
|
|
3926
|
+
.dsh-powerup-prompt-pop-item{display:flex;align-items:center;gap:4px;width:100%;min-width:0;min-height:34px;padding:2px 4px 2px 7px;border:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;text-align:left}
|
|
3886
3927
|
.dsh-powerup-prompt-pop-item:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
3887
3928
|
.dsh-powerup-prompt-pop-main{flex:1 1 auto;display:flex;flex-direction:column;gap:1px;min-width:0;padding:3px 0;border:0;background:transparent;color:inherit;font:inherit;text-align:left;cursor:pointer}
|
|
3888
3929
|
.dsh-powerup-prompt-pop-name{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12.5px;line-height:18px}
|
|
3889
3930
|
.dsh-powerup-prompt-pop-preview{display:block;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary);font-size:10.5px;line-height:15px}
|
|
3890
|
-
.dsh-powerup-prompt-pop-send{flex:none;display:inline-flex;align-items:center;gap:4px;height:24px;padding:0 7px;border:.5px solid var(--dsw-alias-border-l2);border-radius:
|
|
3931
|
+
.dsh-powerup-prompt-pop-send{flex:none;display:inline-flex;align-items:center;gap:4px;height:24px;padding:0 7px;border:.5px solid var(--dsw-alias-border-l2);border-radius:8px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font:inherit;font-size:10.5px;line-height:16px;white-space:nowrap;cursor:pointer;transition:background .12s ease,color .12s ease,border-color .12s ease}
|
|
3891
3932
|
.dsh-powerup-prompt-pop-send:hover{border-color:var(--dsw-alias-state-business-primary);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-brand-primary)}
|
|
3892
3933
|
.dsh-powerup-prompt-pop-send:focus-visible,.dsh-powerup-prompt-pop-main:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px}
|
|
3893
|
-
.dsh-powerup-prompt-pop-sep{height:1px;margin:4px 6px;background:var(--dsw-alias-border-l1)}
|
|
3894
|
-
.dsh-powerup-prompt-pop-create{display:flex;align-items:center;gap:7px;width:100%;min-height:32px;padding:0 10px;border:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-brand-primary);font:inherit;font-size:12px;line-height:18px;cursor:pointer}
|
|
3934
|
+
.dsh-powerup-prompt-pop-sep{flex:none;height:1px;margin:4px 6px;background:var(--dsw-alias-border-l1)}
|
|
3935
|
+
.dsh-powerup-prompt-pop-create{flex:none;display:flex;align-items:center;gap:7px;width:100%;min-height:32px;padding:0 10px;border:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-brand-primary);font:inherit;font-size:12px;line-height:18px;cursor:pointer}
|
|
3895
3936
|
.dsh-powerup-prompt-pop-create:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
3896
3937
|
.dsh-powerup-prompt-pop-empty{padding:12px 10px;color:var(--dsw-alias-label-tertiary);font-size:11.5px;line-height:1.55;text-align:center}
|
|
3897
3938
|
/* DSH-memory-style tab bar: inline segmented control. */
|
|
@@ -3937,7 +3978,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
3937
3978
|
.dsh-powerup-ws-value{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
3938
3979
|
.dsh-powerup-ws-chevron{flex:none;display:inline-flex;color:var(--dsw-alias-label-tertiary);transition:transform .15s ease}
|
|
3939
3980
|
.dsh-powerup-ws-trigger[aria-expanded=true] .dsh-powerup-ws-chevron{transform:rotate(180deg)}
|
|
3940
|
-
.dsh-powerup-ws-menu{position:fixed;z-index:1600;box-sizing:border-box;min-width:180px;max-width:min(360px,calc(100vw - 24px));max-height:min(320px,50vh);overflow-y:auto;padding:4px;border:0;border-radius:
|
|
3981
|
+
.dsh-powerup-ws-menu{position:fixed;z-index:1600;box-sizing:border-box;min-width:180px;max-width:min(360px,calc(100vw - 24px));max-height:min(320px,50vh);overflow-y:auto;padding:4px;border:0;border-radius:10px;background:var(--dsw-alias-bg-layer-2);box-shadow:var(--dsw-elevation-prominent);--dsw-elevation-stroke-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-primary);font-size:12.5px;line-height:1.5;--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2)}
|
|
3941
3982
|
.dsh-powerup-ws-option{display:flex;align-items:center;gap:8px;width:100%;min-height:30px;padding:0 9px;border:0;border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer}
|
|
3942
3983
|
.dsh-powerup-ws-option:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
3943
3984
|
.dsh-powerup-ws-option[aria-selected=true]{background:var(--dsw-alias-interactive-bg-active)}
|
|
@@ -8196,11 +8237,16 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8196
8237
|
* Shared editor for a list of mask rules. `scope` is 'global' or
|
|
8197
8238
|
* 'workspace'; writes go through the matching store functions.
|
|
8198
8239
|
*/
|
|
8199
|
-
function MaskRuleEditor({ scope, t }) {
|
|
8240
|
+
function MaskRuleEditor({ scope, t, workspaceId }) {
|
|
8200
8241
|
const rules = useMaskRules();
|
|
8201
|
-
const
|
|
8242
|
+
const ws = typeof workspaceId === 'string' ? workspaceId : maskRulesWorkspace;
|
|
8243
|
+
const visible = rules.filter((rule) => {
|
|
8244
|
+
const ruleScope = rule.scope || 'global';
|
|
8245
|
+
if (ruleScope !== scope) return false;
|
|
8246
|
+
return scope === 'workspace' ? (rule.workspaceId ?? '') === ws : true;
|
|
8247
|
+
});
|
|
8202
8248
|
const commit = (next) => {
|
|
8203
|
-
if (scope === 'workspace') writeWorkspaceMaskRules(next);
|
|
8249
|
+
if (scope === 'workspace') writeWorkspaceMaskRules(next, ws);
|
|
8204
8250
|
else writeGlobalMaskRules(next);
|
|
8205
8251
|
};
|
|
8206
8252
|
const update = (id, patch) => {
|
|
@@ -8210,7 +8256,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8210
8256
|
commit(visible.filter((rule) => rule.id !== id));
|
|
8211
8257
|
};
|
|
8212
8258
|
const add = () => {
|
|
8213
|
-
commit([...visible, { id: newId(), pattern: '', replacement: '', enabled: true, scope }]);
|
|
8259
|
+
commit([...visible, { id: newId(), pattern: '', replacement: '', enabled: true, scope, workspaceId: scope === 'workspace' ? ws : '' }]);
|
|
8214
8260
|
};
|
|
8215
8261
|
const title = scope === 'workspace' ? t('mask.workspaceTitle') : t('mask.globalTitle');
|
|
8216
8262
|
return h('div', { className: 'dsh-powerup-mask-editor' },
|
|
@@ -8218,27 +8264,47 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8218
8264
|
h('p', { className: 'dsh-powerup-card-desc' }, t('mask.hint')),
|
|
8219
8265
|
...visible.map((rule) => {
|
|
8220
8266
|
let invalid = false;
|
|
8221
|
-
if (rule.pattern !== '') {
|
|
8222
|
-
try { new RegExp(rule.pattern); } catch { invalid = true; }
|
|
8267
|
+
if (rule.pattern !== '' && rule.regex !== false) {
|
|
8268
|
+
try { new RegExp(rule.pattern, 'gums'); } catch { invalid = true; }
|
|
8223
8269
|
}
|
|
8224
8270
|
return h('div', { key: rule.id, className: 'dsh-powerup-mask-row' },
|
|
8225
|
-
h('
|
|
8226
|
-
|
|
8227
|
-
|
|
8228
|
-
|
|
8229
|
-
|
|
8230
|
-
|
|
8231
|
-
|
|
8232
|
-
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
|
|
8236
|
-
|
|
8237
|
-
|
|
8238
|
-
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8271
|
+
h('div', { className: 'dsh-powerup-mask-replacement' },
|
|
8272
|
+
h('input', {
|
|
8273
|
+
type: 'text',
|
|
8274
|
+
className: 'dsh-powerup-mask-input' + (invalid ? ' invalid' : ''),
|
|
8275
|
+
value: rule.pattern,
|
|
8276
|
+
placeholder: t('mask.patternPlaceholder'),
|
|
8277
|
+
'aria-label': t('mask.pattern'),
|
|
8278
|
+
title: invalid ? t('mask.invalid') : t('mask.pattern'),
|
|
8279
|
+
onChange: (event) => update(rule.id, { pattern: event.target.value }),
|
|
8280
|
+
}),
|
|
8281
|
+
h('button', {
|
|
8282
|
+
type: 'button',
|
|
8283
|
+
role: 'switch',
|
|
8284
|
+
'aria-checked': rule.regex !== false ? 'true' : 'false',
|
|
8285
|
+
className: 'dsh-powerup-mask-default' + (rule.regex !== false ? ' on' : ''),
|
|
8286
|
+
title: t('mask.regexHint'),
|
|
8287
|
+
'aria-label': t('mask.regexHint'),
|
|
8288
|
+
onClick: () => update(rule.id, { regex: rule.regex === false }),
|
|
8289
|
+
}, t('mask.regex')),
|
|
8290
|
+
),
|
|
8291
|
+
h('div', { className: 'dsh-powerup-mask-replacement' },
|
|
8292
|
+
h('input', {
|
|
8293
|
+
type: 'text',
|
|
8294
|
+
className: 'dsh-powerup-mask-input',
|
|
8295
|
+
value: rule.replacement,
|
|
8296
|
+
placeholder: t('mask.replacementPlaceholder'),
|
|
8297
|
+
'aria-label': t('mask.replacement'),
|
|
8298
|
+
onChange: (event) => update(rule.id, { replacement: event.target.value }),
|
|
8299
|
+
}),
|
|
8300
|
+
h('button', {
|
|
8301
|
+
type: 'button',
|
|
8302
|
+
className: 'dsh-powerup-mask-default',
|
|
8303
|
+
title: t('mask.useDefaultHint'),
|
|
8304
|
+
'aria-label': t('mask.useDefaultHint'),
|
|
8305
|
+
onClick: () => update(rule.id, { replacement: MASK_PLACEHOLDER }),
|
|
8306
|
+
}, t('mask.useDefault')),
|
|
8307
|
+
),
|
|
8242
8308
|
h('button', {
|
|
8243
8309
|
type: 'button',
|
|
8244
8310
|
role: 'switch',
|
|
@@ -8265,8 +8331,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8265
8331
|
function useMaskRules() {
|
|
8266
8332
|
const [revision, setRevision] = useState(0);
|
|
8267
8333
|
useEffect(() => subscribeMaskRules(() => setRevision((v) => v + 1)), []);
|
|
8334
|
+
useEffect(() => { void loadWorkspaceMaskRules(); }, []);
|
|
8268
8335
|
void revision;
|
|
8269
|
-
return [...globalMaskRules, ...
|
|
8336
|
+
return [...globalMaskRules, ...allWorkspaceMaskRules];
|
|
8270
8337
|
}
|
|
8271
8338
|
|
|
8272
8339
|
/**
|
|
@@ -8395,7 +8462,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8395
8462
|
const workspaceSelector = useMemo(() => (snapshot) => resolveWorkspaceIdFromSnapshot(snapshot, ownerId), [ownerId]);
|
|
8396
8463
|
const workspaceId = typeof useWorkspaces === 'function' ? useWorkspaces(workspaceSelector) ?? '' : '';
|
|
8397
8464
|
useEffect(() => {
|
|
8398
|
-
if (typeof workspaceId === 'string' && workspaceId !== '')
|
|
8465
|
+
if (typeof workspaceId === 'string' && workspaceId !== '') maskRulesWorkspace = workspaceId;
|
|
8466
|
+
void loadWorkspaceMaskRules();
|
|
8399
8467
|
}, [workspaceId]);
|
|
8400
8468
|
void rules; void settings;
|
|
8401
8469
|
return h('div', { className: 'dsh-powerup-page' },
|
|
@@ -8406,7 +8474,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8406
8474
|
h('p', null, t('mask.sessionDesc')),
|
|
8407
8475
|
),
|
|
8408
8476
|
),
|
|
8409
|
-
h(MaskRuleEditor, { scope: 'workspace', t }),
|
|
8477
|
+
h(MaskRuleEditor, { scope: 'workspace', t, workspaceId }),
|
|
8410
8478
|
),
|
|
8411
8479
|
);
|
|
8412
8480
|
}
|
|
@@ -8894,7 +8962,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
8894
8962
|
register('conversation.view', {
|
|
8895
8963
|
id: 'powerup-settings',
|
|
8896
8964
|
order: 20,
|
|
8897
|
-
label: () => translateCurrent('mask.
|
|
8965
|
+
label: () => translateCurrent('mask.viewTabLabel'),
|
|
8898
8966
|
}, (props) => h(WorkspaceSettingsView, { ...props, ctx }), 'dsh-powerup: workspace settings view');
|
|
8899
8967
|
|
|
8900
8968
|
// The update control drives the built-in plugin manager through its
|
package/index.js
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
import { randomUUID } from 'node:crypto';
|
|
34
|
-
import { appendFileSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
34
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
35
35
|
import { dirname, join, resolve as resolvePath, sep } from 'node:path';
|
|
36
36
|
import { homedir } from 'node:os';
|
|
37
37
|
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
@@ -50,11 +50,18 @@ 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
|
-
/**
|
|
54
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Central state lives under ~/.dsh/dsh-powerup so one file holds every
|
|
55
|
+
* workspace's records (each record carries its own workspaceId). This lets the
|
|
56
|
+
* Power-Up settings page manage all workspaces in one place. Older releases
|
|
57
|
+
* kept these files in each workspace's own `.dsh/dsh-powerup`, migrated once
|
|
58
|
+
* on first access by `migrateLegacyStore`.
|
|
59
|
+
*/
|
|
60
|
+
const STORE_DIR_NAME = 'dsh-powerup';
|
|
55
61
|
const PROMPTS_FILE = 'prompts.json';
|
|
56
|
-
/** Per-workspace mask rules used by the content-rendering enhancement. */
|
|
57
62
|
const MASK_RULES_FILE = 'mask-rules.json';
|
|
63
|
+
/** Legacy relative location inside a workspace, used only for migration. */
|
|
64
|
+
const LEGACY_STORE_DIR = join('.dsh', 'dsh-powerup');
|
|
58
65
|
|
|
59
66
|
/** The moment this Host process started; a profile file newer than it may await a restart. */
|
|
60
67
|
const HOST_STARTED_AT = Date.now() - process.uptime() * 1000;
|
|
@@ -350,35 +357,23 @@ export async function performSelfUpdate(ctx, version, registry, options = {}) {
|
|
|
350
357
|
}
|
|
351
358
|
|
|
352
359
|
/**
|
|
353
|
-
* Absolute path of
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
* @param {import('@deepseek-ai/cordis').Context} ctx
|
|
357
|
-
* @param {string} workspaceId
|
|
360
|
+
* Absolute path of the central state file under ~/.dsh/dsh-powerup. One file
|
|
361
|
+
* holds every workspace's records; no workspace registry lookup is needed, so
|
|
362
|
+
* the store works even for workspaces not currently registered.
|
|
358
363
|
* @param {string} fileName
|
|
359
|
-
* @returns {string
|
|
364
|
+
* @returns {string}
|
|
360
365
|
*/
|
|
361
|
-
function
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const workspace = registry?.get?.(workspaceId);
|
|
365
|
-
if (workspace === null || workspace === undefined || typeof workspace.path !== 'string' || workspace.path === '') {
|
|
366
|
-
return undefined;
|
|
367
|
-
}
|
|
368
|
-
const root = resolvePath(workspace.path);
|
|
369
|
-
const target = resolvePath(root, PROMPTS_DIR, fileName);
|
|
370
|
-
// The store must stay inside the workspace, whatever the registry returned.
|
|
371
|
-
const prefix = root.endsWith(sep) ? root : root + sep;
|
|
372
|
-
if (!target.startsWith(prefix)) return undefined;
|
|
373
|
-
return target;
|
|
366
|
+
function storePath(fileName) {
|
|
367
|
+
const home = process.env.DSH_HOME?.trim() || join(homedir(), '.dsh');
|
|
368
|
+
return join(home, STORE_DIR_NAME, fileName);
|
|
374
369
|
}
|
|
375
370
|
|
|
376
|
-
/**
|
|
377
|
-
function promptStorePath(
|
|
378
|
-
return
|
|
371
|
+
/** The central prompts file path (kept for callers/tests). */
|
|
372
|
+
function promptStorePath() {
|
|
373
|
+
return storePath(PROMPTS_FILE);
|
|
379
374
|
}
|
|
380
375
|
|
|
381
|
-
/** Read one
|
|
376
|
+
/** Read one JSON list from disk; a missing file is an empty list. */
|
|
382
377
|
function readJsonStore(filePath) {
|
|
383
378
|
try {
|
|
384
379
|
const parsed = JSON.parse(readFileSync(filePath, 'utf8'));
|
|
@@ -389,6 +384,38 @@ function readJsonStore(filePath) {
|
|
|
389
384
|
}
|
|
390
385
|
}
|
|
391
386
|
|
|
387
|
+
/**
|
|
388
|
+
* One-time migration of the old per-workspace files into the central store.
|
|
389
|
+
* Records from every registered workspace are merged by identity (prompt id /
|
|
390
|
+
* rule id), tagging each with its source workspaceId. A marker file prevents
|
|
391
|
+
* re-merging on later writes. Legacy files are left in place (never deleted).
|
|
392
|
+
* @param {string} fileName
|
|
393
|
+
* @param {'prompts'|'rules'} kind
|
|
394
|
+
*/
|
|
395
|
+
function migrateLegacyStore(ctx, fileName) {
|
|
396
|
+
const target = storePath(fileName);
|
|
397
|
+
const marker = target + '.migrated';
|
|
398
|
+
if (existsSync(marker)) return;
|
|
399
|
+
const registry = ctx?.get?.('workspaceRegistry');
|
|
400
|
+
const workspaces = typeof registry?.list === 'function' ? registry.list() : [];
|
|
401
|
+
const merged = readJsonStore(target);
|
|
402
|
+
const seen = new Set(merged.map((r) => r?.id).filter(Boolean));
|
|
403
|
+
for (const ws of workspaces) {
|
|
404
|
+
if (typeof ws?.path !== 'string' || ws.path === '') continue;
|
|
405
|
+
const legacy = resolvePath(resolvePath(ws.path), LEGACY_STORE_DIR, fileName);
|
|
406
|
+
const rows = readJsonStore(legacy);
|
|
407
|
+
if (rows.length === 0) continue;
|
|
408
|
+
for (const row of rows) {
|
|
409
|
+
if (row === null || typeof row !== 'object' || seen.has(row.id)) continue;
|
|
410
|
+
merged.push({ ...row, workspaceId: row.workspaceId ?? ws.id });
|
|
411
|
+
if (row.id) seen.add(row.id);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
mkdirSync(dirname(target), { recursive: true });
|
|
415
|
+
writeFileSync(target, JSON.stringify(merged, null, 2) + '\n', 'utf8');
|
|
416
|
+
writeFileSync(marker, new Date().toISOString() + '\n', 'utf8');
|
|
417
|
+
}
|
|
418
|
+
|
|
392
419
|
/** Read one workspace's prompts from disk; a missing file is an empty list. */
|
|
393
420
|
function readPromptStore(filePath) {
|
|
394
421
|
return readJsonStore(filePath);
|
|
@@ -413,23 +440,14 @@ async function handle(req, res, ctx) {
|
|
|
413
440
|
}
|
|
414
441
|
|
|
415
442
|
if (op === 'mask-rules') {
|
|
416
|
-
const
|
|
417
|
-
? (url.searchParams.get('workspaceId') ?? '')
|
|
418
|
-
: '';
|
|
419
|
-
let workspaceId = targetId;
|
|
443
|
+
const filePath = storePath(MASK_RULES_FILE);
|
|
420
444
|
if (req.method === 'POST') {
|
|
421
445
|
try {
|
|
422
446
|
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
447
|
const rules = Array.isArray(body?.rules) ? body.rules : [];
|
|
430
448
|
mkdirSync(dirname(filePath), { recursive: true });
|
|
431
449
|
writeFileSync(filePath, JSON.stringify(rules, null, 2) + '\n', 'utf8');
|
|
432
|
-
sendJson(res, { ok: true,
|
|
450
|
+
sendJson(res, { ok: true, rules });
|
|
433
451
|
} catch (error) {
|
|
434
452
|
sendJson(res, { ok: false, error: String(error?.message ?? error) }, 500);
|
|
435
453
|
}
|
|
@@ -440,12 +458,8 @@ async function handle(req, res, ctx) {
|
|
|
440
458
|
return;
|
|
441
459
|
}
|
|
442
460
|
try {
|
|
443
|
-
|
|
444
|
-
|
|
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) });
|
|
461
|
+
migrateLegacyStore(ctx, MASK_RULES_FILE);
|
|
462
|
+
sendJson(res, { ok: true, rules: readJsonStore(filePath) });
|
|
449
463
|
} catch (error) {
|
|
450
464
|
sendJson(res, { ok: false, error: String(error?.message ?? error) }, 500);
|
|
451
465
|
}
|
|
@@ -453,25 +467,16 @@ async function handle(req, res, ctx) {
|
|
|
453
467
|
}
|
|
454
468
|
|
|
455
469
|
if (op === 'prompts') {
|
|
456
|
-
//
|
|
457
|
-
//
|
|
458
|
-
const
|
|
459
|
-
? (url.searchParams.get('workspaceId') ?? '')
|
|
460
|
-
: '';
|
|
461
|
-
let workspaceId = targetId;
|
|
470
|
+
// One central file holds prompts for every workspace; each record carries
|
|
471
|
+
// its own workspaceId ('' means all workspaces). The client filters by scope.
|
|
472
|
+
const filePath = promptStorePath();
|
|
462
473
|
if (req.method === 'POST') {
|
|
463
474
|
try {
|
|
464
475
|
const body = await readJsonBody(req);
|
|
465
|
-
workspaceId = typeof body?.workspaceId === 'string' ? body.workspaceId.trim() : '';
|
|
466
|
-
const filePath = promptStorePath(ctx, workspaceId);
|
|
467
|
-
if (filePath === undefined) {
|
|
468
|
-
sendJson(res, { ok: false, code: 'workspace-not-found', error: 'workspace not found' }, 404);
|
|
469
|
-
return;
|
|
470
|
-
}
|
|
471
476
|
const prompts = Array.isArray(body?.prompts) ? body.prompts : [];
|
|
472
477
|
mkdirSync(dirname(filePath), { recursive: true });
|
|
473
478
|
writeFileSync(filePath, JSON.stringify(prompts, null, 2) + '\n', 'utf8');
|
|
474
|
-
sendJson(res, { ok: true,
|
|
479
|
+
sendJson(res, { ok: true, prompts });
|
|
475
480
|
} catch (error) {
|
|
476
481
|
sendJson(res, { ok: false, error: String(error?.message ?? error) }, 500);
|
|
477
482
|
}
|
|
@@ -482,12 +487,8 @@ async function handle(req, res, ctx) {
|
|
|
482
487
|
return;
|
|
483
488
|
}
|
|
484
489
|
try {
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
sendJson(res, { ok: false, code: 'workspace-not-found', error: 'workspace not found' }, 404);
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
sendJson(res, { ok: true, workspaceId, prompts: readPromptStore(filePath) });
|
|
490
|
+
migrateLegacyStore(ctx, PROMPTS_FILE);
|
|
491
|
+
sendJson(res, { ok: true, prompts: readPromptStore(filePath) });
|
|
491
492
|
} catch (error) {
|
|
492
493
|
sendJson(res, { ok: false, error: String(error?.message ?? error) }, 500);
|
|
493
494
|
}
|
|
@@ -644,12 +645,14 @@ export const __test = {
|
|
|
644
645
|
profileDirectory,
|
|
645
646
|
promptStorePath,
|
|
646
647
|
readPromptStore,
|
|
647
|
-
|
|
648
|
+
storePath,
|
|
648
649
|
readJsonStore,
|
|
650
|
+
migrateLegacyStore,
|
|
651
|
+
PROMPTS_FILE,
|
|
649
652
|
MASK_RULES_FILE,
|
|
650
653
|
HOST_STARTED_AT,
|
|
651
654
|
SELF_VERSION,
|
|
652
655
|
ROUTE,
|
|
653
656
|
MODULE_ID,
|
|
654
|
-
|
|
657
|
+
STORE_DIR_NAME,
|
|
655
658
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restregular/dsh-powerup",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
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",
|