@restregular/dsh-powerup 0.10.2 → 0.10.3

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 -6
  2. package/client.js +438 -112
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -184,13 +184,21 @@ Save reusable prompts and drop one into a new session without retyping it.
184
184
  and the prompt body. Without a title the dropdown shows the first few
185
185
  characters of the body. A blank workspace scope makes the prompt available in
186
186
  every workspace; otherwise it appears only in that one.
187
+ - Prompts are split into two sections: **Global** (visible in every workspace)
188
+ and **This workspace**. Each section can hold custom named groups, which can
189
+ be collapsed and expanded. Prompts not in any group are shown at the same
190
+ level as the group headers, under **Ungrouped**. In the **Prompts** settings
191
+ tab you can create, rename and delete groups for each scope, and **drag a
192
+ prompt onto a group header to move it** (or onto Ungrouped to take it out of
193
+ a group). Deleting a group never deletes its prompts — they become ungrouped.
187
194
  - In the New Session row, to the right of the Agent preset, a dropdown lists the
188
- prompts available in the current workspace. In an **ongoing session** the same
189
- picker also appears in the composer's bottom tool row, just right of the
190
- permission dropdown; there its menu opens **upward**. **Clicking a prompt
191
- fills the composer** so you can keep editing before sending. Each row also has
192
- a **Send now** button that fills and submits immediately, and an **Edit** icon
193
- button that opens the prompt dialog to change its title, scope and text.
195
+ prompts available in the current workspace, grouped the same way. In an
196
+ **ongoing session** the same picker also appears in the composer's bottom
197
+ tool row, just right of the permission dropdown; there its menu opens
198
+ **upward**. **Clicking a prompt fills the composer** so you can keep editing
199
+ before sending. Each row also has a **Send now** button that fills and
200
+ submits immediately, and an **Edit** icon button that opens the prompt dialog
201
+ to change its title, scope and text.
194
202
  - **Create a new prompt…** in the dropdown opens an in-conversation dialog. A
195
203
  prompt created here is pinned to the current workspace — you may only keep
196
204
  that scope or switch to **All workspaces**, never pick another workspace.
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.10.2';
86
+ const VERSION = '0.10.3';
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. */
@@ -350,7 +350,7 @@
350
350
  'prompts.tabFeatures': '功能列表',
351
351
  'prompts.tabManage': '提示词',
352
352
  'prompts.sectionTitle': '统一管理各工作区的提示词',
353
- 'prompts.sectionSub': '提示词按工作区分组保存在工作区目录的 .dsh/dsh-powerup/prompts.json;选择后填入输入框,可继续编辑再发送。',
353
+ 'prompts.sectionSub': '提示词按「全局 / 当前工作区」分区,区内可自定义分组并折叠展开;未分组提示词与分组同级展示,拖拽提示词到分组标题即可移动。',
354
354
  'prompts.new': '新建提示词',
355
355
  'prompts.cancel': '取消',
356
356
  'prompts.save': '保存',
@@ -388,6 +388,18 @@
388
388
  'prompts.createFailed': '创建失败:{message}',
389
389
  'prompts.workspaceCurrent': '当前工作区',
390
390
  'prompts.workspaceNone': '未识别当前工作区,将保存到所有工作区',
391
+ 'prompts.scopeGlobal': '全局提示词',
392
+ 'prompts.scopeWorkspace': '当前工作区',
393
+ 'prompts.ungrouped': '未分组',
394
+ 'prompts.groupNew': '新建分组',
395
+ 'prompts.groupRename': '重命名',
396
+ 'prompts.groupDelete': '删除分组',
397
+ 'prompts.groupNamePlaceholder': '分组名称',
398
+ 'prompts.groupCreate': '创建分组',
399
+ 'prompts.groupConfirmDelete': '删除这个分组?其中的提示词会变为未分组,不会被删除。',
400
+ 'prompts.moveToGroup': '移动到分组',
401
+ 'prompts.moveUngrouped': '移出分组',
402
+ 'prompts.dropHint': '拖拽提示词到分组标题即可移动;拖到「未分组」可移出分组。',
391
403
  },
392
404
  en: {
393
405
  'panel.title': 'Power-Up',
@@ -644,7 +656,7 @@
644
656
  'prompts.tabFeatures': 'Features',
645
657
  'prompts.tabManage': 'Prompts',
646
658
  'prompts.sectionTitle': 'Manage prompts for every workspace',
647
- 'prompts.sectionSub': 'Prompts are grouped by workspace and stored in that workspace\'s .dsh/dsh-powerup/prompts.json. Picking one fills the composer so you can edit before sending.',
659
+ 'prompts.sectionSub': 'Prompts are split into Global / This workspace sections. Each section can have custom collapsible groups; ungrouped prompts sit beside groups, and you can drag a prompt onto a group header to move it.',
648
660
  'prompts.new': 'New prompt',
649
661
  'prompts.cancel': 'Cancel',
650
662
  'prompts.save': 'Save',
@@ -682,6 +694,18 @@
682
694
  'prompts.createFailed': 'Could not create: {message}',
683
695
  'prompts.workspaceCurrent': 'Current workspace',
684
696
  'prompts.workspaceNone': 'Current workspace unknown; it will be saved for all workspaces',
697
+ 'prompts.scopeGlobal': 'Global prompts',
698
+ 'prompts.scopeWorkspace': 'This workspace',
699
+ 'prompts.ungrouped': 'Ungrouped',
700
+ 'prompts.groupNew': 'New group',
701
+ 'prompts.groupRename': 'Rename',
702
+ 'prompts.groupDelete': 'Delete group',
703
+ 'prompts.groupNamePlaceholder': 'Group name',
704
+ 'prompts.groupCreate': 'Create group',
705
+ 'prompts.groupConfirmDelete': 'Delete this group? Its prompts stay as ungrouped and are not deleted.',
706
+ 'prompts.moveToGroup': 'Move to group',
707
+ 'prompts.moveUngrouped': 'Move out of group',
708
+ 'prompts.dropHint': 'Drag a prompt onto a group header to move it; drop on Ungrouped to take it out of a group.',
685
709
  },
