@restregular/dsh-memory 0.5.5 → 0.6.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.
@@ -35,6 +35,11 @@ import { normalizeScopeInput, resolveScopeRef } from '../provider/scope.js'
35
35
 
36
36
                 
37
37
 
38
+
39
+                          
40
+                               
41
+
42
+
38
43
 
39
44
 
40
45
 
@@ -77,8 +82,16 @@ function agentOf(exec ) {
77
82
  return (exec )?.agent
78
83
  }
79
84
 
80
- /** 当前项目 key:配置优先,其次 process.cwd()(与 provider 的缺省一致)。 */
81
- function projectKey(opts ) {
85
+ /**
86
+ * 当前项目 key。优先级:**服务端解析的会话 cwd** → 显式配置 → process.cwd()。
87
+ *
88
+ * 服务端那一步不能省:DSH 服务进程的 process.cwd() 是 profile 目录,只有
89
+ * `session.header.cwd` 才是工作区;而 mock / 旧 provider 没有 `projectKeyFor` 时,
90
+ * 只能退回配置与 process.cwd()(与旧行为一致,不把测试和旧宿主打断)。
91
+ */
92
+ function projectKey(opts , service , agent ) {
93
+ const resolved = service?.projectKeyFor?.(agent)
94
+ if (typeof resolved === 'string' && resolved.length > 0) return resolved
82
95
  return (opts.projectScope ?? `project:${process.cwd()}`)
83
96
  }
84
97
 
@@ -87,7 +100,7 @@ function readScopes(opts , service , agent
87
100
  const provided = service.resolveReadScopes?.(agent)
88
101
  if (Array.isArray(provided) && provided.length > 0) return [...new Set(provided)]
89
102
  // 服务没提供(测试 mock / 旧 provider):退回 defaultScope 口径
90
- const fallback = opts.defaultScope === 'global' ? 'global' : projectKey(opts)
103
+ const fallback = opts.defaultScope === 'global' ? 'global' : projectKey(opts, service, agent)
91
104
  return [...new Set([fallback, 'global'])]
92
105
  }
93
106
 
@@ -108,7 +121,7 @@ function resolveScope(
108
121
  if (!normalized.ok) throw new MemoryToolError('SCOPE_INVALID', normalized.message)
109
122
  if (normalized.kind === 'global') return { scope: 'global' }
110
123
  const agent = agentOf(exec)
111
- const project = projectKey(opts)
124
+ const project = projectKey(opts, service, agent)
112
125
  // 当前会话 key 由 provider 解析(只有它知道 scopes.session 开关与子代理共享父会话的规则);
113
126
  // provider 不在(测试 mock / 旧版本)时不给 session —— 写路径会回退 project,读路径回到合并集合。
114
127
  const session = service.resolveReadScopes?.(agent)?.find((s) => s.startsWith('session:'))
@@ -144,11 +157,11 @@ function resolveScope(
144
157
  export function memorySaveTool(opts ) {
145
158
  return {
146
159
  name: 'memory_save',
147
- description: 'Save a durable memory (fact, decision, preference, procedure) for future sessions.',
160
+ description: 'Save a durable memory (fact, decision, preference, procedure, rule) for future sessions.',
148
161
  parameters: {
149
162
  content: { type: 'string', description: 'Self-contained declarative sentence, readable without context', required: true },
150
163
  scope: { type: 'string', description: SCOPE_DESCRIPTION },
151
- kind: { type: 'string', enum: ['fact', 'decision', 'preference', 'procedure', 'note'] },
164
+ kind: { type: 'string', enum: ['fact', 'decision', 'preference', 'procedure', 'note', 'rule'] },
152
165
  tags: { type: 'array', items: { type: 'string' } },
153
166
  importance: { type: 'number', description: '0~1, higher = more important' },
154
167
  supersedes: { type: 'string', description: 'Record id this corrects/replaces' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restregular/dsh-memory",
3
- "version": "0.5.5",
3
+ "version": "0.6.0",
4
4
  "description": "DeepSeek Harness 本地长期记忆(单包单入口):JSONL 存储 + 本地向量检索(BGE-M3)+ 四个模型工具 + 自动召回注入 + 管理面板。",
5
5
  "icon": "./icon.svg",
6
6
  "type": "module",