@restregular/dsh-memory 0.6.5 → 0.6.7

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 CHANGED
@@ -310,6 +310,8 @@ tools/build-single-package.mjs 构建(产物契约检查 + 可选加载验证)
310
310
 
311
311
  ## 版本
312
312
 
313
+ - **0.6.7** —— 记录卡展开后显示**完整 id**(等宽字体,点击复制)与**标签**;折叠时只保留预览与徽标,列表更安静。
314
+ - **0.6.6** —— 记录卡显示**标签气泡**(之前标签只存不显示,新建后看不到,容易误以为没保存);“修正”关系双向标注:修正版显示「修正自 <旧 id 前 8 位>」,被覆盖的旧记录显示「已被修正」(旧记录仍可检索,只是排序降权 0.3×);面板 `/records` 补齐 `supersededBy` 反查;新建表单的标签输入加了标签名与示例。
313
315
  - **0.6.5** —— 统计卡从「服务」移到「**记录**」页顶部(和记忆列表放在一起),滚动容器高度相应扣掉统计卡那一档。
314
316
  - **0.6.4** —— 标签命名对齐:概览页改名「**服务**」,记忆列表页改名「**记录**」(默认打开);从侧栏入口打开时,记录列表的滚动容器跟着窗口高度长高,不再停在设置面板那档 62vh。
315
317
  - **0.6.3** —— 面板拆成三个标签:服务(统计 / 向量服务 / 维护)、**记录**(记忆列表,默认打开;列表放进独立滚动容器,滚动条为自定义细圆头样式,记忆再多也不把面板撑长)、设置(注入开关与导入导出)。
