dsh-agent-soul 0.9.14 → 0.9.16

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 CHANGED
@@ -7,6 +7,42 @@
7
7
 
8
8
  ---
9
9
 
10
+ ## 0.9.16 · 2026-11-09
11
+
12
+ ### 变更
13
+
14
+ - **长列表自己滚**:日记「最近日记」、记忆记录、笔记列表、目的「惦记的事」四处
15
+ 加 `max-height:min(46vh,420px) + overflow:auto`(跟心情页时间线 `.soul-tl` 同一个套路)。
16
+ 条目一多时不再把整页撑长,下面的卡片不用划半天才看得到。
17
+ 加 `overscroll-behavior:contain`:内层滚到底不把滚动传给外层,免得整页突然跳走。
18
+ - 新增 `tools/sync-preview.mjs`:把 `styles.js` 的 CSS 一键同步进 `docs/preview.html`。
19
+ R15 的 `preview-css` 门禁能拦住「改了样式忘了同步」,但同步一直是手工的 —— 现在是一条命令。
20
+ - 新增 `tests/ui-scroll.test.js`(10 断言):断言样式规则存在(有界高度 / 可滚 / 不传滚动),
21
+ 且四个片段真的挂上了 class —— 只加样式不挂 class 是最常见的「改了等于没改」。
22
+
23
+ ### 修复
24
+
25
+ - `docs/preview.html` 的插件 CSS 与 `styles.js` 同步(否则 `preview-css` 契约红)。
26
+
27
+ ---
28
+
29
+ ## 0.9.15 · 2026-11-10
30
+
31
+ ### 修复
32
+
33
+ - **0.9.14 的两个新功能在设置页看不见**:`diaryToTodayEnabled` / `situationEnabled` 只加了配置键、
34
+ 没加界面 —— 而「每个功能都要在设置 UI 里能关」是这个项目定过的规矩。
35
+ - **卡片只在「今天已经有一句」时才渲染**:用户什么都没看到,会以为功能没做。
36
+ 现在功能开着就一直有这张卡片;今天还没那句时给**一句轻说明**
37
+ (「她写完私密日记、在末尾写一行「想对明天说:…」时就有了」),不是整块消失,也不催更。
38
+
39
+ ### 测试
40
+
41
+ - `tests/r19-situation-to-today.test.js` 加 4 条**界面契约**断言:客户端产物里必须有这张卡片、
42
+ 两个开关、以及那句空状态说明 —— 防止「配了键忘了接界面」这类静默漏做再发生。
43
+
44
+ ---
45
+
10
46
  ## 0.9.14 · 2026-11-10
11
47
 
12
48
  功能增补轮 **R19**(依据 `dsh-agent-soul-0.9.8-功能增补设计.md`,按 0.9.13 的实际代码修正落点)。