686
710
  };
687
711
 
@@ -800,20 +824,46 @@
800
824
  let promptsCache = [];
801
825
  let promptsLoaded = false;
802
826
 
803
- /** Normalize an arbitrary value into a clean prompt record. */
827
+ /** A group record is tagged with kind:'group'; everything else is a prompt. */
828
+ function isGroupRecord(item) {
829
+ return item !== null && typeof item === 'object' && item.kind === 'group';
830
+ }
831
+
832
+ /** Normalize an arbitrary value into a clean prompt or group record. */
804
833
  function normalizePrompt(item) {
805
834
  if (item === null || typeof item !== 'object') return null;
835
+ if (isGroupRecord(item)) {
836
+ return {
837
+ id: typeof item.id === 'string' && item.id !== '' ? item.id : newId(),
838
+ kind: 'group',
839
+ name: typeof item.name === 'string' ? item.name : '',
840
+ workspaceId: typeof item.workspaceId === 'string' ? item.workspaceId : '',
841
+ };
842
+ }
806
843
  return {
807
844
  id: typeof item.id === 'string' && item.id !== '' ? item.id : newId(),
808
845
  title: typeof item.title === 'string' ? item.title : '',
809
846
  text: typeof item.text === 'string' ? item.text : '',
810
847
  workspaceId: typeof item.workspaceId === 'string' ? item.workspaceId : '',
848
+ groupId: typeof item.groupId === 'string' ? item.groupId : '',
811
849
  };
812
850
  }
813
851
 
814
- /** @returns {Array<{id:string,title:string,text:string,workspaceId:string}>} */
852
+ /** @returns {Array<{id:string,title:string,text:string,workspaceId:string,groupId:string}>} */
815
853
  function readPrompts() {
816
- return promptsCache;
854
+ return promptsCache.filter((item) => !isGroupRecord(item));
855
+ }
856
+
857
+ /** @returns {Array<{id:string,kind:'group',name:string,workspaceId:string}>} */
858
+ function readGroups() {
859
+ return promptsCache.filter(isGroupRecord);
860
+ }
861
+
862
+ /** Groups visible in a workspace: its own plus the global ones. */
863
+ function groupsForWorkspace(list, workspaceId) {
864
+ const id = typeof workspaceId === 'string' ? workspaceId : '';
865
+ return (Array.isArray(list) ? list : []).filter((item) => isGroupRecord(item)
866
+ && (item.workspaceId === '' || item.workspaceId === id));
817
867
  }
818
868
 
819
869
  /**
@@ -835,8 +885,7 @@
835
885
  return promptsCache;
836
886
  }
837
887
 
838
- function writePrompts(list) {
839
- const next = (Array.isArray(list) ? list : []).map(normalizePrompt).filter(Boolean);
888
+ function commitStore(next) {
840
889
  promptsCache = next;
841
890
  promptsLoaded = true;
842
891
  emitPrompts();
@@ -849,6 +898,23 @@
849
898
  });
850
899
  }
851
900
 
901
+ /** Replace prompts, keeping the group records already in the cache. */
902
+ function writePrompts(list) {
903
+ const prompts = (Array.isArray(list) ? list : []).map(normalizePrompt).filter(Boolean);
904
+ commitStore([...promptsCache.filter(isGroupRecord), ...prompts]);
905
+ }
906
+
907
+ /** Replace group records, keeping the prompts already in the cache. */
908
+ function writeGroups(list) {
909
+ const groups = (Array.isArray(list) ? list : []).map(normalizePrompt).filter(Boolean);
910
+ commitStore([...groups, ...promptsCache.filter((item) => !isGroupRecord(item))]);
911
+ }
912
+
913
+ /** Replace the whole store (prompts and groups), e.g. after a drag move. */
914
+ function writeAll(list) {
915
+ commitStore((Array.isArray(list) ? list : []).map(normalizePrompt).filter(Boolean));
916
+ }
917
+
852
918
  const promptsListeners = new Set();
853
919
  function subscribePrompts(listener) {
854
920
  promptsListeners.add(listener);
@@ -1029,7 +1095,34 @@
1029
1095
  */
1030
1096
  function promptsForWorkspace(list, workspaceId) {
1031
1097
  const id = typeof workspaceId === 'string' ? workspaceId : '';
1032
- return (Array.isArray(list) ? list : []).filter((item) => item.workspaceId === '' || item.workspaceId === id);
1098
+ return (Array.isArray(list) ? list : []).filter((item) => !isGroupRecord(item)
1099
+ && (item.workspaceId === '' || item.workspaceId === id));
1100
+ }
1101
+
1102
+ /**
1103
+ * Build the grouped view for one scope: custom groups first (in store
1104
+ * order), then ungrouped prompts as a peer group with id ''. Only prompts
1105
+ * whose groupId resolves to a group of the same scope are placed; an
1106
+ * orphaned groupId falls back to ungrouped so no prompt disappears.
1107
+ */
1108
+ function groupPrompts(prompts, groups, scopeId) {
1109
+ const scopeGroups = (Array.isArray(groups) ? groups : [])
1110
+ .filter((group) => group.workspaceId === scopeId);
1111
+ const scopePrompts = (Array.isArray(prompts) ? prompts : [])
1112
+ .filter((prompt) => prompt.workspaceId === scopeId);
1113
+ const known = new Set(scopeGroups.map((group) => group.id));
1114
+ const buckets = new Map(scopeGroups.map((group) => [group.id, []]));
1115
+ const loose = [];
1116
+ for (const prompt of scopePrompts) {
1117
+ const gid = typeof prompt.groupId === 'string' ? prompt.groupId : '';
1118
+ if (gid !== '' && buckets.has(gid)) buckets.get(gid).push(prompt);
1119
+ else loose.push(prompt);
1120
+ }
1121
+ const sections = scopeGroups.map((group) => ({
1122
+ id: group.id, name: group.name, group, items: buckets.get(group.id), isUngrouped: false,
1123
+ }));
1124
+ sections.push({ id: '', name: '', items: loose, isUngrouped: true });
1125
+ return sections;
1033
1126
  }
1034
1127
 
1035
1128
  /** Title, else the first characters of the body, else a localized fallback. */
@@ -1049,6 +1142,13 @@
1049
1142
  return value;
1050
1143
  }
