@restregular/dsh-powerup 0.14.0 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/client.js +258 -91
- package/index.js +18 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -449,10 +449,13 @@ the running agent:
|
|
|
449
449
|
|
|
450
450
|
Requirements are a **list of records** (just like prompts), managed in the
|
|
451
451
|
Power-Up page's dedicated **Requirements** tab and in the conversation's
|
|
452
|
-
Power-Up settings tab.
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
requirements
|
|
452
|
+
Power-Up settings tab. On creation you pick the workspace (or "all workspaces");
|
|
453
|
+
only scopes that actually contain requirements are listed. Each record can be
|
|
454
|
+
enabled/disabled, edited and deleted. When generating progress you **check the
|
|
455
|
+
requirements you want** — checked ones fill an editable text box that you may
|
|
456
|
+
freely modify, and generation/refresh uses the full box text verbatim. The panel
|
|
457
|
+
also has a **New requirement** entry with a modal pinned to the session's
|
|
458
|
+
workspace (like the prompt picker).
|
|
456
459
|
The panel is wider by default, resizable from its bottom-right corner (size
|
|
457
460
|
persisted), and its header tint shifts from blue toward warning red as the
|
|
458
461
|
report ages. Every refresh adds a new report to a per-session history stored on
|
package/client.js
CHANGED
|
@@ -81,9 +81,11 @@
|
|
|
81
81
|
* of resetting it. Cleared once the prompt is actually created.
|
|
82
82
|
*/
|
|
83
83
|
const promptCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
|
|
84
|
+
/** In-progress "new requirement" dialog draft (progress panel). */
|
|
85
|
+
const requirementCreateDraft = { workspaceId: null, title: '', text: '', scope: 'current' };
|
|
84
86
|
/** Fallback bucket when the hero cannot resolve an owning workspace yet. */
|
|
85
87
|
const UNSCOPED_WORKSPACE = '__unscoped__';
|
|
86
|
-
const VERSION = '0.
|
|
88
|
+
const VERSION = '0.15.0';
|
|
87
89
|
const MENU_GAP = 8;
|
|
88
90
|
const MENU_WIDTH = 248;
|
|
89
91
|
/** Reference scheme understood by the Host's `powerup_step_read` tool. */
|
|
@@ -387,7 +389,10 @@
|
|
|
387
389
|
'progress.reqHint': '每条要求可设置语言、结构、必须包含的数据、额外展示区要回答的问题等;按工作区隔离,留空工作区则对所有工作区生效。生成进度时可勾选本次要应用哪些要求。',
|
|
388
390
|
'progress.reqNew': '新建要求',
|
|
389
391
|
'progress.reqSelect': '本次应用的要求',
|
|
390
|
-
'progress.reqSelectHint': '
|
|
392
|
+
'progress.reqSelectHint': '勾选要求后内容会填入下方输入框,可自由修改;生成/刷新时会使用输入框里的完整要求。',
|
|
393
|
+
'progress.reqEditPlaceholder': '在这里编辑本次生成要使用的要求…',
|
|
394
|
+
'progress.reqTextLabel': '要求内容',
|
|
395
|
+
'progress.sectionTitle': '生成要求',
|
|
391
396
|
'progress.reqGlobal': '通用要求(设置页)',
|
|
392
397
|
'progress.reqWorkspace': '工作区要求',
|
|
393
398
|
'progress.reqSession': '会话要求',
|
|
@@ -774,7 +779,10 @@
|
|
|
774
779
|
'progress.reqHint': 'Each requirement sets language, structure, required data, questions for the display area, etc. Scoped per workspace; a blank workspace applies everywhere. Choose which ones to apply when generating progress.',
|
|
775
780
|
'progress.reqNew': 'New requirement',
|
|
776
781
|
'progress.reqSelect': 'Requirements for this run',
|
|
777
|
-
'progress.reqSelectHint': '
|
|
782
|
+
'progress.reqSelectHint': 'Checked requirements fill the box below; edit freely. Generation uses the full text in the box.',
|
|
783
|
+
'progress.reqEditPlaceholder': 'Edit the requirements to use for this generation…',
|
|
784
|
+
'progress.reqTextLabel': 'Requirement text',
|
|
785
|
+
'progress.sectionTitle': 'Generation requirements',
|
|
778
786
|
'progress.reqGlobal': 'Global requirements (settings)',
|
|
779
787
|
'progress.reqWorkspace': 'Workspace requirements',
|
|
780
788
|
'progress.reqSession': 'Session requirements',
|
|
@@ -4614,6 +4622,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
4614
4622
|
.dsh-powerup-req-option{display:flex;align-items:center;gap:8px;padding:5px 8px;border-radius:6px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);font-size:11.5px;cursor:pointer}
|
|
4615
4623
|
.dsh-powerup-req-option:hover{background:var(--dsw-alias-interactive-bg-hover)}
|
|
4616
4624
|
.dsh-powerup-req-option input{flex:none;accent-color:var(--dsw-alias-brand-primary)}
|
|
4625
|
+
.dsh-powerup-req-textarea{min-height:96px;margin-top:6px}
|
|
4626
|
+
.dsh-powerup-req-create{margin-top:8px}
|
|
4627
|
+
.dsh-powerup-prompt-scope-options{display:flex;flex-wrap:wrap;gap:8px}
|
|
4617
4628
|
.dsh-powerup-req-manager{display:flex;flex-direction:column;gap:16px}
|
|
4618
4629
|
.dsh-powerup-req-list{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;list-style:none}
|
|
4619
4630
|
.dsh-powerup-req-item{display:flex;align-items:flex-start;gap:10px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1)}
|
|
@@ -9625,7 +9636,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
9625
9636
|
),
|
|
9626
9637
|
),
|
|
9627
9638
|
h(MaskRuleEditor, { scope: 'workspace', t, workspaceId }),
|
|
9628
|
-
h(RequirementManager, { ctx
|
|
9639
|
+
h(RequirementManager, { ctx }),
|
|
9629
9640
|
),
|
|
9630
9641
|
);
|
|
9631
9642
|
}
|
|
@@ -10326,31 +10337,56 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10326
10337
|
.filter((r) => r.workspaceId === '' || r.workspaceId === id);
|
|
10327
10338
|
}
|
|
10328
10339
|
|
|
10329
|
-
/**
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10335
|
-
|
|
10336
|
-
|
|
10337
|
-
|
|
10338
|
-
onChange: (event) =>
|
|
10340
|
+
/**
|
|
10341
|
+
* Create/edit form for one requirement record. On creation the workspace
|
|
10342
|
+
* is chosen here (any workspace, or global) — exactly like the prompt form.
|
|
10343
|
+
*/
|
|
10344
|
+
function RequirementForm({ draft, setDraft, workspaces, t, save, cancel }) {
|
|
10345
|
+
const field = (key, placeholder, className) => h('label', { className: 'dsh-powerup-prompt-field' },
|
|
10346
|
+
h('input', {
|
|
10347
|
+
className: 'dsh-powerup-prompt-input' + (className ? ' ' + className : ''),
|
|
10348
|
+
type: 'text', value: draft?.[key] ?? '', placeholder,
|
|
10349
|
+
onChange: (event) => setDraft({ ...draft, [key]: event.target.value }),
|
|
10339
10350
|
}),
|
|
10340
10351
|
);
|
|
10352
|
+
return h('div', { className: 'dsh-powerup-req-form' },
|
|
10353
|
+
field('title', t('prompts.titlePlaceholder')),
|
|
10354
|
+
h('label', { className: 'dsh-powerup-prompt-field' },
|
|
10355
|
+
h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.workspaceLabel')),
|
|
10356
|
+
h(WorkspaceSelect, {
|
|
10357
|
+
value: draft?.workspaceId ?? '',
|
|
10358
|
+
options: [
|
|
10359
|
+
{ value: '', label: t('prompts.anyWorkspace') },
|
|
10360
|
+
...workspaces.map((ws) => ({ value: ws.workspaceId, label: ws.title || ws.workspaceId, hint: ws.title ? ws.workspaceId : undefined })),
|
|
10361
|
+
],
|
|
10362
|
+
onChange: (value) => setDraft({ ...draft, workspaceId: value }),
|
|
10363
|
+
t,
|
|
10364
|
+
}),
|
|
10365
|
+
),
|
|
10366
|
+
h('label', { className: 'dsh-powerup-prompt-field' },
|
|
10367
|
+
h('span', { className: 'dsh-powerup-prompt-field-label' }, t('progress.reqTextLabel')),
|
|
10368
|
+
h('textarea', {
|
|
10369
|
+
className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea',
|
|
10370
|
+
value: draft?.text ?? '', placeholder: t('progress.reqPlaceholder'),
|
|
10371
|
+
onChange: (event) => setDraft({ ...draft, text: event.target.value }),
|
|
10372
|
+
}),
|
|
10373
|
+
),
|
|
10374
|
+
h('div', { className: 'dsh-powerup-prompt-form-actions' },
|
|
10375
|
+
h('button', { type: 'button', className: 'dsh-powerup-prompt-new', onClick: cancel }, t('prompts.cancel')),
|
|
10376
|
+
h('button', { type: 'button', className: 'dsh-powerup-prompt-new', onClick: save }, t('prompts.save')),
|
|
10377
|
+
),
|
|
10378
|
+
);
|
|
10341
10379
|
}
|
|
10342
10380
|
|
|
10343
10381
|
/**
|
|
10344
|
-
*
|
|
10345
|
-
*
|
|
10346
|
-
*
|
|
10347
|
-
* the workspace-scoped editor in the conversation settings tab.
|
|
10382
|
+
* Settings-page manager, modelled on PromptManager: "New requirement"
|
|
10383
|
+
* opens the form where the workspace is picked; only scopes that actually
|
|
10384
|
+
* contain requirements are listed (global first, then each such workspace).
|
|
10348
10385
|
*/
|
|
10349
|
-
function RequirementManager({ ctx
|
|
10386
|
+
function RequirementManager({ ctx }) {
|
|
10350
10387
|
const reqs = useRequirements();
|
|
10351
10388
|
const [, forceLocale] = useState(0);
|
|
10352
10389
|
const [draft, setDraft] = useState(null);
|
|
10353
|
-
const [expanded, setExpanded] = useState(null);
|
|
10354
10390
|
const t = (key, params) => translateCurrent(key, params);
|
|
10355
10391
|
useEffect(() => {
|
|
10356
10392
|
const locale = ctx?.get?.('locale');
|
|
@@ -10363,22 +10399,9 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10363
10399
|
return Array.isArray(snapshot?.items) ? snapshot.items : [];
|
|
10364
10400
|
} catch { return []; }
|
|
10365
10401
|
})();
|
|
10366
|
-
const
|
|
10367
|
-
? reqs.filter((r) => r.workspaceId === (typeof workspaceId === 'string' ? workspaceId : ''))
|
|
10368
|
-
: reqs;
|
|
10369
|
-
|
|
10370
|
-
const sections = workspaceOnly
|
|
10371
|
-
? [{ id: workspaceId ?? '', label: t('progress.reqWorkspace'), items: visible }]
|
|
10372
|
-
: [
|
|
10373
|
-
{ id: '', label: t('prompts.scopeGlobal'), items: reqs.filter((r) => r.workspaceId === '') },
|
|
10374
|
-
...workspaces.map((ws) => ({
|
|
10375
|
-
id: ws.workspaceId,
|
|
10376
|
-
label: ws.title ?? ws.workspaceId,
|
|
10377
|
-
items: reqs.filter((r) => r.workspaceId === ws.workspaceId),
|
|
10378
|
-
})),
|
|
10379
|
-
];
|
|
10402
|
+
const titleOf = (id) => id === '' ? t('prompts.anyWorkspace') : (workspaces.find((ws) => ws.workspaceId === id)?.title || id);
|
|
10380
10403
|
|
|
10381
|
-
const cancel = () =>
|
|
10404
|
+
const cancel = () => setDraft(null);
|
|
10382
10405
|
const save = () => {
|
|
10383
10406
|
if (draft === null) return;
|
|
10384
10407
|
const text = typeof draft.text === 'string' ? draft.text.trim() : '';
|
|
@@ -10404,12 +10427,41 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10404
10427
|
saveRequirements(reqs.map((r) => (r.id === record.id ? { ...r, enabled: r.enabled === false } : r)));
|
|
10405
10428
|
};
|
|
10406
10429
|
|
|
10407
|
-
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10430
|
+
// Only show scopes that have requirements (plus orphaned ids).
|
|
10431
|
+
const scopeIds = [];
|
|
10432
|
+
if (reqs.some((r) => r.workspaceId === '')) scopeIds.push('');
|
|
10433
|
+
for (const ws of workspaces) {
|
|
10434
|
+
if (reqs.some((r) => r.workspaceId === ws.workspaceId)) scopeIds.push(ws.workspaceId);
|
|
10435
|
+
}
|
|
10436
|
+
for (const r of reqs) {
|
|
10437
|
+
if (!scopeIds.includes(r.workspaceId)) scopeIds.push(r.workspaceId);
|
|
10438
|
+
}
|
|
10439
|
+
|
|
10440
|
+
return h('div', null,
|
|
10441
|
+
h('div', { className: 'dsh-powerup-prompt-head' },
|
|
10442
|
+
h('div', null,
|
|
10443
|
+
h('div', { className: 'dsh-powerup-prompt-head-title' }, t('progress.sectionTitle')),
|
|
10444
|
+
h('div', { className: 'dsh-powerup-prompt-head-sub' }, t('progress.reqHint')),
|
|
10445
|
+
),
|
|
10446
|
+
h('button', {
|
|
10447
|
+
type: 'button', className: 'dsh-powerup-prompt-new',
|
|
10448
|
+
onClick: () => setDraft({ id: '', title: '', text: '', workspaceId: '', enabled: true }),
|
|
10449
|
+
}, t('progress.reqNew')),
|
|
10450
|
+
),
|
|
10451
|
+
draft !== null ? h('section', { className: 'dsh-powerup-prompt-card' },
|
|
10452
|
+
h(RequirementForm, { draft, setDraft, workspaces, t, save, cancel }),
|
|
10453
|
+
) : null,
|
|
10454
|
+
scopeIds.length === 0
|
|
10455
|
+
? h('div', { className: 'dsh-powerup-prompt-empty' }, t('progress.reqEmpty'))
|
|
10456
|
+
: h('div', { className: 'dsh-powerup-prompt-scopes' }, scopeIds.map((scopeId) => h('section', {
|
|
10457
|
+
key: 'scope:' + scopeId, className: 'dsh-powerup-prompt-scope',
|
|
10458
|
+
},
|
|
10459
|
+
h('div', { className: 'dsh-powerup-prompt-scope-head' },
|
|
10460
|
+
h('span', { className: 'dsh-powerup-prompt-scope-title' }, titleOf(scopeId)),
|
|
10461
|
+
),
|
|
10462
|
+
h('div', { className: 'dsh-powerup-req-list' }, reqs.filter((r) => r.workspaceId === scopeId).map((r) => h('div', {
|
|
10463
|
+
key: r.id, className: 'dsh-powerup-req-item' + (r.enabled === false ? ' off' : ''),
|
|
10464
|
+
},
|
|
10413
10465
|
h('button', {
|
|
10414
10466
|
type: 'button', role: 'switch', 'aria-checked': r.enabled !== false ? 'true' : 'false',
|
|
10415
10467
|
className: 'dsh-powerup-switch', title: t('page.enabled'),
|
|
@@ -10420,61 +10472,131 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10420
10472
|
h('span', { className: 'dsh-powerup-req-text' }, r.text),
|
|
10421
10473
|
),
|
|
10422
10474
|
h('button', {
|
|
10423
|
-
type: 'button', className: 'dsh-powerup-
|
|
10475
|
+
type: 'button', className: 'dsh-powerup-linkbtn',
|
|
10476
|
+
onClick: () => setDraft({ ...r }),
|
|
10424
10477
|
}, t('prompts.edit')),
|
|
10425
10478
|
h('button', {
|
|
10426
|
-
type: 'button', className: 'dsh-powerup-
|
|
10479
|
+
type: 'button', className: 'dsh-powerup-linkbtn danger',
|
|
10480
|
+
onClick: () => remove(r),
|
|
10427
10481
|
}, t('prompts.delete')),
|
|
10428
|
-
)),
|
|
10429
|
-
),
|
|
10430
|
-
expanded === `new-${section.id}` && draft !== null
|
|
10431
|
-
? h(RequirementForm, { draft, setDraft, workspaces, workspaceOnly, scopeId: section.id, t, save, cancel })
|
|
10432
|
-
: null,
|
|
10433
|
-
h('button', {
|
|
10434
|
-
type: 'button', className: 'dsh-powerup-prompt-new',
|
|
10435
|
-
onClick: () => { setDraft({ id: '', title: '', text: '', workspaceId: section.id, enabled: true }); setExpanded(`new-${section.id}`); },
|
|
10436
|
-
}, t('progress.reqNew')),
|
|
10437
|
-
)),
|
|
10482
|
+
))),
|
|
10483
|
+
))),
|
|
10438
10484
|
);
|
|
10439
10485
|
}
|
|
10440
10486
|
|
|
10441
|
-
/**
|
|
10442
|
-
|
|
10443
|
-
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10448
|
-
|
|
10449
|
-
|
|
10450
|
-
|
|
10451
|
-
|
|
10452
|
-
|
|
10453
|
-
|
|
10454
|
-
|
|
10455
|
-
|
|
10456
|
-
|
|
10457
|
-
|
|
10458
|
-
|
|
10459
|
-
|
|
10460
|
-
|
|
10461
|
-
|
|
10462
|
-
|
|
10487
|
+
/**
|
|
10488
|
+
* Create-requirement modal for the session progress panel, mirroring
|
|
10489
|
+
* PromptCreateModal: pinned to the session's workspace, choose keep or
|
|
10490
|
+
* "all workspaces", with an in-memory draft that survives reopening.
|
|
10491
|
+
*/
|
|
10492
|
+
function RequirementCreateModal({ workspaceId, workspaceTitle, onClose, onCreated }) {
|
|
10493
|
+
const t = (key, params) => translateCurrent(key, params);
|
|
10494
|
+
const fixedScope = typeof workspaceId !== 'string' || workspaceId === '';
|
|
10495
|
+
const key = fixedScope ? '' : workspaceId;
|
|
10496
|
+
if (requirementCreateDraft.workspaceId !== key) {
|
|
10497
|
+
requirementCreateDraft.workspaceId = key;
|
|
10498
|
+
requirementCreateDraft.title = '';
|
|
10499
|
+
requirementCreateDraft.text = '';
|
|
10500
|
+
requirementCreateDraft.scope = fixedScope ? 'all' : 'current';
|
|
10501
|
+
}
|
|
10502
|
+
const [title, setTitle] = useState(requirementCreateDraft.title);
|
|
10503
|
+
const [text, setText] = useState(requirementCreateDraft.text);
|
|
10504
|
+
const [scope, setScope] = useState(requirementCreateDraft.scope);
|
|
10505
|
+
const [closing, setClosing] = useState(false);
|
|
10506
|
+
const closingRef = useRef(false);
|
|
10507
|
+
const requestClose = () => {
|
|
10508
|
+
if (closingRef.current) return;
|
|
10509
|
+
closingRef.current = true;
|
|
10510
|
+
setClosing(true);
|
|
10511
|
+
setTimeout(() => { try { onClose(); } catch { /* parent owns unmount */ } }, 140);
|
|
10512
|
+
};
|
|
10513
|
+
useEffect(() => {
|
|
10514
|
+
requirementCreateDraft.title = title;
|
|
10515
|
+
requirementCreateDraft.text = text;
|
|
10516
|
+
requirementCreateDraft.scope = scope;
|
|
10517
|
+
}, [title, text, scope]);
|
|
10518
|
+
useEffect(() => {
|
|
10519
|
+
const onKey = (event) => { if (event.key === 'Escape') { event.preventDefault(); requestClose(); } };
|
|
10520
|
+
document.addEventListener('keydown', onKey, true);
|
|
10521
|
+
return () => document.removeEventListener('keydown', onKey, true);
|
|
10522
|
+
}, []);
|
|
10523
|
+
const save = () => {
|
|
10524
|
+
const body = typeof text === 'string' ? text.trim() : '';
|
|
10525
|
+
if (body === '') return;
|
|
10526
|
+
const record = {
|
|
10527
|
+
id: newId(),
|
|
10528
|
+
title: typeof title === 'string' ? title.trim() : '',
|
|
10529
|
+
text: body,
|
|
10530
|
+
workspaceId: scope === 'current' && typeof workspaceId === 'string' ? workspaceId : '',
|
|
10531
|
+
enabled: true,
|
|
10532
|
+
};
|
|
10533
|
+
saveRequirements([...requirementsCache, record]);
|
|
10534
|
+
requirementCreateDraft.title = '';
|
|
10535
|
+
requirementCreateDraft.text = '';
|
|
10536
|
+
requirementCreateDraft.scope = fixedScope ? 'all' : 'current';
|
|
10537
|
+
if (!closingRef.current) { closingRef.current = true; setClosing(true); }
|
|
10538
|
+
setTimeout(() => { try { onCreated(record); } catch { /* ignore */ } }, 140);
|
|
10539
|
+
};
|
|
10540
|
+
return renderInBody(h('div', {
|
|
10541
|
+
className: 'dsh-powerup-prompt-modal-mask' + (closing ? ' is-closing' : ''),
|
|
10542
|
+
onPointerDown: (event) => { if (event.target === event.currentTarget) requestClose(); },
|
|
10543
|
+
},
|
|
10544
|
+
h('div', { className: 'dsh-powerup-prompt-modal' + (closing ? ' is-closing' : ''), role: 'dialog', 'aria-modal': 'true' },
|
|
10545
|
+
h('div', { className: 'dsh-powerup-prompt-modal-head' },
|
|
10546
|
+
h('div', null,
|
|
10547
|
+
h('div', { className: 'dsh-powerup-prompt-modal-heading' }, t('progress.reqNew')),
|
|
10548
|
+
h('p', { className: 'dsh-powerup-prompt-modal-sub' }, t('prompts.createScopeHint')),
|
|
10549
|
+
),
|
|
10550
|
+
h('button', { type: 'button', className: 'dsh-powerup-prompt-modal-close', 'aria-label': t('prompts.cancel'), onClick: requestClose }, '×'),
|
|
10551
|
+
),
|
|
10552
|
+
h('div', { className: 'dsh-powerup-prompt-modal-body' },
|
|
10553
|
+
h('label', { className: 'dsh-powerup-prompt-field' },
|
|
10554
|
+
h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.titleLabel')),
|
|
10555
|
+
h('input', { className: 'dsh-powerup-prompt-input', type: 'text', value: title, placeholder: t('prompts.titlePlaceholder'), onChange: (e) => setTitle(e.target.value) }),
|
|
10556
|
+
),
|
|
10557
|
+
h('label', { className: 'dsh-powerup-prompt-field' },
|
|
10558
|
+
h('span', { className: 'dsh-powerup-prompt-field-label' }, t('prompts.workspaceLabel')),
|
|
10559
|
+
h('div', { className: 'dsh-powerup-prompt-scope-options' },
|
|
10560
|
+
h('button', {
|
|
10561
|
+
type: 'button', role: 'switch', 'aria-checked': scope === 'all' ? 'true' : 'false',
|
|
10562
|
+
className: 'dsh-powerup-switch', onClick: () => setScope('all'),
|
|
10563
|
+
}, t('prompts.anyWorkspace')),
|
|
10564
|
+
fixedScope ? null : h('button', {
|
|
10565
|
+
type: 'button', role: 'switch', 'aria-checked': scope === 'current' ? 'true' : 'false',
|
|
10566
|
+
className: 'dsh-powerup-switch', onClick: () => setScope('current'),
|
|
10567
|
+
}, workspaceTitle || t('prompts.workspaceCurrent')),
|
|
10568
|
+
),
|
|
10569
|
+
),
|
|
10570
|
+
h('label', { className: 'dsh-powerup-prompt-field' },
|
|
10571
|
+
h('span', { className: 'dsh-powerup-prompt-field-label' }, t('progress.reqTextLabel')),
|
|
10572
|
+
h('textarea', { className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea', value: text, placeholder: t('progress.reqPlaceholder'), onChange: (e) => setText(e.target.value) }),
|
|
10573
|
+
),
|
|
10574
|
+
),
|
|
10575
|
+
h('div', { className: 'dsh-powerup-prompt-modal-foot' },
|
|
10576
|
+
h('button', { type: 'button', className: 'dsh-powerup-update-ghost', onClick: requestClose }, t('prompts.cancel')),
|
|
10577
|
+
h('button', { type: 'button', className: 'dsh-powerup-update-primary', disabled: text.trim() === '', onClick: save }, t('prompts.create')),
|
|
10578
|
+
),
|
|
10463
10579
|
),
|
|
10464
|
-
);
|
|
10580
|
+
));
|
|
10465
10581
|
}
|
|
10466
10582
|
|
|
10467
|
-
/**
|
|
10468
|
-
|
|
10469
|
-
|
|
10583
|
+
/**
|
|
10584
|
+
* Panel editor: check requirements to fill the text box, then freely edit
|
|
10585
|
+
* the combined text. On generate/refresh the full text is sent verbatim.
|
|
10586
|
+
*/
|
|
10587
|
+
function RequirementPicker({ reqs, selectedIds, text, onToggle, onTextChange, t }) {
|
|
10470
10588
|
return h('div', { className: 'dsh-powerup-req-picker' },
|
|
10471
|
-
reqs.
|
|
10472
|
-
h('
|
|
10473
|
-
|
|
10474
|
-
onChange: () => onToggle(r.id),
|
|
10475
|
-
|
|
10476
|
-
|
|
10477
|
-
|
|
10589
|
+
reqs.length === 0
|
|
10590
|
+
? h('p', { className: 'dsh-powerup-progress-empty' }, t('progress.reqEmpty'))
|
|
10591
|
+
: reqs.map((r) => h('label', { key: r.id, className: 'dsh-powerup-req-option' },
|
|
10592
|
+
h('input', { type: 'checkbox', checked: selectedIds.includes(r.id), onChange: () => onToggle(r.id) }),
|
|
10593
|
+
h('span', null, r.title || (r.text.slice(0, 50) + (r.text.length > 50 ? '…' : ''))),
|
|
10594
|
+
)),
|
|
10595
|
+
h('textarea', {
|
|
10596
|
+
className: 'dsh-powerup-prompt-input dsh-powerup-prompt-textarea dsh-powerup-req-textarea',
|
|
10597
|
+
value: text ?? '', placeholder: t('progress.reqEditPlaceholder'),
|
|
10598
|
+
onChange: (event) => onTextChange(event.target.value),
|
|
10599
|
+
}),
|
|
10478
10600
|
);
|
|
10479
10601
|
}
|
|
10480
10602
|
|
|
@@ -10633,17 +10755,41 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10633
10755
|
const [historyIndex, setHistoryIndex] = useState(0);
|
|
10634
10756
|
const [showRaw, setShowRaw] = useState(false);
|
|
10635
10757
|
const [showReq, setShowReq] = useState(false);
|
|
10636
|
-
//
|
|
10758
|
+
// Selected requirement ids + the free-editable combined text.
|
|
10637
10759
|
const [selectedReqIds, setSelectedReqIds] = useState([]);
|
|
10760
|
+
const [reqText, setReqText] = useState('');
|
|
10761
|
+
const [creatingReq, setCreatingReq] = useState(false);
|
|
10638
10762
|
const reqs = useRequirements();
|
|
10639
|
-
// Resolve the owning workspace for requirement filtering.
|
|
10763
|
+
// Resolve the owning workspace for requirement filtering + create modal.
|
|
10640
10764
|
const workspaceId = useMemo(() => {
|
|
10641
10765
|
try {
|
|
10642
10766
|
const snapshot = ctxRef.current?.get?.('workspaces')?.list?.getSnapshot?.();
|
|
10643
10767
|
return resolveWorkspaceIdFromSnapshot(snapshot, sessionRef.current) ?? '';
|
|
10644
10768
|
} catch { return ''; }
|
|
10645
10769
|
}, [sessionId, open]);
|
|
10770
|
+
const workspaceTitle = useMemo(() => {
|
|
10771
|
+
try {
|
|
10772
|
+
const items = ctxRef.current?.get?.('workspaces')?.list?.getSnapshot?.()?.items ?? [];
|
|
10773
|
+
const found = items.find((ws) => ws?.workspaceId === workspaceId);
|
|
10774
|
+
return found?.title ?? '';
|
|
10775
|
+
} catch { return ''; }
|
|
10776
|
+
}, [workspaceId, open]);
|
|
10646
10777
|
const visibleReqs = requirementsForWorkspace(reqs, workspaceId);
|
|
10778
|
+
/** Concatenate the enabled+selected requirements into editable text. */
|
|
10779
|
+
const composeReqText = useCallback((ids) => {
|
|
10780
|
+
return visibleReqs
|
|
10781
|
+
.filter((r) => ids.includes(r.id) && r.enabled !== false && typeof r.text === 'string' && r.text.trim() !== '')
|
|
10782
|
+
.map((r) => r.text.trim())
|
|
10783
|
+
.join('\n\n');
|
|
10784
|
+
}, [visibleReqs]);
|
|
10785
|
+
/** Toggle one requirement: rebuild the box from the current selection. */
|
|
10786
|
+
const toggleReq = useCallback((id) => {
|
|
10787
|
+
setSelectedReqIds((cur) => {
|
|
10788
|
+
const next = cur.includes(id) ? cur.filter((x) => x !== id) : [...cur, id];
|
|
10789
|
+
setReqText(composeReqText(next));
|
|
10790
|
+
return next;
|
|
10791
|
+
});
|
|
10792
|
+
}, [composeReqText]);
|
|
10647
10793
|
const [size, setSize] = useState(() => {
|
|
10648
10794
|
try {
|
|
10649
10795
|
const saved = JSON.parse(localStorage.getItem('dsh-powerup:progress:size:v1') || 'null');
|
|
@@ -10699,7 +10845,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10699
10845
|
if (typeof id !== 'string' || id === '') return;
|
|
10700
10846
|
setBusy(true);
|
|
10701
10847
|
try {
|
|
10702
|
-
|
|
10848
|
+
// Send the full, possibly user-edited text verbatim.
|
|
10849
|
+
const body = await progressRequest(id, 'start', { requirements: reqText });
|
|
10703
10850
|
setView(body);
|
|
10704
10851
|
setHistoryIndex(0);
|
|
10705
10852
|
} catch (error) {
|
|
@@ -10708,7 +10855,7 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10708
10855
|
setBusy(false);
|
|
10709
10856
|
if (!open) setOpen(true);
|
|
10710
10857
|
}
|
|
10711
|
-
}, [open,
|
|
10858
|
+
}, [open, reqText]);
|
|
10712
10859
|
|
|
10713
10860
|
const clearHistory = useCallback(async () => {
|
|
10714
10861
|
const id = sessionRef.current;
|
|
@@ -10878,9 +11025,15 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10878
11025
|
h(RequirementPicker, {
|
|
10879
11026
|
reqs: visibleReqs,
|
|
10880
11027
|
selectedIds: selectedReqIds,
|
|
11028
|
+
text: reqText,
|
|
10881
11029
|
t,
|
|
10882
|
-
onToggle:
|
|
11030
|
+
onToggle: toggleReq,
|
|
11031
|
+
onTextChange: setReqText,
|
|
10883
11032
|
}),
|
|
11033
|
+
h('button', {
|
|
11034
|
+
type: 'button', className: 'dsh-powerup-prompt-new dsh-powerup-req-create',
|
|
11035
|
+
onClick: () => setCreatingReq(true),
|
|
11036
|
+
}, t('progress.reqNew')),
|
|
10884
11037
|
) : null;
|
|
10885
11038
|
|
|
10886
11039
|
const panel = !open ? null : h('div', {
|
|
@@ -10948,6 +11101,18 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
10948
11101
|
return h('span', { style: { display: 'inline-flex', alignItems: 'center' } },
|
|
10949
11102
|
button,
|
|
10950
11103
|
renderInBody(panel),
|
|
11104
|
+
creatingReq ? h(RequirementCreateModal, {
|
|
11105
|
+
workspaceId,
|
|
11106
|
+
workspaceTitle,
|
|
11107
|
+
onClose: () => setCreatingReq(false),
|
|
11108
|
+
onCreated: (record) => {
|
|
11109
|
+
setCreatingReq(false);
|
|
11110
|
+
// Auto-select the freshly created requirement and append its text
|
|
11111
|
+
// to the editable box (the cache may not have re-rendered yet).
|
|
11112
|
+
setSelectedReqIds((cur) => cur.includes(record.id) ? cur : [...cur, record.id]);
|
|
11113
|
+
setReqText((cur) => record.text ? (cur ? `${cur}\n\n${record.text.trim()}` : record.text.trim()) : cur);
|
|
11114
|
+
},
|
|
11115
|
+
}) : null,
|
|
10951
11116
|
);
|
|
10952
11117
|
}
|
|
10953
11118
|
|
|
@@ -11112,6 +11277,8 @@ html[data-platform="darwin"] .dsh-powerup-scrolltop:hover{background:var(--dsw-s
|
|
|
11112
11277
|
PROGRESS_CSS,
|
|
11113
11278
|
ProgressControl,
|
|
11114
11279
|
RequirementManager,
|
|
11280
|
+
RequirementCreateModal,
|
|
11281
|
+
RequirementForm,
|
|
11115
11282
|
RequirementPicker,
|
|
11116
11283
|
requirementForWorkspace: requirementsForWorkspace,
|
|
11117
11284
|
DirectAskButton,
|
package/index.js
CHANGED
|
@@ -627,9 +627,13 @@ async function handle(req, res, ctx) {
|
|
|
627
627
|
return;
|
|
628
628
|
}
|
|
629
629
|
try {
|
|
630
|
-
//
|
|
631
|
-
//
|
|
632
|
-
|
|
630
|
+
// The panel sends the full (possibly user-edited) requirements text in
|
|
631
|
+
// `requirements`. It is used verbatim. The older `requirementIds`
|
|
632
|
+
// selection remains as a fallback for clients that send it.
|
|
633
|
+
if (typeof body?.requirements === 'string') {
|
|
634
|
+
ctx.__powerupProgressText = ctx.__powerupProgressText ?? {};
|
|
635
|
+
ctx.__powerupProgressText[sessionId] = body.requirements;
|
|
636
|
+
} else if (Array.isArray(body?.requirementIds)) {
|
|
633
637
|
ctx.__powerupProgressSelection = ctx.__powerupProgressSelection ?? {};
|
|
634
638
|
ctx.__powerupProgressSelection[sessionId] = body.requirementIds.map(String);
|
|
635
639
|
}
|
|
@@ -922,7 +926,11 @@ export function apply(ctx) {
|
|
|
922
926
|
// Requirements are a flat list of records: {id,title,text,workspaceId,enabled}.
|
|
923
927
|
// workspaceId '' = global. The panel sends the ids it wants; the Host only
|
|
924
928
|
// includes records visible to the session's workspace and explicitly picked.
|
|
925
|
-
const requirementsFor = (sessionId, selectedIds) => {
|
|
929
|
+
const requirementsFor = (sessionId, selectedIds, editedText) => {
|
|
930
|
+
// A panel-edited full text wins verbatim (the user may freely modify the
|
|
931
|
+
// concatenated requirements before generating).
|
|
932
|
+
if (typeof editedText === 'string' && editedText.trim() !== '') return editedText;
|
|
933
|
+
if (editedText === '') return ''; // user cleared everything on purpose
|
|
926
934
|
const file = storePath(PROGRESS_REQUIREMENTS_FILE);
|
|
927
935
|
let raw;
|
|
928
936
|
try {
|
|
@@ -986,7 +994,11 @@ export function apply(ctx) {
|
|
|
986
994
|
? selection
|
|
987
995
|
: undefined;
|
|
988
996
|
},
|
|
989
|
-
getRequirements: (sessionId) => requirementsFor(
|
|
997
|
+
getRequirements: (sessionId) => requirementsFor(
|
|
998
|
+
sessionId,
|
|
999
|
+
ctx.__powerupProgressSelection?.[sessionId],
|
|
1000
|
+
ctx.__powerupProgressText?.[sessionId],
|
|
1001
|
+
),
|
|
990
1002
|
onHistoryChange: (sessionId, history) => {
|
|
991
1003
|
try {
|
|
992
1004
|
const all = readJsonObject(historyPath);
|
|
@@ -1015,6 +1027,7 @@ export function apply(ctx) {
|
|
|
1015
1027
|
};
|
|
1016
1028
|
ctx.__powerupProgress = manager;
|
|
1017
1029
|
ctx.__powerupProgressSelection = ctx.__powerupProgressSelection ?? {};
|
|
1030
|
+
ctx.__powerupProgressText = ctx.__powerupProgressText ?? {};
|
|
1018
1031
|
scope.effect(() => () => {
|
|
1019
1032
|
if (ctx.__powerupProgress === manager) ctx.__powerupProgress = undefined;
|
|
1020
1033
|
}, 'dsh-powerup: progress manager');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@restregular/dsh-powerup",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "为 DeepSeek Harness 提供一组可选的小型增强:轨迹右键菜单与步骤引用、后台任务停止原因、插件一键安装、侧边栏图标网格、会话切换、定位当前会话、工作区提示词、旁路模型生成的结构化任务进度;所有功能均可在 Power-Up 页面独立开关。 · Opt-in upgrades for DeepSeek Harness: Trajectory context menu and step references, job stop reasons, one-click plugin install, an adaptive sidebar launcher, session switching, locating the current session, workspace prompts, and non-blocking model-generated structured task progress — each toggled independently on the Power-Up page.",
|
|
5
5
|
"icon": "./icon.svg",
|
|
6
6
|
"type": "module",
|