package/lib/client.js CHANGED
@@ -79,6 +79,13 @@ window.__ModuleLoader__.load({
79
79
  '.memp .chev.open{transform:rotate(90deg)}',
80
80
  '.memp .badge{border:1px solid var(--dsw-alias-border-l1);border-radius:5px;padding:0 6px;line-height:1.7;color:var(--dsw-alias-label-secondary);flex:none}',
81
81
  '.memp .badge.scope{color:var(--dsw-alias-brand-primary);max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}',
82
+ '.memp .badge.corrected{color:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary)}',
83
+ '.memp .tags{display:flex;flex-wrap:wrap;gap:4px;margin-top:6px}',
84
+ '.memp .tag{font-size:11px;line-height:1.7;padding:0 6px;border-radius:999px;border:1px solid var(--dsw-alias-border-l1);color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2)}',
85
+ '.memp .meta{display:flex;align-items:center;gap:8px;margin-top:8px;font-size:12px;color:var(--dsw-alias-label-secondary)}',
86
+ '.memp .meta-id{font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11.5px;padding:1px 6px;border-radius:5px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);cursor:pointer;user-select:all}',
87
+ '.memp .meta-id:hover{color:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary)}',
88
+ '.memp .meta-done{color:var(--dsw-alias-brand-primary);font-size:11.5px}',
82
89
  '.memp .pending{flex:none}',
83
90
  '.memp .time{margin-left:auto;flex:none}',
84
91
  '.memp .preview{margin-top:7px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dsw-alias-label-secondary);line-height:1.5}',
@@ -220,6 +227,15 @@ window.__ModuleLoader__.load({
220
227
  const [importance, setImportance] = React.useState(rec.importance)
221
228
  const [busy, setBusy] = React.useState(false)
222
229
  const [error, setError] = React.useState('')
230
+ const [copied, setCopied] = React.useState(false)
231
+
232
+ const copyId = () => {
233
+ try {
234
+ if (navigator?.clipboard?.writeText) void navigator.clipboard.writeText(rec.id)
235
+ setCopied(true)
236
+ setTimeout(() => setCopied(false), 1200)
237
+ } catch { /* 剪贴板不可用时忽略 */ }
238
+ }
223
239
 
224
240
  // editing implies expanded: the editor replaces the body
225
241
  const open = expanded || editing
@@ -267,7 +283,18 @@ window.__ModuleLoader__.load({
267
283
  h('span', { className: open ? 'chev open' : 'chev' }, '▶'),
268
284
  h('span', { className: 'badge scope', title: rec.scope }, scopeLabel(rec.scope, labels)),
269
285
  h('span', { className: 'badge' }, rec.kind),
270
- rec.supersedes ? h('span', { className: 'badge', title: `修正 #${rec.supersedes}` }, '修正') : null,
286
+ rec.supersedes
287
+ ? h('span', {
288
+ className: 'badge corrected',
289
+ title: `修正版:它覆盖了旧记录 #${rec.supersedes}(旧记录仍可检索,只是排序降权)`,
290
+ }, `修正自 ${rec.supersedes.slice(0, 8)}`)
291
+ : null,
292
+ rec.supersededBy
293
+ ? h('span', {
294
+ className: 'badge',
295
+ title: `已被 #${rec.supersededBy} 修正(旧记录仍可检索,只是排序降权)`,
296
+ }, '已被修正')
297
+ : null,
271
298
  // 只在"待嵌入"时提示:已嵌入是常态,向量没启用时这条也没有行动价值。
272
299
  !rec.embedded && vectorOn ? h('span', { className: 'pending', title: '待嵌入:向量服务就绪后会自动补上' }, '待嵌入') : null,
273
300
  h('span', { className: 'time', title: `更新于 ${fmtTime(rec.updatedAt)}` }, fmtTime(rec.updatedAt)),
@@ -295,7 +322,17 @@ window.__ModuleLoader__.load({
295
322
  h('button', { disabled: busy, onClick: cancelEdit }, '取消'),
296
323
  ),
297
324
  )
298
- : h('div', { className: 'content' }, rec.content),
325
+ : h('div', null,
326
+ h('div', { className: 'content' }, rec.content),
327
+ h('div', { className: 'meta' },
328
+ h('span', { className: 'meta-label' }, 'id'),
329
+ h('code', { className: 'meta-id', title: '点击复制完整 id', onClick: copyId }, rec.id),
330
+ copied ? h('span', { className: 'meta-done' }, '已复制') : null,
331
+ ),
332
+ rec.tags && rec.tags.length > 0
333
+ ? h('div', { className: 'tags' }, rec.tags.map((tag) => h('span', { className: 'tag', key: tag }, tag)))
334
+ : null,
335
+ ),
299
336
  )
300
337
  : null,
301
338
  error ? h('div', { className: 'err' }, error) : null,
@@ -844,7 +881,11 @@ window.__ModuleLoader__.load({
844
881
  }),
845
882
  ),
846
883
  h('div', { className: 'row' },
847
- h('input', { type: 'text', placeholder: '标签, 逗号分隔', value: tags, onChange: (e) => setTags(e.target.value) }),
884
+ h('label', { className: 'set-field' }, '标签 ',
885
+ h('input', {
886
+ type: 'text', style: { width: 190 }, placeholder: '逗号分隔,例如 pnpm, 工具链',
887
+ value: tags, onChange: (e) => setTags(e.target.value),
888
+ })),
848
889
  h('label', null, '重要度 ',
849
890
  h('input', { type: 'number', min: 0, max: 1, step: 0.1, value: importance, onChange: (e) => setImportance(e.target.value) })),
850
891
  h('button', { onClick: submit, disabled: busy || content.trim() === '' || resolvedScope === '' }, busy ? '保存中…' : '保存'),
package/lib/panel.js CHANGED
@@ -193,7 +193,7 @@ function discoverScopes(memory, store) {
193
193
  } catch { /* discovery is best-effort */ }
194
194
  }
195
195
 
196
- function wireRecord(rec, scopeStore) {
196
+ function wireRecord(rec, scopeStore, supersededBy = null) {
197
197
  return {
198
198
  id: rec.id,
199
199
  scope: rec.scope,
@@ -204,15 +204,20 @@ function wireRecord(rec, scopeStore) {
204
204
  createdAt: rec.createdAt,
205
205
  updatedAt: rec.updatedAt,
206
206
  accessCount: rec.accessCount ?? 0,
207
- supersededBy: rec.supersededBy ?? null,
207
+ supersededBy,
208
208
  supersedes: rec.supersedes ?? null,
209
209
  embedded: !scopeStore.embedPending.has(rec.id) && scopeStore.vectors.has(rec.id),
210
210
  }
211
211
  }
212
212
 
213
213
  function collectScope(scopeStore) {
214
+ // supersedes 是"新记录 → 旧记录"的指向;反查一次,给旧记录标上"已被修正"。
215
+ const correctedBy = new Map()
216
+ for (const rec of scopeStore.records.values()) {
217
+ if (rec.supersedes) correctedBy.set(rec.supersedes, rec.id)
218
+ }
214
219
  const out = []
215
- for (const rec of scopeStore.records.values()) out.push(wireRecord(rec, scopeStore))
220
+ for (const rec of scopeStore.records.values()) out.push(wireRecord(rec, scopeStore, correctedBy.get(rec.id) ?? null))
216
221
  return out.sort((a, b) => b.updatedAt - a.updatedAt)
217
222
  }
218
223
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-memory",
3
- "version": "0.6.5",
3
+ "version": "0.6.7",
4
4
  "description": "DeepSeek Harness 本地长期记忆(单包单入口):JSONL 存储 + 本地向量检索(BGE-M3)+ 四个模型工具 + 自动召回注入 + 管理面板。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",