dsh-plugin-memory 0.18.2 → 0.18.4

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
@@ -2,6 +2,18 @@
2
2
 
3
3
  所有记录跟随 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/) 风格;版本号与 `package.json` 保持一致。
4
4
 
5
+ ## [0.18.4] - 2026-11-10
6
+
7
+ ### Fixed
8
+
9
+ - **双击打开报 `no registered tab type claims "dsh-resource://file/absolute/..."`**:host 在无 session id 时兜底选中的会话可能属于另一个项目(cwd 不含记忆库),客户端因此退回 `absolute` 地址;而侧栏只认 `session/<id>/<相对路径>` 地址。现在 host 兜底优先选「cwd 包含记忆库目录」的会话;文件确实在工作区外时客户端直接给出「不在当前工作区、已用系统文件管理器打开」的说明,不再尝试注定失败的 absolute 地址。
10
+
11
+ ## [0.18.3] - 2026-11-10
12
+
13
+ ### Fixed
14
+
15
+ - **双击节点提示 `no-session`**:设置面板里的图谱没有 session id,而 `/api/memory/session` 在追踪器未记录"说过话的会话"时(例如刚刷新页面还没发消息)返回 no-session。现在无 sessionId 时兜底取第一个已挂载会话(优先带工作区 cwd 的),侧栏打开就能解析出 `session/<id>/<path>` 地址。
16
+
5
17
  ## [0.18.2] - 2026-11-10
6
18
 
7
19
  ### Fixed
@@ -26,8 +26,8 @@
26
26
  },
