@restregular/dsh-powerup 0.10.1 → 0.10.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 +2 -1
- package/client.js +103 -42
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -189,7 +189,8 @@ Save reusable prompts and drop one into a new session without retyping it.
|
|
|
189
189
|
picker also appears in the composer's bottom tool row, just right of the
|
|
190
190
|
permission dropdown; there its menu opens **upward**. **Clicking a prompt
|
|
191
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
|
|
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.
|
|
193
194
|
- **Create a new prompt…** in the dropdown opens an in-conversation dialog. A
|
|
194
195
|
prompt created here is pinned to the current workspace — you may only keep
|
|
195
196
|
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.
|
|
86
|
+
const VERSION = '0.10.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. */
|
|
@@ -382,6 +382,8 @@
|
|
|
382
382
|
'prompts.createNew': '创建新的提示词…',
|
|
383
383
|
'prompts.noPrompts': '这个工作区还没有提示词',
|
|
384
384
|
'prompts.createTitle': '新建提示词',
|
|
385
|
+
'prompts.editTitle': '编辑提示词',
|
|
386
|
+
'prompts.editHint': '修改这条提示词的标题、可见范围与正文。',
|
|
385
387
|
'prompts.createScopeHint': '这个提示词会自动归属到当前工作区;你也可以改为「所有工作区」。',
|
|
386
388
|
'prompts.createFailed': '创建失败:{message}',
|
|
387
389
|
'prompts.workspaceCurrent': '当前工作区',
|
|
@@ -674,6 +676,8 @@
|
|
|
674
676
|
'prompts.createNew': 'Create a new prompt…',
|
|
675
677
|
'prompts.noPrompts': 'No prompts for this workspace yet',
|
|
676
678
|
'prompts.createTitle': 'New prompt',
|
|
679
|
+
'prompts.editTitle': 'Edit prompt',
|
|
680
|
+
'prompts.editHint': 'Change this prompt\'s title, scope and text.',
|
|
677
681
|
'prompts.createScopeHint': 'This prompt will belong to the current workspace automatically; you can also choose "All workspaces".',
|
|
678
682
|
'prompts.createFailed': 'Could not create: {message}',
|
|
679
683
|
'prompts.workspaceCurrent': 'Current workspace',
|
|
@@ -2856,7 +2860,7 @@
|
|
|
2856
2860
|
* Open the prompt picker next to the hero control. Returns a disposer.
|
|
2857
2861
|
* DOM-based like the session switcher so it survives host re-renders.
|
|
2858
2862
|
*/
|
|
2859
|
-
function openPromptPopover({ anchor, t, items, onPick, onSend, onCreate, onDispose, placement }) {
|
|
2863
|
+
function openPromptPopover({ anchor, t, items, onPick, onSend, onEdit, onCreate, onDispose, placement }) {
|
|
2860
2864
|
if (anchor === null || anchor === undefined || typeof document === 'undefined') return () => {};
|
|
2861
2865
|
const element = document.createElement('div');
|
|
2862
2866
|
element.className = 'dsh-powerup-prompt-pop';
|
|
@@ -2926,7 +2930,25 @@
|
|
|
2926
2930
|
dispose();
|
|
2927
2931
|
onSend(prompt);
|
|
2928
2932
|
});
|
|
2929
|
-
row.append(main
|
|
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) => {
|
|
2944
|
+
event.preventDefault();
|
|
2945
|
+
event.stopPropagation();
|
|
2946
|
+
dispose();
|
|
2947
|
+
onEdit(prompt);
|
|
2948
|
+
});
|
|
2949
|
+
row.append(edit);
|
|
2950
|
+
}
|
|
2951
|
+
row.append(send);
|
|
2930
2952
|
list.appendChild(row);
|
|
2931
2953
|
}
|
|
2932
2954
|
element.appendChild(list);
|
|
@@ -2986,28 +3008,34 @@
|
|
|
2986
3008
|
}
|
|
2987
3009
|
|
|
2988
3010
|
/**
|
|
2989
|
-
* In-conversation
|
|
2990
|
-
*
|
|
2991
|
-
*
|
|
3011
|
+
* In-conversation prompt dialog: creates a new prompt, or edits an
|
|
3012
|
+
* existing one when `prompt` is passed. For creation the workspace is
|
|
3013
|
+
* pinned to the session's own workspace: the user may only keep it or
|
|
3014
|
+
* switch to "all workspaces", never pick another workspace.
|
|
2992
3015
|
*/
|
|
2993
|
-
function PromptCreateModal({ workspaceId, workspaceTitle, onClose, onCreated }) {
|
|
3016
|
+
function PromptCreateModal({ workspaceId, workspaceTitle, onClose, onCreated, prompt, onUpdated }) {
|
|
2994
3017
|
const t = (key, params) => translateCurrent(key, params);
|
|
2995
|
-
const
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
promptCreateDraft.workspaceId
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3018
|
+
const editing = prompt !== null && prompt !== undefined && typeof prompt === 'object';
|
|
3019
|
+
const fixedScope = !editing && (typeof workspaceId !== 'string' || workspaceId === '');
|
|
3020
|
+
if (!editing) {
|
|
3021
|
+
// Reopening the dialog for the same workspace restores the previous
|
|
3022
|
+
// draft; switching to another workspace starts from a clean slate.
|
|
3023
|
+
const sameWorkspace = promptCreateDraft.workspaceId === (fixedScope ? '' : workspaceId);
|
|
3024
|
+
if (!sameWorkspace) {
|
|
3025
|
+
promptCreateDraft.workspaceId = fixedScope ? '' : workspaceId;
|
|
3026
|
+
promptCreateDraft.title = '';
|
|
3027
|
+
promptCreateDraft.text = '';
|
|
3028
|
+
promptCreateDraft.scope = fixedScope ? 'all' : 'current';
|
|
3029
|
+
}
|
|
3030
|
+
}
|
|
3031
|
+
const [title, setTitle] = useState(editing ? (prompt.title || '') : promptCreateDraft.title);
|
|
3032
|
+
const [text, setText] = useState(editing ? (prompt.text || '') : promptCreateDraft.text);
|
|
3033
|
+
const [scope, setScope] = useState(editing
|
|
3034
|
+
? (prompt.workspaceId && prompt.workspaceId === workspaceId ? 'current' : 'all')
|
|
3035
|
+
: promptCreateDraft.scope);
|
|
3008
3036
|
const titleRef = useRef(null);
|
|
3009
3037
|
// Close plays an exit animation first, so the dialog does not vanish
|
|
3010
|
-
// abruptly; the draft is already persisted by the effect below.
|
|
3038
|
+
// abruptly; the create draft is already persisted by the effect below.
|
|
3011
3039
|
const [closing, setClosing] = useState(false);
|
|
3012
3040
|
const closingRef = useRef(false);
|
|
3013
3041
|
const requestClose = () => {
|
|
@@ -3023,10 +3051,11 @@
|
|
|
3023
3051
|
}, 140);
|
|
3024
3052
|
};
|
|
3025
3053
|
useEffect(() => {
|
|
3054
|
+
if (editing) return;
|
|
3026
3055
|
promptCreateDraft.title = title;
|
|
3027
3056
|
promptCreateDraft.text = text;
|
|
3028
3057
|
promptCreateDraft.scope = scope;
|
|
3029
|
-
}, [title, text, scope]);
|
|
3058
|
+
}, [title, text, scope, editing]);
|
|
3030
3059
|
useEffect(() => {
|
|
3031
3060
|
try {
|
|
3032
3061
|
// preventScroll keeps the focus from scrolling the page mid-animation.
|
|
@@ -3048,19 +3077,34 @@
|
|
|
3048
3077
|
const save = () => {
|
|
3049
3078
|
const body = typeof text === 'string' ? text.trim() : '';
|
|
3050
3079
|
if (body === '') return;
|
|
3051
|
-
const record = {
|
|
3052
|
-
id: newId(),
|
|
3053
|
-
title: typeof title === 'string' ? title.trim() : '',
|
|
3054
|
-
text: body,
|
|
3055
|
-
workspaceId: scope === 'current' && typeof workspaceId === 'string' ? workspaceId : '',
|
|
3056
|
-
};
|
|
3057
3080
|
const list = readPrompts();
|
|
3058
|
-
|
|
3081
|
+
let record;
|
|
3082
|
+
if (editing) {
|
|
3083
|
+
record = {
|
|
3084
|
+
id: prompt.id,
|
|
3085
|
+
title: typeof title === 'string' ? title.trim() : '',
|
|
3086
|
+
text: body,
|
|
3087
|
+
workspaceId: scope === 'current' && typeof workspaceId === 'string' ? workspaceId : '',
|
|
3088
|
+
};
|
|
3089
|
+
const index = list.findIndex((p) => p.id === record.id);
|
|
3090
|
+
if (index === -1) list.push(record);
|
|
3091
|
+
else list[index] = record;
|
|
3092
|
+
} else {
|
|
3093
|
+
record = {
|
|
3094
|
+
id: newId(),
|
|
3095
|
+
title: typeof title === 'string' ? title.trim() : '',
|
|
3096
|
+
text: body,
|
|
3097
|
+
workspaceId: scope === 'current' && typeof workspaceId === 'string' ? workspaceId : '',
|
|
3098
|
+
};
|
|
3099
|
+
list.push(record);
|
|
3100
|
+
}
|
|
3059
3101
|
writePrompts(list);
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3102
|
+
if (!editing) {
|
|
3103
|
+
// The draft became a real prompt: the next dialog starts empty.
|
|
3104
|
+
promptCreateDraft.title = '';
|
|
3105
|
+
promptCreateDraft.text = '';
|
|
3106
|
+
promptCreateDraft.scope = fixedScope ? 'all' : 'current';
|
|
3107
|
+
}
|
|
3064
3108
|
// Play the exit animation before telling the parent to unmount.
|
|
3065
3109
|
if (!closingRef.current) {
|
|
3066
3110
|
closingRef.current = true;
|
|
@@ -3068,7 +3112,11 @@
|
|
|
3068
3112
|
}
|
|
3069
3113
|
setTimeout(() => {
|
|
3070
3114
|
try {
|
|
3071
|
-
|
|
3115
|
+
if (editing) {
|
|
3116
|
+
if (typeof onUpdated === 'function') onUpdated(record);
|
|
3117
|
+
} else if (typeof onCreated === 'function') {
|
|
3118
|
+
onCreated(record);
|
|
3119
|
+
}
|
|
3072
3120
|
} catch {
|
|
3073
3121
|
/* The parent owns unmounting. */
|
|
3074
3122
|
}
|
|
@@ -3088,13 +3136,13 @@
|
|
|
3088
3136
|
className: 'dsh-powerup-prompt-modal' + (closing ? ' is-closing' : ''),
|
|
3089
3137
|
role: 'dialog',
|
|
3090
3138
|
'aria-modal': 'true',
|
|
3091
|
-
'aria-label': t('prompts.createTitle'),
|
|
3139
|
+
'aria-label': t(editing ? 'prompts.editTitle' : 'prompts.createTitle'),
|
|
3092
3140
|
},
|
|
3093
3141
|
h('div', { className: 'dsh-powerup-prompt-modal-head' },
|
|
3094
3142
|
h('div', null,
|
|
3095
|
-
h('div', { className: 'dsh-powerup-prompt-modal-heading' }, t('prompts.createTitle')),
|
|
3143
|
+
h('div', { className: 'dsh-powerup-prompt-modal-heading' }, t(editing ? 'prompts.editTitle' : 'prompts.createTitle')),
|
|
3096
3144
|
h('p', { className: 'dsh-powerup-prompt-modal-sub' },
|
|
3097
|
-
fixedScope ? t('prompts.workspaceNone') : t('prompts.createScopeHint')),
|
|
3145
|
+
editing ? t('prompts.editHint') : (fixedScope ? t('prompts.workspaceNone') : t('prompts.createScopeHint'))),
|
|
3098
3146
|
),
|
|
3099
3147
|
h('button', {
|
|
3100
3148
|
type: 'button',
|
|
@@ -3150,7 +3198,7 @@
|
|
|
3150
3198
|
className: 'dsh-powerup-prompt-modal-save',
|
|
3151
3199
|
disabled: text.trim() === '',
|
|
3152
3200
|
onClick: save,
|
|
3153
|
-
}, t('prompts.create')),
|
|
3201
|
+
}, t(editing ? 'prompts.save' : 'prompts.create')),
|
|
3154
3202
|
),
|
|
3155
3203
|
),
|
|
3156
3204
|
));
|
|
@@ -3174,6 +3222,7 @@
|
|
|
3174
3222
|
const prompts = usePrompts(workspaceId);
|
|
3175
3223
|
const [, forceLocale] = useState(0);
|
|
3176
3224
|
const [creating, setCreating] = useState(false);
|
|
3225
|
+
const [editing, setEditing] = useState(null);
|
|
3177
3226
|
const anchorRef = useRef(null);
|
|
3178
3227
|
const disposeRef = useRef(null);
|
|
3179
3228
|
const t = (key, params) => translateCurrent(key, params);
|
|
@@ -3263,6 +3312,7 @@
|
|
|
3263
3312
|
placement: (node) => popoverPlacement(node, 360, 340, { preferUp: compact }),
|
|
3264
3313
|
onPick: (prompt) => apply(prompt, false),
|
|
3265
3314
|
onSend: (prompt) => apply(prompt, true),
|
|
3315
|
+
onEdit: (prompt) => setEditing(prompt),
|
|
3266
3316
|
onCreate: () => setCreating(true),
|
|
3267
3317
|
onDispose: () => {
|
|
3268
3318
|
disposeRef.current = null;
|
|
@@ -3299,6 +3349,15 @@
|
|
|
3299
3349
|
},
|
|
3300
3350
|
})
|
|
3301
3351
|
: null,
|
|
3352
|
+
editing
|
|
3353
|
+
? h(PromptCreateModal, {
|
|
3354
|
+
workspaceId,
|
|
3355
|
+
workspaceTitle,
|
|
3356
|
+
prompt: editing,
|
|
3357
|
+
onClose: () => setEditing(null),
|
|
3358
|
+
onUpdated: () => setEditing(null),
|
|
3359
|
+
})
|
|
3360
|
+
: null,
|
|
3302
3361
|
);
|
|
3303
3362
|
}
|
|
3304
3363
|
|
|
@@ -3976,10 +4035,10 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
3976
4035
|
.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}
|
|
3977
4036
|
.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}
|
|
3978
4037
|
.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}
|
|
3979
|
-
.dsh-powerup-prompt-pop-send{flex:none;display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font:inherit;line-height:1;cursor:pointer;transition:background .12s ease,color .12s ease,border-color .12s ease}
|
|
3980
|
-
.dsh-powerup-prompt-pop-send svg{width:14px;height:14px}
|
|
3981
|
-
.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)}
|
|
3982
|
-
.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}
|
|
4038
|
+
.dsh-powerup-prompt-pop-send,.dsh-powerup-prompt-pop-edit{flex:none;display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;padding:0;border:.5px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-secondary);font:inherit;line-height:1;cursor:pointer;transition:background .12s ease,color .12s ease,border-color .12s ease}
|
|
4039
|
+
.dsh-powerup-prompt-pop-send svg,.dsh-powerup-prompt-pop-edit svg{width:14px;height:14px}
|
|
4040
|
+
.dsh-powerup-prompt-pop-send:hover,.dsh-powerup-prompt-pop-edit:hover{border-color:var(--dsw-alias-state-business-primary);background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-brand-primary)}
|
|
4041
|
+
.dsh-powerup-prompt-pop-send:focus-visible,.dsh-powerup-prompt-pop-edit: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}
|
|
3983
4042
|
.dsh-powerup-prompt-pop-sep{flex:none;height:1px;margin:4px 6px;background:var(--dsw-alias-border-l1)}
|
|
3984
4043
|
.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}
|
|
3985
4044
|
.dsh-powerup-prompt-pop-create:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
@@ -9205,6 +9264,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9205
9264
|
readLastPrompt,
|
|
9206
9265
|
writeLastPrompt,
|
|
9207
9266
|
resolveWorkspaceIdFromSnapshot,
|
|
9267
|
+
openPromptPopover,
|
|
9268
|
+
PromptCreateModal,
|
|
9208
9269
|
HeroPromptsControl,
|
|
9209
9270
|
PromptManager,
|
|
9210
9271
|
runningSessionRows,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restregular/dsh-powerup",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.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",
|