dsh-memory-palace 1.7.1 → 1.7.2-alpha.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/README.md CHANGED
@@ -2,20 +2,19 @@
2
2
 
3
3
  把 WorkBuddy 的文件式记忆系统移植进 [DeepSeek Harness](https://www.deepseek.com/harness/) —— 为 Harness 提供**跨会话持久化、人类可直接编辑的 Markdown 记忆**。
4
4
 
5
- [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE) [![Awesome DSH Plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com) [![npm](https://img.shields.io/npm/v/dsh-memory-palace.svg?label=npm&labelColor=000000&color=ff4b01)](https://www.npmjs.com/package/dsh-memory-palace) [![DeepSeek Harness:0.1.5-rc.1](https://img.shields.io/badge/DeepSeek%20Harness-0.1.5--rc.1-success.svg?labelColor=4D6BFE)](https://github.com/deepseek-ai/deepseek-harness)
5
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE) [![Awesome DSH Plugin](https://awesome-dsh-plugin.com/badge.svg)](https://awesome-dsh-plugin.com) [![npm](https://img.shields.io/npm/v/dsh-memory-palace.svg?label=npm&labelColor=000000&color=ff4b01)](https://www.npmjs.com/package/dsh-memory-palace) [![DeepSeek Harness:0.1.7-alpha.1](https://img.shields.io/badge/DeepSeek%20Harness-0.1.7--alpha.1-success.svg?labelColor=4D6BFE)](https://github.com/deepseek-ai/deepseek-harness)
6
6
 
7
7
  ## 特性
8
8
 
9
9
  - **人类可读的真源**:记忆以纯 Markdown 存储,任何编辑器都能直接修改,数据始终属于你。
10
10
  - **双层记忆**:用户级(跨项目个人偏好)+ 工作区级(项目约定),互不干扰。
11
- - **日志自动沉淀**:超过保留期的每日日志自动并入长期记忆,结论不丢。
12
11
  - **WorkBuddy / CodeBuddy 桥接**:项目已有对应记忆目录时直接读写,无需重复维护。
13
12
  - **记忆工具**:AI 可主动写入、聚合读取、按内容删除(删除需人工确认),写入自带去重。
14
13
  - **手动蒸馏**:会话标题栏一键把当前对话或项目记忆提炼成长期记忆。
15
14
  - **设置页集成**:全部配置均可在 DSH 设置面板中图形化调整(按板块折叠),无需改配置文件。
16
15
  - **自定义指令**:不适合写进记忆的特殊指令可在设置页配置,插件经系统提示词注入。
17
- - **主动记忆(插件模式)**:以指令引导 AI 在完成任务、修复问题、确定决策、获知偏好时主动落档。
18
- - **智能模式**:由模型自动提炼每轮新增内容,摘要进日志、长期事实进记忆。
16
+ - **主动记忆(插件模式)**:以指令引导 AI 在完成任务、修复问题、确定决策、获知偏好时主动落档。*即将移除*
17
+ - **智能模式**:由模型自动提炼每轮新增内容,摘要进日志、长期事实进记忆。*即将移除*
19
18
  - **记忆注入**:长期记忆与今日日志以「会话起始快照」常驻上下文、按文件身份各只注入一次 —— 既保证每个步骤都可见,又不破坏前缀缓存、不堆积冗余快照。
20
19
  - **混合模式(🔥推荐)**:子代理每轮自动整理日志并去重,长期记忆由主 AI 主动维护,兼顾自动化与可控性。
21
20
  - **标准插件包**:经官方插件机制一键安装,无需改动 harness。
@@ -42,8 +41,8 @@
42
41
  **读取(每轮对话)**——两条通道并行:
43
42
 
44
43
  ```
45
- ① 长期记忆:全程常驻,每个步骤都可见;内容未变只写一次,压缩后自动重注
46
- ② 今日日志:随系统提示词按轮次注入(高频变化,不进对话历史以免膨胀)
44
+ ① 系统提示词(恒定):记忆公民指令 / 自定义指令等固定内容,前缀缓存友好
45
+ ② 对话历史投影(易变):用户级 + 项目级长期记忆、今日日志——按文件身份各注入一次,压缩后自动重注最新版
47
46
  ```
48
47
 
49
48
  **写入(每轮结束)**——经「防闲聊闸门」判定后异步追加:
@@ -78,7 +77,7 @@
78
77
 
79
78
  ```bash
80
79
  dsh plugin --profile web add github:lovezi0/dsh-memory-palace
81
- # 锁定版本:dsh plugin --profile web add github:lovezi0/dsh-memory-palace#v1.7.1
80
+ # 锁定版本:dsh plugin --profile web add github:lovezi0/dsh-memory-palace#v1.7.2-alpha.2
82
81
  ```
83
82
 
84
83
  方式二:clone 后本地安装(开发 / 修改源码场景)
@@ -119,6 +118,13 @@ dsh plugin --profile web remove dsh-memory-palace
119
118
 
120
119
  ## 版本历史
121
120
 
121
+ - **1.7.2**
122
+ - **1.7.2-alpha.2**
123
+ - 💪适配deepseek harness 0.1.7-alpha.1
124
+ - 💪add memory plugin icon
125
+ - 💪记忆模式默认为[混合模式] *未来的版本将移除插件模式&智能模式*
126
+ - **1.7.2-alpha.1**
127
+ - 💪dsh Agent 预设[极简模式]时禁用记忆注入、记忆生成、记忆工具
122
128
  - **1.7.1**
123
129
  - 💪移除日志重注机制优化缓存命中降低堆积冗余
124
130
  - 💪记忆设置UI优化
@@ -0,0 +1,17 @@
1
+ <svg width="28" height="28" viewBox="0 0 28 28" xmlns="http://www.w3.org/2000/svg">
2
+ <!-- 记忆图标 · DSH 鲸鱼 + 双星芒(源码直出合并)· 28×28 -->
3
+ <!-- 鲸鱼(全精度 path,位置 4,9 → 17×12.75) -->
4
+ <g transform="translate(4 9) scale(0.7340 0.7482) translate(0 -3.52)">
5
+ <path d="M23.0584 4.95203C22.8129 4.83203 22.7074 5.06103 22.5639 5.17704C22.5149 5.21454 22.4734 5.26354 22.4319 5.30854C22.0734 5.69155 21.6543 5.94306 21.1073 5.91306C20.3073 5.86806 19.6243 6.11957 19.0203 6.73158C18.8918 5.97706 18.4652 5.52655 17.8162 5.23754C17.4767 5.08753 17.1332 4.93703 16.8952 4.61052C16.7292 4.37801 16.6837 4.11901 16.6007 3.8635C16.5477 3.70949 16.4952 3.55199 16.3177 3.52549C16.1252 3.49549 16.0497 3.65699 15.9742 3.792C15.6722 4.34401 15.5552 4.95203 15.5667 5.56805C15.5932 6.95359 16.1782 8.05712 17.3407 8.84215C17.4727 8.93215 17.5067 9.02215 17.4652 9.15366C17.3857 9.42416 17.2917 9.68667 17.2087 9.95718C17.1557 10.1297 17.0767 10.1677 16.8917 10.0922C16.2537 9.82568 15.7027 9.43117 15.2156 8.95465C14.3891 8.15513 13.6416 7.2726 12.7096 6.58158C12.4906 6.42007 12.2716 6.27007 12.045 6.12707C11.094 5.20354 12.1696 4.44502 12.4186 4.35501C12.6791 4.26101 12.5091 3.938 11.6675 3.942C10.826 3.9455 10.056 4.22751 9.07446 4.60302C8.93096 4.65952 8.77995 4.70052 8.62545 4.73452C7.73492 4.56552 6.80989 4.52802 5.84386 4.63702C4.02481 4.83953 2.57177 5.69955 1.50373 7.1676C0.220694 8.93215 -0.0813148 10.9372 0.288196 13.0283C0.676708 15.2323 1.80174 17.0569 3.53029 18.4834C5.32285 19.9625 7.38741 20.6875 9.74298 20.5485C11.1735 20.466 12.7661 20.2745 14.5626 18.7539C15.0156 18.9795 15.4912 19.0695 16.2797 19.137C16.8872 19.1935 17.4722 19.107 17.9252 19.013C18.6347 18.8629 18.5857 18.2059 18.3292 18.0854C16.2497 17.1169 16.7062 17.5109 16.2912 17.1919C17.3477 15.9419 18.9618 13.7198 19.4598 10.6942C19.5088 10.3602 19.5713 9.88968 19.5638 9.61917C19.5598 9.45417 19.5978 9.39016 19.7863 9.37116C20.3073 9.31116 20.8128 9.16866 21.2773 8.91315C22.6249 8.17713 23.1684 6.96809 23.2964 5.51905C23.3154 5.29754 23.2924 5.06853 23.0584 4.95203ZM11.3165 17.9954C9.30097 16.4109 8.32344 15.8894 7.91992 15.9119C7.54241 15.9344 7.61042 16.3664 7.69342 16.6479C7.78042 16.9259 7.89342 17.1174 8.05193 17.3614C8.16143 17.5229 8.23694 17.7629 7.94243 17.9434C7.29341 18.3449 6.16487 17.8084 6.11187 17.7819C4.79833 17.0084 3.7003 15.9874 2.92628 14.5908C2.17875 13.2468 1.74474 11.8047 1.67324 10.2657C1.65424 9.89418 1.76374 9.76267 2.13375 9.69517C2.62077 9.60517 3.12278 9.58617 3.6093 9.65767C5.66636 9.95818 7.41741 10.8777 8.88545 12.3348C9.72348 13.1643 10.3575 14.1558 11.0105 15.1243C11.705 16.1529 12.4521 17.1329 13.4036 17.9364C13.7396 18.2179 14.0076 18.4319 14.2641 18.5899C13.4906 18.6764 12.1996 18.6949 11.3165 17.9964V17.9954ZM12.2826 11.7817C12.2826 11.6167 12.4146 11.4852 12.5806 11.4852C12.6181 11.4852 12.6521 11.4927 12.6826 11.5037C12.7241 11.5187 12.7621 11.5412 12.7921 11.5752C12.8451 11.6277 12.8751 11.7027 12.8751 11.7817C12.8751 11.9467 12.7431 12.0782 12.5771 12.0782C12.4111 12.0782 12.2826 11.9467 12.2826 11.7817ZM15.2831 13.3208C15.0906 13.3998 14.8981 13.4673 14.7131 13.4748C14.4261 13.4898 14.1131 13.3733 13.9431 13.2308C13.6791 13.0093 13.4901 12.8853 13.4111 12.4988C13.3771 12.3338 13.3961 12.0782 13.4261 11.9317C13.4941 11.6162 13.4186 11.4137 13.1961 11.2297C13.0151 11.0797 12.7846 11.0382 12.5316 11.0382C12.4371 11.0382 12.3506 10.9967 12.2861 10.9632C12.1806 10.9107 12.0936 10.7792 12.1766 10.6177C12.2031 10.5652 12.3316 10.4377 12.3616 10.4152C12.7051 10.2197 13.1011 10.2837 13.4676 10.4302C13.8071 10.5692 14.0641 10.8242 14.4336 11.1847C14.8111 11.6202 14.8791 11.7402 15.0941 12.0672C15.2641 12.3228 15.4186 12.5853 15.5247 12.8858C15.5887 13.0733 15.5057 13.2268 15.2831 13.3208Z" fill="#000000"/>
6
+ </g>
7
+ <!-- 大星(x.svg 大星全精度 path,位置 19,3 → 6×6,持续闪烁) -->
8
+ <g transform="translate(19 3) scale(0.8286) translate(0.059 -2.790)">
9
+ <path d="M3.80671 9.79513C3.72888 10.0318 3.39417 10.0318 3.31634 9.79513L2.8653 8.42365C2.66042 7.80074 2.17185 7.31217 1.54894 7.1073L0.177462 6.65626C-0.0591539 6.57843 -0.0591539 6.24371 0.177462 6.16589L1.54894 5.71484C2.17185 5.50997 2.66042 5.0214 2.8653 4.39849L3.31634 3.02701C3.39417 2.79039 3.72888 2.79039 3.80671 3.02701L4.25775 4.39849C4.46262 5.0214 4.9512 5.50997 5.57411 5.71484L6.94558 6.16589C7.1822 6.24371 7.1822 6.57843 6.94558 6.65626L5.57411 7.1073C4.9512 7.31217 4.46262 7.80074 4.25775 8.42365L3.80671 9.79513Z" fill="#426EFE"/>
10
+ <animate attributeName="opacity" values="1;0.15;1" keyTimes="0;0.5;1" dur="1.2s" repeatCount="indefinite"/>
11
+ </g>
12
+ <!-- 小星(x.svg 小星全精度 path,位置 23,1 → 4×4,轻闪烁) -->
13
+ <g transform="translate(23 1) scale(0.9837) translate(-5.987 0.033)">
14
+ <path d="M8.15819 3.90034C8.11449 4.03322 7.92653 4.03322 7.88282 3.90034L7.62954 3.13018C7.51449 2.78038 7.24013 2.50602 6.89033 2.39097L6.12016 2.13769C5.98729 2.09398 5.98729 1.90602 6.12016 1.86231L6.89033 1.60903C7.24013 1.49398 7.51449 1.21962 7.62954 0.869819L7.88282 0.0996549C7.92653 -0.0332183 8.11449 -0.0332183 8.15819 0.0996549L8.41148 0.869819C8.52653 1.21962 8.80089 1.49398 9.15069 1.60903L9.92085 1.86231C10.0537 1.90602 10.0537 2.09398 9.92085 2.13769L9.15069 2.39097C8.80089 2.50602 8.52653 2.78038 8.41148 3.13018L8.15819 3.90034Z" fill="#426EFE"/>
15
+ <animate attributeName="opacity" values="1;0.45;1" keyTimes="0;0.5;1" dur="1.6s" repeatCount="indefinite"/>
16
+ </g>
17
+ </svg>
package/lib/client.js CHANGED
@@ -27,6 +27,8 @@ window.__ModuleLoader__.load({
27
27
  bridgeHint: "项目已存在 .workbuddy / .codebuddy 记忆目录时直接读写,不再建 .deepseek-harness/memory/",
28
28
  dirsLabel: "buddy 记忆目录(逗号分隔,按序优先)",
29
29
  dirsHint: "例如:.workbuddy/memory, .codebuddy/memory",
30
+ silentPresetsLabel: "静默预设(逗号分隔)",
31
+ silentPresetsHint: "这些 agent 预设下本插件整体隐身:不注入系统提示词与记忆投影、记忆工具不对模型暴露、不写日志、不跑记忆子代理(官方极简模式即「裸测环境」跑分口径)。默认 minimal;留空=关闭该机制。切换预设需新建会话生效。",
30
32
  userPathLabel: "用户级记忆文件",
31
33
  userPathHint: "跨项目个人偏好记忆,默认 ~/.deepseek-harness/MEMORY.md",
32
34
  wsDirLabel: "工作区记忆目录(回退)",
@@ -39,13 +41,13 @@ window.__ModuleLoader__.load({
39
41
  wsBudgetLabel: "工作区预算(字符)",
40
42
  wsBudgetHint: "工作区 MEMORY.md 的最大字符数",
41
43
  summarizeLabel: "轮次结束自动记录",
42
- summarizeHint: "两种记忆模式的共用总闸门:关闭后无论插件模式还是智能模式都不写记忆。插件模式下它作为「agent 主动记忆」主路径失效时的安全网,只留原始文本、不做总结;智能模式下开启则走 LLM 智能摘要(总结 + 提炼)。",
44
+ summarizeHint: "三种记忆模式的共用总闸门:关闭后三种模式都不写记忆。插件模式下它作为「agent 主动记忆」主路径失效时的安全网,只留原始文本、不做总结;智能模式走 LLM 智能摘要(总结 + 提炼);混合模式下整个记忆子代理停摆(不做兜底写入)。",
43
45
  autoCaptureErrorsLabel: "对话出错时自动记录到记忆",
44
46
  autoCaptureErrorsHint: "对话中(含代码运行报错、工具执行失败)出错时,自动把「错误现象」写入对应 MEMORY.md(用户级/项目级);「根因/方案」由 agent 按记忆公民指令主动记。默认开,关闭无需重启。",
45
47
  memoryModeLabel: "记忆模式",
46
48
  memoryModeHintPlugin: "插件模式:记忆公民指令 + 轮次轻量 + 错误捕获。切换需重启 dsh 生效。",
47
49
  memoryModeHintSmart: "智能模式:LLM 智能会话摘要(summary→每日日志 + durable→MEMORY.md)。切换需重启 dsh 生效。",
48
- memoryModeHintHybrid: "混合模式:记忆子代理自动维护今日日志(章节化、标删去重),agent 主动维护 MEMORY.md(章节化写入、整章节替换、门禁内全量重整)。切换需重启 dsh 生效。",
50
+ memoryModeHintHybrid: "混合模式(默认):记忆子代理自动维护今日日志(章节化、标删去重),agent 主动维护 MEMORY.md(章节化写入、整章节替换、门禁内全量重整)。切换需重启 dsh 生效。",
49
51
  reorgCooldownLabel: "重整冷却(天)",
50
52
  reorgCooldownHint: "项目级 MEMORY.md 全量重整的冷却天数(距上次重整);与「超出注入预算」双条件同时满足才允许 memory_reorganize。默认 7 天。",
51
53
  subagentLogBudgetLabel: "子代理日志回喂预算(字符)",
@@ -110,6 +112,8 @@ window.__ModuleLoader__.load({
110
112
  bridgeHint: "Read/write directly into existing .workbuddy / .codebuddy memory dirs instead of creating .deepseek-harness/memory/",
111
113
  dirsLabel: "Buddy memory dirs (comma-separated, first wins)",
112
114
  dirsHint: "e.g. .workbuddy/memory, .codebuddy/memory",
115
+ silentPresetsLabel: "Silent presets (comma-separated)",
116
+ silentPresetsHint: "Under these agent presets the plugin goes fully invisible: no system-prompt or memory projection injection, memory tools hidden from the model, no logging, no memory sub-agent (the official minimal mode is the bare-benchmark preset). Default: minimal; leave empty to disable this rule. Switching presets takes effect in a new session.",
113
117
  userPathLabel: "User memory file",
114
118
  userPathHint: "Cross-project preferences, default ~/.deepseek-harness/MEMORY.md",
115
119
  wsDirLabel: "Workspace memory dir (fallback)",
@@ -122,13 +126,13 @@ window.__ModuleLoader__.load({
122
126
  wsBudgetLabel: "Workspace budget (chars)",
123
127
  wsBudgetHint: "Max chars for the workspace MEMORY.md",
124
128
  summarizeLabel: "Auto-record at turn end",
125
- summarizeHint: "The shared master gate for both memory modes: when off, neither plugin nor smart mode writes any memory. In plugin mode it is the safety net when the 'agent proactive memory' main path fails (keeps raw text, no summarization); in smart mode it enables the LLM summarization path (summary + extraction).",
129
+ summarizeHint: "The shared master gate for all three memory modes: when off, none of them writes any memory. In plugin mode it is the safety net when the 'agent proactive memory' main path fails (keeps raw text, no summarization); in smart mode it enables the LLM summarization path (summary + extraction); in hybrid mode the whole memory sub-agent stays idle (no fallback entry either).",
126
130
  autoCaptureErrorsLabel: "Auto-record conversation errors",
127
131
  autoCaptureErrorsHint: "On in-session errors, auto write the 'error' into the corresponding MEMORY.md (user/project); 'root cause / fix' is recorded proactively by the agent. On by default; off takes effect without restart.",
128
132
  memoryModeLabel: "Memory mode",
129
133
  memoryModeHintPlugin: "Plugin mode: memory-citizen instructions + turn-end light entries + error capture. Switching requires a dsh restart.",
130
134
  memoryModeHintSmart: "Smart mode: LLM conversation summarization (summary -> daily log + durable -> MEMORY.md). Switching requires a dsh restart.",
131
- memoryModeHintHybrid: "Hybrid mode: a memory sub-agent auto-maintains today's daily log (chaptered, dedupe by strikethrough); the agent proactively maintains MEMORY.md (chaptered writes, section replace, gated full reorganize). Switching requires a dsh restart.",
135
+ memoryModeHintHybrid: "Hybrid mode (default): a memory sub-agent auto-maintains today's daily log (chaptered, dedupe by strikethrough); the agent proactively maintains MEMORY.md (chaptered writes, section replace, gated full reorganize). Switching requires a dsh restart.",
132
136
  reorgCooldownLabel: "Reorganize cooldown (days)",
133
137
  reorgCooldownHint: "Cooldown days between full reorganizes of the project MEMORY.md; combined with 'over injection budget' both gates must pass for memory_reorganize. Default 7.",
134
138
  subagentLogBudgetLabel: "Sub-agent log feed budget (chars)",
@@ -186,6 +190,8 @@ window.__ModuleLoader__.load({
186
190
  return {
187
191
  bridgeBuddyMemory: v.bridgeBuddyMemory === false ? "false" : "true",
188
192
  buddyWorkspaceMemoryDirs: Array.isArray(v.buddyWorkspaceMemoryDirs) ? v.buddyWorkspaceMemoryDirs.join(", ") : ".workbuddy/memory, .codebuddy/memory",
193
+ // v1.7.2:静默预设名单(数组 ↔ 逗号串,与 buddyWorkspaceMemoryDirs 同款约定)
194
+ silentPresets: Array.isArray(v.silentPresets) ? v.silentPresets.join(", ") : "minimal",
189
195
  userMemoryPath: v.userMemoryPath || "~/.deepseek-harness/MEMORY.md",
190
196
  workspaceMemoryDir: v.workspaceMemoryDir || ".deepseek-harness/memory",
191
197
  dailyLogRetentionDays: v.dailyLogRetentionDays != null ? String(v.dailyLogRetentionDays) : "30",
@@ -195,7 +201,7 @@ window.__ModuleLoader__.load({
195
201
  autoCaptureErrors: v.autoCaptureErrors === false ? "false" : "true",
196
202
  distillDebugLog: v.distillDebugLog === false ? "false" : "true",
197
203
  summaryTimeoutMs: v.summaryTimeoutMs != null ? String(Math.round((Number(v.summaryTimeoutMs) || 0) / 1000)) : "60",
198
- memoryMode: v.memoryMode || "plugin",
204
+ memoryMode: v.memoryMode || "hybrid",
199
205
  summaryModel: v.summaryModel || "",
200
206
  summaryMaxTokens: v.summaryMaxTokens != null ? String(v.summaryMaxTokens) : "2000",
201
207
  projectMaxTokens: v.projectMaxTokens != null ? String(v.projectMaxTokens) : "8000",
@@ -352,6 +358,9 @@ window.__ModuleLoader__.load({
352
358
  }
353
359
  } else if (field === "buddyWorkspaceMemoryDirs") {
354
360
  section[field] = text.split(",").map((s) => s.trim()).filter(Boolean);
361
+ } else if (field === "silentPresets") {
362
+ // v1.7.2:数组型配置(同 buddyWorkspaceMemoryDirs)。空串 → 空数组 = 关闭该机制。
363
+ section[field] = text.split(",").map((s) => s.trim()).filter(Boolean);
355
364
  } else {
356
365
  if (text !== "") section[field] = text;
357
366
  }
@@ -649,7 +658,18 @@ window.__ModuleLoader__.load({
649
658
  ...num("buddyWorkspaceMemoryDirs"),
650
659
  type: "text",
651
660
  placeholder: ".workbuddy/memory, .codebuddy/memory"
652
- }), "buddyWorkspaceMemoryDirs")
661
+ }), "buddyWorkspaceMemoryDirs"),
662
+ // v1.7.2:静默预设(极简模式等)。命中后本插件在该会话整体隐身(提示词/投影/工具/写入/子代理)。
663
+ // 用普通文本输入(非 num —— 这里填的是预设 id 列表,不是数字)。
664
+ row(t("silentPresetsLabel"), t("silentPresetsHint"),
665
+ h("input", {
666
+ type: "text",
667
+ value: draft.silentPresets,
668
+ disabled,
669
+ style: { ...inputStyle, borderColor: "var(--dsw-alias-border-l2, #e5e7eb)" },
670
+ placeholder: "minimal",
671
+ onChange: (e) => edit("silentPresets", e.target.value)
672
+ }), "silentPresets")
653
673
  ]),
654
674
  // v1.7.1(特性3):自定义指令。非空时经 system prompt 追加到「记忆分工说明」之后;
655
675
  // 它是恒定内容(用户配置一次不变),故放 section 而非 E 投影 —— 零缓存成本。
@@ -681,7 +701,7 @@ window.__ModuleLoader__.load({
681
701
  ? t("memoryModeHintHybrid")
682
702
  : t("memoryModeHintPlugin"),
683
703
  h("select", {
684
- value: ["plugin", "smart", "hybrid"].includes(draft.memoryMode) ? draft.memoryMode : "plugin",
704
+ value: ["plugin", "smart", "hybrid"].includes(draft.memoryMode) ? draft.memoryMode : "hybrid",
685
705
  disabled,
686
706
  onChange: (e) => edit("memoryMode", e.target.value),
687
707
  style: selectStyle
@@ -707,7 +727,7 @@ window.__ModuleLoader__.load({
707
727
  row(t("summaryModelLabel"), t("summaryModelHint"),
708
728
  h("select", {
709
729
  // 已存储值不在下拉选项内(如旧版双前缀脏数据)→ 归零为「复用当前会话模型」,
710
- // 避免 select 显示悬空值、保存时又把脏值写回 settings.yaml。
730
+ // 避免 select 显示悬空值、保存时又把脏值写回 profile 条目 config。
711
731
  value: modelOptions.some((o) => o.value === draft.summaryModel) ? draft.summaryModel : "",
712
732
  disabled,
713
733
  style: selectStyle,
@@ -737,7 +757,8 @@ window.__ModuleLoader__.load({
737
757
 
738
758
 
739
759
  // ---- v1.2.0 会话标题栏「记忆」按钮(蒸馏入口)----
740
- // sparkle-twinkle.svg 内联(assets/ 不在 package.json files 数组、不随 npm 分发,不能按路径引用)。
760
+ // sparkle-twinkle.svg 内联(client 侧只能 require("react")、不能按包内路径取资源;该文件也不在
761
+ // package.json files 数组内,不随 npm 分发——files 里只多列了 assets/memory-icon.svg 供宿主插件面板读取)。
741
762
  // 类名/渐变 id 加 mpd- 前缀防全局冲突;twinkle 动画 keyframes 由注入的样式表提供。
742
763
  const SPARKLE_SVG =
743
764
  '<svg width="14" height="14" viewBox="0 0 11 10" fill="none" xmlns="http://www.w3.org/2000/svg">' +
@@ -763,6 +784,30 @@ window.__ModuleLoader__.load({
763
784
  document.head.appendChild(style);
764
785
  }
765
786
 
787
+ // ---- v1.8.0 设置面板 nav 图标(「记忆」条目)----
788
+ // 宿主 SettingsRoot.navIcon(id) 是**硬编码白名单**(account/models/agent-presets/plugins/archived-sessions),
789
+ // 未列出的第三方 section 一律回退齿轮图标,且 slots 契约(id/order/label)没开 nav 图标位、
790
+ // 官方文档亦无「从 manifest 取 nav 图标」的机制(manifest icon 只进插件管理面板的卡片/行)。
791
+ // 故在插件边界内绕行两步:
792
+ // ① label 返回 React 节点 —— 宿主 ui-slots 的 resolveSlotLabel 是 `typeof label === 'function' ? label() : label`
793
+ // (原样返回、不做字符串强转),SettingsRoot 直接把它当 children 渲染,节点可行;
794
+ // ② 注入 CSS 用 :has() 命中「含本星标的 nav 按钮」,隐藏其**直接子 svg**(即宿主齿轮;星标在 label span 内部,不在命中面)。
795
+ // 失效面:宿主若改结构/去掉 :has 支持 → 退化为「齿轮 + 星标」并排,不报错、不影响功能(有意选的可降级方案)。
796
+ function ensureNavStarStyles() {
797
+ if (typeof document === "undefined") return; // 非浏览器环境(单测/构建期)静默跳过
798
+ injectDistillStyles(); // 星标动画 keyframes 与蒸馏按钮共用同一份样式表
799
+ if (document.getElementById("memory-palace-nav-star-styles")) return;
800
+ const style = document.createElement("style");
801
+ style.id = "memory-palace-nav-star-styles";
802
+ style.textContent = [
803
+ // 星标容器:与宿主 navIcon 同尺寸(16px)、紧贴文字前。
804
+ ".mp-nav-star{display:inline-flex;flex:none;align-items:center;margin-right:8px;line-height:0}",
805
+ ".mp-nav-star svg{display:block;width:16px;height:16px}",
806
+ "button:has(.mp-nav-star)>svg{display:none!important}"
807
+ ].join("");
808
+ document.head.appendChild(style);
809
+ }
810
+
766
811
 
767
812
  // 会话标题栏「记忆」胶囊按钮:点击开合下拉(蒸馏会话/蒸馏项目记忆)→ 自绘确认弹窗 → fetch route → 浏览器通知。
768
813
  function DistillButton(props) {
@@ -1001,13 +1046,26 @@ window.__ModuleLoader__.load({
1001
1046
  // v1.1.3:设置读写走自有 route(/memory-palace/api),不再 bind settingsScope——
1002
1047
  // 非 loopback 下 settingsScope persistence=memory(set() no-op),保存永不落盘。
1003
1048
  const controller = new MemoryPalaceController(ctx);
1049
+ // v1.8.0:设置面板 nav 条目换成自家 sparkle-twinkle 星标——宿主无 nav 图标位,
1050
+ // 走「label 传节点 + CSS 隐藏回退齿轮」两步(原理/失效面见 40-sparkle.js 的 ensureNavStarStyles)。
1051
+ ensureNavStarStyles();
1052
+ const navLabel = () =>
1053
+ react.createElement("span", { className: "mp-nav-label" }, [
1054
+ react.createElement("span", {
1055
+ key: "star",
1056
+ className: "mp-nav-star",
1057
+ "aria-hidden": "true",
1058
+ dangerouslySetInnerHTML: { __html: SPARKLE_SVG },
1059
+ }),
1060
+ t("nav"),
1061
+ ]);
1004
1062
  // v1.6.0-rc1:枚举已配置模型改走 ctx.remote.session.modelCatalog()(ApiProxy 已删),
1005
1063
  // 枚举失败则降级为空列表。
1006
1064
  ctx.slots.inject("settings.section", () => ctx.slots.register({
1007
1065
  name: "settings.section",
1008
1066
  id: "memory-palace",
1009
1067
  order: 20,
1010
- label: () => t("nav"),
1068
+ label: navLabel,
1011
1069
  locale: NS,
1012
1070
  inject: () => controller.inject()
1013
1071
  }, (props) => MemoryPalaceSection({ ...props, fetchModels: () => fetchModelOptions(ctx) })));
package/lib/distill.mjs CHANGED
@@ -152,7 +152,7 @@ export function createDistill({ ctx, getConfig, paths, records, state }) {
152
152
  messages = [
153
153
  createUserMessage({
154
154
  content: [{ type: "text", text: "以下是现有记忆(仅供你增量维护参考,不要当作本次对话内容):\n" + fbText }],
155
- source: { kind: "plugin", plugin: "memory-palace" },
155
+ source: { kind: "plugin:dsh-memory-palace" },
156
156
  }),
157
157
  ...hist,
158
158
  ];
@@ -331,7 +331,7 @@ export function createDistill({ ctx, getConfig, paths, records, state }) {
331
331
  messages: [
332
332
  createUserMessage({
333
333
  content: [{ type: "text", text: raw }],
334
- source: { kind: "plugin", plugin: "memory-palace" },
334
+ source: { kind: "plugin:dsh-memory-palace" },
335
335
  }),
336
336
  ],
337
337
  },
@@ -17,7 +17,7 @@ import { HYBRID_PROACTIVE, SUBAGENT_SYSTEM } from "./prompts.mjs";
17
17
  export { HYBRID_PROACTIVE };
18
18
 
19
19
  const MAX_ROUNDS = 6; // 循环轮次上限(含首轮);超限降级
20
- const MAX_RETRY = 3; // 未知工具触发的催促重试预算(v1.6.3,人定)
20
+ const MAX_RETRY = 3; // 未知工具触发的催促重试预算(v1.6.3 定为 3)
21
21
  const SURFACE = new Set(["user/message", "assistant/message", "tool/result"]);
22
22
 
23
23
  // 日志文件写锁(全局 promise 链串行化):子 agent 落盘与手动蒸馏按钮/其他写路径并发防护。
@@ -276,7 +276,7 @@ export async function runMemorySubagent({ ctx, getConfig, paths, state, session,
276
276
  `请按系统指令处理上面的本轮对话(对话见前文消息):判定是否有实质内容需要写入日志,并执行。${brief}`,
277
277
  },
278
278
  ],
279
- source: { kind: "plugin", plugin: "memory-palace" },
279
+ source: { kind: "plugin:dsh-memory-palace" },
280
280
  });
281
281
 
282
282
  const tools = [
@@ -368,7 +368,7 @@ export async function runMemorySubagent({ ctx, getConfig, paths, state, session,
368
368
  `本轮唯一可用的写入工具是 log_write_ops(ops 支持 append / new_section / mark_delete);` +
369
369
  `需要读取章节时用 log_read_section。请立即重新提交写入。\n` +
370
370
  `若你重新判定本轮确实没有值得记录的内容,请输出一行纯文本说明后结束。` }],
371
- source: { kind: "plugin", plugin: "memory-palace" },
371
+ source: { kind: "plugin:dsh-memory-palace" },
372
372
  }));
373
373
  dbgFail("retry after unknown tool", { retries, names });
374
374
  continue;
package/lib/index.js CHANGED
@@ -40,72 +40,120 @@ export const name = "memory-palace";
40
40
  // v1.6.0-rc1:settingsNamespace() 已删除,namespace 直接用字符串(宿主侧做类型级校验)。
41
41
  const MEMORY_PALACE_SETTINGS_NAMESPACE = "memory-palace";
42
42
 
43
+ // v1.8.0:适配 dsh 0.1.7-alpha.1 契约破坏(DSH-CONTRACT-TRACKING.md §1.6)。
44
+ // - 契约5:MessageSourceMap 删除通用 'plugin' kind → 投影/子代理消息 source 改用宿主
45
+ // v3→v4 迁移约定 `plugin:dsh-memory-palace`(去重判据向后兼容旧形态,防升级前已 resume 的会话重复注入)。
46
+ // - 契约10:SettingsProvider.installSection 整包删除 → ctx.settings 改挂 SettingsForms
47
+ // (describe/replace,写 profile patch)。配置项全部标 `.volatile()`:0.1.7 中「无 volatile 字段的
48
+ // 条目不进设置表单、replace 直接抛错」。volatile HMR 把新值原地提交进同一 Volatile 引用,故
49
+ // source() 每次解包读 config 即得最新值,不再需要旧版 setSource 覆盖层切换。
50
+ // - settings.yaml 已被宿主移除(导入 profile patch 一次)→ distillLogLevel 说明改口。
43
51
  export const Config = Schema.object({
44
- enabled: Schema.boolean().default(true).description("启用 memory-palace 记忆注入与每日日志写入。"),
45
- userMemoryPath: Schema.string().default("~/.deepseek-harness/MEMORY.md").description("用户级记忆文件路径(支持 ~ 展开)。"),
46
- workspaceMemoryDir: Schema.string().default(".deepseek-harness/memory").description("无 buddy 目录时使用的项目级每日日志目录;项目级 MEMORY.md 位于其同级(.deepseek-harness/MEMORY.md)。"),
47
- dailyLogRetentionDays: Schema.number().default(30).description("每日日志保留天数,过期日志会被蒸馏进 MEMORY.md。"),
48
- userBudgetChars: Schema.number().default(4000).description("注入系统提示词的用户级记忆长度上限(字符)。"),
49
- workspaceBudgetChars: Schema.number().default(3000).description("注入系统提示词的工作区级记忆长度上限(字符)。"),
52
+ enabled: Schema.boolean().default(true).description("启用 memory-palace 记忆注入与每日日志写入。").volatile(),
53
+ // ---- v1.7.2:预设级静默(官方 minimal「裸测环境」口径)----
54
+ // 宿主把「模式」实现为 agent 平面的 preset:minimal 预设用 persona complete:true 独占 system prompt。
55
+ // 但本插件注册在 host 平面(profile bundle 的 insert),各通道对**每个 agent** 都生效,preset 并不会
56
+ // 把它摘掉——故须自行按会话判据静默,否则记忆正文仍会经 E 投影进历史(实测症状)。
57
+ silentPresets: Schema.array(Schema.string()).default(["minimal"]).description("在这些 agent 预设下本插件整体静默(等价 enabled=false):不注入系统提示词与投影、记忆工具对模型隐身、不写日志、不跑记忆子代理。默认 [\"minimal\"](官方极简模式);置空数组 = 关闭该机制。判据取会话创建头 agentPreset 与 agent-preset/selected 事件(宿主公开事实)。").volatile(),
58
+ userMemoryPath: Schema.string().default("~/.deepseek-harness/MEMORY.md").description("用户级记忆文件路径(支持 ~ 展开)。").volatile(),
59
+ workspaceMemoryDir: Schema.string().default(".deepseek-harness/memory").description("无 buddy 目录时使用的项目级每日日志目录;项目级 MEMORY.md 位于其同级(.deepseek-harness/MEMORY.md)。").volatile(),
60
+ dailyLogRetentionDays: Schema.number().default(30).description("每日日志保留天数,过期日志会被蒸馏进 MEMORY.md。").volatile(),
61
+ userBudgetChars: Schema.number().default(4000).description("注入系统提示词的用户级记忆长度上限(字符)。").volatile(),
62
+ workspaceBudgetChars: Schema.number().default(3000).description("注入系统提示词的工作区级记忆长度上限(字符)。").volatile(),
50
63
  // 桥接 WorkBuddy / CodeBuddy 项目记忆:项目已存在这些目录时直接读写,不再单独建 .deepseek-harness/memory/。
51
- bridgeBuddyMemory: Schema.boolean().default(true).description("检测并直接读写 WorkBuddy / CodeBuddy 项目记忆目录。"),
52
- buddyWorkspaceMemoryDirs: Schema.array(Schema.string()).default([".workbuddy/memory", ".codebuddy/memory"]).description("要桥接的 buddy 项目记忆目录列表(按优先级,全部已存在目录会同步写入)。"),
64
+ bridgeBuddyMemory: Schema.boolean().default(true).description("检测并直接读写 WorkBuddy / CodeBuddy 项目记忆目录。").volatile(),
65
+ buddyWorkspaceMemoryDirs: Schema.array(Schema.string()).default([".workbuddy/memory", ".codebuddy/memory"]).description("要桥接的 buddy 项目记忆目录列表(按优先级,全部已存在目录会同步写入)。").volatile(),
53
66
  // ---- v0.7.1 调整:废弃插件侧 callLlm,主路径 = 记忆公民 prompt 主动记忆;turn/end 仅做轻量兜底 ----
54
- summarize: Schema.boolean().default(true).description("它是「agent 主动记忆」主路径失效时的安全网,保证实质工作不丢,代价是只留原始文本、不做总结。"),
55
- autoCaptureErrors: Schema.boolean().default(true).description("对话出错时(含代码运行报错、工具执行失败)自动把『错误现象』写入对应 MEMORY.md(『根因/方案』由 agent 按记忆公民指令场景①主动记;默认开,关闭无需重启)。"),
67
+ summarize: Schema.boolean().default(true).description("它是「agent 主动记忆」主路径失效时的安全网,保证实质工作不丢,代价是只留原始文本、不做总结。").volatile(),
68
+ autoCaptureErrors: Schema.boolean().default(true).description("对话出错时(含代码运行报错、工具执行失败)自动把『错误现象』写入对应 MEMORY.md(『根因/方案』由 agent 按记忆公民指令场景①主动记;默认开,关闭无需重启)。").volatile(),
56
69
  // ---- v1.1.0:记忆模式(plugin=记忆公民指令+轮次轻量+错误捕获;smart=LLM 智能会话摘要)----
57
70
  // v1.6.0:+hybrid(子 agent 自动维护日志 + agent 主动维护 MEMORY.md),三档并存,切换需重启 dsh。
58
- memoryMode: Schema.union(["plugin", "smart", "hybrid"]).default("plugin").description("记忆模式:plugin=记忆公民指令+轮次轻量+错误捕获;smart=LLM 智能会话摘要(summary→每日日志 + durable→MEMORY.md);hybrid=记忆子代理自动维护今日日志(标删去重)+ agent 主动维护 MEMORY.md(章节化写入/整章节替换/门禁内全量重整)。切换需重启 dsh 生效。"),
59
- summaryModel: Schema.string().default("").description("记忆插件当前使用的模型(智能模式会话摘要 / 手动蒸馏 / hybrid 记忆子代理共用)。留空=复用当前会话 provider/model;也可填 provider/model(如 deepseek/deepseek-chat)固定廉价模型省 token。"),
60
- summaryTimeoutMs: Schema.number().default(60000).description("蒸馏 LLM 调用的超时(毫秒),超时视为失败并降级;覆盖智能模式摘要与手动蒸馏两条链路;默认 60000(60s)。"),
61
- distillDebugLog: Schema.boolean().default(false).description("调试开关:向 dsh 服务端 stderr 输出蒸馏 LLM 调用诊断。distillLogLevel=info 时仅输出元数据(模型解析/请求参数/流进度/错误详情,不含文本);distillLogLevel=debug 会额外打印 LLM 原始响应文本(分隔符包裹),仅限受信本地排障开启。"),
71
+ memoryMode: Schema.union(["plugin", "smart", "hybrid"]).default("hybrid").description("记忆模式(默认 hybrid):plugin=记忆公民指令+轮次轻量+错误捕获;smart=LLM 智能会话摘要(summary→每日日志 + durable→MEMORY.md);hybrid=记忆子代理自动维护今日日志(标删去重)+ agent 主动维护 MEMORY.md(章节化写入/整章节替换/门禁内全量重整)。切换需重启 dsh 生效。").volatile(),
72
+ summaryModel: Schema.string().default("").description("记忆插件当前使用的模型(智能模式会话摘要 / 手动蒸馏 / hybrid 记忆子代理共用)。留空=复用当前会话 provider/model;也可填 provider/model(如 deepseek/deepseek-chat)固定廉价模型省 token。").volatile(),
73
+ summaryTimeoutMs: Schema.number().default(60000).description("蒸馏 LLM 调用的超时(毫秒),超时视为失败并降级;覆盖智能模式摘要与手动蒸馏两条链路;默认 60000(60s)。").volatile(),
74
+ distillDebugLog: Schema.boolean().default(false).description("调试开关:向 dsh 服务端 stderr 输出蒸馏 LLM 调用诊断。distillLogLevel=info 时仅输出元数据(模型解析/请求参数/流进度/错误详情,不含文本);distillLogLevel=debug 会额外打印 LLM 原始响应文本(分隔符包裹),仅限受信本地排障开启。").volatile(),
62
75
  // ---- v1.4.1:蒸馏 stderr 日志级别(平铺键,不进 UI;默认 info;distillDebugLog=true 时生效) ----
63
- distillLogLevel: Schema.string().default("info").description("蒸馏 stderr 日志级别:info=仅元数据诊断(默认,不打印 LLM 原始响应);debug=额外打印 LLM 原始响应文本(分隔符包裹),仅限受信本地排障开启。无需 UI 配置,经 DSH home($DSH_HOME)根目录的 settings.yaml 设置 distillLogLevel 键。"),
76
+ distillLogLevel: Schema.string().default("info").description("蒸馏 stderr 日志级别:info=仅元数据诊断(默认,不打印 LLM 原始响应);debug=额外打印 LLM 原始响应文本(分隔符包裹),仅限受信本地排障开启。无需 UI 配置,经 profile 的 cordis.patch.yml 在 memory-palace 条目 config 下设置 distillLogLevel 键(dsh 0.1.7 起 settings.yaml 已被宿主移除、导入 profile patch)。").volatile(),
64
77
  // ---- v1.4.0:智能模式最终输出软预算(v1.4.1 起语义变更:prompt 软约束,思考不受限;实际硬上限由模型自身 maxTokens 决定) ----
65
- summaryMaxTokens: Schema.number().default(2000).description("会话摘要 LLM 的最终输出软预算(prompt 约束,思考不受限;实际硬上限由模型自身 maxTokens 决定)。默认 2000;可调大以容纳更多 durable 事实。"),
66
- projectMaxTokens: Schema.number().default(8000).description("手动「蒸馏项目记忆」LLM 的最终输出软预算(prompt 约束,思考不受限;实际硬上限由模型自身 maxTokens 决定)。默认 8000。"),
78
+ summaryMaxTokens: Schema.number().default(2000).description("会话摘要 LLM 的最终输出软预算(prompt 约束,思考不受限;实际硬上限由模型自身 maxTokens 决定)。默认 2000;可调大以容纳更多 durable 事实。").volatile(),
79
+ projectMaxTokens: Schema.number().default(8000).description("手动「蒸馏项目记忆」LLM 的最终输出软预算(prompt 约束,思考不受限;实际硬上限由模型自身 maxTokens 决定)。默认 8000。").volatile(),
67
80
  // ---- v1.4.0:蒸馏时回喂存量记忆(特性3,默认关;开启后自动智能模式 turn/end 与手动蒸馏按钮均回喂,delete 仅手动放开) ----
68
- feedbackEnabled: Schema.boolean().default(false).description("每次蒸馏时把项目级 + 用户级 MEMORY.md 全文(逐行编号、无截断)回喂给 LLM,使其能基于既有记忆做增量维护。delete 仍仅手动蒸馏按钮开放,自动模式跳过(防误删)。hybrid 模式下仅手动触发蒸馏受影响(自动路径走记忆子代理,自带日志回喂)。默认关。"),
81
+ feedbackEnabled: Schema.boolean().default(false).description("每次蒸馏时把项目级 + 用户级 MEMORY.md 全文(逐行编号、无截断)回喂给 LLM,使其能基于既有记忆做增量维护。delete 仍仅手动蒸馏按钮开放,自动模式跳过(防误删)。hybrid 模式下仅手动触发蒸馏受影响(自动路径走记忆子代理,自带日志回喂)。默认关。").volatile(),
69
82
  // ---- v1.6.0:hybrid 模式配置(仅 memoryMode=hybrid 时生效) ----
70
- reorgCooldownDays: Schema.number().default(7).description("hybrid 模式:项目级 MEMORY.md 全量重整的冷却天数(距上次重整)。与「超出注入预算」双条件同时满足才允许 memory_reorganize;时间戳以 HTML 注释落在 MEMORY.md 文件尾。"),
71
- subagentLogBudget: Schema.number().default(20000).description("hybrid 模式:记忆子代理回喂今日工作日志的字符上限。超出时仅回喂章节目录,子代理用 log_read_section 按需读取章节。"),
83
+ reorgCooldownDays: Schema.number().default(7).description("hybrid 模式:项目级 MEMORY.md 全量重整的冷却天数(距上次重整)。与「超出注入预算」双条件同时满足才允许 memory_reorganize;时间戳以 HTML 注释落在 MEMORY.md 文件尾。").volatile(),
84
+ subagentLogBudget: Schema.number().default(20000).description("hybrid 模式:记忆子代理回喂今日工作日志的字符上限。超出时仅回喂章节目录,子代理用 log_read_section 按需读取章节。").volatile(),
72
85
  // ---- v1.7.1(特性3):自定义指令(用户自写,经 system prompt 注入到「记忆分工 prompt」之后) ----
73
86
  // 放 system 而非 E 投影:用户配置一次即恒定 → 零缓存成本(见下方 section 的分流原则)。
74
- customInstructions: Schema.string().default("").description("自定义指令:非空时追加到系统提示词「记忆分工说明」之后,用于承载不适合写进用户记忆的特殊指令。对全部会话与三种记忆模式生效;留空则不注入。"),
87
+ customInstructions: Schema.string().default("").description("自定义指令:非空时追加到系统提示词「记忆分工说明」之后,用于承载不适合写进用户记忆的特殊指令。对全部会话与三种记忆模式生效;留空则不注入。").volatile(),
75
88
  });
76
89
 
77
90
  export const inject = ["systemPrompt", "tools", "llm", "webServer", "webRuntime"];
78
91
 
92
+ /**
93
+ * v1.8.0(dsh 0.1.7 适配):解包 cordis 解析后的 cosmokit Volatile 引用。
94
+ * 0.1.7 起 Config schema 字段标 `.volatile()`,loader 解析后该字段值不再是原始值,
95
+ * 而是 `{ get(): snapshot, [writeSymbol]: fn }` 引用对象(热改时原地更新、不重载 fiber)。
96
+ * 宿主自己的 consumer 一律 `.get()` 读;本插件全部配置经 source() 消费,故在此统一解包。
97
+ * 判定用鸭子类型(cosmokit 跨包不共享私有 write Symbol,不能用它的 isVolatile 判外部对象;
98
+ * 本项目配置字段里没有任何自带 `.get` 方法的值,误判面为零)。递归处理数组/对象。
99
+ * @param {unknown} value 解析后的配置值
100
+ * @returns {unknown} 纯数据快照(与旧宿主行为一致)
101
+ */
102
+ function unwrapConfig(value) {
103
+ if (value === null || typeof value !== "object") return value;
104
+ if (typeof value.get === "function" && !Array.isArray(value)) return unwrapConfig(value.get());
105
+ if (Array.isArray(value)) return value.map(unwrapConfig);
106
+ const out = {};
107
+ for (const [k, v] of Object.entries(value)) out[k] = unwrapConfig(v);
108
+ return out;
109
+ }
110
+
79
111
  export function apply(ctx, config) {
80
112
  // 设置集成:在 DSH 设置页暴露 memory-palace 配置面板;运行时优先读用户设置覆盖层,
81
113
  // 未挂载 settings 服务时回退到 cordis 组合里的 config。
82
114
  // v1.6.0-rc1:注册动作挪进下方 ctx.inject(["settings"]) 回调(installSection 是
83
115
  // SettingsProvider 实例方法,须等 settings 服务挂载;其内部同步 setSource,时序与旧版等价)。
84
- let source = () => config;
116
+ // v1.8.0:配置真源统一 = cordis 注入的 config(0.1.7 起即 profile 条目 config、热改原地生效)。
117
+ let source = () => unwrapConfig(config);
85
118
  const baseEntry = { ...config };
86
119
 
87
- // ---- v1.1.3:设置读写 route(真保存)----
88
- // client fetch 同源 /memory-palace/api/settings.get|update,绕过 settingsScope(persistence=memory no-op)
89
- // 与 apiproxy allowlist 两层限制;handler 内直接走服务端 settings → settings-file 持久化。
120
+ // ---- v1.1.3:设置读写 route(真保存)/ v1.8.0:适配 dsh 0.1.7 SettingsForms ----
121
+ // client fetch 同源 /memory-palace/api/settings.get|update,绕过 apiproxy allowlist;
122
+ // handler 内直接走服务端 settings 面 → profile patch 持久化。
90
123
  // 写用 replace 语义(整节替换):表单里留空的字段自动回退 base/schema 默认,与「保存=提交整个表单」一致。
124
+ // v1.8.0 适配(dsh 0.1.7-alpha.1):dsh-settings 整包重写为 SettingsForms——
125
+ // ① 不再有 installSection / setSource / onChange:配置的**唯一真源 = profile 条目 config**,
126
+ // 应用值就是 cordis 注入的 config,且热改经 loader 原地生效(volatile 字段经引用更新、
127
+ // 其余字段整 fiber 重载),故 source 恒为 () => config,无需 setSource 切换。
128
+ // ⚠️ cordis loader 解析后 volatile 字段是 cosmokit 引用对象 `{ get(), [write] }`
129
+ // (非原始值!schemastery resolve 对 meta.volatile 的字段 createVolatile 包装)——
130
+ // 所有配置读取必须经下方 unwrapConfig() 解包,否则 cfg.enabled 拿到对象→真值判断全乱。
131
+ // 鸭子判定 typeof value.get === 'function'(cosmokit 的 write Symbol 跨包不共享、
132
+ // 不能用它的 isVolatile 判外部对象;本项目 config 值里没有自带 get() 的字段,零误判面)。
133
+ // ② describe({redactSecrets:true}) 返回 SettingsDescriptor[](ns/schema/value/revision/user),
134
+ // replace/update/mutate 签名保持 (ns, section, expectedRevision)——本插件整节提交走 replace。
135
+ // ③ 前提:Config schema 须显式 .volatile()(0.1.7 只把 volatile 字段投影进表单;
136
+ // 全无 volatile 的条目 describe 不列出、write 直接抛「no volatile fields」)。
91
137
  let settingsFace = null;
92
138
  ctx.inject(["settings"], (sctx) => {
93
139
  const ns = MEMORY_PALACE_SETTINGS_NAMESPACE;
94
- // v1.6.0-rc1:设置节注册挪到此处(settings 服务就绪后)。installSection 内部会同步
95
- // 执行 setSource(() => scope.get()),把 source 从 cordis config 切到用户设置覆盖层;
96
- // owner=ctx 使插件卸载时宿主自动回退 setSource(() => entry)。与旧版自由函数时序等价。
97
- sctx.settings.installSection(ctx, ns, Config, baseEntry, {
98
- setSource: (next) => {
99
- source = next;
100
- },
101
- onChange: () => {},
102
- });
103
140
  const viewOf = () => {
104
141
  const descriptor = sctx.settings.describe({ redactSecrets: true }).find((candidate) => candidate.ns === ns);
105
142
  return descriptor === undefined
106
143
  ? { value: undefined, user: undefined, revision: undefined }
107
144
  : { value: descriptor.value, user: descriptor.user, revision: descriptor.revision };
108
145
  };
146
+ // v1.8.0 双栈:旧宿主(0.1.6 线 SettingsProvider)有 installSection,须注册节并把 setSource
147
+ // 切到解析层;新宿主(0.1.7 SettingsForms)无此方法——配置真源即 profile 条目 config,
148
+ // 热改经 loader 生效,source 保持 () => config 即可。describe/replace 两栈签名兼容。
149
+ if (typeof sctx.settings.installSection === "function") {
150
+ sctx.settings.installSection(ctx, ns, Config, baseEntry, {
151
+ setSource: (next) => {
152
+ source = () => unwrapConfig(next());
153
+ },
154
+ onChange: () => {},
155
+ });
156
+ }
109
157
  settingsFace = {
110
158
  get: viewOf,
111
159
  replace: async (section, expectedRevision) => {
@@ -128,6 +176,9 @@ export function apply(ctx, config) {
128
176
  lastSummarizedSeq: -1, // 智能模式增量摘要断点(session 事件 seq)
129
177
  summarySessionId: null,
130
178
  planModeActive: false, // 计划模式:禁写记忆(硬编码默认,无开关;仅经 session/event 的 plan/mode 翻转;未装 dsh-plan-mode 永不触发=不拦截)
179
+ // v1.7.2:会话 → agent 预设 id(仅"切换预设"事件写入;创建头另在 presetOfSession 里兜底读)。
180
+ // 只增不减:会话结束后残留几条字符串,代价可忽略;切回同一 session 断言预设不变(宿主侧保证)。
181
+ presetBySession: new Map(),
131
182
  // v1.7.0:injectedSessionIds 已删除——记忆正文改经 E 投影(src/projection.mjs)注入为
132
183
  // 常驻消息,compaction 后由投影自动重注,不再需要"仅首次注入"的会话级标记。
133
184
  };
@@ -137,6 +188,45 @@ export function apply(ctx, config) {
137
188
  const TURN_BUFFER_CHAR_CAP = 30000;
138
189
  const SETTLE_DELAY = 1500;
139
190
 
191
+ // ---------- v1.7.2:预设级静默判据(官方 minimal = 宿主给模型的"裸测环境") ----------
192
+ // 背景:宿主的「模式」= agent 平面的 preset(`packages/preset/agent-presets/presets/*/agent.cordis.yml`),
193
+ // minimal 预设以 persona `complete: true` 独占 system prompt 并关掉 runtime context——那是官方跑分口径
194
+ // 的刻意设计。而本插件是 host 平面插件(profile bundle insert),其 systemPrompt.section / agent/pre-step
195
+ // 投影 / 工具注册对**每个 agent** 都生效,preset 不会把它摘掉;`complete` 又只吞 sections、不裁 tools。
196
+ // 结果就是"指令没了、记忆正文照进、工具 schema 照发"的半残状态(实测:极简模式下投影仍在注入)。
197
+ // 因此必须自行判定会话预设并整体静默。
198
+ //
199
+ // 判据取宿主公开事实,不引入额外服务依赖:
200
+ // ① session.header.agentPreset —— 创建头,由 session-controller 的 composeAgent 写入**解析后**的
201
+ // 预设 id(未显式指定时即部署默认),故默认预设会话同样能识别;
202
+ // ② `agent-preset/selected` 事件 —— 仅"尚未产生任何消息"的空会话可切预设,切换时追加,
203
+ // 由下方 session/event 监听捕获。
204
+ // 二者合起来等价于宿主的 `agentPreset` 会话投影(init=header,apply=该事件),无需注入 sessionProjections。
205
+ // fail-open:判据缺失(老宿主 / 非 preset 部署)一律视为"不静默",绝不因判据缺失而丢掉记忆能力。
206
+ function presetOfSession(session) {
207
+ if (!session) return undefined;
208
+ const switched = state.presetBySession.get(session.id);
209
+ if (typeof switched === "string" && switched) return switched;
210
+ const header = session.header?.agentPreset;
211
+ return typeof header === "string" && header ? header : undefined;
212
+ }
213
+
214
+ /**
215
+ * 该会话是否应整体静默:`enabled=false`(全局停用)或命中「静默预设」名单。
216
+ * 命中后 section / E 投影 / turn-end 写入 / 记忆工具 / hybrid 子代理一并关闭——
217
+ * 语义等价于该会话里没装本插件。
218
+ * @param {object|undefined} session
219
+ * @returns {boolean}
220
+ */
221
+ function isSessionSilent(session) {
222
+ const cfg = source();
223
+ if (!cfg.enabled) return true;
224
+ const list = Array.isArray(cfg.silentPresets) ? cfg.silentPresets.filter((x) => typeof x === "string" && x) : [];
225
+ if (!list.length) return false; // 名单空 = 关闭该机制(只受 enabled 管)
226
+ const preset = presetOfSession(session);
227
+ return preset !== undefined && list.includes(preset);
228
+ }
229
+
140
230
  // ---- 装配:路径解析 / 记录读写 / 蒸馏 / 工具 / route ----
141
231
  const paths = createPaths(() => source(), () => state.activeCwd);
142
232
  const records = createRecords({ getConfig: () => source(), paths });
@@ -145,15 +235,82 @@ export function apply(ctx, config) {
145
235
  registerApi({ ctx, paths, distill, state, getSettingsFace });
146
236
  // v1.6.0:hybrid 模式独立模块。必须【无条件注册】——apply() 同步段执行时 settings 服务
147
237
  // 尚未挂载(v1.6.0-rc1 起设置节经 SettingsProvider.installSection 在 ctx.inject(["settings"])
148
- // 回调里注册并同步 setSource),此刻 source() 读的是 cordis 组合配置(默认 plugin),
238
+ // 回调里注册并同步 setSource),此刻 source() 读的是 cordis 组合配置(未显式配置时即 schema 默认),
149
239
  // 条件注册会导致设置页切 hybrid 后工具/子代理从未注册(v1.6.0 实装踩坑:settings.yaml
150
240
  // memoryMode=hybrid 但 registerHybrid 未执行 → 子代理 TypeError 被吞、日志全空)。
151
241
  // 运行时分派靠 _settle / proactive 的热 source() 判断;工具注册无副作用(plugin/smart
152
242
  // 的 prompt 不引导使用,guards 白名单只拦 hybrid 工具)。
153
243
  const hybrid = registerHybrid({ ctx, getConfig: () => source(), paths, records, state });
154
244
  // v1.7.0 特性1:E 投影通道(记忆正文常驻注入)。与 hybrid 同理,无条件注册——
155
- // 其内部读热配置,无副作用(enabled=false 时 buildProjections 返回空)。
156
- registerProjection({ ctx, getConfig: () => source(), paths });
245
+ // 其内部读热配置,无副作用(enabled=false 或命中静默预设时 buildProjections 返回空)。
246
+ // v1.7.2:把 isSessionSilent 透传下去——投影按**会话**判定,故必须知道 agent 所属会话的预设。
247
+ registerProjection({ ctx, getConfig: () => source(), paths, isSilent: isSessionSilent });
248
+
249
+ // ---------- v1.7.2:静默会话(enabled=false 或命中静默预设)的工具 schema 隐身 ----------
250
+ // 背景:`complete: true` 只收缩 sections、**不裁剪 tools**——记忆工具的 schema 仍会经 toolProvider
251
+ // 进 assemble,在"裸测环境"里白吃 token 且可能被模型幻觉调用。故静默会话需显式隐身工具。
252
+ // 机制约束:① enabled / silentPresets 都是热配置,apply() 同步段读不到 → 不能条件注册(否则切回后
253
+ // 工具从未注册,同 v1.6.0 hybrid 踩坑);② tools.restrict() 要求 agent 作用域 ctx、静态名单、
254
+ // dispose 才解除;③ 宿主无"当前是哪个 preset"的装配期 API,但 agent/created 时 session 创建头已带
255
+ // agentPreset(composeAgent 写入解析后的 id),故此处判定可靠。
256
+ // 落法:挂 agent/created 建立掩码,并在**空会话切换预设**时同步(宿主允许"尚未产生任何消息"的会话
257
+ // 改预设;此时模型还没看过任何东西,掩码必须跟着变,否则切到极简后工具仍暴露)。
258
+ // 语义与 model selection 一致(能力集在 agent 装配前冻结):运行中热切 enabled / silentPresets
259
+ // 仅影响后续新建 agent,当前 agent 不变——可接受(execute 内已有 enabled 兜底,即便残留 schema 被调
260
+ // 也返回 disabled)。
261
+ // deny 名单含 4 基础工具 + 3 hybrid 工具;log_read_section / log_write_ops 是子 agent 内部工具
262
+ // (经 ctx.llm.stream 的 tools 参数、不入全局层),列进 deny 会触发 unknown-tool 抛错,故不含。
263
+ const MEMORY_TOOL_NAMES = [
264
+ "memory_note",
265
+ "memory_note_user",
266
+ "memory_read",
267
+ "memory_delete",
268
+ "memory_write",
269
+ "memory_update_section",
270
+ "memory_reorganize",
271
+ ];
272
+ // sessionId → agent(仅用于切换预设时重新同步掩码;agent/disposed 时清理,避免长跑进程里越积越多)
273
+ const agentBySession = new Map();
274
+ // sessionId → restrict() 的解除函数(掩码是否已戴,靠它判断 + 反向解除)
275
+ const toolMaskBySession = new Map();
276
+
277
+ /** 按会话当前预设同步工具掩码:静默→戴上(deny 全部记忆工具),非静默→摘下。幂等。 */
278
+ function syncToolMask(agent) {
279
+ const sessionId = agent?.session?.id;
280
+ if (!sessionId) return;
281
+ const masked = toolMaskBySession.has(sessionId);
282
+ const silent = isSessionSilent(agent?.session);
283
+ if (silent === masked) return;
284
+ try {
285
+ if (silent) {
286
+ const release = agent?.ctx?.tools?.restrict({ deny: MEMORY_TOOL_NAMES });
287
+ if (typeof release === "function") toolMaskBySession.set(sessionId, release);
288
+ } else {
289
+ toolMaskBySession.get(sessionId)?.();
290
+ toolMaskBySession.delete(sessionId);
291
+ }
292
+ } catch (error) {
293
+ // 绝不冒泡:restrict 抛错(如某工具因异常未注册命中 unknown-tool)时降级为"不隐身",
294
+ // 由 execute 的 enabled 兜底保证功能仍停用,只是没省掉 schema token。
295
+ console.error(`[memory-palace] tool-hide skipped: ${error?.message || String(error)}`);
296
+ }
297
+ }
298
+
299
+ ctx.on("agent/created", ({ agent }) => {
300
+ if (agent?.session?.id) agentBySession.set(agent.session.id, agent);
301
+ syncToolMask(agent);
302
+ });
303
+ ctx.on("agent/disposed", ({ agent }) => {
304
+ const sessionId = agent?.session?.id;
305
+ if (!sessionId) return;
306
+ try {
307
+ toolMaskBySession.get(sessionId)?.();
308
+ } catch {
309
+ /* scope 已在卸载,忽略 */
310
+ }
311
+ toolMaskBySession.delete(sessionId);
312
+ agentBySession.delete(sessionId);
313
+ });
157
314
 
158
315
  // ---- session/event 跟踪:更新 activeCwd/activeSession/增量断点 + 累积 turnBuffer ----
159
316
  // 关键:一次用户请求在 dsh agent 循环里会被拆成多个 turn(每个工具调用一轮),
@@ -169,6 +326,16 @@ export function apply(ctx, config) {
169
326
  state.lastSummarizedSeq = session.firstLiveSeq;
170
327
  }
171
328
  const type = event?.type;
329
+ // v1.7.2:预设切换(仅空会话可切;宿主在切换提交后追加该事件)。记进 Map 供 isSessionSilent 读取。
330
+ if (type === "agent-preset/selected") {
331
+ const id = event?.data?.agentPreset;
332
+ if (session?.id && typeof id === "string" && id) state.presetBySession.set(session.id, id);
333
+ // 掩码跟随:会话切进/切出静默预设时立即戴上或摘下(此时模型尚未看过任何内容,
334
+ // 不做这一步会出现"切到极简、工具 schema 仍暴露"的漏网)。
335
+ const owner = session?.id ? agentBySession.get(session.id) : undefined;
336
+ if (owner) syncToolMask(owner);
337
+ return;
338
+ }
172
339
  // 计划模式:禁写记忆(硬编码默认行为,无开关;不依赖 dsh-plan-mode 服务,未装则永不触发=安全降级=不拦截)
173
340
  if (type === "plan/mode") {
174
341
  state.planModeActive = !!(event?.data?.active);
@@ -223,9 +390,15 @@ export function apply(ctx, config) {
223
390
  ctx.systemPrompt.section({
224
391
  name: "memory-palace",
225
392
  order: 50,
226
- text: () => {
393
+ // v1.7.2:text 接收宿主 AssembleContext(`{ agent, scope, signal }`,见 agent 包 assembleContextFor),
394
+ // 故可按**会话**判定预设静默 —— 与投影/工具/写入同一判据,避免"half-injected"状态。
395
+ text: (context) => {
227
396
  const cfg = source();
228
397
  if (!cfg.enabled) return "";
398
+ // v1.7.2:极简(裸测)预设整体静默。注:minimal 预设的 complete:true 本来也会吞掉本节,
399
+ // 这里显式返回空串是为了① 覆盖"自定义静默预设未用 complete"的情形;② 让本节的去留与其余
400
+ // 通道严格一致,便于排障(不会出现"投影关了、section 还在"的错觉)。
401
+ if (isSessionSilent(context?.agent?.session)) return "";
229
402
  // v1.7.0:alreadyInjected / injectedSessionIds 已整体删除(记忆正文改走 E 投影)。
230
403
  // intro(含记忆公民指令)仍【始终】注入——若因记忆为空而整体返回空串,agent 将不知道
231
404
  // 记忆系统存在、不会主动记,形成「无记忆 → 无指令 → 永不记」死循环。
@@ -278,6 +451,9 @@ export function apply(ctx, config) {
278
451
  if (state.planModeActive) return;
279
452
  const cfg = source();
280
453
  if (!cfg.enabled) return;
454
+ // v1.7.2:静默会话(极简等预设)不写任何记忆——错误捕获 / 轻量兜底 / smart 摘要 / hybrid 子代理
455
+ // 全部在此一处提前返回(hybrid 分支在其下方,天然被拦)。
456
+ if (isSessionSilent(state.activeSession)) return;
281
457
  const dirs = paths.writeDirs();
282
458
  if (!dirs.length) return;
283
459
 
@@ -15,6 +15,9 @@
15
15
  // (此前日志在 section 里每步求值,一变就让序列最前的整段前缀作废)。
16
16
  // - compaction 把消息移出 surface 后,身份判据即判为缺失 → 自动重注**磁盘最新版**,
17
17
  // 顺带完成一次「刷新到最新」。
18
+ // - v1.7.2 起**静默会话整体不投影**(isSilent(session)):宿主「模式」是 agent 平面预设,
19
+ // 本插件却在 host 平面,投影对每个 agent 都生效——官方 minimal 预设(persona complete:true
20
+ // 独占 system prompt 的"裸测环境")下必须自行按会话静默,否则记忆正文仍会常驻历史吃 token。
18
21
  //
19
22
  // 实现照抄宿主 `packages/context/agent-instructions/src/index.ts` 三件套(API 全公开、无第一方特权):
20
23
  // 1. `inject: ['sessionProjections']`(服务随 dsh-base 默认装载)
@@ -32,12 +35,16 @@ import { createUserMessage } from "@deepseek-ai/dsh-llm";
32
35
  import { expandHome, toHomeShort, todayISO, readMdSync, budgetClip, stripSmartTag, stripDeletedLines } from "./common/text.mjs";
33
36
 
34
37
  // 投影消息的 source 标注。
35
- // - kind: 'plugin' → 明确标注"插件注入",供下游按 source 过滤(子 agent 去噪 / turnBuffer 采集)。
38
+ // v1.8.0(dsh 0.1.7 适配):宿主删除了通用 catch-all `plugin` kind(MessageSourceMap 不再含
39
+ // 'plugin' 键),改为「每个生产者在自己的模块里声明自有 kind」;v3→v4 会话持久化迁移把第三方
40
+ // 旧源 `{kind:'plugin',plugin:X}` 规范化为 `plugin:X`(见 session-format-v3-to-v4/sources.ts
41
+ // producerKind())。故本插件合规 kind = 'plugin:dsh-memory-palace'。运行时不校验 kind 白名单
42
+ // (createMessage 仅 deepFreeze(structuredClone)),但未知 kind 在 UI 走兜底呈现、且未来宿主
43
+ // 若加校验即炸——按迁移约定写才安全。
36
44
  // - form: 'instructions' → 宿主 ContextForm 联合内的合法值(曾拟用 'memory',但其不在该联合内,
37
45
  // 属类型不合法;'instructions' 语义接近"指令性内容"且类型安全,UI 按指令样式呈现)。
38
46
  const PROJECTION_SOURCE = Object.freeze({
39
- kind: "plugin",
40
- plugin: "dsh-memory-palace",
47
+ kind: "plugin:dsh-memory-palace",
41
48
  form: "instructions",
42
49
  });
43
50
 
@@ -51,8 +58,14 @@ function projectionIdentity(msg) {
51
58
 
52
59
  // 只在双方都是本插件投影时才比身份 —— 规避真实用户消息与宿主注入消息
53
60
  // (runtime context / skill 目录等)因首行文本巧合而误撞。
61
+ // v1.8.0:新消息 kind='plugin:dsh-memory-palace';同时**保留旧 kind='plugin'+plugin 字段的识别**
62
+ // —— 历史会话里已持久化的旧投影消息经宿主 v3→v4 迁移会变成 plugin:dsh-memory-palace,但旧宿主
63
+ // (<0.1.7)与未迁移数据仍是旧形状,双认可防「换 kind 当天在老会话里重复注入」。
54
64
  function isOwnProjection(msg) {
55
- return msg?.source?.kind === "plugin" && msg?.source?.plugin === "dsh-memory-palace";
65
+ const s = msg?.source;
66
+ if (!s || s.form !== "instructions") return false;
67
+ if (s.kind === "plugin:dsh-memory-palace") return true;
68
+ return s.kind === "plugin" && s.plugin === "dsh-memory-palace";
56
69
  }
57
70
 
58
71
  function sameProjectionIdentity(left, right) {
@@ -86,12 +99,16 @@ function buildProjection(text, heading) {
86
99
  /**
87
100
  * 收集本步要投影的消息(用户级 / 项目级 MEMORY.md / 今日工作日志,各自独立一条)。
88
101
  * 拆成多条独立消息(v1.7.0 定案,v1.7.1 扩展):否则"某一条内容一改,其余连带重发"。
89
- * @param {{ getConfig: () => object, paths: object }} deps
102
+ * v1.7.2:新增 `session` + `isSilent` —— 静默会话(官方 minimal 等预设)整体不投影。
103
+ * @param {{ getConfig: () => object, paths: object, session?: object, isSilent?: (session?: object) => boolean }} deps
90
104
  * @returns {object[]} 按 [用户级, 项目级…, 今日日志…] 顺序的消息数组(可能为空)
91
105
  */
92
- export function buildProjections({ getConfig, paths }) {
106
+ export function buildProjections({ getConfig, paths, session, isSilent }) {
93
107
  const cfg = getConfig();
94
108
  if (!cfg.enabled) return [];
109
+ // v1.7.2:静默会话(极简模式等)不投影——投影消息是**常驻历史**,比 section 更"重":
110
+ // 它要一路吃 token 直到 compaction,正是"裸测环境"最不该有的东西。
111
+ if (isSilent?.(session)) return [];
95
112
  const out = [];
96
113
  // 用户级 MEMORY.md
97
114
  const userFile = expandHome(cfg.userMemoryPath);
@@ -129,9 +146,9 @@ export function buildProjections({ getConfig, paths }) {
129
146
 
130
147
  /**
131
148
  * 注册 E 投影钩子。
132
- * @param {{ ctx: object, getConfig: () => object, paths: object }} deps
149
+ * @param {{ ctx: object, getConfig: () => object, paths: object, isSilent?: (session?: object) => boolean }} deps
133
150
  */
134
- export function registerProjection({ ctx, getConfig, paths }) {
151
+ export function registerProjection({ ctx, getConfig, paths, isSilent }) {
135
152
  ctx.on("agent/pre-step", async ({ agent, messages, step, signal }, next) => {
136
153
  // 先让瀑布流继续,拿到宿主与其他插件合成后的决策——投影要折叠进它的 messages。
137
154
  const decision = await next();
@@ -139,7 +156,9 @@ export function registerProjection({ ctx, getConfig, paths }) {
139
156
  signal?.throwIfAborted?.();
140
157
  if (decision.kind !== "enter") return decision;
141
158
  const session = agent?.session;
142
- const desired = buildProjections({ getConfig, paths });
159
+ // v1.7.2:静默会话(极简模式等)不投影。放在 next() 之后、构造之前,成本最低。
160
+ if (isSilent?.(session)) return decision;
161
+ const desired = buildProjections({ getConfig, paths, session, isSilent });
143
162
  if (!desired.length) return decision;
144
163
  // 逐条去重(按**文件身份**、非内容):已被本步 messages 覆盖、或已在 surface 上的,跳过。
145
164
  const pending = desired.filter((msg) =>
package/package.json CHANGED
@@ -1,56 +1,58 @@
1
- {
2
- "name": "dsh-memory-palace",
3
- "version": "1.7.1",
4
- "description": "把 WorkBuddy 的文件式记忆系统移植进 DeepSeek Harness:用户级 + 工作区的人类可读 Markdown 记忆(~/.deepseek-harness/MEMORY.md 与 <cwd>/.deepseek-harness/memory/)。",
5
- "type": "module",
6
- "main": "lib/index.js",
7
- "exports": {
8
- ".": "./lib/index.js",
9
- "./client": "./lib/client.js",
10
- "./package.json": "./package.json"
11
- },
12
- "files": [
13
- "lib",
14
- "cordis.patch.yml",
15
- "README.md",
16
- "LICENSE"
17
- ],
18
- "publishConfig": {
19
- "registry": "https://registry.npmjs.org/"
20
- },
21
- "repository": {
22
- "type": "git",
23
- "url": "git+https://github.com/lovezi0/dsh-memory-palace.git"
24
- },
25
- "license": "MIT",
26
- "dsh": {
27
- "bundle": {
28
- "patch": "./cordis.patch.yml"
29
- },
30
- "client": {
31
- "platform": "web",
32
- "inject": [
33
- "@deepseek-ai/dsh-client-ui-settings",
34
- "@deepseek-ai/dsh-client-ui-renderer",
35
- "@deepseek-ai/dsh-client-locale",
36
- "@deepseek-ai/dsh-client-connection",
37
- "@deepseek-ai/dsh-api-remotes",
38
- "@deepseek-ai/dsh-api-session-controller"
39
- ]
40
- }
41
- },
42
- "peerDependencies": {
43
- "@deepseek-ai/cordis": "*",
44
- "@deepseek-ai/dsh-llm": "*",
45
- "@deepseek-ai/dsh-settings": "^0.1.2-alpha.2",
46
- "@deepseek-ai/dsh-tools": "^0.1.2-alpha.2",
47
- "@deepseek-ai/schemastery": "^3.18.2"
48
- },
49
- "devDependencies": {
50
- "@deepseek-ai/dsh-settings": "^0.1.2-alpha.2"
51
- },
52
- "scripts": {
53
- "build": "node scripts/build.mjs",
54
- "prepublishOnly": "npm run build"
55
- }
56
- }
1
+ {
2
+ "name": "dsh-memory-palace",
3
+ "version": "1.7.2-alpha.2",
4
+ "description": "把 WorkBuddy 的文件式记忆系统移植进 DeepSeek Harness:用户级 + 工作区的人类可读 Markdown 记忆(~/.deepseek-harness/MEMORY.md 与 <cwd>/.deepseek-harness/memory/)。",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "exports": {
8
+ ".": "./lib/index.js",
9
+ "./client": "./lib/client.js",
10
+ "./package.json": "./package.json"
11
+ },
12
+ "files": [
13
+ "lib",
14
+ "cordis.patch.yml",
15
+ "README.md",
16
+ "LICENSE",
17
+ "assets/memory-icon.svg"
18
+ ],
19
+ "publishConfig": {
20
+ "registry": "https://registry.npmjs.org/"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/lovezi0/dsh-memory-palace.git"
25
+ },
26
+ "license": "MIT",
27
+ "dsh": {
28
+ "bundle": {
29
+ "patch": "./cordis.patch.yml"
30
+ },
31
+ "client": {
32
+ "platform": "web",
33
+ "inject": [
34
+ "@deepseek-ai/dsh-client-ui-settings",
35
+ "@deepseek-ai/dsh-client-ui-renderer",
36
+ "@deepseek-ai/dsh-client-locale",
37
+ "@deepseek-ai/dsh-client-connection",
38
+ "@deepseek-ai/dsh-api-remotes",
39
+ "@deepseek-ai/dsh-api-session-controller"
40
+ ]
41
+ }
42
+ },
43
+ "peerDependencies": {
44
+ "@deepseek-ai/cordis": "*",
45
+ "@deepseek-ai/dsh-llm": "^0.1.7-alpha.1",
46
+ "@deepseek-ai/dsh-settings": "^0.1.7-alpha.1",
47
+ "@deepseek-ai/dsh-tools": "^0.1.7-alpha.1",
48
+ "@deepseek-ai/schemastery": "^3.18.3"
49
+ },
50
+ "devDependencies": {
51
+ "@deepseek-ai/dsh-settings": "^0.1.7-alpha.1"
52
+ },
53
+ "scripts": {
54
+ "build": "node scripts/build.mjs",
55
+ "prepublishOnly": "npm run build"
56
+ },
57
+ "icon": "./assets/memory-icon.svg"
58
+ }