dsh-plugin-memory 0.8.0 → 0.9.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/CHANGELOG.md +33 -0
- package/README.md +10 -0
- package/lib/client.js +101 -1
- package/lib/digest-guard.js +5 -2
- package/lib/recall-nudge.js +5 -2
- package/lib/settings-nav-icon.js +126 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
所有记录跟随 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格;版本号与 `package.json` 保持一致。
|
|
4
4
|
|
|
5
|
+
## [0.9.0] - 2026-09-28
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **设置侧栏专属标记(大脑 + 节点)**:官方 `settings.section` 槽**只投影 `id` / `order` / `label`**,没有 icon 字段可传;设置 shell 的 `navIcon(id)` 只认一小撮白名单 id(account / models / agent-presets / plugins / archived-sessions),其余一律回落到它自己的齿轮——所以本插件(以及所有第三方区块)此前都挂着齿轮。现在挂载后**按 label 认出自己那一行**,给它打标记、藏掉齿轮,再用 `mask-image` 画专属标记;`MutationObserver` 跟随语言切换与重挂载重新认领,`ctx.effect` 负责摘干净。**只碰我们自己那一行**,不触摸任何 shell 结构。纯判定逻辑在 `lib/settings-nav-icon.js`(含单测),客户端半按项目既有约定内联一份等价实现(同 `graph-drag`)。⚠️ **官方哪天给 `settings.section` 长出 `icon` 字段,这段即可删除**——dsh-market、dsh-better-sidebar、dsh-skill-mcp-panel 用的是同一招。
|
|
10
|
+
- **图形不是手搓的**:轮廓取自 **Lucide 的 `brain`(MIT)左半球**,程序化等比缩放到这张 16×16 网格。实测教训:手绘贝塞尔试了四版,脑回起伏在 16px 下全糊成一个 C 或一朵云;换成专业几何才读得出脑叶。
|
|
11
|
+
- **设置区块底部新增「反馈 / 提 issue」入口**:按钮样式(带边框与底色、`padding: 8px 16px`),指向本仓库的 issue 新建页,`target="_blank"` + `rel="noopener noreferrer"`(DSH Desktop 会把外部 HTTPS 交给系统浏览器打开,不携带内嵌会话或 token)。
|
|
12
|
+
|
|
13
|
+
### Changed
|
|
14
|
+
|
|
15
|
+
- **侧栏区块名 `记忆 Memory` → `Memory`**(只保留英文)。注意这个字符串**同时是图标认领的匹配键**——显示文案与匹配键必须是同一个,否则语言切换后行与标记会对不上。
|
|
16
|
+
|
|
17
|
+
### Tests
|
|
18
|
+
|
|
19
|
+
- 新增 `test/settings-nav-icon.test.mjs`(**9 项**):label 精确匹配(trim 后全等,非子串)、空 label 谁都不认领、CSS 生成(藏齿轮 + mask + currentColor 跟随主题)、标记 SVG 规格(`viewBox 0 0 16 16` / `stroke-width 1.3` / round cap+join / 纯黑因 mask 只读 alpha)、图形元素计数(1 闭合轮廓 + 3 引出线 + 5 节点)。
|
|
20
|
+
- 全量 **173/173 通过**。
|
|
21
|
+
|
|
22
|
+
## [0.8.1] - 2026-09-28
|
|
23
|
+
|
|
24
|
+
### Fixed(DSH session format v4 兼容)
|
|
25
|
+
|
|
26
|
+
- **修复注入消息被 v4 拒绝导致的运行失败**:`recall-nudge` 与 `digest-guard` 生成的消息 source 从 `{ kind: 'plugin', plugin: 'memory' }` 改为 **`{ kind: 'plugin:memory' }`**。
|
|
27
|
+
- **症状**:`SessionFormatError: format v4 message requires a producer-owned source kind`。它被 `dsh-agent-loop` 当作非 LLM 错误包成 `{ message, code: 'UNKNOWN' }`,界面上显示为 `... source kind UNKNOWN`——**`UNKNOWN` 是错误码,不是 kind 值**。
|
|
28
|
+
- **原因**:session format **v4**(官方 DeepSeek Harness **0.1.7+**)的原生准入 `source()` 明确拒绝 `kind === "plugin"` 这一 v3 时代的 wrapper,要求 producer-owned kind;第三方插件的形态是 `plugin:<name>`(`producerKind()` 的兜底分支)。
|
|
29
|
+
- **兼容性门槛(重要)**:v4 校验与 v3 的 `SOURCE_KINDS` 白名单**互斥**——v3 白名单里只有 `plugin`,没有 `plugin:memory`,所以**无法同时兼容两版**。**本版起要求 DSH session format v4(官方 0.1.7+)**;旧版 DSH 请停留在 0.8.0。
|
|
30
|
+
- **历史 session 不受影响**:v3→v4 迁移的 `rewritePluginSource()` 会自动把旧 wrapper 转换成新格式,只有**新注入**的消息需要改。
|
|
31
|
+
|
|
32
|
+
### Tests
|
|
33
|
+
|
|
34
|
+
- `test/recall-nudge.test.mjs` / `test/digest-guard.test.mjs` 的 source 断言改为 `deepEqual(source, { kind: 'plugin:memory' })`——顺带卡住「不得再带 `plugin` 字段」。
|
|
35
|
+
- 先写测试并确认其失败(`actual: {kind:'plugin',plugin:'memory'}` vs `expected: {kind:'plugin:memory'}`)后才改实现。
|
|
36
|
+
- 单测 **32/32 通过**。全量 151 项中 3 项失败(`insights-route` / `page-access` / `plugin-metadata`)为既有的 `@deepseek-ai/schemastery` 依赖缺失,已用 `git stash` 基线对比确认**与本次改动无关**。
|
|
37
|
+
|
|
5
38
|
## [0.8.0] - 2026-09-24
|
|
6
39
|
|
|
7
40
|
### Added(checkup 报告 + 注入瘦身 + 日志修复)
|
package/README.md
CHANGED
|
@@ -69,6 +69,16 @@ dsh plugin --profile <profile> add dsh-plugin-memory
|
|
|
69
69
|
|
|
70
70
|
重启 profile(DSH Desktop 重启应用)后生效。
|
|
71
71
|
|
|
72
|
+
> 📌 **版本要求:DSH session format v4(官方 DeepSeek Harness 0.1.7+)**
|
|
73
|
+
>
|
|
74
|
+
> 注入消息的 source 使用 producer-owned kind `plugin:memory`。v4 的原生准入明确拒绝 v3 时代的
|
|
75
|
+
> `{ kind: 'plugin', plugin: 'memory' }` wrapper,报
|
|
76
|
+
> `format v4 message requires a producer-owned source kind`(该错误被包成 `code: "UNKNOWN"`,
|
|
77
|
+
> 所以在界面上会显示成 `... source kind UNKNOWN`——`UNKNOWN` 是错误码,不是 kind 值)。
|
|
78
|
+
>
|
|
79
|
+
> v4 与 v3 的白名单**互斥**(v3 只认 `plugin`),因此无法同时兼容两版。
|
|
80
|
+
> **0.8.0 及更早版本在 v4 上会触发该错误**;旧版 DSH 请停留在 0.8.0。
|
|
81
|
+
|
|
72
82
|
> ⚠️ **不要**再往 profile 的 `cordis.patch.yml` 里手写 `- insert: {id: dsh-memory, ...}`:
|
|
73
83
|
> 那会与 bundle manifest 的自动挂载产生两条同名 entry,整个 profile 会以
|
|
74
84
|
> `duplicate loader entry id "dsh-memory"` 启动失败(2026-08-18 实机事故)。
|
package/lib/client.js
CHANGED
|
@@ -488,6 +488,29 @@ window.__ModuleLoader__.load({
|
|
|
488
488
|
React.createElement('div', { style: { padding: '14px 16px', fontSize: '12px', lineHeight: '18px', color: 'var(--dsw-alias-label-secondary, #888)' } },
|
|
489
489
|
`当前:${value.enabled === false ? '已停用' : `记忆库位于 ${value.memoryDir ?? '(未配置)'}`}。修改即时生效。`,
|
|
490
490
|
),
|
|
491
|
+
// 反馈入口:做成按钮而不是小字链接,方便一眼看到。
|
|
492
|
+
// 外部 HTTPS 在 DSH Desktop 里由系统浏览器打开(不带内嵌会话或 token)。
|
|
493
|
+
React.createElement('div', { style: { padding: '2px 16px 18px' } },
|
|
494
|
+
React.createElement('a', {
|
|
495
|
+
href: MEMORY_FEEDBACK_URL,
|
|
496
|
+
target: '_blank',
|
|
497
|
+
rel: 'noopener noreferrer',
|
|
498
|
+
style: {
|
|
499
|
+
display: 'inline-flex',
|
|
500
|
+
alignItems: 'center',
|
|
501
|
+
gap: '6px',
|
|
502
|
+
padding: '8px 16px',
|
|
503
|
+
fontSize: '13px',
|
|
504
|
+
fontWeight: '500',
|
|
505
|
+
lineHeight: '18px',
|
|
506
|
+
borderRadius: '6px',
|
|
507
|
+
border: '1px solid var(--dsw-alias-border-l2, #d4d4d8)',
|
|
508
|
+
background: 'var(--dsw-alias-bg-layer-1, #f4f4f5)',
|
|
509
|
+
color: 'var(--dsw-alias-label-primary, #18181b)',
|
|
510
|
+
textDecoration: 'none',
|
|
511
|
+
},
|
|
512
|
+
}, '🐛 反馈 / 提 issue'),
|
|
513
|
+
),
|
|
491
514
|
)
|
|
492
515
|
}
|
|
493
516
|
|
|
@@ -938,13 +961,90 @@ window.__ModuleLoader__.load({
|
|
|
938
961
|
return React.createElement(GraphView, { graph, fetchedAt })
|
|
939
962
|
}
|
|
940
963
|
|
|
964
|
+
// ---------------- 设置侧栏标记(导航图标) ----------------
|
|
965
|
+
//
|
|
966
|
+
// Inlined from lib/settings-nav-icon.js: the client bundle can only require
|
|
967
|
+
// platform seeds, so the claim logic lives here in the same shape. The
|
|
968
|
+
// canonical module (with its tests) is the source of truth; this mirrors it.
|
|
969
|
+
//
|
|
970
|
+
// 官方 settings.section 只投影 id / order / label,没有 icon 可传;设置 shell
|
|
971
|
+
// 的 navIcon(id) 只认一小撮白名单 id,其余一律回落到它自己的齿轮。所以我们
|
|
972
|
+
// 挂载后按 label 认出自己那一行,藏掉齿轮、用 mask 画自己的标记。
|
|
973
|
+
// 官方哪天给 settings.section 长出 icon 字段,这段即可删除。
|
|
974
|
+
const NAV_ROW_SELECTOR = '[role="dialog"] nav button'
|
|
975
|
+
const NAV_ICON_ATTR = 'data-dsh-memory-nav-icon'
|
|
976
|
+
const MEMORY_SECTION_LABEL = 'Memory'
|
|
977
|
+
const MEMORY_FEEDBACK_URL = 'https://github.com/LittleBlackTong/dsh-plugin-memory/issues/new'
|
|
978
|
+
const ICON_MEDIUM_STROKE = 1.3
|
|
979
|
+
const BRAIN_CIRCUIT_PATHS = [
|
|
980
|
+
{ kind: 'path', d: 'M7.3 3.71C7.302 3.057 6.95 2.454 6.38 2.134 5.81 1.815 5.112 1.83 4.556 2.172 3.999 2.515 3.672 3.132 3.702 3.785 2.987 3.969 2.397 4.471 2.101 5.147 1.805 5.823 1.836 6.597 2.186 7.247 1.57 7.747 1.241 8.521 1.308 9.312 1.375 10.102 1.829 10.81 2.52 11.2 2.405 12.087 2.793 12.963 3.526 13.475 4.259 13.987 5.216 14.049 6.008 13.636 6.801 13.224 7.299 12.404 7.3 11.51Z' },
|
|
981
|
+
{ kind: 'circle', cx: 9.1, cy: 2.4, r: 0.85 },
|
|
982
|
+
{ kind: 'path', d: 'M7.5 5.4 10.6 4.2' },
|
|
983
|
+
{ kind: 'circle', cx: 11.8, cy: 3.7, r: 1 },
|
|
984
|
+
{ kind: 'path', d: 'M7.5 7.5H10.5' },
|
|
985
|
+
{ kind: 'circle', cx: 11.5, cy: 7.5, r: 0.85 },
|
|
986
|
+
{ kind: 'path', d: 'M7.5 9.6 10.5 10.8' },
|
|
987
|
+
{ kind: 'circle', cx: 11.5, cy: 11.3, r: 0.85 },
|
|
988
|
+
{ kind: 'circle', cx: 9.1, cy: 13.2, r: 0.85 },
|
|
989
|
+
]
|
|
990
|
+
const brainCircuitSvg = () => `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="${ICON_MEDIUM_STROKE}" stroke-linecap="round" stroke-linejoin="round">${BRAIN_CIRCUIT_PATHS.map((p) => (p.kind === 'circle' ? `<circle cx="${p.cx}" cy="${p.cy}" r="${p.r}"/>` : `<path d="${p.d}"/>`)).join('')}</svg>`
|
|
991
|
+
const brainCircuitMaskUrl = (svg = brainCircuitSvg()) => `data:image/svg+xml,${encodeURIComponent(svg)}`
|
|
992
|
+
const navIconCss = (maskUrl) => [
|
|
993
|
+
`[${NAV_ICON_ATTR}] > svg { display: none; }`,
|
|
994
|
+
`[${NAV_ICON_ATTR}]::before {`,
|
|
995
|
+
` content: '';`,
|
|
996
|
+
` flex: none;`,
|
|
997
|
+
` width: 16px;`,
|
|
998
|
+
` height: 16px;`,
|
|
999
|
+
` background-color: currentColor;`,
|
|
1000
|
+
` -webkit-mask-image: url("${maskUrl}");`,
|
|
1001
|
+
` mask-image: url("${maskUrl}");`,
|
|
1002
|
+
` -webkit-mask-repeat: no-repeat;`,
|
|
1003
|
+
` mask-repeat: no-repeat;`,
|
|
1004
|
+
` -webkit-mask-position: center;`,
|
|
1005
|
+
` mask-position: center;`,
|
|
1006
|
+
` -webkit-mask-size: contain;`,
|
|
1007
|
+
` mask-size: contain;`,
|
|
1008
|
+
`}`,
|
|
1009
|
+
].join('\n')
|
|
1010
|
+
const isOwnNavRow = (rowText, wantedLabel) => {
|
|
1011
|
+
const wanted = String(wantedLabel == null ? '' : wantedLabel).trim()
|
|
1012
|
+
if (wanted.length === 0) return false
|
|
1013
|
+
return String(rowText == null ? '' : rowText).trim() === wanted
|
|
1014
|
+
}
|
|
1015
|
+
/** 认领设置侧栏里我们自己那一行;返回 teardown。 */
|
|
1016
|
+
function claimNavIcon(readLabel) {
|
|
1017
|
+
const style = document.createElement('style')
|
|
1018
|
+
style.textContent = navIconCss(brainCircuitMaskUrl())
|
|
1019
|
+
document.head.appendChild(style)
|
|
1020
|
+
const sync = () => {
|
|
1021
|
+
const rows = document.querySelectorAll(NAV_ROW_SELECTOR)
|
|
1022
|
+
const want = readLabel()
|
|
1023
|
+
for (const row of rows) {
|
|
1024
|
+
if (isOwnNavRow(row.textContent, want)) row.setAttribute(NAV_ICON_ATTR, '')
|
|
1025
|
+
else row.removeAttribute(NAV_ICON_ATTR)
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
sync()
|
|
1029
|
+
// 语言切换 / 面板重挂载后重新认领,保证 label 与标记永不打架。
|
|
1030
|
+
const observer = new MutationObserver(sync)
|
|
1031
|
+
observer.observe(document.body, { childList: true, subtree: true, characterData: true })
|
|
1032
|
+
return () => {
|
|
1033
|
+
observer.disconnect()
|
|
1034
|
+
style.remove()
|
|
1035
|
+
for (const row of document.querySelectorAll(`[${NAV_ICON_ATTR}]`)) row.removeAttribute(NAV_ICON_ATTR)
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
|
|
941
1039
|
function apply(ctx) {
|
|
942
1040
|
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
943
1041
|
name: 'settings.section',
|
|
944
1042
|
id: 'memory',
|
|
945
1043
|
order: 100,
|
|
946
|
-
label: () =>
|
|
1044
|
+
label: () => MEMORY_SECTION_LABEL,
|
|
947
1045
|
}, MemorySection))
|
|
1046
|
+
// 官方 settings.section 没有 icon 字段,侧栏标记只能靠自己认领。
|
|
1047
|
+
ctx.effect(() => claimNavIcon(() => MEMORY_SECTION_LABEL), 'memory: settings nav icon')
|
|
948
1048
|
}
|
|
949
1049
|
|
|
950
1050
|
exports.apply = apply
|
package/lib/digest-guard.js
CHANGED
|
@@ -78,7 +78,7 @@ export function lastStoreWriteMs(memoryDir) {
|
|
|
78
78
|
* @param {number} staleMinutes how long the store has been unwritten
|
|
79
79
|
* @param {{ indexHint?: string }} [options] optional routing-table drift line,
|
|
80
80
|
* rendered on its own so the message stays a checklist, not a paragraph
|
|
81
|
-
* @returns {{ id: string, role: 'user', content: [{type:'text', text:string}], source: {kind:'plugin'
|
|
81
|
+
* @returns {{ id: string, role: 'user', content: [{type:'text', text:string}], source: {kind:'plugin:memory'} }}
|
|
82
82
|
*/
|
|
83
83
|
export function buildDigestNudgeMessage(staleMinutes, options = {}) {
|
|
84
84
|
const hint = typeof options.hint === 'string' ? options.hint.trim() : ''
|
|
@@ -100,7 +100,10 @@ export function buildDigestNudgeMessage(staleMinutes, options = {}) {
|
|
|
100
100
|
'完成后继续手头的事即可,不要开启新任务。',
|
|
101
101
|
].join('\n'),
|
|
102
102
|
}],
|
|
103
|
-
|
|
103
|
+
// Session format v4 admits only a producer-owned kind. The retired
|
|
104
|
+
// {kind:'plugin', plugin:'memory'} wrapper is rejected at adoption
|
|
105
|
+
// ("format v4 message requires a producer-owned source kind").
|
|
106
|
+
source: { kind: 'plugin:memory' },
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
|
package/lib/recall-nudge.js
CHANGED
|
@@ -69,7 +69,7 @@ export function listRecallCandidates(memoryDir, count = 3) {
|
|
|
69
69
|
* not a command: first-person, Small-Blue voice, explicitly bounded by
|
|
70
70
|
* "only what's really in memory, never invent, don't repeat yourself".
|
|
71
71
|
* @param {string[]} candidates optional seed headlines
|
|
72
|
-
* @returns {{ id: string, role: 'user', content: [{type:'text', text:string}], source: {kind:'plugin'
|
|
72
|
+
* @returns {{ id: string, role: 'user', content: [{type:'text', text:string}], source: {kind:'plugin:memory'} }}
|
|
73
73
|
*/
|
|
74
74
|
export function buildRecallNudgeMessage(candidates) {
|
|
75
75
|
const list = Array.isArray(candidates)
|
|
@@ -92,7 +92,10 @@ export function buildRecallNudgeMessage(candidates) {
|
|
|
92
92
|
seed,
|
|
93
93
|
].filter(Boolean).join('\n'),
|
|
94
94
|
}],
|
|
95
|
-
|
|
95
|
+
// Session format v4 admits only a producer-owned kind. The retired
|
|
96
|
+
// {kind:'plugin', plugin:'memory'} wrapper is rejected at adoption
|
|
97
|
+
// ("format v4 message requires a producer-owned source kind").
|
|
98
|
+
source: { kind: 'plugin:memory' },
|
|
96
99
|
}
|
|
97
100
|
}
|
|
98
101
|
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 记忆插件的设置侧栏标记(导航图标)。
|
|
3
|
+
*
|
|
4
|
+
* 为什么需要这个模块:官方 `settings.section` 槽**只投影 id / order / label**,
|
|
5
|
+
* 没有 icon 字段可传;设置 shell 的 `navIcon(id)` 只认一小撮白名单 id
|
|
6
|
+
* (account / models / agent-presets / plugins / archived-sessions),其余一律
|
|
7
|
+
* 回落到它自己的齿轮。所以注册方拿不到图标位。
|
|
8
|
+
*
|
|
9
|
+
* 做法(与 dsh-market 的 `settings-nav-icon.ts`、dsh-better-sidebar、
|
|
10
|
+
* dsh-skill-mcp-panel 同款):挂载后按 **label 文本**认出自己那一行,给它打一个
|
|
11
|
+
* 标记属性,再注入样式把 shell 的齿轮藏掉、用 mask 画我们自己的标记。
|
|
12
|
+
* MutationObserver 跟着语言切换/重挂载重新认领;调用方的 disposer 负责摘干净。
|
|
13
|
+
*
|
|
14
|
+
* 范围刻意收窄:**只碰我们自己那一行**,不触摸任何 shell 结构。
|
|
15
|
+
* 官方哪天给 `settings.section` 长出 `icon` 字段,本模块即可删除。
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** 设置面板的 nav 行:shell 把每个 `settings.section` 渲染成 `<nav>` 里的一个 button。 */
|
|
19
|
+
export const NAV_ROW_SELECTOR = '[role="dialog"] nav button'
|
|
20
|
+
|
|
21
|
+
/** 认领标记。样式只挂在带此属性的行上,绝不波及别人。 */
|
|
22
|
+
export const NAV_ICON_ATTR = 'data-dsh-memory-nav-icon'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 本区块的 label。
|
|
26
|
+
*
|
|
27
|
+
* 它同时是**显示文案**和**认领时的匹配键**——两者必须是同一个字符串,
|
|
28
|
+
* 否则语言切换后行与标记会对不上。
|
|
29
|
+
*/
|
|
30
|
+
export const MEMORY_SECTION_LABEL = 'Memory'
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 标记的绘图元素:一个闭合的大脑半球轮廓 + 三条从脑缘引出的线 + 五个节点
|
|
34
|
+
* (三条线各带一个,另有顶部、底部两个游离点)。
|
|
35
|
+
*
|
|
36
|
+
* 顺序有意义:`BRAIN_CIRCUIT_PATHS[0]` 是那个闭合轮廓。
|
|
37
|
+
* 坐标按 16×16 网格手绘,与官方设置图标同一套规格。
|
|
38
|
+
*/
|
|
39
|
+
export const BRAIN_CIRCUIT_PATHS = [
|
|
40
|
+
{
|
|
41
|
+
kind: 'path',
|
|
42
|
+
d: 'M7.3 3.71C7.302 3.057 6.95 2.454 6.38 2.134 5.81 1.815 5.112 1.83 4.556 2.172 3.999 2.515 3.672 3.132 3.702 3.785 2.987 3.969 2.397 4.471 2.101 5.147 1.805 5.823 1.836 6.597 2.186 7.247 1.57 7.747 1.241 8.521 1.308 9.312 1.375 10.102 1.829 10.81 2.52 11.2 2.405 12.087 2.793 12.963 3.526 13.475 4.259 13.987 5.216 14.049 6.008 13.636 6.801 13.224 7.299 12.404 7.3 11.51Z',
|
|
43
|
+
},
|
|
44
|
+
{ kind: 'circle', cx: 9.1, cy: 2.4, r: 0.85 },
|
|
45
|
+
{ kind: 'path', d: 'M7.5 5.4 10.6 4.2' },
|
|
46
|
+
{ kind: 'circle', cx: 11.8, cy: 3.7, r: 1 },
|
|
47
|
+
{ kind: 'path', d: 'M7.5 7.5H10.5' },
|
|
48
|
+
{ kind: 'circle', cx: 11.5, cy: 7.5, r: 0.85 },
|
|
49
|
+
{ kind: 'path', d: 'M7.5 9.6 10.5 10.8' },
|
|
50
|
+
{ kind: 'circle', cx: 11.5, cy: 11.3, r: 0.85 },
|
|
51
|
+
{ kind: 'circle', cx: 9.1, cy: 13.2, r: 0.85 },
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
/** 与官方 `ICON_MEDIUM_STROKE` 一致,保证与相邻区块图标视觉重量相同。 */
|
|
55
|
+
export const ICON_MEDIUM_STROKE = 1.3
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 标记的 SVG 源码。
|
|
59
|
+
*
|
|
60
|
+
* 描边用纯黑是**故意的**:mask 只读 alpha,可见颜色来自承载元素的
|
|
61
|
+
* `background-color: currentColor`,所以深浅主题都能跟随。
|
|
62
|
+
*
|
|
63
|
+
* @returns {string} 一个 16×16 的 outline SVG。
|
|
64
|
+
*/
|
|
65
|
+
export function brainCircuitSvg() {
|
|
66
|
+
const shapes = BRAIN_CIRCUIT_PATHS
|
|
67
|
+
.map((p) => (p.kind === 'circle'
|
|
68
|
+
? `<circle cx="${p.cx}" cy="${p.cy}" r="${p.r}"/>`
|
|
69
|
+
: `<path d="${p.d}"/>`))
|
|
70
|
+
.join('')
|
|
71
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" stroke="#000" stroke-width="${ICON_MEDIUM_STROKE}" stroke-linecap="round" stroke-linejoin="round">${shapes}</svg>`
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 标记的 CSS `mask-image` URL。运行时编码,不手写转义。
|
|
76
|
+
*
|
|
77
|
+
* @param {string} [svg] 覆盖默认标记(测试用)。
|
|
78
|
+
* @returns {string} `data:image/svg+xml,...` URL。
|
|
79
|
+
*/
|
|
80
|
+
export function brainCircuitMaskUrl(svg = brainCircuitSvg()) {
|
|
81
|
+
return `data:image/svg+xml,${encodeURIComponent(svg)}`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 这一行是不是我们自己那一行。
|
|
86
|
+
*
|
|
87
|
+
* 这是本功能**唯一的判断**,所以刻意做成纯函数、精确匹配(trim 之后):
|
|
88
|
+
* 认错行就会把别人的图标盖掉,因此不做子串匹配。空 label 谁都不匹配——
|
|
89
|
+
* 语言尚未就绪时不能把整个 nav 都认领了。
|
|
90
|
+
*
|
|
91
|
+
* @param {string | null | undefined} rowText 该行的可见文本。
|
|
92
|
+
* @param {string | null | undefined} wantedLabel 期望的区块 label。
|
|
93
|
+
* @returns {boolean} 是否为我们的行。
|
|
94
|
+
*/
|
|
95
|
+
export function isOwnNavRow(rowText, wantedLabel) {
|
|
96
|
+
const wanted = String(wantedLabel ?? '').trim()
|
|
97
|
+
if (wanted.length === 0) return false
|
|
98
|
+
return String(rowText ?? '').trim() === wanted
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 认领行的样式表:藏掉 shell 的齿轮,用 mask 画出我们的标记。
|
|
103
|
+
*
|
|
104
|
+
* @param {string} maskUrl 由 {@link brainCircuitMaskUrl} 产出的 URL。
|
|
105
|
+
* @returns {string} 可直接塞进 `<style>` 的 CSS。
|
|
106
|
+
*/
|
|
107
|
+
export function navIconCss(maskUrl) {
|
|
108
|
+
return [
|
|
109
|
+
`[${NAV_ICON_ATTR}] > svg { display: none; }`,
|
|
110
|
+
`[${NAV_ICON_ATTR}]::before {`,
|
|
111
|
+
` content: '';`,
|
|
112
|
+
` flex: none;`,
|
|
113
|
+
` width: 16px;`,
|
|
114
|
+
` height: 16px;`,
|
|
115
|
+
` background-color: currentColor;`,
|
|
116
|
+
` -webkit-mask-image: url("${maskUrl}");`,
|
|
117
|
+
` mask-image: url("${maskUrl}");`,
|
|
118
|
+
` -webkit-mask-repeat: no-repeat;`,
|
|
119
|
+
` mask-repeat: no-repeat;`,
|
|
120
|
+
` -webkit-mask-position: center;`,
|
|
121
|
+
` mask-position: center;`,
|
|
122
|
+
` -webkit-mask-size: contain;`,
|
|
123
|
+
` mask-size: contain;`,
|
|
124
|
+
`}`,
|
|
125
|
+
].join('\n')
|
|
126
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-memory",
|
|
3
3
|
"description": "Long-term memory plugin for DeepSeek Harness: persistent cross-session markdown memory with a soul/persona file, auto-injected at every session start, plus remember/recall/consolidate/forget workflows and portable migration tooling.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.9.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|