@user-mrz/dsh-system-prompt-studio 0.3.1 → 0.3.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/CHANGELOG.md +34 -1
- package/README.md +8 -4
- package/lib/client.js +167 -4
- package/lib/index.js +60 -11
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,38 @@ integration still targets the same DSH shapes, a major bump means it may not.
|
|
|
12
12
|
|
|
13
13
|
Nothing yet.
|
|
14
14
|
|
|
15
|
+
## [0.3.2] — 2026-11-19
|
|
16
|
+
|
|
17
|
+
### Fixed
|
|
18
|
+
|
|
19
|
+
- **The stale-section warning ignored the workspace and global scopes.** `sectionsStale` compared
|
|
20
|
+
only `state.sessions[sessionId]`, so after saving a workspace-level or global-level override the panel
|
|
21
|
+
kept showing the *previous* assembly's section list without saying so — precisely the misleading case
|
|
22
|
+
that field exists to prevent. The comparison now resolves the entry that is actually in force: the
|
|
23
|
+
session's own entry, the **ancestor's** entry when the rule is inherited by a fork, the workspace
|
|
24
|
+
entry, or the global entry. A fork whose parent's rules change is now flagged as stale too, which it
|
|
25
|
+
previously never was because the fork has no session entry of its own.
|
|
26
|
+
|
|
27
|
+
- **The panel never showed the state file's health.** The host has always reported `health`
|
|
28
|
+
(`stateFile`, `error`, `backup`) and `persisted`, but no part of the client read them. A corrupt state
|
|
29
|
+
file — backed up to `.corrupt-<timestamp>` and restarted empty — and a failed write that exists only in
|
|
30
|
+
memory were both completely invisible, contradicting the README's promise that a failed write is
|
|
31
|
+
stated plainly. The panel now shows a banner: red when the write did not persist (lost on restart),
|
|
32
|
+
amber for a read error with the backup path.
|
|
33
|
+
|
|
34
|
+
- **`resetAll` was implemented but unreachable.** The host accepted `action: 'resetAll'`, yet the panel
|
|
35
|
+
had no entry point, so clearing accumulated per-conversation overrides meant deleting them one at a
|
|
36
|
+
time. There is now a **Clear all conversation overrides** button with a second confirmation, disabled
|
|
37
|
+
when there is nothing to clear (`sessionCount`, a new counter symmetrical with `workspaceCount`). The
|
|
38
|
+
confirmation states that workspace rules and the global default are unaffected, and `resetAll` still
|
|
39
|
+
leaves both untouched.
|
|
40
|
+
|
|
41
|
+
### Changed
|
|
42
|
+
|
|
43
|
+
- Ten new client checks and twelve new host checks cover the three fixes, including that a fork is
|
|
44
|
+
flagged stale when its ancestor's rules change, and that a global save is flagged stale for the
|
|
45
|
+
session that triggered it.
|
|
46
|
+
|
|
15
47
|
## [0.3.1] — 2026-11-19
|
|
16
48
|
|
|
17
49
|
### Changed
|
|
@@ -313,7 +345,8 @@ scoped name unambiguous for anyone who arrives from GitHub.
|
|
|
313
345
|
- Read-only assembly observer listing the real section names, order and size.
|
|
314
346
|
- Loopback-only HTTP route for the panel; forged `Host` headers are refused.
|
|
315
347
|
|
|
316
|
-
[Unreleased]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.3.
|
|
348
|
+
[Unreleased]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.3.2...HEAD
|
|
349
|
+
[0.3.2]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.3.1...v0.3.2
|
|
317
350
|
[0.3.1]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.3.0...v0.3.1
|
|
318
351
|
[0.3.0]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.2.1...v0.3.0
|
|
319
352
|
[0.2.1]: https://github.com/user-Mrz/dsh-system-prompt-studio/compare/v0.2.0...v0.2.1
|
package/README.md
CHANGED
|
@@ -91,7 +91,7 @@ dsh plugin --profile <profile> add @user-mrz/dsh-system-prompt-studio
|
|
|
91
91
|
From GitHub, which tracks the default branch and therefore needs a ref if you want a fixed version:
|
|
92
92
|
|
|
93
93
|
```bash
|
|
94
|
-
dsh plugin --profile <profile> add github:user-Mrz/dsh-system-prompt-studio#v0.3.
|
|
94
|
+
dsh plugin --profile <profile> add github:user-Mrz/dsh-system-prompt-studio#v0.3.2
|
|
95
95
|
```
|
|
96
96
|
|
|
97
97
|
Replace `<profile>` with your profile name — for the Web build that is usually `web`.
|
|
@@ -100,7 +100,7 @@ Replace `<profile>` with your profile name — for the Web build that is usually
|
|
|
100
100
|
changes what you install next time:
|
|
101
101
|
|
|
102
102
|
```bash
|
|
103
|
-
dsh plugin --profile <profile> add @user-mrz/dsh-system-prompt-studio@0.3.
|
|
103
|
+
dsh plugin --profile <profile> add @user-mrz/dsh-system-prompt-studio@0.3.2
|
|
104
104
|
```
|
|
105
105
|
|
|
106
106
|
<details>
|
|
@@ -360,6 +360,10 @@ POST /api/system-prompt-studio
|
|
|
360
360
|
is not resolved (that needs filesystem semantics this plugin does not touch) and symlinks are not
|
|
361
361
|
followed. The host prefers the `workspaceRegistry` entry, whose path is canonicalised by DSH itself,
|
|
362
362
|
so the normal case is exact.
|
|
363
|
+
8. **A corrupt or unwritable state file is reported in the panel, not repaired.** A damaged file is
|
|
364
|
+
backed up to `state.json.corrupt-<timestamp>` and the plugin starts empty; a failed write stays in
|
|
365
|
+
memory only. Both now surface as a banner at the top of the panel, with the file path and any backup
|
|
366
|
+
path — check it before assuming your rules were saved.
|
|
363
367
|
|
|
364
368
|
## Development
|
|
365
369
|
|
|
@@ -438,13 +442,13 @@ dsh plugin --profile <profile> add @user-mrz/dsh-system-prompt-studio
|
|
|
438
442
|
或从 GitHub(跟随默认分支,建议锁 tag):
|
|
439
443
|
|
|
440
444
|
```bash
|
|
441
|
-
dsh plugin --profile <profile> add github:user-Mrz/dsh-system-prompt-studio#v0.3.
|
|
445
|
+
dsh plugin --profile <profile> add github:user-Mrz/dsh-system-prompt-studio#v0.3.2
|
|
442
446
|
```
|
|
443
447
|
|
|
444
448
|
锁定版本,保证装到的是一份确定的代码:
|
|
445
449
|
|
|
446
450
|
```bash
|
|
447
|
-
dsh plugin --profile <profile> add @user-mrz/dsh-system-prompt-studio@0.3.
|
|
451
|
+
dsh plugin --profile <profile> add @user-mrz/dsh-system-prompt-studio@0.3.2
|
|
448
452
|
```
|
|
449
453
|
|
|
450
454
|
`prepare` 脚本只校验入口文件存在,不做编译。若被 pnpm 拦下,把 `pnpm-workspace.yaml` 里
|
package/lib/client.js
CHANGED
|
@@ -114,6 +114,18 @@ window.__ModuleLoader__.load({
|
|
|
114
114
|
emptyText: '启用覆盖但正文为空,请填写正文。',
|
|
115
115
|
targetRequired: '替换模式必须填写目标段名。',
|
|
116
116
|
subagentNote: '子代理会话默认不继承全局默认。',
|
|
117
|
+
stateNotPersisted: '保存只在内存里:写入磁盘失败,重启后会丢失。',
|
|
118
|
+
stateError: '状态文件有问题:',
|
|
119
|
+
stateBackup: '原文件已备份到:',
|
|
120
|
+
stateFileLabel: '状态文件:',
|
|
121
|
+
resetAll: '清除所有会话覆盖',
|
|
122
|
+
resetAllTitle: '清除所有会话级覆盖?',
|
|
123
|
+
resetAllBody: '这会删除每一条「本对话」级别的覆盖(共 {n} 条),且无法撤销。',
|
|
124
|
+
resetAllKeep: '工作区规则与全局默认不受影响。',
|
|
125
|
+
resetAllConfirm: '清除全部',
|
|
126
|
+
resetAllCancel: '取消',
|
|
127
|
+
resetAllDone: '已清除全部会话级覆盖。',
|
|
128
|
+
resetAllNone: '当前没有会话级覆盖。',
|
|
117
129
|
},
|
|
118
130
|
en: {
|
|
119
131
|
action: 'System prompt',
|
|
@@ -191,6 +203,18 @@ window.__ModuleLoader__.load({
|
|
|
191
203
|
emptyText: 'The override is enabled but the body is empty.',
|
|
192
204
|
targetRequired: 'Replace mode needs a target section name.',
|
|
193
205
|
subagentNote: 'Subagent conversations do not inherit the global default.',
|
|
206
|
+
stateNotPersisted: 'Saved in memory only: the file write failed, so it will be lost on restart.',
|
|
207
|
+
stateError: 'State file problem: ',
|
|
208
|
+
stateBackup: 'The original was backed up to: ',
|
|
209
|
+
stateFileLabel: 'State file: ',
|
|
210
|
+
resetAll: 'Clear all conversation overrides',
|
|
211
|
+
resetAllTitle: 'Clear every per-conversation override?',
|
|
212
|
+
resetAllBody: 'This deletes all {n} conversation-level override(s). It cannot be undone.',
|
|
213
|
+
resetAllKeep: 'Workspace rules and the global default are not affected.',
|
|
214
|
+
resetAllConfirm: 'Clear all',
|
|
215
|
+
resetAllCancel: 'Cancel',
|
|
216
|
+
resetAllDone: 'All conversation-level overrides cleared.',
|
|
217
|
+
resetAllNone: 'There are no conversation-level overrides right now.',
|
|
194
218
|
},
|
|
195
219
|
}
|
|
196
220
|
|
|
@@ -313,6 +337,8 @@ window.__ModuleLoader__.load({
|
|
|
313
337
|
[data-sps="button"]:hover{border-color:var(--dsw-alias-brand-primary)}
|
|
314
338
|
[data-sps="button"][data-primary="true"]{background:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-bg-base);font-weight:600}
|
|
315
339
|
[data-sps="button"]:disabled{opacity:.55;cursor:not-allowed}
|
|
340
|
+
[data-sps="button"][data-danger="true"]:not(:disabled){border-color:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-state-error-primary)}
|
|
341
|
+
[data-sps="button"][data-danger="true"]:not(:disabled):hover{background:color-mix(in srgb, var(--dsw-alias-state-error-primary) 12%, transparent)}
|
|
316
342
|
[data-sps="details"]{border:1px solid var(--dsw-alias-border-l1);border-radius:10px;padding:10px 12px}
|
|
317
343
|
[data-sps="details"] summary{cursor:pointer;font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary)}
|
|
318
344
|
[data-sps="pre"]{margin:8px 0 0;max-height:220px;overflow:auto;white-space:pre-wrap;word-break:break-word;font:12px/1.6 ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;color:var(--dsw-alias-label-primary)}
|
|
@@ -467,6 +493,13 @@ window.__ModuleLoader__.load({
|
|
|
467
493
|
* 也不会漏报(比如只切了模式、只动了一个勾选框)。
|
|
468
494
|
*/
|
|
469
495
|
const [baseline, setBaseline] = React.useState({ mode: 'append', text: '', target: '', enabled: true })
|
|
496
|
+
/**
|
|
497
|
+
* 「清除所有会话覆盖」的二次确认。
|
|
498
|
+
*
|
|
499
|
+
* 与 `confirmClose`(放弃未保存改动)是两件不同的事,所以独立 state:
|
|
500
|
+
* 混用一个布尔会让「关闭时确认」和「清空时确认」互相串味。
|
|
501
|
+
*/
|
|
502
|
+
const [confirmReset, setConfirmReset] = React.useState(false)
|
|
470
503
|
const [confirmClose, setConfirmClose] = React.useState(false)
|
|
471
504
|
const textareaRef = React.useRef(null)
|
|
472
505
|
const backdropRef = React.useRef(null)
|
|
@@ -550,11 +583,13 @@ window.__ModuleLoader__.load({
|
|
|
550
583
|
}, [])
|
|
551
584
|
|
|
552
585
|
// Esc 关闭 + 打开时聚焦正文。确认态下 Esc 取消放弃,而不是连按就丢。
|
|
586
|
+
// 清空确认层打开时,Esc 同样只取消清空,不会连带着关闭整个面板。
|
|
553
587
|
React.useEffect(() => {
|
|
554
588
|
const onKey = (event) => {
|
|
555
589
|
if (event.key !== 'Escape') return
|
|
556
590
|
event.stopPropagation()
|
|
557
|
-
if (
|
|
591
|
+
if (confirmReset) setConfirmReset(false)
|
|
592
|
+
else if (confirmClose) cancelDiscard()
|
|
558
593
|
else requestClose()
|
|
559
594
|
}
|
|
560
595
|
document.addEventListener('keydown', onKey, true)
|
|
@@ -569,7 +604,7 @@ window.__ModuleLoader__.load({
|
|
|
569
604
|
document.removeEventListener('keydown', onKey, true)
|
|
570
605
|
clearTimeout(timer)
|
|
571
606
|
}
|
|
572
|
-
}, [confirmClose, cancelDiscard, requestClose])
|
|
607
|
+
}, [confirmReset, confirmClose, cancelDiscard, requestClose])
|
|
573
608
|
|
|
574
609
|
// 关标签页/刷新的兜底:只在有未保存改动时注册。
|
|
575
610
|
React.useEffect(() => {
|
|
@@ -625,6 +660,19 @@ window.__ModuleLoader__.load({
|
|
|
625
660
|
// 只在「本对话」这一档提示工作区来源:站在工作区 tab 上说「规则来自工作区」
|
|
626
661
|
// 是废话,用户此刻正在编辑的就是那条规则。
|
|
627
662
|
const workspaceFrom = scope === 'session' ? payload?.effective?.workspaceKey ?? '' : ''
|
|
663
|
+
/**
|
|
664
|
+
* 状态文件健康度:Host 一直在回报,面板此前从不显示。
|
|
665
|
+
*
|
|
666
|
+
* `persisted === false` 表示这次写入没落盘(只在内存,重启丢失);
|
|
667
|
+
* `health.error` 非空表示读取或写入出过错(损坏的文件会被备份后空态起步)。
|
|
668
|
+
* 两者都不该静默——用户有权知道自己的规则到底存住了没有。
|
|
669
|
+
*/
|
|
670
|
+
const notPersisted = payload !== null && payload !== undefined && payload.persisted === false
|
|
671
|
+
const healthError = typeof payload?.health?.error === 'string' ? payload.health.error : ''
|
|
672
|
+
const healthBackup = typeof payload?.health?.backup === 'string' ? payload.health.backup : ''
|
|
673
|
+
const healthFile = typeof payload?.health?.stateFile === 'string' ? payload.health.stateFile : ''
|
|
674
|
+
/** 会话级覆盖条数;面板据此决定「清除所有会话覆盖」是否可点。 */
|
|
675
|
+
const sessionCount = typeof payload?.sessionCount === 'number' ? payload.sessionCount : 0
|
|
628
676
|
const disabled = blocked.off || blocked.noService || blocked.noAgents || busy
|
|
629
677
|
const completeOk = !blocked.complete && (mode !== 'complete' || ack)
|
|
630
678
|
|
|
@@ -762,6 +810,28 @@ window.__ModuleLoader__.load({
|
|
|
762
810
|
}
|
|
763
811
|
}
|
|
764
812
|
|
|
813
|
+
/**
|
|
814
|
+
* 清除所有会话级覆盖。
|
|
815
|
+
*
|
|
816
|
+
* Host 早就支持 `resetAll`,但面板一直没有入口,用户攒了几十条规则只能
|
|
817
|
+
* 一条条清。这里补上,并且**只**清会话级:工作区规则是攒下来的项目配置,
|
|
818
|
+
* 全局默认是刻意的兜底,两者都不该被这个按钮带走(确认层里写明了这一点)。
|
|
819
|
+
*/
|
|
820
|
+
const onResetAll = async () => {
|
|
821
|
+
setConfirmReset(false)
|
|
822
|
+
setBusy(true)
|
|
823
|
+
setNotice({ kind: '', text: '' })
|
|
824
|
+
try {
|
|
825
|
+
const result = await api.save({ action: 'resetAll', confirm: true })
|
|
826
|
+
setStatus({ phase: 'ready', payload: result, error: '' })
|
|
827
|
+
setNotice({ kind: 'ok', text: t('resetAllDone') })
|
|
828
|
+
} catch (error) {
|
|
829
|
+
setNotice({ kind: 'error', text: `${t('saveFailed')}${String(error?.message ?? error)}` })
|
|
830
|
+
} finally {
|
|
831
|
+
setBusy(false)
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
|
|
765
835
|
const onPin = async () => {
|
|
766
836
|
setBusy(true)
|
|
767
837
|
setNotice({ kind: '', text: '' })
|
|
@@ -846,6 +916,27 @@ window.__ModuleLoader__.load({
|
|
|
846
916
|
blocked.noService ? h('div', { key: 'nos', 'data-sps': 'error' }, t('disabledNoService')) : null,
|
|
847
917
|
blocked.noAgents ? h('div', { key: 'noa', 'data-sps': 'error' }, t('disabledNoAgents')) : null,
|
|
848
918
|
|
|
919
|
+
/**
|
|
920
|
+
* 状态文件健康度。
|
|
921
|
+
*
|
|
922
|
+
* Host 侧一直在回报 `health`(读取错误、备份路径)与 `persisted`
|
|
923
|
+
* (写盘是否成功),但面板此前从不显示它们——于是「状态文件损坏、
|
|
924
|
+
* 已备份并以空状态起步」和「保存只在内存里」这两种情况,用户零感知。
|
|
925
|
+
* README 明确承诺「写失败会明说」,这里就是那个出口。
|
|
926
|
+
*
|
|
927
|
+
* 两种严重程度分开渲染:写盘失败是错误(重启即丢失),读取错误只是
|
|
928
|
+
* 警告(插件仍然可用,原文件已备份)。
|
|
929
|
+
*/
|
|
930
|
+
healthError !== ''
|
|
931
|
+
? h(
|
|
932
|
+
'div',
|
|
933
|
+
{ key: 'health', 'data-sps': notPersisted ? 'error' : 'warn' },
|
|
934
|
+
notPersisted ? `${t('stateNotPersisted')}\n${healthError}` : `${t('stateError')}${healthError}`,
|
|
935
|
+
healthBackup !== '' ? `\n${t('stateBackup')}${healthBackup}` : '',
|
|
936
|
+
healthFile !== '' ? `\n${t('stateFileLabel')}${healthFile}` : '',
|
|
937
|
+
)
|
|
938
|
+
: null,
|
|
939
|
+
|
|
849
940
|
// 继承状态:让「我的规则从哪来」可见,而不是静默生效
|
|
850
941
|
inheritFrom !== ''
|
|
851
942
|
? h(
|
|
@@ -1209,6 +1300,24 @@ window.__ModuleLoader__.load({
|
|
|
1209
1300
|
{ type: 'button', 'data-sps': 'button', disabled: disabled, onClick: onClear },
|
|
1210
1301
|
t('clear'),
|
|
1211
1302
|
),
|
|
1303
|
+
/**
|
|
1304
|
+
* 清除所有会话覆盖。
|
|
1305
|
+
*
|
|
1306
|
+
* 没有会话级条目时禁用——避免用户点开二次确认才发现「没东西可清」。
|
|
1307
|
+
* `sessionCount` 由 Host 回报,与 `workspaceCount` 对称。
|
|
1308
|
+
*/
|
|
1309
|
+
h(
|
|
1310
|
+
'button',
|
|
1311
|
+
{
|
|
1312
|
+
type: 'button',
|
|
1313
|
+
'data-sps': 'button',
|
|
1314
|
+
'data-danger': 'true',
|
|
1315
|
+
disabled: busy || sessionCount === 0,
|
|
1316
|
+
title: sessionCount === 0 ? t('resetAllNone') : t('resetAll'),
|
|
1317
|
+
onClick: () => setConfirmReset(true),
|
|
1318
|
+
},
|
|
1319
|
+
t('resetAll'),
|
|
1320
|
+
),
|
|
1212
1321
|
),
|
|
1213
1322
|
h('span', { 'data-sps': 'spacer' }),
|
|
1214
1323
|
h(
|
|
@@ -1278,6 +1387,58 @@ window.__ModuleLoader__.load({
|
|
|
1278
1387
|
)
|
|
1279
1388
|
: null
|
|
1280
1389
|
|
|
1390
|
+
/**
|
|
1391
|
+
* 清除所有会话覆盖的确认层。
|
|
1392
|
+
*
|
|
1393
|
+
* 与 `discardLayer` 分开构造:两者可以同时存在(用户在确认清空时,
|
|
1394
|
+
* 编辑区里可能还有未保存的改动),混成一个会丢掉其中一个的语义。
|
|
1395
|
+
* 正文里明确写出条数与「不动工作区/全局」,让用户知道自己在点掉什么。
|
|
1396
|
+
*/
|
|
1397
|
+
const resetLayer = confirmReset
|
|
1398
|
+
? h(
|
|
1399
|
+
'div',
|
|
1400
|
+
{
|
|
1401
|
+
'data-sps': 'dialog',
|
|
1402
|
+
role: 'alertdialog',
|
|
1403
|
+
'aria-modal': 'true',
|
|
1404
|
+
'aria-label': t('resetAllTitle'),
|
|
1405
|
+
style: { width: 'min(440px, 100%)', maxHeight: 'none' },
|
|
1406
|
+
onClick: (event) => event.stopPropagation(),
|
|
1407
|
+
},
|
|
1408
|
+
h(
|
|
1409
|
+
'div',
|
|
1410
|
+
{ 'data-sps': 'head' },
|
|
1411
|
+
h('div', { 'data-sps': 'headmain' }, h('div', { 'data-sps': 'title' }, t('resetAllTitle'))),
|
|
1412
|
+
),
|
|
1413
|
+
h(
|
|
1414
|
+
'div',
|
|
1415
|
+
{ 'data-sps': 'body', style: { gap: 8 } },
|
|
1416
|
+
h('div', { 'data-sps': 'muted' }, t('resetAllBody').replace('{n}', String(sessionCount))),
|
|
1417
|
+
h('div', { 'data-sps': 'muted' }, t('resetAllKeep')),
|
|
1418
|
+
),
|
|
1419
|
+
h(
|
|
1420
|
+
'div',
|
|
1421
|
+
{ 'data-sps': 'head', style: { borderBottom: 'none', borderTop: '1px solid var(--dsw-alias-border-l1)', paddingTop: 12 } },
|
|
1422
|
+
h('span', { 'data-sps': 'spacer' }),
|
|
1423
|
+
h(
|
|
1424
|
+
'button',
|
|
1425
|
+
{ type: 'button', 'data-sps': 'button', onClick: () => setConfirmReset(false), autoFocus: true },
|
|
1426
|
+
t('resetAllCancel'),
|
|
1427
|
+
),
|
|
1428
|
+
h(
|
|
1429
|
+
'button',
|
|
1430
|
+
{
|
|
1431
|
+
type: 'button',
|
|
1432
|
+
'data-sps': 'button',
|
|
1433
|
+
style: { borderColor: 'var(--dsw-alias-state-error-primary)', color: 'var(--dsw-alias-state-error-primary)' },
|
|
1434
|
+
onClick: onResetAll,
|
|
1435
|
+
},
|
|
1436
|
+
t('resetAllConfirm'),
|
|
1437
|
+
),
|
|
1438
|
+
),
|
|
1439
|
+
)
|
|
1440
|
+
: null
|
|
1441
|
+
|
|
1281
1442
|
return ReactDOM.createPortal(
|
|
1282
1443
|
h(
|
|
1283
1444
|
'div',
|
|
@@ -1285,9 +1446,11 @@ window.__ModuleLoader__.load({
|
|
|
1285
1446
|
'data-sps': 'backdrop',
|
|
1286
1447
|
ref: backdropRef,
|
|
1287
1448
|
// 遮罩点击同样走关闭保护:有未保存改动时先确认,不直接丢。
|
|
1288
|
-
|
|
1449
|
+
// 清空确认层打开时,点遮罩等于取消清空(更安全的那个分支)。
|
|
1450
|
+
onClick: confirmReset ? () => setConfirmReset(false) : confirmClose ? cancelDiscard : requestClose,
|
|
1289
1451
|
},
|
|
1290
|
-
|
|
1452
|
+
// 清空确认层优先:它是用户此刻正在做的决定。
|
|
1453
|
+
resetLayer ?? discardLayer ?? dialog,
|
|
1291
1454
|
),
|
|
1292
1455
|
document.body,
|
|
1293
1456
|
)
|
package/lib/index.js
CHANGED
|
@@ -1332,6 +1332,55 @@ export const apply = mountOnce(name, function apply(ctx, rawConfig) {
|
|
|
1332
1332
|
}
|
|
1333
1333
|
}
|
|
1334
1334
|
|
|
1335
|
+
/**
|
|
1336
|
+
* 「当前真正生效的那一条状态」——用来判断段清单是否早于它。
|
|
1337
|
+
*
|
|
1338
|
+
* 为什么不能只看会话条目:`sectionsStale` 原本只比较
|
|
1339
|
+
* `state.sessions[sessionId]`,于是工作区级和全局级的保存完全不会被察觉。
|
|
1340
|
+
* 用户在「本工作区」保存后,面板仍然显示上一次装配的旧清单且不提示——正是
|
|
1341
|
+
* 这个字段当初要防的那种误导,只是漏了另外两档。
|
|
1342
|
+
*
|
|
1343
|
+
* 四档各自对应哪一条:
|
|
1344
|
+
* - `session` + 有 `inheritedFrom`:取**祖先**条目。fork 会话自己没有条目,
|
|
1345
|
+
* 生效的是祖先的规则;拿会话条目会得到 `undefined`,过期提示永远不会出现。
|
|
1346
|
+
* - `session`:取会话条目。
|
|
1347
|
+
* - `workspace`:取该工作区条目(键从 `effective.workspaceKey` 来)。
|
|
1348
|
+
* - `global`:取全局条目。
|
|
1349
|
+
* - `none`:没有生效覆盖,返回 undefined(此时「清单过期」无从谈起)。
|
|
1350
|
+
*/
|
|
1351
|
+
function entryForEffective(effective, sessionId) {
|
|
1352
|
+
if (effective === null || effective === undefined) return undefined
|
|
1353
|
+
const source = effective.source
|
|
1354
|
+
if (source === 'session') {
|
|
1355
|
+
// 继承来的规则属于祖先条目,不属于这个会话。
|
|
1356
|
+
const inherited = typeof effective.inheritedFrom === 'string' ? effective.inheritedFrom : ''
|
|
1357
|
+
if (inherited !== '') return runtime.state.sessions[inherited]
|
|
1358
|
+
return typeof sessionId === 'string' && sessionId !== '' ? runtime.state.sessions[sessionId] : undefined
|
|
1359
|
+
}
|
|
1360
|
+
if (source === 'workspace') {
|
|
1361
|
+
const key = typeof effective.workspaceKey === 'string' ? effective.workspaceKey : ''
|
|
1362
|
+
return key === '' ? undefined : workspaceEntryFor(key)
|
|
1363
|
+
}
|
|
1364
|
+
if (source === 'global') return runtime.state.global.enabled ? runtime.state.global : undefined
|
|
1365
|
+
return undefined
|
|
1366
|
+
}
|
|
1367
|
+
|
|
1368
|
+
/**
|
|
1369
|
+
* 段清单相对当前覆盖是否过期。
|
|
1370
|
+
*
|
|
1371
|
+
* 比较写入序号而不是时间戳:保存和装配可能落在同一毫秒,
|
|
1372
|
+
* `updatedAt > watch.at` 会在那时为假,把一份真正过期的清单判成最新。
|
|
1373
|
+
* 序号严格单调,没有这个问题。旧状态文件里没有 `writeSeq`(升级前写的
|
|
1374
|
+
* 条目),那种情况退回时间戳比较,行为与之前一致。
|
|
1375
|
+
*/
|
|
1376
|
+
function staleFor(watch, effective, sessionId) {
|
|
1377
|
+
if (watch === undefined) return false
|
|
1378
|
+
const entry = entryForEffective(effective, sessionId)
|
|
1379
|
+
if (entry === undefined) return false
|
|
1380
|
+
if (typeof entry.writeSeq === 'number') return entry.writeSeq > (typeof watch.seq === 'number' ? watch.seq : -1)
|
|
1381
|
+
return typeof entry.updatedAt === 'number' && entry.updatedAt > watch.at
|
|
1382
|
+
}
|
|
1383
|
+
|
|
1335
1384
|
function snapshot(sessionId) {
|
|
1336
1385
|
const registry = agents()
|
|
1337
1386
|
const sessions = service('sessions')
|
|
@@ -1391,6 +1440,13 @@ export const apply = mountOnce(name, function apply(ctx, rawConfig) {
|
|
|
1391
1440
|
},
|
|
1392
1441
|
/** 已配置的工作区数量,面板用来提示「还有 N 个项目有自己的规则」。 */
|
|
1393
1442
|
workspaceCount: Object.keys(runtime.state.workspaces).length,
|
|
1443
|
+
/**
|
|
1444
|
+
* 会话级覆盖的数量。
|
|
1445
|
+
*
|
|
1446
|
+
* 面板用它决定「清除所有会话覆盖」是否可点:没有条目时按钮应当禁用,
|
|
1447
|
+
* 而不是让用户点开二次确认才发现没东西可清。与 workspaceCount 对称。
|
|
1448
|
+
*/
|
|
1449
|
+
sessionCount: Object.keys(runtime.state.sessions).length,
|
|
1394
1450
|
effective: {
|
|
1395
1451
|
kind: effective.kind,
|
|
1396
1452
|
target: effective.target ?? '',
|
|
@@ -1416,19 +1472,12 @@ export const apply = mountOnce(name, function apply(ctx, rawConfig) {
|
|
|
1416
1472
|
/** 该次装配时的写入序号;与 entry.writeSeq 比较即可判新鲜度。 */
|
|
1417
1473
|
sectionsSeq: watch === undefined || typeof watch.seq !== 'number' ? 0 : watch.seq,
|
|
1418
1474
|
/**
|
|
1419
|
-
*
|
|
1475
|
+
* 清单是否早于当前生效的覆盖。true = 面板必须提示「这是保存前的清单」。
|
|
1420
1476
|
*
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
* 单调,没有这个问题。旧状态文件里没有 `writeSeq`(升级前写的条目),
|
|
1424
|
-
* 那种情况退回时间戳比较,行为与之前一致。
|
|
1477
|
+
* 判定按**生效来源**取条目(会话 / 继承祖先 / 工作区 / 全局),不再只看
|
|
1478
|
+
* 会话条目——否则在工作区档或全局档保存后,面板会拿着旧清单一声不响。
|
|
1425
1479
|
*/
|
|
1426
|
-
sectionsStale:
|
|
1427
|
-
watch === undefined || entry === undefined
|
|
1428
|
-
? false
|
|
1429
|
-
: typeof entry.writeSeq === 'number'
|
|
1430
|
-
? entry.writeSeq > (typeof watch.seq === 'number' ? watch.seq : -1)
|
|
1431
|
-
: typeof entry.updatedAt === 'number' && entry.updatedAt > watch.at,
|
|
1480
|
+
sectionsStale: staleFor(watch, effective, sessionId),
|
|
1432
1481
|
/**
|
|
1433
1482
|
* 当前生效的是 complete 模式。
|
|
1434
1483
|
*
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@user-mrz/dsh-system-prompt-studio",
|
|
3
3
|
"displayName": "System prompt studio",
|
|
4
4
|
"description": "Per-conversation and per-workspace system prompt control for DeepSeek Harness: append a section, shadow-replace one named section, or replace the whole prompt. Applies on the next model request, persists per session and per working directory, and inherits along fork lineage.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.2",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"exports": {
|