27
27
  "versions": [
28
28
  {
29
- "version": "0.18.1",
30
- "publishTimestamp": 1794275944,
29
+ "version": "0.18.3",
30
+ "publishTimestamp": 1794277109,
31
31
  "source": {
32
32
  "type": "npm"
33
33
  },
package/lib/client.js CHANGED
@@ -178,6 +178,7 @@ window.__ModuleLoader__.load({
178
178
  graphCopyFailed: '复制路径失败',
179
179
  graphRevealFallback: '打开失败,已复制路径;在 Finder 里按 ⌘⇧G 粘贴路径即可跳转',
180
180
  graphSidebarFailed: '侧栏打开失败:',
181
+ graphSidebarOutside: '该文件不在当前会话的工作区内,侧栏无法预览;已用系统文件管理器打开',
181
182
  graphStats: '{pages} 页 · {links} 条页间互链 · {tagEdges} 条共享 tag',
182
183
  graphIndexRoutes: '{count} 条索引路由(虚线)',
183
184
  graphIsolated: '{count} 页暂时孤立',
@@ -336,6 +337,7 @@ window.__ModuleLoader__.load({
336
337
  graphCopyFailed: 'Could not copy the path',
337
338
  graphRevealFallback: 'Reveal failed; the path was copied — paste it in your file manager to jump there',
338
339
  graphSidebarFailed: 'Sidebar open failed: ',
340
+ graphSidebarOutside: 'This file is outside the current session workspace, so the sidebar cannot preview it; opened it in the OS file manager instead',
339
341
  graphStats: '{pages} pages · {links} page links · {tagEdges} shared tags',
340
342
  graphIndexRoutes: '{count} index routes (dashed)',
341
343
  graphIsolated: '{count} pages isolated',
@@ -2065,13 +2067,13 @@ window.__ModuleLoader__.load({
2065
2067
  const encodePath = (path) => path.split('/')
2066
2068
  .map((segment, index) => (index === 0 && /^[A-Za-z]:$/.test(segment) ? segment : encodeURIComponent(segment)))
2067
2069
  .join('/')
2068
- let address
2069
- if (root !== undefined && (absolute === root || absolute.startsWith(`${root}/`))) {
2070
- const relative = absolute.slice(root.length).replace(/^\/+/, '')
2071
- address = `dsh-resource://file/session/${encodeURIComponent(session.sessionId)}/${encodePath(relative)}`
2072
- } else {
2073
- address = `dsh-resource://file/absolute/${encodePath(absolute.replace(/^\/+/, ''))}`
2070
+ // The sidebar only opens `session/<id>/<relative>` addresses; an
2071
+ // absolute address has no authorized session and cannot be claimed.
2072
+ if (root === undefined || (absolute !== root && !absolute.startsWith(`${root}/`))) {
2073
+ return { ok: false, reason: 'outside-workspace' }
2074
2074
  }
2075
+ const relative = absolute.slice(root.length).replace(/^\/+/, '')
2076
+ const address = `dsh-resource://file/session/${encodeURIComponent(session.sessionId)}/${encodePath(relative)}`
2075
2077
  try {
2076
2078
  await sidebar.openResource(address)
2077
2079
  } catch (error) {
@@ -2080,11 +2082,14 @@ window.__ModuleLoader__.load({
2080
2082
  return { ok: true }
2081
2083
  }
2082
2084
  const openNode = (id) => {
2085
+ const message = (result) => result.reason === 'outside-workspace'
2086
+ ? t('graphSidebarOutside')
2087
+ : `${t('graphSidebarFailed')}${result.reason}`
2083
2088
  openInSidebar(id)
2084
2089
  .then((result) => {
2085
2090
  if (result.ok === true) return
2086
- setNotice(`${t('graphSidebarFailed')}${result.reason}`)
2087
- revealNode(id, `${t('graphSidebarFailed')}${result.reason}`)
2091
+ setNotice(message(result))
2092
+ revealNode(id, message(result))
2088
2093
  })
2089
2094
  .catch((error) => {
2090
2095
  const reason = error instanceof Error ? error.message : String(error)
package/lib/index.js CHANGED
@@ -775,15 +775,33 @@ export function apply(ctx, config = {}) {
775
775
  const url = new URL(req.url ?? '/', 'http://localhost')
776
776
  const resolveAgent = (sessionId) => {
777
777
  const id = typeof sessionId === 'string' && sessionId.length > 0 ? sessionId : tracker.activeId()
778
- if (id === undefined) return undefined
779
- const direct = ctx.agents.get?.(id)
780
- if (direct !== undefined) return direct
781
- // Some hosts key the registry differently from the session id the
782
- // client sends; scanning the roots keeps the chip working either way.
783
- const roots = typeof ctx.agents.roots === 'function' ? ctx.agents.roots() : []
784
- return roots.find((agent) => agent.id === id
785
- || agent.session?.header?.id === id
786
- || agent.session?.id === id)
778
+ const roots = typeof ctx.agents?.roots === 'function' ? ctx.agents.roots() : []
779
+ if (id !== undefined) {
780
+ const direct = ctx.agents.get?.(id)
781
+ if (direct !== undefined) return direct
782
+ // Some hosts key the registry differently from the session id the
783
+ // client sends; scanning the roots keeps the chip working either way.
784
+ return roots.find((agent) => agent.id === id
785
+ || agent.session?.header?.id === id
786
+ || agent.session?.id === id)
787
+ }
788
+ // 0.18.3/0.18.4: the Settings panel has no session id, and the
789
+ // tracker only knows sessions that have spoken. Fall back to a
790
+ // mounted session, preferring one whose workspace contains the
791
+ // memory store: the sidebar only opens `session/<id>/<relative>`
792
+ // addresses, so a session from another project cannot preview it.
793
+ const normalize = (value) => typeof value === 'string'
794
+ ? value.replace(/\\/g, '/').replace(/\/+$/, '')
795
+ : ''
796
+ const memoryRoot = normalize(currentMemoryDir)
797
+ const cwdOf = (agent) => normalize(agent.session?.header?.cwd)
798
+ const insideStore = (agent) => {
799
+ const dir = cwdOf(agent)
800
+ return dir.length > 0 && (memoryRoot === dir || memoryRoot.startsWith(`${dir}/`))
801
+ }
802
+ return roots.find(insideStore)
803
+ ?? roots.find((agent) => cwdOf(agent).length > 0)
804
+ ?? roots[0]
787
805
  }
788
806
  const sendJson = (status, payload) => {
789
807
  res.writeHead(status, { 'content-type': 'application/json; charset=utf-8' })
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.18.2",
4
+ "version": "0.18.4",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "main": "lib/index.js",