1051
1144
 
1145
+ function usePromptGroups() {
1146
+ const [value, setValue] = useState(readGroups);
1147
+ useEffect(() => subscribePrompts(() => setValue(readGroups())), []);
1148
+ useEffect(() => { void loadPrompts(); }, []);
1149
+ return value;
1150
+ }
1151
+
1052
1152
  // ------------------------------------------------------------------
1053
1153
  // Sidebar launcher: the panel list as an adaptive icon grid
1054
1154
  // ------------------------------------------------------------------
@@ -2860,7 +2960,7 @@
2860
2960
  * Open the prompt picker next to the hero control. Returns a disposer.
2861
2961
  * DOM-based like the session switcher so it survives host re-renders.
2862
2962
  */
2863
- function openPromptPopover({ anchor, t, items, onPick, onSend, onEdit, onCreate, onDispose, placement }) {
2963
+ function openPromptPopover({ anchor, t, sections, collapsed, onToggleGroup, onPick, onSend, onEdit, onCreate, onDispose, placement }) {
2864
2964
  if (anchor === null || anchor === undefined || typeof document === 'undefined') return () => {};
2865
2965
  const element = document.createElement('div');
2866
2966
  element.className = 'dsh-powerup-prompt-pop';
@@ -2890,72 +2990,126 @@
2890
2990
  element.appendChild(head);
2891
2991
  const list = document.createElement('div');
2892
2992
  list.className = 'dsh-powerup-prompt-pop-list';
2893
- if (items.length === 0) {
2894
- const empty = document.createElement('div');
2895
- empty.className = 'dsh-powerup-prompt-pop-empty';
2896
- empty.textContent = t('prompts.noPrompts');
2897
- element.appendChild(empty);
2898
- } else {
2899
- for (const prompt of items) {
2900
- const row = document.createElement('div');
2901
- row.className = 'dsh-powerup-prompt-pop-item';
2902
- const main = document.createElement('button');
2903
- main.type = 'button';
2904
- main.className = 'dsh-powerup-prompt-pop-main';
2905
- main.setAttribute('data-prompt-id', prompt.id);
2906
- const name = document.createElement('span');
2907
- name.className = 'dsh-powerup-prompt-pop-name';
2908
- name.textContent = promptLabel(prompt, t);
2909
- const preview = document.createElement('span');
2910
- preview.className = 'dsh-powerup-prompt-pop-preview';
2911
- preview.textContent = [...(prompt.text || '').trim()].slice(0, 40).join('');
2912
- main.append(name, preview);
2913
- main.addEventListener('click', (event) => {
2914
- event.preventDefault();
2915
- event.stopPropagation();
2916
- dispose();
2917
- onPick(prompt);
2918
- });
2919
- const send = document.createElement('button');
2920
- send.type = 'button';
2921
- send.className = 'dsh-powerup-prompt-pop-send';
2922
- send.setAttribute('data-prompt-send', prompt.id);
2923
- send.setAttribute('aria-label', t('prompts.sendDirect'));
2924
- send.setAttribute('title', t('prompts.sendDirect'));
2925
- // Icon-only send action; label moved to title/aria-label above.
2926
- send.innerHTML = '<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false"><path d="M2 7.5 13.5 3 9 14.5 7.4 9.2 2 7.5Z" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>';
2927
- send.addEventListener('click', (event) => {
2993
+ const renderRow = (prompt) => {
2994
+ const row = document.createElement('div');
2995
+ row.className = 'dsh-powerup-prompt-pop-item';
2996
+ const main = document.createElement('button');
2997
+ main.type = 'button';
2998
+ main.className = 'dsh-powerup-prompt-pop-main';
2999
+ main.setAttribute('data-prompt-id', prompt.id);
3000
+ const name = document.createElement('span');
3001
+ name.className = 'dsh-powerup-prompt-pop-name';
3002
+ name.textContent = promptLabel(prompt, t);
3003
+ const preview = document.createElement('span');
3004
+ preview.className = 'dsh-powerup-prompt-pop-preview';
3005
+ preview.textContent = [...(prompt.text || '').trim()].slice(0, 40).join('');
3006
+ main.append(name, preview);
3007
+ main.addEventListener('click', (event) => {
3008
+ event.preventDefault();
3009
+ event.stopPropagation();
3010
+ dispose();
3011
+ onPick(prompt);
3012
+ });
3013
+ const send = document.createElement('button');
3014
+ send.type = 'button';
3015
+ send.className = 'dsh-powerup-prompt-pop-send';
3016
+ send.setAttribute('data-prompt-send', prompt.id);
3017
+ send.setAttribute('aria-label', t('prompts.sendDirect'));
3018
+ send.setAttribute('title', t('prompts.sendDirect'));
3019
+ // Icon-only send action; label moved to title/aria-label above.
3020
+ send.innerHTML = '<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false"><path d="M2 7.5 13.5 3 9 14.5 7.4 9.2 2 7.5Z" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/></svg>';
3021
+ send.addEventListener('click', (event) => {
3022
+ event.preventDefault();
3023
+ event.stopPropagation();
3024
+ dispose();
3025
+ onSend(prompt);
3026
+ });
3027
+ row.append(main);
3028
+ if (typeof onEdit === 'function') {
3029
+ const edit = document.createElement('button');
3030
+ edit.type = 'button';
3031
+ edit.className = 'dsh-powerup-prompt-pop-edit';
3032
+ edit.setAttribute('data-prompt-edit', prompt.id);
3033
+ edit.setAttribute('aria-label', t('prompts.edit'));
3034
+ edit.setAttribute('title', t('prompts.edit'));
3035
+ // Icon-only edit action; label moved to title/aria-label above.
3036
+ edit.innerHTML = '<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false"><path d="M11.2 2.6a1.3 1.3 0 0 1 1.8 1.8L6 11.4l-2.4.6.6-2.4 7-7Z" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/><path d="M3 14h10" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/></svg>';
3037
+ edit.addEventListener('click', (event) => {
2928
3038
  event.preventDefault();
2929
3039
  event.stopPropagation();
2930
3040
  dispose();
2931
- onSend(prompt);
3041
+ onEdit(prompt);
2932
3042
  });
2933
- row.append(main);
2934
- if (typeof onEdit === 'function') {
2935
- const edit = document.createElement('button');
2936
- edit.type = 'button';
2937
- edit.className = 'dsh-powerup-prompt-pop-edit';
2938
- edit.setAttribute('data-prompt-edit', prompt.id);
2939
- edit.setAttribute('aria-label', t('prompts.edit'));
2940
- edit.setAttribute('title', t('prompts.edit'));
2941
- // Icon-only edit action; label moved to title/aria-label above.
2942
- edit.innerHTML = '<svg width="14" height="14" viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false"><path d="M11.2 2.6a1.3 1.3 0 0 1 1.8 1.8L6 11.4l-2.4.6.6-2.4 7-7Z" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/><path d="M3 14h10" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/></svg>';
2943
- edit.addEventListener('click', (event) => {
3043
+ row.append(edit);
3044
+ }
3045
+ row.append(send);
3046
+ return row;
3047
+ };
3048
+ const sectionsList = Array.isArray(sections) ? sections : [];
3049
+ const emptyNode = document.createElement('div');
3050
+ emptyNode.className = 'dsh-powerup-prompt-pop-empty';
3051
+ emptyNode.textContent = t('prompts.noPrompts');
3052
+ const sep = document.createElement('div');
3053
+ sep.className = 'dsh-powerup-prompt-pop-sep';
3054
+ const localCollapsed = new Set(collapsed instanceof Set ? collapsed : []);
3055
+ const renderList = () => {
3056
+ while (list.firstChild) list.removeChild(list.firstChild);
3057
+ let total = 0;
3058
+ for (const section of sectionsList) {
3059
+ for (const group of section.groups) total += group.items.length;
3060
+ }
3061
+ if (total === 0) {
3062
+ if (emptyNode.parentNode !== element) element.appendChild(emptyNode);
3063
+ if (list.parentNode === element) element.removeChild(list);
3064
+ if (sep.parentNode === element) element.removeChild(sep);
3065
+ return;
3066
+ }
3067
+ if (emptyNode.parentNode === element) element.removeChild(emptyNode);
3068
+ if (list.parentNode !== element) element.insertBefore(list, sep.parentNode === element ? sep : null);
3069
+ if (sep.parentNode !== element) element.appendChild(sep);
3070
+ for (const section of sectionsList) {
3071
+ const scopeHead = document.createElement('div');
3072
+ scopeHead.className = 'dsh-powerup-prompt-pop-scope';
3073
+ scopeHead.textContent = section.label;
3074
+ list.appendChild(scopeHead);
3075
+ for (const group of section.groups) {
3076
+ if (group.items.length === 0 && !group.group) continue;
3077
+ const isUngrouped = group.isUngrouped === true;
3078
+ const key = section.key + ':' + group.id;
3079
+ const isCollapsed = localCollapsed.has(key);
3080
+ if (isUngrouped) {
3081
+ // Ungrouped prompts sit at the same level as group headers.
3082
+ for (const prompt of group.items) list.appendChild(renderRow(prompt));
3083
+ continue;
3084
+ }
3085
+ const head = document.createElement('button');
3086
+ head.type = 'button';
3087
+ head.className = 'dsh-powerup-prompt-pop-group';
3088
+ head.setAttribute('data-prompt-group', key);
3089
+ head.setAttribute('aria-expanded', isCollapsed ? 'false' : 'true');
3090
+ head.innerHTML = '<svg width="10" height="10" viewBox="0 0 16 16" fill="none" aria-hidden="true" focusable="false"><path d="m4 6 4 4 4-4" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"/></svg>';
3091
+ const label = document.createElement('span');
3092
+ label.textContent = group.name || t('prompts.untitled');
3093
+ const count = document.createElement('span');
3094
+ count.className = 'dsh-powerup-prompt-pop-group-count';
3095
+ count.textContent = String(group.items.length);
3096
+ head.append(label, count);
3097
+ head.addEventListener('click', (event) => {
2944
3098
  event.preventDefault();
2945
3099
  event.stopPropagation();
2946
- dispose();
2947
- onEdit(prompt);
3100
+ if (localCollapsed.has(key)) localCollapsed.delete(key);
3101
+ else localCollapsed.add(key);
3102
+ if (typeof onToggleGroup === 'function') onToggleGroup(key, !localCollapsed.has(key));
3103
+ renderList();
2948
3104
  });
2949
- row.append(edit);
3105
+ list.appendChild(head);
3106
+ if (!isCollapsed) {
3107
+ for (const prompt of group.items) list.appendChild(renderRow(prompt));
3108
+ }
2950
3109
  }
2951
- row.append(send);
2952
- list.appendChild(row);
2953
3110
  }
2954
- element.appendChild(list);
2955
- const sep = document.createElement('div');
2956
- sep.className = 'dsh-powerup-prompt-pop-sep';
2957
- element.appendChild(sep);
2958
- }
3111
+ };
3112
+ renderList();
2959
3113
  const create = document.createElement('button');
2960
3114
  create.type = 'button';
2961
3115
  create.className = 'dsh-powerup-prompt-pop-create';
@@ -3220,9 +3374,11 @@
3220
3374
  ? useWorkspaces(workspaceSelector) ?? ''
3221
3375
  : '';
3222
3376
  const prompts = usePrompts(workspaceId);
3377
+ const groups = usePromptGroups();
3223
3378
  const [, forceLocale] = useState(0);
3224
3379
  const [creating, setCreating] = useState(false);
3225
3380
  const [editing, setEditing] = useState(null);
3381
+ const [collapsed, setCollapsed] = useState(() => new Set());
3226
3382
  const anchorRef = useRef(null);
3227
3383
  const disposeRef = useRef(null);
3228
3384
  const t = (key, params) => translateCurrent(key, params);
@@ -3247,6 +3403,25 @@
3247
3403
  if (!settings.workspacePrompts) return null;
3248
3404
 
3249
3405
  const visible = promptsForWorkspace(prompts, workspaceId);
3406
+ const sections = [];
3407
+ if (workspaceId !== '') {
3408
+ sections.push({
3409
+ key: 'global',
3410
+ label: t('prompts.scopeGlobal'),
3411
+ groups: groupPrompts(visible, groups, ''),
3412
+ });
3413
+ }
3414
+ sections.push({
3415
+ key: 'workspace',
3416
+ label: workspaceId === '' ? t('prompts.scopeGlobal') : t('prompts.scopeWorkspace'),
3417
+ groups: groupPrompts(visible, groups, workspaceId),
3418
+ });
3419
+ const toggleGroup = (key) => setCollapsed((current) => {
3420
+ const next = new Set(current);
3421
+ if (next.has(key)) next.delete(key);
3422
+ else next.add(key);
3423
+ return next;
3424
+ });
3250
3425
  const lastId = readLastPrompt(workspaceId);
3251
3426
  const last = visible.find((p) => p.id === lastId);
3252
3427
  const label = last !== undefined ? promptLabel(last, t) : t('prompts.pick');
@@ -3308,7 +3483,9 @@
3308
3483
  const dispose = openPromptPopover({
3309
3484
  anchor,
3310
3485
  t,
3311
- items: visible,
3486
+ sections,
3487
+ collapsed,
3488
+ onToggleGroup: toggleGroup,
3312
3489
  placement: (node) => popoverPlacement(node, 360, 340, { preferUp: compact }),
3313
3490
  onPick: (prompt) => apply(prompt, false),
3314
3491
  onSend: (prompt) => apply(prompt, true),
@@ -4029,6 +4206,12 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4029
4206
  .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)}
4030
4207
  .dsh-powerup-prompt-pop.is-open{opacity:1;transform:none}
4031
4208
  .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}
4209
+ .dsh-powerup-prompt-pop-scope{flex:none;padding:5px 9px 3px;color:var(--dsw-alias-label-tertiary);font-size:10px;font-weight:600;letter-spacing:.03em}
4210
+ .dsh-powerup-prompt-pop-group{flex:none;display:flex;align-items:center;gap:5px;width:100%;min-height:26px;padding:2px 9px;border:0;border-radius:7px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:11px;font-weight:600;line-height:1.5;text-align:left;cursor:pointer}
4211
+ .dsh-powerup-prompt-pop-group svg{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .12s ease}
4212
+ .dsh-powerup-prompt-pop-group[aria-expanded=false] svg{transform:rotate(-90deg)}
4213
+ .dsh-powerup-prompt-pop-group:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
4214
+ .dsh-powerup-prompt-pop-group-count{margin-left:auto;color:var(--dsw-alias-label-tertiary);font-size:10px;font-weight:400}
4032
4215
  .dsh-powerup-prompt-pop-list{flex:1 1 auto;min-height:0;display:flex;flex-direction:column;gap:4px;padding:6px;overflow-y:auto;overflow-x:hidden}
4033
4216
  .dsh-powerup-prompt-pop-item{box-sizing:border-box;display:flex;align-items:center;gap:6px;width:100%;min-width:0;min-height:38px;padding:4px 5px 4px 9px;border:.5px solid transparent;border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;text-align:left;transition:border-color .12s ease,background .12s ease}
4034
4217
  .dsh-powerup-prompt-pop-item:hover{border-color:var(--dsw-alias-border-l2);background:var(--dsw-alias-interactive-bg-hover)}
@@ -4057,18 +4240,29 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
4057
4240
  .dsh-powerup-prompt-new{height:30px;padding:0 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font:inherit;font-size:12.5px;line-height:1.5;cursor:pointer;transition:border-color .12s ease,color .12s ease}
4058
4241
  .dsh-powerup-prompt-new:hover{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-brand-primary)}
4059
4242
  .dsh-powerup-prompt-new:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
4060
- .dsh-powerup-prompt-groups{display:flex;flex-direction:column;gap:14px;margin-top:14px}
4061
- .dsh-powerup-prompt-group{border:1px solid var(--dsw-alias-border-l1);border-radius:12px;background:var(--dsw-alias-bg-layer-2);overflow:hidden}
4062
- .dsh-powerup-prompt-group-head{display:flex;align-items:center;gap:8px;width:100%;padding:9px 12px;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer}
4063
- .dsh-powerup-prompt-group-head:hover{background:var(--dsw-alias-interactive-bg-hover)}
4064
- .dsh-powerup-prompt-group-head:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:-2px}
4243
+ .dsh-powerup-prompt-scopes{display:flex;flex-direction:column;gap:16px;margin-top:14px}
4244
+ .dsh-powerup-prompt-scope-head{display:flex;align-items:center;gap:8px;padding:4px 2px}
4245
+ .dsh-powerup-prompt-scope-title{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-secondary);font-size:11.5px;font-weight:600;letter-spacing:.03em}
4246
+ .dsh-powerup-prompt-groups{display:flex;flex-direction:column;gap:8px;margin-top:4px}
4247
+ .dsh-powerup-prompt-group{border:1px solid var(--dsw-alias-border-l1);border-radius:12px;background:var(--dsw-alias-bg-layer-2);overflow:hidden;transition:border-color .12s ease,background .12s ease}
4248
+ .dsh-powerup-prompt-group.drop-target{border-color:var(--dsw-alias-state-business-primary);background:var(--dsw-alias-interactive-bg-hover)}
4249
+ .dsh-powerup-prompt-group-head{display:flex;align-items:center;gap:8px;width:100%;padding:7px 12px;background:transparent}
4250
+ .dsh-powerup-prompt-group-toggle{display:flex;flex:1 1 auto;align-items:center;gap:8px;min-width:0;padding:2px 0;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;text-align:left;cursor:pointer}
4251
+ .dsh-powerup-prompt-group-toggle:hover{color:var(--dsw-alias-brand-primary)}
4252
+ .dsh-powerup-prompt-group-toggle:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:-2px}
4253
+ .dsh-powerup-prompt-group-actions{display:flex;align-items:center;gap:2px;flex:none}
4065
4254
  .dsh-powerup-prompt-group-chevron{flex:none;display:inline-flex;color:var(--dsw-alias-label-tertiary);transition:transform .15s ease}
4066
4255
  .dsh-powerup-prompt-group.is-collapsed .dsh-powerup-prompt-group-chevron{transform:rotate(-90deg)}
4067
4256
  .dsh-powerup-prompt-group-title{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:600;line-height:1.4}
4068
4257
  .dsh-powerup-prompt-group-count{flex:none;color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:1.5;font-variant-numeric:tabular-nums}
4069
4258
  .dsh-powerup-prompt-group-body{display:flex;flex-direction:column;gap:7px;padding:0 8px 8px}
4070
- .dsh-powerup-prompt-card{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1);overflow:hidden}
4071
- .dsh-powerup-prompt-card-head{display:flex;align-items:center;gap:10px;padding:8px 11px;flex-wrap:wrap}
4259
+ .dsh-powerup-group-form{display:flex;align-items:center;gap:6px;padding:6px 12px 9px}
4260
+ .dsh-powerup-group-form .dsh-powerup-prompt-input{flex:1 1 auto;min-width:0}
4261
+ .dsh-powerup-prompt-card{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1);overflow:hidden;transition:border-color .12s ease}
4262
+ .dsh-powerup-prompt-card.drop-target{border-color:var(--dsw-alias-state-business-primary);background:var(--dsw-alias-interactive-bg-hover)}
4263
+ .dsh-powerup-prompt-card[draggable=true]{cursor:grab}
4264
+ .dsh-powerup-prompt-drag-handle{flex:none;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1;cursor:grab}
4265
+ .dsh-powerup-prompt-card-head{display:flex;align-items:center;gap:8px;padding:8px 11px;flex-wrap:wrap}
4072
4266
  .dsh-powerup-prompt-name{font-size:13px;font-weight:600;line-height:1.4;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
4073
4267
  .dsh-powerup-prompt-card-actions{display:flex;align-items:center;gap:4px;margin-left:auto;flex-wrap:wrap}
4074
4268
  .dsh-powerup-linkbtn{background:none;border:0;padding:2px 4px;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;line-height:1.7;cursor:pointer;border-radius:5px}
@@ -8699,11 +8893,17 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8699
8893
 
8700
8894
  function PromptManager({ ctx }) {
8701
8895
  const prompts = usePrompts();
8896
+ const groups = usePromptGroups();
8702
8897
  const [, forceLocale] = useState(0);
8703
8898
  const [expanded, setExpanded] = useState(null);
8704
8899
  const [draft, setDraft] = useState(null);
8705
8900
  // Groups start expanded; collapsing one only affects this view.
8706
8901
  const [collapsedGroups, setCollapsedGroups] = useState(() => new Set());
8902
+ // Group create/rename: { scopeId, id:'', name:'' } (id='' => create).
8903
+ const [groupDraft, setGroupDraft] = useState(null);
8904
+ // Prompt id currently being dragged, for move-to-group drops.
8905
+ const dragRef = useRef(null);
8906
+ const [dragOver, setDragOver] = useState(null);
8707
8907
  const t = (key, params) => translateCurrent(key, params);
8708
8908
  useEffect(() => {
8709
8909
  const locale = ctx.get('locale');
@@ -8756,6 +8956,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8756
8956
  title: typeof draft.title === 'string' ? draft.title.trim() : '',
8757
8957
  text,
8758
8958
  workspaceId: typeof draft.workspaceId === 'string' ? draft.workspaceId.trim() : '',
8959
+ groupId: typeof draft.groupId === 'string' ? draft.groupId : '',
8759
8960
  };
8760
8961
  const next = prompts.filter((p) => p.id !== record.id);
8761
8962
  next.push(record);
@@ -8767,6 +8968,55 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8767
8968
  && !window.confirm(t('prompts.confirmDelete'))) return;
8768
8969
  writePrompts(prompts.filter((p) => p.id !== prompt.id));
8769
8970
  };
8971
+
8972
+ // ---- Group management ------------------------------------------
8973
+ const saveGroup = () => {
8974
+ if (groupDraft === null) return;
8975
+ const name = typeof groupDraft.name === 'string' ? groupDraft.name.trim() : '';
8976
+ if (name === '') return;
8977
+ const id = groupDraft.id;
8978
+ if (id === '') {
8979
+ writeGroups([...groups, {
8980
+ id: newId(), kind: 'group', name, workspaceId: groupDraft.scopeId,
8981
+ }]);
8982
+ } else {
8983
+ writeGroups(groups.map((g) => (g.id === id ? { ...g, name } : g)));
8984
+ }
8985
+ setGroupDraft(null);
8986
+ };
8987
+ const deleteGroup = (group) => {
8988
+ if (typeof window !== 'undefined' && typeof window.confirm === 'function'
8989
+ && !window.confirm(t('prompts.groupConfirmDelete'))) return;
8990
+ // Detach its prompts so none disappear; store both lists in one write.
8991
+ writeAll([
8992
+ ...groups.filter((g) => g.id !== group.id),
8993
+ ...prompts.map((p) => (p.groupId === group.id ? { ...p, groupId: '' } : p)),
8994
+ ]);
8995
+ };
8996
+ /** Move the dragged prompt into a group ('' = ungrouped) of a scope. */
8997
+ const movePrompt = (groupId, scopeId) => {
8998
+ const id = dragRef.current;
8999
+ dragRef.current = null;
9000
+ setDragOver(null);
9001
+ if (typeof id !== 'string' || id === '') return;
9002
+ writeAll([
9003
+ ...groups,
9004
+ ...prompts.map((p) => (p.id === id
9005
+ ? { ...p, groupId, workspaceId: scopeId }
9006
+ : p)),
9007
+ ]);
9008
+ };
9009
+ const dropProps = (key, groupId, scopeId) => ({
9010
+ onDragOver: (event) => {
9011
+ event.preventDefault();
9012
+ if (dragOver !== key) setDragOver(key);
9013
+ },
9014
+ onDragLeave: () => setDragOver((current) => (current === key ? null : current)),
9015
+ onDrop: (event) => {
9016
+ event.preventDefault();
9017
+ movePrompt(groupId, scopeId);
9018
+ },
9019
+ });
8770
9020
  const field = (label, key, placeholder, className) => h('label', { className: 'dsh-powerup-prompt-field' },
8771
9021
  h('span', { className: 'dsh-powerup-prompt-field-label' }, label),
8772
9022
  key === 'text'
@@ -8816,40 +9066,32 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8816
9066
  return found?.title || id;
8817
9067
  };
8818
9068
 
8819
- /**
8820
- * Group prompts by workspace: "all workspaces" first, then every real
8821
- * workspace in list order, then any orphaned scope not in the registry.
8822
- */
8823
- const groups = [];
8824
- const seenScope = new Set();
8825
- const pushGroup = (id) => {
8826
- if (seenScope.has(id)) return;
8827
- const items = prompts.filter((p) => p.workspaceId === id);
8828
- if (items.length === 0) return;
8829
- seenScope.add(id);
8830
- groups.push({ id, title: workspaceTitleOf(id), items });
8831
- };
8832
- pushGroup('');
8833
- for (const ws of workspaces) pushGroup(ws.workspaceId);
8834
- for (const prompt of prompts) pushGroup(prompt.workspaceId);
8835
-
8836
- const toggleGroup = (id) => {
9069
+ const toggleGroup = (key) => {
8837
9070
  setCollapsedGroups((current) => {
8838
9071
  const next = new Set(current);
8839
- if (next.has(id)) next.delete(id);
8840
- else next.add(id);
9072
+ if (next.has(key)) next.delete(key);
9073
+ else next.add(key);
8841
9074
  return next;
8842
9075
  });
8843
9076
  };
8844
9077
 
8845
- /** One collapsed prompt card: only the title plus edit/delete actions. */
8846
- const promptCard = (prompt) => {
9078
+ /** One collapsed prompt card: title + edit/delete, draggable. */
9079
+ const promptCard = (prompt, scopeId) => {
8847
9080
  const isExpanded = expanded === prompt.id;
8848
9081
  return h('section', {
8849
9082
  key: prompt.id,
8850
- className: 'dsh-powerup-prompt-card' + (isExpanded ? '' : ' folded'),
9083
+ draggable: !isExpanded,
9084
+ 'data-prompt-drag': prompt.id,
9085
+ className: 'dsh-powerup-prompt-card' + (isExpanded ? '' : ' folded')
9086
+ + (dragOver === 'card:' + prompt.id ? ' drop-target' : ''),
9087
+ onDragStart: (event) => {
9088
+ dragRef.current = prompt.id;
9089
+ try { event.dataTransfer?.setData?.('text/plain', prompt.id); } catch { /* best effort */ }
9090
+ },
9091
+ onDragEnd: () => { dragRef.current = null; setDragOver(null); },
8851
9092
  },
8852
9093
  h('div', { className: 'dsh-powerup-prompt-card-head' },
9094
+ h('span', { className: 'dsh-powerup-prompt-drag-handle', 'aria-hidden': 'true' }, '\u2807'),
8853
9095
  h('span', { className: 'dsh-powerup-prompt-name' }, promptLabel(prompt, t)),
8854
9096
  h('div', { className: 'dsh-powerup-prompt-card-actions' },
8855
9097
  h('button', {
@@ -8868,19 +9110,26 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8868
9110
  );
8869
9111
  };
8870
9112
 
8871
- const groupsView = groups.length === 0
8872
- ? h('div', { className: 'dsh-powerup-prompt-empty' }, t('prompts.empty'))
8873
- : h('div', { className: 'dsh-powerup-prompt-groups' }, groups.map((group) => {
8874
- const collapsed = collapsedGroups.has(group.id);
8875
- return h('section', {
8876
- key: 'group:' + group.id,
8877
- className: 'dsh-powerup-prompt-group' + (collapsed ? ' is-collapsed' : ''),
8878
- },
9113
+ /** One group block: header (drop target) + collapsible body. */
9114
+ const groupBlock = (section, scopeId) => {
9115
+ const key = scopeId + ':' + section.id;
9116
+ const collapsed = collapsedGroups.has(key);
9117
+ const isUngrouped = section.isUngrouped;
9118
+ const drop = dropProps(key, section.id, scopeId);
9119
+ const editingThis = groupDraft !== null && groupDraft.scopeId === scopeId
9120
+ && groupDraft.id === (isUngrouped ? '' : section.group.id);
9121
+ return h('section', {
9122
+ key,
9123
+ className: 'dsh-powerup-prompt-group' + (isUngrouped ? ' dsh-powerup-prompt-ungrouped' : '')
9124
+ + (collapsed ? ' is-collapsed' : '') + (dragOver === key ? ' drop-target' : ''),
9125
+ ...drop,
9126
+ },
9127
+ h('div', { className: 'dsh-powerup-prompt-group-head' },
8879
9128
  h('button', {
8880
9129
  type: 'button',
8881
- className: 'dsh-powerup-prompt-group-head',
9130
+ className: 'dsh-powerup-prompt-group-toggle',
8882
9131
  'aria-expanded': collapsed ? 'false' : 'true',
8883
- onClick: () => toggleGroup(group.id),
9132
+ onClick: () => toggleGroup(key),
8884
9133
  },
8885
9134
  h('span', {
8886
9135
  className: 'dsh-powerup-prompt-group-chevron',
@@ -8893,12 +9142,85 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
8893
9142
  strokeLinecap: 'round',
8894
9143
  strokeLinejoin: 'round',
8895
9144
  }))),
8896
- h('span', { className: 'dsh-powerup-prompt-group-title' }, group.title),
9145
+ h('span', { className: 'dsh-powerup-prompt-group-title' },
9146
+ isUngrouped ? t('prompts.ungrouped') : (section.name || t('prompts.untitled'))),
8897
9147
  h('span', { className: 'dsh-powerup-prompt-group-count' },
8898
- t('prompts.itemsCount', { count: group.items.length })),
9148
+ t('prompts.itemsCount', { count: section.items.length })),
8899
9149
  ),
8900
- collapsed ? null : h('div', { className: 'dsh-powerup-prompt-group-body' },
8901
- group.items.map(promptCard)),
9150
+ !isUngrouped
9151
+ ? h('div', { className: 'dsh-powerup-prompt-group-actions' },
9152
+ h('button', {
9153
+ type: 'button', className: 'dsh-powerup-linkbtn',
9154
+ onClick: () => setGroupDraft({ scopeId, id: section.group.id, name: section.name }),
9155
+ }, t('prompts.groupRename')),
9156
+ h('button', {
9157
+ type: 'button', className: 'dsh-powerup-linkbtn danger',
9158
+ onClick: () => deleteGroup(section.group),
9159
+ }, t('prompts.groupDelete')),
9160
+ )
9161
+ : null,
9162
+ ),
9163
+ editingThis
9164
+ ? h('div', { className: 'dsh-powerup-group-form' },
9165
+ h('input', {
9166
+ className: 'dsh-powerup-prompt-input',
9167
+ type: 'text',
9168
+ value: groupDraft.name,
9169
+ placeholder: t('prompts.groupNamePlaceholder'),
9170
+ onChange: (event) => setGroupDraft((current) => ({ ...current, name: event.target.value })),
9171
+ }),
9172
+ h('button', { type: 'button', className: 'dsh-powerup-prompt-new', onClick: saveGroup },
9173
+ groupDraft.id === '' ? t('prompts.groupCreate') : t('prompts.save')),
9174
+ h('button', { type: 'button', className: 'dsh-powerup-prompt-new', onClick: () => setGroupDraft(null) },
9175
+ t('prompts.cancel')),
9176
+ )
9177
+ : null,
9178
+ collapsed ? null : h('div', { className: 'dsh-powerup-prompt-group-body' },
9179
+ section.items.map((prompt) => promptCard(prompt, scopeId))),
9180
+ );
9181
+ };
9182
+
9183
+ // Scopes: global first, then every registered workspace, then orphaned.
9184
+ const scopeIds = [];
9185
+ if (prompts.some((p) => p.workspaceId === '') || groups.some((g) => g.workspaceId === '')) scopeIds.push('');
9186
+ for (const ws of workspaces) {
9187
+ if (prompts.some((p) => p.workspaceId === ws.workspaceId)
9188
+ || groups.some((g) => g.workspaceId === ws.workspaceId)) scopeIds.push(ws.workspaceId);
9189
+ }
9190
+ for (const prompt of prompts) {
9191
+ if (!scopeIds.includes(prompt.workspaceId)) scopeIds.push(prompt.workspaceId);
9192
+ }
9193
+ for (const group of groups) {
9194
+ if (!scopeIds.includes(group.workspaceId)) scopeIds.push(group.workspaceId);
9195
+ }
9196
+
9197
+ const groupsView = scopeIds.length === 0
9198
+ ? h('div', { className: 'dsh-powerup-prompt-empty' }, t('prompts.empty'))
9199
+ : h('div', { className: 'dsh-powerup-prompt-scopes' }, scopeIds.map((scopeId) => {
9200
+ const sub = groupPrompts(prompts, groups, scopeId);
9201
+ const creatingGroupHere = groupDraft !== null && groupDraft.scopeId === scopeId && groupDraft.id === '';
9202
+ return h('section', { key: 'scope:' + scopeId, className: 'dsh-powerup-prompt-scope' },
9203
+ h('div', { className: 'dsh-powerup-prompt-scope-head' },
9204
+ h('span', { className: 'dsh-powerup-prompt-scope-title' }, workspaceTitleOf(scopeId)),
9205
+ h('button', {
9206
+ type: 'button', className: 'dsh-powerup-linkbtn',
9207
+ onClick: () => setGroupDraft({ scopeId, id: '', name: '' }),
9208
+ }, t('prompts.groupNew')),
9209
+ ),
9210
+ creatingGroupHere
9211
+ ? h('div', { className: 'dsh-powerup-group-form' },
9212
+ h('input', {
9213
+ className: 'dsh-powerup-prompt-input', type: 'text', value: groupDraft.name,
9214
+ placeholder: t('prompts.groupNamePlaceholder'),
9215
+ onChange: (event) => setGroupDraft((current) => ({ ...current, name: event.target.value })),
9216
+ }),
9217
+ h('button', { type: 'button', className: 'dsh-powerup-prompt-new', onClick: saveGroup },
9218
+ t('prompts.groupCreate')),
9219
+ h('button', { type: 'button', className: 'dsh-powerup-prompt-new', onClick: () => setGroupDraft(null) },
9220
+ t('prompts.cancel')),
9221
+ )
9222
+ : null,
9223
+ h('div', { className: 'dsh-powerup-prompt-groups' }, sub.map((section) => groupBlock(section, scopeId))),
8902
9224
  );
8903
9225
  }));
8904
9226
 
@@ -9259,6 +9581,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
9259
9581
  promptCreateDraft,
9260
9582
  readPrompts,
9261
9583
  writePrompts,
9584
+ readGroups,
9585
+ writeGroups,
9586
+ writeAll,
9587
+ groupPrompts,
9262
9588
  promptsForWorkspace,
9263
9589
  promptLabel,
9264
9590
  readLastPrompt,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-powerup",
3
- "version": "0.10.2",
3
+ "version": "0.10.3",
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",