package/docs/preview.html CHANGED
@@ -57,6 +57,7 @@ border:1px solid var(--soul-line);border-radius:14px;overflow:hidden;background:
57
57
  .soul-badge.fuzzy{background:rgba(255,176,32,.17);color:#8a6a2f}
58
58
  .soul-badge.trace{background:rgba(255,92,92,.14);color:#a83a2c}
59
59
  .soul-list{display:flex;flex-direction:column;gap:6px;margin-top:8px}
60
+ .soul-list-fixed{max-height:min(46vh,420px);overflow:auto;overscroll-behavior:contain;padding-right:4px}
60
61
  .soul-item{display:flex;gap:8px;align-items:flex-start;border:1px solid var(--soul-line-soft);border-radius:8px;padding:9px 10px;background:var(--soul-bg)}
61
62
  .soul-item:hover{border-color:var(--soul-line)}
62
63
  .soul-item-text{flex:1 1 auto;min-width:0;word-break:break-word}
@@ -126,8 +127,7 @@ border:1px solid var(--soul-line);border-radius:14px;overflow:hidden;background:
126
127
  .soul-tl-delta.up{color:#c0392b}
127
128
  .soul-tl-delta.down{color:#2f6b46}
128
129
  .soul-tl-body{flex:1 1 auto;min-width:0;color:var(--soul-muted);word-break:break-word}
129
- @supports not (color:var(--dsw-alias-label-primary)){.soul-app{--soul-fg:#241f18;--soul-muted:#6f6558;--soul-faint:#9a9084;--soul-line:#e0d7c8;--soul-line-soft:#ece5d8;--soul-bg:#fffdf8;--soul-bg2:#f6f2ea;--soul-brand:#1f6feb;--soul-ok:#2f6b46;--soul-warn:#8a6a2f;--soul-err:#a83a2c}}
130
- </style>
130
+ @supports not (color:var(--dsw-alias-label-primary)){.soul-app{--soul-fg:#241f18;--soul-muted:#6f6558;--soul-faint:#9a9084;--soul-line:#e0d7c8;--soul-line-soft:#ece5d8;--soul-bg:#fffdf8;--soul-bg2:#f6f2ea;--soul-brand:#1f6feb;--soul-ok:#2f6b46;--soul-warn:#8a6a2f;--soul-err:#a83a2c}}</style>
131
131
  </head>
132
132
  <body>
133
133
  <div class="pv-wrap">
@@ -294,6 +294,35 @@
294
294
  onChange: function (e) { patch({ diaryEnabled: e.target.checked }) },
295
295
  })
296
296
  ),
297
+ // 昨天想对今天说的(2026-11-09 R19 / ⑥):开关放这儿,
298
+ // 「每个功能都要在设置 UI 里能关」是树树定过的规矩。
299
+ h('div', { className: 'soul-row', style: { padding: '6px 0' } },
300
+ h('div', { className: 'soul-grow' },
301
+ h('div', null, '昨天想对今天说的'),
302
+ h('p', { className: 'soul-note' },
303
+ '她写完私密日记后,可以在末尾写一行「想对明天说:…」;这句话当天每个新会话的第一轮会带上,'
304
+ + '你也可以在下面改写或删掉。关掉 = 不产出、不注入、不显示。')
305
+ ),
306
+ h('input', {
307
+ type: 'checkbox',
308
+ checked: config.diaryToTodayEnabled !== false,
309
+ onChange: function (e) { patch({ diaryToTodayEnabled: e.target.checked }) },
310
+ })
311
+ ),
312
+ // 现实情境(2026-11-09 R19 / ④):只喂日记素材与目的段那一句,不进提示词主干。
313
+ h('div', { className: 'soul-row', style: { padding: '6px 0' } },
314
+ h('div', { className: 'soul-grow' },
315
+ h('div', null, '现实情境(时段 / 节日 / 久未聊)'),
316
+ h('p', { className: 'soul-note' },
317
+ '写日记时带上「深夜 / 国庆 / 三天没聊了」这类背景事实;目的那段也会带一句很短的状态。'
318
+ + '纯规则、不花模型;不进提示词主干(否则每轮上下文都会抖)。')
319
+ ),
320
+ h('input', {
321
+ type: 'checkbox',
322
+ checked: config.situationEnabled !== false,
323
+ onChange: function (e) { patch({ situationEnabled: e.target.checked }) },
324
+ })
325
+ ),
297
326
  h('div', { className: 'soul-row', style: { padding: '6px 0' } },
298
327
  h('span', { className: 'soul-grow' }, '兜底检查间隔'),
299
328
  h('input', {
@@ -430,32 +459,35 @@
430
459
  ),
431
460
 
432
461
  // ---- 昨天想对今天说的(2026-11-09 R19 / ⑥)----
433
- // 只在功能开着时出现;今天没有这句就**不留空卡片**(不引导补写)——
434
- // 「没写就不写」是这个功能的规矩,UI 不该替她催更。
435
- config && config.diaryToTodayEnabled !== false && toToday
462
+ // 功能开着就出现这张卡片。今天还没有这句时,**只给一句轻说明**,不留空卡片、
463
+ // 不引导补写(「没写就不写」是这功能的规矩);但也不能整块消失 —— 那样用户会以为没做。
464
+ config && config.diaryToTodayEnabled !== false
436
465
  ? h(Card, { title: '昨天想对今天说的', meta: '从私密日记里挑的、她愿意给你看的一句' },
437
- editingToToday
438
- ? h('div', null,
439
- h('input', {
440
- className: 'soul-input',
441
- value: toTodayDraft,
442
- maxLength: 60,
443
- onChange: function (e) { setToTodayDraft(e.target.value) }
444
- }),
445
- h('div', { className: 'soul-row', style: { marginTop: 8 } },
446
- h('button', { className: 'soul-btn', disabled: busy === 'toToday', onClick: saveToTodayEdit }, '保存'),
447
- h('button', { className: 'soul-btn', onClick: function () { setEditingToToday(false) } }, '取消')
466
+ toToday === null || toToday === undefined
467
+ ? h('p', { className: 'soul-note' },
468
+ '今天还没有这一句 —— 她写完私密日记、在末尾写一行「想对明天说:…」时就有了。')
469
+ : editingToToday
470
+ ? h('div', null,
471
+ h('input', {
472
+ className: 'soul-input',
473
+ value: toTodayDraft,
474
+ maxLength: 60,
475
+ onChange: function (e) { setToTodayDraft(e.target.value) }
476
+ }),
477
+ h('div', { className: 'soul-row', style: { marginTop: 8 } },
478
+ h('button', { className: 'soul-btn', disabled: busy === 'toToday', onClick: saveToTodayEdit }, '保存'),
479
+ h('button', { className: 'soul-btn', onClick: function () { setEditingToToday(false) } }, '取消')
480
+ )
448
481
  )
449
- )
450
- : h('div', null,
451
- h('p', { className: 'soul-note', style: { margin: '2px 0 8px' } }, toToday.date),
452
- h('p', { style: { fontSize: 15, margin: '0 0 10px', lineHeight: 1.6 } }, '「' + toToday.text + '」'),
453
- h('p', { className: 'soul-note' }, '今天每个新会话的第一轮会带上这一句;已开的会话不会变。'),
454
- h('div', { className: 'soul-row', style: { marginTop: 8 } },
455
- h('button', { className: 'soul-btn', onClick: beginEditToToday }, '改写'),
456
- h('button', { className: 'soul-btn', disabled: busy === 'toToday', onClick: deleteToToday }, '删掉')
482
+ : h('div', null,
483
+ h('p', { className: 'soul-note', style: { margin: '2px 0 8px' } }, toToday.date),
484
+ h('p', { style: { fontSize: 15, margin: '0 0 10px', lineHeight: 1.6 } }, '「' + toToday.text + '」'),
485
+ h('p', { className: 'soul-note' }, '今天每个新会话的第一轮会带上这一句;已开的会话不会变。'),
486
+ h('div', { className: 'soul-row', style: { marginTop: 8 } },
487
+ h('button', { className: 'soul-btn', onClick: beginEditToToday }, '改写'),
488
+ h('button', { className: 'soul-btn', disabled: busy === 'toToday', onClick: deleteToToday }, '删掉')
489
+ )
457
490
  )
458
- )
459
491
  )
460
492
  : null,
461
493
 
@@ -463,7 +495,7 @@
463
495
  h(Card, { title: '最近日记', meta: '公开日记可直接看,私密日记不出服务器' },
464
496
  data === null || data.length === 0
465
497
  ? h('div', { className: 'soul-empty' }, '还没有写过日记')
466
- : h('div', { className: 'soul-list' }, data.map(function (item) {
498
+ : h('div', { className: 'soul-list soul-list-fixed' }, data.map(function (item) {
467
499
  return h('div', { key: item.date, className: 'soul-item' },
468
500
  h('div', { className: 'soul-item-text' },
469
501
  h('div', { style: { display: 'flex', gap: 8, alignItems: 'center' } },
@@ -115,7 +115,7 @@
115
115
 
116
116
  records.length === 0
117
117
  ? h('div', { className: 'soul-empty' }, query ? '没搜到' : '还没有记忆。多聊几句,值得记的会自动进来')
118
- : h('div', { className: 'soul-list' }, records.map(function (r) {
118
+ : h('div', { className: 'soul-list soul-list-fixed' }, records.map(function (r) {
119
119
  return h('div', { key: r.id, className: 'soul-item' },
120
120
  h(Badge, { clarity: r.clarity }, CLARITY_LABEL[r.clarity] || r.clarity),
121
121
  h('div', { className: 'soul-item-text' },
@@ -103,7 +103,7 @@
103
103
  ),
104
104
  list.length === 0
105
105
  ? h('div', { className: 'soul-empty' }, '还没写过东西。等她在对话里想到什么,这里就会长出来')
106
- : h('div', { className: 'soul-list' }, list.map(function (entry) {
106
+ : h('div', { className: 'soul-list soul-list-fixed' }, list.map(function (entry) {
107
107
  return h('div', {
108
108
  key: entry.slug,
109
109
  className: 'soul-item',
@@ -28,7 +28,7 @@
28
28
  h('p', { className: 'soul-note' }, '这些会出现在她的提示词里,但明确写了「不需要每轮都提」——所以不会变成复读。'),
29
29
  (purpose.goals || []).length === 0
30
30
  ? h('div', { className: 'soul-empty' }, '暂时没有。她答应过的事、没弄明白的事会自动长出来')
31
- : h('div', { className: 'soul-list' }, (purpose.goals || []).map(function (goal) {
31
+ : h('div', { className: 'soul-list soul-list-fixed' }, (purpose.goals || []).map(function (goal) {
32
32
  return h('div', { key: goal.id, className: 'soul-item' },
33
33
  h('span', { className: 'soul-badge' }, KIND_LABEL[goal.kind] || '想试试'),
34
34
  h('div', { className: 'soul-item-text' },
@@ -61,6 +61,11 @@
61
61
  '.soul-badge.trace{background:rgba(255,92,92,.14);color:#a83a2c}',
62
62
 
63
63
  '.soul-list{display:flex;flex-direction:column;gap:6px;margin-top:8px}',
64
+ // 长列表自己滚(2026-11-09):日记 / 记忆 / 笔记 / 惦记的事条目一多,
65
+ // 整页被撑得很长,要划半天才能看到下一张卡片。这里给它们一个**有界高度**,
66
+ // 跟心情页时间线(.soul-tl)同样的做法。
67
+ // overscroll-behavior:contain —— 滚到底时不把滚动传给外层,免得整页突然跳走。
68
+ '.soul-list-fixed{max-height:min(46vh,420px);overflow:auto;overscroll-behavior:contain;padding-right:4px}',
64
69
  '.soul-item{display:flex;gap:8px;align-items:flex-start;border:1px solid var(--soul-line-soft);border-radius:8px;padding:9px 10px;background:var(--soul-bg)}',
65
70
  '.soul-item:hover{border-color:var(--soul-line)}',
66
71
  '.soul-item-text{flex:1 1 auto;min-width:0;word-break:break-word}',
package/lib/client.js CHANGED
@@ -87,6 +87,11 @@ window.__ModuleLoader__.load({
87
87
  '.soul-badge.trace{background:rgba(255,92,92,.14);color:#a83a2c}',
88
88
 
89
89
  '.soul-list{display:flex;flex-direction:column;gap:6px;margin-top:8px}',
90
+ // 长列表自己滚(2026-11-09):日记 / 记忆 / 笔记 / 惦记的事条目一多,
91
+ // 整页被撑得很长,要划半天才能看到下一张卡片。这里给它们一个**有界高度**,
92
+ // 跟心情页时间线(.soul-tl)同样的做法。
93
+ // overscroll-behavior:contain —— 滚到底时不把滚动传给外层,免得整页突然跳走。
94
+ '.soul-list-fixed{max-height:min(46vh,420px);overflow:auto;overscroll-behavior:contain;padding-right:4px}',
90
95
  '.soul-item{display:flex;gap:8px;align-items:flex-start;border:1px solid var(--soul-line-soft);border-radius:8px;padding:9px 10px;background:var(--soul-bg)}',
91
96
  '.soul-item:hover{border-color:var(--soul-line)}',
92
97
  '.soul-item-text{flex:1 1 auto;min-width:0;word-break:break-word}',
@@ -1033,7 +1038,7 @@ window.__ModuleLoader__.load({
1033
1038
 
1034
1039
  records.length === 0
1035
1040
  ? h('div', { className: 'soul-empty' }, query ? '没搜到' : '还没有记忆。多聊几句,值得记的会自动进来')
1036
- : h('div', { className: 'soul-list' }, records.map(function (r) {
1041
+ : h('div', { className: 'soul-list soul-list-fixed' }, records.map(function (r) {
1037
1042
  return h('div', { key: r.id, className: 'soul-item' },
1038
1043
  h(Badge, { clarity: r.clarity }, CLARITY_LABEL[r.clarity] || r.clarity),
1039
1044
  h('div', { className: 'soul-item-text' },
@@ -1198,7 +1203,7 @@ window.__ModuleLoader__.load({
1198
1203
  h('p', { className: 'soul-note' }, '这些会出现在她的提示词里,但明确写了「不需要每轮都提」——所以不会变成复读。'),
1199
1204
  (purpose.goals || []).length === 0
1200
1205
  ? h('div', { className: 'soul-empty' }, '暂时没有。她答应过的事、没弄明白的事会自动长出来')
1201
- : h('div', { className: 'soul-list' }, (purpose.goals || []).map(function (goal) {
1206
+ : h('div', { className: 'soul-list soul-list-fixed' }, (purpose.goals || []).map(function (goal) {
1202
1207
  return h('div', { key: goal.id, className: 'soul-item' },
1203
1208
  h('span', { className: 'soul-badge' }, KIND_LABEL[goal.kind] || '想试试'),
1204
1209
  h('div', { className: 'soul-item-text' },
@@ -1839,6 +1844,35 @@ window.__ModuleLoader__.load({
1839
1844
  onChange: function (e) { patch({ diaryEnabled: e.target.checked }) },
1840
1845
  })
1841
1846
  ),
1847
+ // 昨天想对今天说的(2026-11-09 R19 / ⑥):开关放这儿,
1848
+ // 「每个功能都要在设置 UI 里能关」是树树定过的规矩。
1849
+ h('div', { className: 'soul-row', style: { padding: '6px 0' } },
1850
+ h('div', { className: 'soul-grow' },
1851
+ h('div', null, '昨天想对今天说的'),
1852
+ h('p', { className: 'soul-note' },
1853
+ '她写完私密日记后,可以在末尾写一行「想对明天说:…」;这句话当天每个新会话的第一轮会带上,'
1854
+ + '你也可以在下面改写或删掉。关掉 = 不产出、不注入、不显示。')
1855
+ ),
1856
+ h('input', {
1857
+ type: 'checkbox',
1858
+ checked: config.diaryToTodayEnabled !== false,
1859
+ onChange: function (e) { patch({ diaryToTodayEnabled: e.target.checked }) },
1860
+ })
1861
+ ),
1862
+ // 现实情境(2026-11-09 R19 / ④):只喂日记素材与目的段那一句,不进提示词主干。
1863
+ h('div', { className: 'soul-row', style: { padding: '6px 0' } },
1864
+ h('div', { className: 'soul-grow' },
1865
+ h('div', null, '现实情境(时段 / 节日 / 久未聊)'),
1866
+ h('p', { className: 'soul-note' },
1867
+ '写日记时带上「深夜 / 国庆 / 三天没聊了」这类背景事实;目的那段也会带一句很短的状态。'
1868
+ + '纯规则、不花模型;不进提示词主干(否则每轮上下文都会抖)。')
1869
+ ),
1870
+ h('input', {
1871
+ type: 'checkbox',
1872
+ checked: config.situationEnabled !== false,
1873
+ onChange: function (e) { patch({ situationEnabled: e.target.checked }) },
1874
+ })
1875
+ ),
1842
1876
  h('div', { className: 'soul-row', style: { padding: '6px 0' } },
1843
1877
  h('span', { className: 'soul-grow' }, '兜底检查间隔'),
1844
1878
  h('input', {
@@ -1975,32 +2009,35 @@ window.__ModuleLoader__.load({
1975
2009
  ),
1976
2010
 
1977
2011
  // ---- 昨天想对今天说的(2026-11-09 R19 / ⑥)----
1978
- // 只在功能开着时出现;今天没有这句就**不留空卡片**(不引导补写)——
1979
- // 「没写就不写」是这个功能的规矩,UI 不该替她催更。
1980
- config && config.diaryToTodayEnabled !== false && toToday
2012
+ // 功能开着就出现这张卡片。今天还没有这句时,**只给一句轻说明**,不留空卡片、
2013
+ // 不引导补写(「没写就不写」是这功能的规矩);但也不能整块消失 —— 那样用户会以为没做。
2014
+ config && config.diaryToTodayEnabled !== false
1981
2015
  ? h(Card, { title: '昨天想对今天说的', meta: '从私密日记里挑的、她愿意给你看的一句' },
1982
- editingToToday
1983
- ? h('div', null,
1984
- h('input', {
1985
- className: 'soul-input',
1986
- value: toTodayDraft,
1987
- maxLength: 60,
1988
- onChange: function (e) { setToTodayDraft(e.target.value) }
1989
- }),
1990
- h('div', { className: 'soul-row', style: { marginTop: 8 } },
1991
- h('button', { className: 'soul-btn', disabled: busy === 'toToday', onClick: saveToTodayEdit }, '保存'),
1992
- h('button', { className: 'soul-btn', onClick: function () { setEditingToToday(false) } }, '取消')
2016
+ toToday === null || toToday === undefined
2017
+ ? h('p', { className: 'soul-note' },
2018
+ '今天还没有这一句 —— 她写完私密日记、在末尾写一行「想对明天说:…」时就有了。')
2019
+ : editingToToday
2020
+ ? h('div', null,
2021
+ h('input', {
2022
+ className: 'soul-input',
2023
+ value: toTodayDraft,
2024
+ maxLength: 60,
2025
+ onChange: function (e) { setToTodayDraft(e.target.value) }
2026
+ }),
2027
+ h('div', { className: 'soul-row', style: { marginTop: 8 } },
2028
+ h('button', { className: 'soul-btn', disabled: busy === 'toToday', onClick: saveToTodayEdit }, '保存'),
2029
+ h('button', { className: 'soul-btn', onClick: function () { setEditingToToday(false) } }, '取消')
2030
+ )
1993
2031
  )
1994
- )
1995
- : h('div', null,
1996
- h('p', { className: 'soul-note', style: { margin: '2px 0 8px' } }, toToday.date),
1997
- h('p', { style: { fontSize: 15, margin: '0 0 10px', lineHeight: 1.6 } }, '「' + toToday.text + '」'),
1998
- h('p', { className: 'soul-note' }, '今天每个新会话的第一轮会带上这一句;已开的会话不会变。'),
1999
- h('div', { className: 'soul-row', style: { marginTop: 8 } },
2000
- h('button', { className: 'soul-btn', onClick: beginEditToToday }, '改写'),
2001
- h('button', { className: 'soul-btn', disabled: busy === 'toToday', onClick: deleteToToday }, '删掉')
2032
+ : h('div', null,
2033
+ h('p', { className: 'soul-note', style: { margin: '2px 0 8px' } }, toToday.date),
2034
+ h('p', { style: { fontSize: 15, margin: '0 0 10px', lineHeight: 1.6 } }, '「' + toToday.text + '」'),
2035
+ h('p', { className: 'soul-note' }, '今天每个新会话的第一轮会带上这一句;已开的会话不会变。'),
2036
+ h('div', { className: 'soul-row', style: { marginTop: 8 } },
2037
+ h('button', { className: 'soul-btn', onClick: beginEditToToday }, '改写'),
2038
+ h('button', { className: 'soul-btn', disabled: busy === 'toToday', onClick: deleteToToday }, '删掉')
2039
+ )
2002
2040
  )
2003
- )
2004
2041
  )
2005
2042
  : null,
2006
2043
 
@@ -2008,7 +2045,7 @@ window.__ModuleLoader__.load({
2008
2045
  h(Card, { title: '最近日记', meta: '公开日记可直接看,私密日记不出服务器' },
2009
2046
  data === null || data.length === 0
2010
2047
  ? h('div', { className: 'soul-empty' }, '还没有写过日记')
2011
- : h('div', { className: 'soul-list' }, data.map(function (item) {
2048
+ : h('div', { className: 'soul-list soul-list-fixed' }, data.map(function (item) {
2012
2049
  return h('div', { key: item.date, className: 'soul-item' },
2013
2050
  h('div', { className: 'soul-item-text' },
2014
2051
  h('div', { style: { display: 'flex', gap: 8, alignItems: 'center' } },
@@ -2196,7 +2233,7 @@ window.__ModuleLoader__.load({
2196
2233
  ),
2197
2234
  list.length === 0
2198
2235
  ? h('div', { className: 'soul-empty' }, '还没写过东西。等她在对话里想到什么,这里就会长出来')
2199
- : h('div', { className: 'soul-list' }, list.map(function (entry) {
2236
+ : h('div', { className: 'soul-list soul-list-fixed' }, list.map(function (entry) {
2200
2237
  return h('div', {
2201
2238
  key: entry.slug,
2202
2239
  className: 'soul-item',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-agent-soul",
3
- "version": "0.9.14",
3
+ "version": "0.9.16",
4
4
  "type": "module",
5
5
  "description": "给 DSH 的 agent 一套会忘事的记忆、一份会变的人格和一份会起伏的心情:每轮注入人格 / 记忆 / 笔记 / 目的四段上下文,心情自己判起伏、再补一段状态与语气(可关);记忆按人的规律衰减(清晰→模糊→只剩印象→遗忘),「心里惦记的事」让她的主动有连续性。",
6
6
  "keywords": [
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * 把 lib/client/styles.js 的 CSS 同步进 docs/preview.html(2026-11-09)。
4
+ *
5
+ * 为什么需要它:preview.html 里 `.soul-*` 那一段是**手工复制**的样式产物。
6
+ * R15 加了 `tests/preview-css.test.js` 拦住「改了样式忘了同步」——但拦下来之后,
7
+ * 同步这件事仍然是手工的。这个脚本让它是**一条命令**。
8
+ *
9
+ * 用法:node tools/sync-preview.mjs
10
+ */
11
+ import { readFileSync, writeFileSync } from 'node:fs'
12
+ import { dirname, join } from 'node:path'
13
+ import { fileURLToPath } from 'node:url'
14
+
15
+ const root = join(dirname(fileURLToPath(import.meta.url)), '..')
16
+
17
+ // 1. 求值 CSS 数组(只跑数组字面量,不加载整个片段、不碰 DOM)
18
+ const stylesSrc = readFileSync(join(root, 'lib', 'client', 'styles.js'), 'utf8')
19
+ const arr = stylesSrc.match(/var CSS = \[([\s\S]*?)\]\s*\.join\(/)
20
+ if (arr === null) {
21
+ console.error('styles.js 里没找到 CSS 数组(正则失配,样式结构可能变了)')
22
+ process.exit(1)
23
+ }
24
+ // 注意:必须用普通字符串拼 "].join('\\n')" —— 写进模板字符串的话 \n 会变成真换行,
25
+ // 生成的代码就断了(我自己先踩了一次)。
26
+ const generated = new Function(`return [${arr[1]}].join('\\n')`)()
27
+
28
+ // 2. 替换 preview.html 里的插件段(从 .soul-app{ 到 </style> 之前)
29
+ const previewPath = join(root, 'docs', 'preview.html')
30
+ const preview = readFileSync(previewPath, 'utf8')
31
+ const styleStart = preview.indexOf('<style>')
32
+ const styleEnd = preview.indexOf('</style>')
33
+ if (styleStart < 0 || styleEnd <= styleStart) {
34
+ console.error('preview.html 里没找到 <style> 块')
35
+ process.exit(1)
36
+ }
37
+ const soulAt = preview.indexOf('.soul-app{', styleStart)
38
+ if (soulAt <= styleStart) {
39
+ console.error('preview.html 的 style 块里没有插件段(.soul-app{ 起始)')
40
+ process.exit(1)
41
+ }
42
+
43
+ // 行尾跟随原文件:Windows 检出是 CRLF,别把整份文件改成 LF
44
+ const eol = preview.includes('\r\n') ? '\r\n' : '\n'
45
+ const body = generated.split('\n').join(eol)
46
+ const next = preview.slice(0, soulAt) + body + preview.slice(styleEnd)
47
+
48
+ if (next === preview) {
49
+ console.log('preview.html 已经是最新的(无需改动)')
50
+ process.exit(0)
51
+ }
52
+ writeFileSync(previewPath, next, 'utf8')
53
+ console.log(`preview.html 已同步(插件 CSS 段 ${generated.length} 字符)`)