dsh-instruction-memory 1.6.0 → 1.6.1
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 +68 -0
- package/README.md +43 -12
- package/lib/client.js +16 -4
- package/lib/index.js +31 -4
- package/package.json +4 -7
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,74 @@
|
|
|
7
7
|
> 1.0.13 起由 CI 经 OIDC Trusted Publishing 发布(首个带 provenance 的版本)。
|
|
8
8
|
> 这些历史 tag **不应回填**——npm 上的版本号已被占用。
|
|
9
9
|
|
|
10
|
+
## [1.6.1] — 2026-11-18
|
|
11
|
+
|
|
12
|
+
一次针对"桌面端 / 网页端两个宿主"的缺陷审计(架构、授权安全、验收边界三方独立复查 + 代码级复核)
|
|
13
|
+
之后的修复批次。没有新功能:改动集中在**声明与实际不一致**、**失败被静默**、**门禁够不到真实宿主**三类。
|
|
14
|
+
|
|
15
|
+
### 修复(安全)
|
|
16
|
+
|
|
17
|
+
- **`send-feedback` 与 `export-to-dir` 移出只读方法集合**。两者从来不是"读":一个用操作者自己的
|
|
18
|
+
SMTP 账号发信,一个往备份目录落盘。在没有 `connection` 服务的 profile 上,`READ_ONLY_METHODS`
|
|
19
|
+
是写门唯一的豁口,等于允许本机任意进程(含 Android 上任何装了 App 的程序)用用户邮箱发信
|
|
20
|
+
(冷却期内每分钟 2 封)并持续落盘。现在两者与其它写方法一致:无鉴权门时需 `Origin` 或
|
|
21
|
+
`Sec-Fetch-Site: same-origin`。浏览器设置页不受影响。
|
|
22
|
+
- **`reload` 有意留在只读集合**:它只重读磁盘,首次落盘是幂等的;而桌面壳的转发层会剥掉
|
|
23
|
+
`Origin`,把它移出会让"无鉴权门的桌面 profile"上这一按钮直接 403。
|
|
24
|
+
|
|
25
|
+
### 修复(面板行为)
|
|
26
|
+
|
|
27
|
+
- **桌面端导出不再无条件报"已保存"**。`<a download>` + blob 点击后立刻显示成功,而 Electron
|
|
28
|
+
主窗口的 `will-download` 只处理 `#dsh-download=` 前缀的 URL,其余(含 blob)交给默认行为——
|
|
29
|
+
用户取消保存框或下载被策略拦下时,面板和用户都不会知道。文案改为"已请求保存",并说明
|
|
30
|
+
取消 / 被拦时不会产生文件。
|
|
31
|
+
- **导入加了确认**。整库恢复(restore)一直有确认,导入没有;于是别人递来的一份"记忆备份"
|
|
32
|
+
可以静默成为此后每轮注入的指令。现在导入走同一套 `askConfirm`,没有对话框的环境按
|
|
33
|
+
fail-closed 处理(拒绝而不是静默合并)。
|
|
34
|
+
|
|
35
|
+
### 修复(声明与实际不一致)
|
|
36
|
+
|
|
37
|
+
- **删除 `dsh.compatibility.dsh`**。宿主 `dsh-app-boot` 的 `unmetRequirements()` 只读 **顶层**
|
|
38
|
+
`engines.dsh`,缺失则回落 `peerDependencies`(两处都用 `includePrerelease: true` 求值);
|
|
39
|
+
本包 `engines` 只有 `node`,`engines.dsh` 写在 `dsh` 命名空间下,宿主**不读**。
|
|
40
|
+
`dsh.compatibility.dsh` 在已安装运行时树(`dsh-app-boot`、`dsh-client-ui-plugin-manager`、
|
|
41
|
+
`dshmarket`)里 grep 无读取方。三份"逐字节一致"的副本,实际只有 peer 那份生效。
|
|
42
|
+
- **区间补洞**:`>=0.1.5-alpha.1` 作为起点把 `0.1.5-alpha.0` / `0.1.5-0` 漏在区间外,
|
|
43
|
+
改为 `>=0.1.5-0`。`host-range-test.mjs` 矩阵新增这两个版本,并新增
|
|
44
|
+
"`dsh.compatibility.dsh` 必须不存在"断言(防第三份副本长回来)。
|
|
45
|
+
- **桌面端 Origin 围栏的文档说反了**:桌面壳对所有非静态路径调用 `forwardWebRequest()`,
|
|
46
|
+
转发前删除 `host` / `origin` / `cookie` / `sec-fetch-site` 并注入宿主 cookie。因此插件的
|
|
47
|
+
`requestOriginVerdict()` 在桌面端**根本不执行**,桌面端的边界是"回环绑定 + 宿主 cookie"。
|
|
48
|
+
README 与 `TRUSTED_HOSTS` 注释按此更正;旧版"渲染器改用 `dsh-app://` 会整片 403"的推演已被证伪。
|
|
49
|
+
- **Windows 上的 `0o600` 不再被当作权限承诺**:Windows 文件系统忽略 `mode`,文件只是继承目录
|
|
50
|
+
ACL。README 补上 `memory.json` 的 `icacls` 收紧命令(与 `feedback.json` 既有说明对齐)。
|
|
51
|
+
- **反馈披露补齐**:面板声明与真实发送字段对齐(补上界面语言、时区、User-Agent 的说明)。
|
|
52
|
+
|
|
53
|
+
### 修复(测试与门禁)
|
|
54
|
+
|
|
55
|
+
- **新增 `section-order-test.mjs`**:从**已安装宿主**(profile 树优先,其次桌面 `app.asar`)读出
|
|
56
|
+
`SECTION_ORDERS`,断言 `SECTION_ORDER = 950` 未被占用、严格落在 `FILE_REFERENCE(900)` 与
|
|
57
|
+
`TOOL_BASH(1000)` 之间,且紧邻下方仍是 `FILE_REFERENCE`。宿主换表时注入块会静默移位,
|
|
58
|
+
此前没有任何断言兜住。解析兼容 `1e3` 形式的字面量(0.2.2 起宿主用科学计数法写表)。
|
|
59
|
+
- **CI 新增 `host-smoke`(`workflow_dispatch`,self-hosted)**:真实宿主端到端(注入 / SSE /
|
|
60
|
+
路由 / 跨端快照)此前不在任何门禁里,只有 `smoke:hosts` 这个没人记得跑的手动脚本。该作业在
|
|
61
|
+
缺少 `DSH_GUI_URL` / `DSH_GUI_TOKEN` 时打印 notice 并跳过,不会让 fork 变红。
|
|
62
|
+
|
|
63
|
+
### 兼容性
|
|
64
|
+
|
|
65
|
+
- 存储格式不变(`version: 2`)。**唯一的行为收紧**:在没有 `connection` 服务、也没有浏览器
|
|
66
|
+
来源标记的环境里,`send-feedback` 与 `export-to-dir` 现在会被 **403**。让宿主发布
|
|
67
|
+
`connection`(桌面 / 网页端默认如此)或设 `DSH_INSTRUCTION_MEMORY_REQUIRE_AUTH_FENCE=1` 均可。
|
|
68
|
+
- 声明上界仍是 `<0.3.0-0`:0.3.x(含预发布)**不在**声明范围内,宿主升级后本插件会被
|
|
69
|
+
`skipping profile bundle` 跳过。**本次没有放宽**——没有在 0.3.x 上做过任何实测,
|
|
70
|
+
不放宽未验证的声明。
|
|
71
|
+
|
|
72
|
+
### 未做(明确记录,不是"已验证")
|
|
73
|
+
|
|
74
|
+
- 真实宿主上的点击级验证(面板渲染、SSE 重连、导出取消分支)**未执行**:GUI 需 launch token,
|
|
75
|
+
本轮无凭据。`host-smoke` 作业与 token 留给有宿主的环境。
|
|
76
|
+
- 跨进程并发写仍保留"锁超时后继续写"的活性优先策略;契约测试里那条并发用例是进程内模拟。
|
|
77
|
+
|
|
10
78
|
## [1.6.0] — 2026-11-14
|
|
11
79
|
|
|
12
80
|
让「按需(auto)」条目第一次真正有机会被执行。此前的 auto 只在会话开头注入一次、措辞是「参考」,
|
package/README.md
CHANGED
|
@@ -64,9 +64,10 @@ profile 的解析顺序是 **`$DSH_PROFILE_DIR` → `--profile <名字>` → `$D
|
|
|
64
64
|
| `ui-test.mjs` | 设置页行为测试:用一个 ~60 行的 React 垫片真实渲染面板、点按钮/填输入框,再断言注入内容随之变化(不出图、不依赖浏览器) |
|
|
65
65
|
| `verify.mjs` | 装载验证:按 DSH 的方式加载两半,并逐项断言 `memory.schema.json` 与代码中的上限一致 |
|
|
66
66
|
| `smoke-test.mjs` | 注入渲染逻辑的单元测试(含「只渲染激活配置集」的隔离断言与 cwd 红线) |
|
|
67
|
-
| `host-range-test.mjs` | 宿主版本范围契约测试:固定矩阵 × 两种 semver
|
|
67
|
+
| `host-range-test.mjs` | 宿主版本范围契约测试:固定矩阵 × 两种 semver 判定模式,把 `peerDependencies`(**被执行的那个**)与 `dsh.engines.dsh` 锁到同一个生成值,并断言第三处副本 `dsh.compatibility.dsh` **不存在**(1.6.1 删除:宿主不读它,留着只会让人以为"改了这里就放宽了兼容") |
|
|
68
|
+
| `section-order-test.mjs` | 注入位置契约测试:从**已安装宿主**(profile 树优先,其次桌面 `app.asar`)读出 `SECTION_ORDERS`,断言 `SECTION_ORDER = 950` 未被占用、严格落在 `FILE_REFERENCE(900)` 与 `TOOL_BASH(1000)` 之间、且紧邻下方仍是 `FILE_REFERENCE`。宿主换表时注入块会**静默移位**,这条断言是唯一护栏 |
|
|
68
69
|
| `lint.mjs` | 静态门禁,已并入 `npm test`:`node --check` 解析所有随包发布与本仓库运行的 JS 文件,并断言 `lib/` 里不出现 `@deepseek-ai/*` 的包名导入(插件只该通过宿主传进来的上下文对象接触宿主,按包名 import 会把插件钉死在某个安装位置,在 headless / CI / 检出目录里直接解析失败) |
|
|
69
|
-
| `live-host-smoke.mjs` | 双端冒烟(**1.4.8 起宿主有鉴权门,需 `--token <启动 token>` 换会话 cookie**,否则全 401):对**正在运行**的 web / 桌面宿主各测 `state` p50/p95、SSE 首事件、注入注册与字符数,并比对两端快照(除 `injection.pulls` 外须逐字段相同);`npm run smoke:hosts`,`--require-pulls` 可把「从未经历真实 Agent 回合」判为失败。单宿主拓扑(桌面应用自己服务 `11685`)用 `--base http://127.0.0.1:11685`,parity 会**显式跳过**而不是假装比过;`--web` / `--desktop` 各选一端,同时给直接报错、零探测时打印 `NO HOST PROBED` 而不是 `ALL CHECKS PASSED`。**刻意不进 `npm test`**——CI
|
|
70
|
+
| `live-host-smoke.mjs` | 双端冒烟(**1.4.8 起宿主有鉴权门,需 `--token <启动 token>` 换会话 cookie**,否则全 401):对**正在运行**的 web / 桌面宿主各测 `state` p50/p95、SSE 首事件、注入注册与字符数,并比对两端快照(除 `injection.pulls` 外须逐字段相同);`npm run smoke:hosts`,`--require-pulls` 可把「从未经历真实 Agent 回合」判为失败。单宿主拓扑(桌面应用自己服务 `11685`)用 `--base http://127.0.0.1:11685`,parity 会**显式跳过**而不是假装比过;`--web` / `--desktop` 各选一端,同时给直接报错、零探测时打印 `NO HOST PROBED` 而不是 `ALL CHECKS PASSED`。**刻意不进 `npm test`**——CI 没有桌面端。1.6.1 起 CI 另有 `workflow_dispatch` 的 `host-smoke` 作业(self-hosted,读 `DSH_GUI_URL` / `DSH_GUI_TOKEN`);缺凭据时它打印 notice 并跳过,不会让 fork 变红。请求走 Node `http` 直连,绕开 `http_proxy`(否则回环请求也会被代理转发,读数虚高) |
|
|
70
71
|
| `docs/demo.html` | 离线演示页:桩掉 DSH 外壳、加载真实 Client 半渲染设置页(1.5.5 起随 npm 包发布,手机上也能直接打开预演布局) |
|
|
71
72
|
| `memory.schema.json` | 手改存储文件用的 JSON Schema(随包发布,并被宿主复制到 `memory.json` 旁边) |
|
|
72
73
|
|
|
@@ -626,6 +627,18 @@ smtp://用户:密码@smtp.example.com:587?secure=0&from=bot@example.com
|
|
|
626
627
|
文件权限请自行收紧(Windows 可用 `icacls feedback.json /inheritance:r /grant:r "%USERNAME%:R"`)。
|
|
627
628
|
凭据缺失时只报"未配置",不会把已配置的密码回显到页面或日志。
|
|
628
629
|
|
|
630
|
+
> **`memory.json` 同理,而且更值得收紧(1.6.1 更正)**:插件写存储时传的是 `0o600`,
|
|
631
|
+
> 但那只在 **POSIX 上是边界**——Windows 文件系统**忽略 `mode`**,文件只是继承目录 ACL。
|
|
632
|
+
> 也就是说 Windows 上"只有你能读"成不成立,取决于 `%USERPROFILE%` 那条 ACL,而不是插件。
|
|
633
|
+
> 多用户共用一台机器时请自己收一次(先备份,再改):
|
|
634
|
+
>
|
|
635
|
+
> ```
|
|
636
|
+
> icacls "%USERPROFILE%\.dsh\instruction-memory\memory.json" /inheritance:r /grant:r "%USERNAME%:(R,W)"
|
|
637
|
+
> icacls "%USERPROFILE%\.dsh\instruction-memory" /inheritance:r /grant:r "%USERNAME%:(OI)(CI)(F)"
|
|
638
|
+
> ```
|
|
639
|
+
>
|
|
640
|
+
> 面板也不会再暗示"已设为 0600"——那是 `open(…, 0o600)` 的解释器参数,不是 Windows 上的权限事实。
|
|
641
|
+
|
|
629
642
|
### 收件邮箱加密(可选)
|
|
630
643
|
|
|
631
644
|
如果不想让收件邮箱以明文留在 `feedback.json` 里(例如担心截图、误提交或备份泄漏),
|
|
@@ -724,6 +737,14 @@ DNS 重绑定恰好推翻了它**:`evil.com` 解析到 `127.0.0.1` 之后,
|
|
|
724
737
|
`Sec-Fetch-Site` 不是 `cross-site`),本插件不再重复判——重复判会把反代域名全部 403;
|
|
725
738
|
没有门时非回环绑定直接 503,根本走不到这里。
|
|
726
739
|
|
|
740
|
+
**没有 `connection` 时,哪些方法还算"只读"(1.6.1 更正)**:写门把方法分成两拨——只读集合
|
|
741
|
+
(`state`、`history-list`、`read-source`、`export-data`)直接放行,其余一律要求浏览器来源标记
|
|
742
|
+
(`Origin` 或 `Sec-Fetch-Site: same-origin`),否则 403。`export-to-dir` 与 `send-feedback`
|
|
743
|
+
**不在**只读集合里:前者往备份目录写文件,后者用**你自己的 SMTP 账号**发信,两者都是需要来源
|
|
744
|
+
确认的写操作。1.6.0 及以前它们被错放进只读集合,等于让本机任意进程(Android 上则是任何装了
|
|
745
|
+
App 的程序)绕过写门发信。`reload` 仍留在只读集合内,这是有意的:它只重读磁盘、首次落盘幂等,
|
|
746
|
+
而桌面壳转发时会剥掉 `Origin`,移出去会让"重新读取"在无门 profile 上直接 403。
|
|
747
|
+
|
|
727
748
|
### 宿主的鉴权门(connection):非回环绑定没有它就直接拒绝
|
|
728
749
|
|
|
729
750
|
路由挂载后会向宿主申请 `connection` 服务(DSH 的 Web / Go 端都提供,负责把浏览器会话换成
|
|
@@ -797,11 +818,15 @@ nginx / Caddy 等反向代理之后远程访问,需要注意:
|
|
|
797
818
|
> 后,"没有 `connection` 服务"直接变成 **503**,而不再退回"仅回环"。桌面单用户机器上回环还能
|
|
798
819
|
> 当边界用;Android 上不能——整机共享回环命名空间,任何装了 App 的程序都能连 127.0.0.1。
|
|
799
820
|
|
|
800
|
-
>
|
|
801
|
-
>
|
|
802
|
-
>
|
|
803
|
-
>
|
|
804
|
-
>
|
|
821
|
+
> **桌面端为什么看不到 `Origin: dsh-app://app`**(1.6.1 更正;2026-11-18 复核桌面壳源码):
|
|
822
|
+
> 桌面窗口的 document origin 确实是 `dsh-app://app`,但主进程只把固定静态路径当资源,
|
|
823
|
+
> **其余所有路径都经 `forwardWebRequest()` 转发到宿主回环端口**,转发前**删掉 `host` /
|
|
824
|
+
> `origin` / `cookie` / `sec-fetch-site` 四个头**,再注入宿主自己的 cookie
|
|
825
|
+
> (`resources/app/lib/main.js` 的 `forwardWebRequest`)。因此到达本插件的请求**没有 `Origin`**,
|
|
826
|
+
> `requestOriginVerdict()` 里"origin 为空即放行"那一条生效——插件的同源判定在桌面端**根本不执行**。
|
|
827
|
+
> 桌面端的真实边界是**回环绑定 + 宿主 cookie**,不是插件自己的 origin 判定。
|
|
828
|
+
> 上一版这里写的"渲染器若改用 `dsh-app://` 会让设置页整片 403"属于推演,**已被证伪**:该
|
|
829
|
+
> scheme 的请求压根到不了插件路由。若将来壳层不再剥离 `Origin`,这一段需要重验。
|
|
805
830
|
|
|
806
831
|
### 在 DSH Go(Android)上:鉴权来自平台补丁,不是本插件
|
|
807
832
|
|
|
@@ -819,22 +844,28 @@ DSH Go 给官方 Web 服务器包了一层**构建期补丁** `runtime/patches/r
|
|
|
819
844
|
|
|
820
845
|
## 兼容性
|
|
821
846
|
|
|
822
|
-
|
|
847
|
+
同一串范围写在**两处**(1.6.1 删掉了无人读取的第三处),而**宿主只强制其中一处**:
|
|
823
848
|
|
|
824
849
|
| 位置 | 谁读它 | 作用 |
|
|
825
850
|
| --- | --- | --- |
|
|
826
|
-
| **`peerDependencies`**(`@deepseek-ai/dsh-system-prompt`) | **宿主**:`evaluatePluginCompatibility()`(`dsh-app-boot`),在**安装**与 **profile 启动**时执行 | **门禁之一**,不是唯一。1.5.7 起两处实测结论必须同时写在这里:① 门禁读的是**宿主自身版本**(`getDshRuntimeVersion()` → `dsh-app-boot` 的 package.json),并用 `{ includePrerelease: true }` 求值,所以预发布行不会被误判;② 在 `0.2.2-rc.3` 的宿主实现里**存在 `engines.dsh` 时 `peerDependencies` 的区间被忽略**(`dsh-app-boot/src/plugin-compatibility.ts:52`)——也就是说这段 peer
|
|
851
|
+
| **`peerDependencies`**(`@deepseek-ai/dsh-system-prompt`) | **宿主**:`evaluatePluginCompatibility()`(`dsh-app-boot`),在**安装**与 **profile 启动**时执行 | **门禁之一**,不是唯一。1.5.7 起两处实测结论必须同时写在这里:① 门禁读的是**宿主自身版本**(`getDshRuntimeVersion()` → `dsh-app-boot` 的 package.json),并用 `{ includePrerelease: true }` 求值,所以预发布行不会被误判;② 在 `0.2.2-rc.3` 的宿主实现里**存在 `engines.dsh` 时 `peerDependencies` 的区间被忽略**(`dsh-app-boot/src/plugin-compatibility.ts:52`)——也就是说这段 peer 区间可能完全不参与判定,只用来在报错时点名。本仓库仍让两处**逐字节同值**(1.6.1 删掉了无人读取的第三处),就是为了不依赖"到底哪一处生效"。这条已从"真正的门禁"更正:**能证明它生效的只有实测,不能靠读声明推断** |
|
|
827
852
|
| `dsh.engines.dsh` | 插件市场(第三方,服务端读取) | 市场卡片上的兼容性判定与展示 |
|
|
828
|
-
|
|
|
853
|
+
| ~~`dsh.compatibility.dsh`~~ | **1.6.1 已删除**:`dsh-app-boot`、`dsh-client-ui-plugin-manager`、`dshmarket` 全树 grep 无读取方 | 曾经只是人类可读的重复声明,留在包里只会让人以为"改了这里就放宽了兼容" |
|
|
829
854
|
|
|
830
855
|
**1.0.14 之前这里只有后两处,没有 `peerDependencies`**——而宿主的门禁在读到缺失的 `peerDependencies` 时会直接 `return undefined`(`if (!Object.hasOwn(fields, "peerDependencies")) return void 0`),也就是**跳过检查**。换句话说,范围之外的宿主在此之前可以装上而**没有任何拦截或警告**;那串范围当时只是市场元数据,不是门禁。1.0.14 补上 peer 之后,它才真正生效。
|
|
831
856
|
|
|
832
|
-
|
|
857
|
+
同一串范围(两处逐字节一致,由 `host-range-test.mjs` 锁定;第三处 `dsh.compatibility.dsh` 已于 1.6.1 删除):
|
|
833
858
|
|
|
834
859
|
```
|
|
835
|
-
>=0.1.3-alpha.2 <0.1.4 || >=0.1.4-0 <0.1.5-0 || >=0.1.5-
|
|
860
|
+
>=0.1.3-alpha.2 <0.1.4 || >=0.1.4-0 <0.1.5-0 || >=0.1.5-0 <0.1.6-0 || >=0.1.6-alpha.0 <0.1.7-0 || >=0.1.7-alpha.0 <0.2.0-0 || >=0.2.1-alpha.0 <0.3.0-0 || >=0.2.2-alpha.0 <0.3.0-0 || >=0.2.0-0 <0.3.0-0
|
|
836
861
|
```
|
|
837
862
|
|
|
863
|
+
**1.6.1 更正一处机制描述**:上面第 ② 条说的"存在 `engines.dsh` 时 peer 被忽略",读的是
|
|
864
|
+
`package.json` **顶层**的 `engines.dsh`。本包的 `engines` 字段只有 `node`,`engines.dsh` 是写在
|
|
865
|
+
`dsh` 命名空间下的(`dsh.engines.dsh`),宿主**不读**后者。所以在本包当前的写法下,真正生效的
|
|
866
|
+
永远是 `peerDependencies` 那一条;`dsh.engines.dsh` 只是市场卡片用的展示副本。0.1.5 行的下界
|
|
867
|
+
同时从 `>=0.1.5-alpha.1` 改为 `>=0.1.5-0`(旧写法把 `0.1.5-alpha.0` 漏在区间外,是枚举时的一处空洞)。
|
|
868
|
+
|
|
838
869
|
**验证范围与证据等级**——三者不可混为一谈,下面每一行都标了它到底证明了什么:
|
|
839
870
|
|
|
840
871
|
| 等级 | 证明什么 | 覆盖 |
|
package/lib/client.js
CHANGED
|
@@ -273,6 +273,7 @@ window.__ModuleLoader__.load({
|
|
|
273
273
|
'err.httpDetail': '宿主返回 HTTP {status}:{detail}',
|
|
274
274
|
'err.timeout': '请求宿主超时(15 秒无响应)',
|
|
275
275
|
'export.failed': '导出失败:宿主返回了无法识别的数据',
|
|
276
|
+
'import.confirm': '导入会把文件里的配置集、条目与用户形象并入当前记忆:现有内容不会被删除,但你当前的排列会被整体改写。确定继续?',
|
|
276
277
|
'import.notJson': '导入文件不是有效的 JSON({detail})',
|
|
277
278
|
'import.tooLarge': '文件约 {size} MB,远超本插件可导入的规模(约 {limit} MB 以内)。请确认选择的是「导出」生成的 JSON 文件。',
|
|
278
279
|
'editor.new': '新增指令',
|
|
@@ -366,7 +367,7 @@ window.__ModuleLoader__.load({
|
|
|
366
367
|
'profiles.truncatedTitle': '这张形象超过注入字数上限,只有开头进入本轮提示',
|
|
367
368
|
'profiles.omitted': '本轮未包含',
|
|
368
369
|
'profiles.omittedTitle': '这张形象因注入字数上限未进入本轮提示',
|
|
369
|
-
'export.saved': '
|
|
370
|
+
'export.saved': '已请求保存。若保存框被取消、或下载被浏览器/系统拦下,文件不会出现——请重试,或改用下面的「完整 JSON」',
|
|
370
371
|
'export.savedToApp': '已交给 DSH Go 保存:在系统分享面板里选「保存到文件」即可',
|
|
371
372
|
'export.fallbackHint': '当前环境无法触发文件下载,完整 JSON 已放在下面:全选复制后自行保存',
|
|
372
373
|
'export.fallbackClose': '关闭',
|
|
@@ -477,7 +478,7 @@ window.__ModuleLoader__.load({
|
|
|
477
478
|
'feedback.bodyPlaceholder': '复现步骤、期望结果、实际表现;建议请说明使用场景',
|
|
478
479
|
'feedback.contactLabel': '联系方式(可选)',
|
|
479
480
|
'feedback.contactPlaceholder': '邮箱 / 微信 / GitHub 用户名,便于回复你',
|
|
480
|
-
'feedback.hint': '发送时会自动附带插件版本、DSH / Node
|
|
481
|
+
'feedback.hint': '发送时会自动附带插件版本、DSH / Node 版本、运行平台(系统与架构)、界面语言、时区与浏览器标识(User-Agent),不包含你的指令内容。',
|
|
481
482
|
'feedback.send': '发送反馈',
|
|
482
483
|
'feedback.sending': '正在发送…',
|
|
483
484
|
'feedback.clear': '清空',
|
|
@@ -575,6 +576,7 @@ window.__ModuleLoader__.load({
|
|
|
575
576
|
'err.httpDetail': 'Host returned HTTP {status}: {detail}',
|
|
576
577
|
'err.timeout': 'Host request timed out (no response for 15 s)',
|
|
577
578
|
'export.failed': 'Export failed: the host returned unrecognized data',
|
|
579
|
+
'import.confirm': 'Import merges the file’s sets, entries and personas into the current memory: nothing is deleted, but your current arrangement is rewritten. Continue?',
|
|
578
580
|
'import.notJson': 'The import file is not valid JSON ({detail})',
|
|
579
581
|
'import.tooLarge': 'This file is about {size} MB, far beyond what this plugin can import (keep it within about {limit} MB). Make sure you selected a JSON file produced by Export.',
|
|
580
582
|
'editor.new': 'New instruction',
|
|
@@ -668,7 +670,7 @@ window.__ModuleLoader__.load({
|
|
|
668
670
|
'profiles.truncatedTitle': 'This persona exceeds the injection limit; only its head reached this turn',
|
|
669
671
|
'profiles.omitted': 'Not in this turn',
|
|
670
672
|
'profiles.omittedTitle': 'This persona was dropped by the injection limit and did not reach this turn',
|
|
671
|
-
'export.saved': '
|
|
673
|
+
'export.saved': 'Save requested. If you cancelled the dialog or the download was blocked, no file is written — retry, or use the full JSON below',
|
|
672
674
|
'export.savedToApp': 'Handed to DSH Go — pick “Save to Files” in the system share sheet',
|
|
673
675
|
'export.fallbackHint': 'This environment cannot start a file download; the full JSON is below — select all and copy it',
|
|
674
676
|
'export.fallbackClose': 'Close',
|
|
@@ -779,7 +781,7 @@ window.__ModuleLoader__.load({
|
|
|
779
781
|
'feedback.bodyPlaceholder': 'Steps to reproduce, expected result, actual result; for a suggestion, describe the use case',
|
|
780
782
|
'feedback.contactLabel': 'Contact (optional)',
|
|
781
783
|
'feedback.contactPlaceholder': 'Email / WeChat / GitHub handle so the maintainer can reply',
|
|
782
|
-
'feedback.hint': 'The mail automatically includes the plugin version, DSH / Node versions and
|
|
784
|
+
'feedback.hint': 'The mail automatically includes the plugin version, DSH / Node versions, platform (OS and arch), interface locale, time zone and browser User-Agent — never your instruction content.',
|
|
783
785
|
'feedback.send': 'Send feedback',
|
|
784
786
|
'feedback.sending': 'Sending…',
|
|
785
787
|
'feedback.clear': 'Clear',
|
|
@@ -2890,6 +2892,16 @@ window.__ModuleLoader__.load({
|
|
|
2890
2892
|
setError(t('import.notJson', { detail: String(err && err.message ? err.message : err) }))
|
|
2891
2893
|
return
|
|
2892
2894
|
}
|
|
2895
|
+
// 1.6.1: the whole-store restore above asks first; import did not, so
|
|
2896
|
+
// a file someone handed the user could become the instructions
|
|
2897
|
+
// injected into every later turn with no confirmation at all. Same
|
|
2898
|
+
// ask, same fallback semantics: with no dialog available, refuse
|
|
2899
|
+
// rather than merge silently.
|
|
2900
|
+
const askImport = askConfirm(t('import.confirm'))
|
|
2901
|
+
if (askImport !== CONFIRM_YES) {
|
|
2902
|
+
if (askImport === CONFIRM_UNAVAILABLE) setError(t('confirm.unavailable'))
|
|
2903
|
+
return
|
|
2904
|
+
}
|
|
2893
2905
|
await send('import-data', { payload, baseRev: revOf() })
|
|
2894
2906
|
} catch (err) {
|
|
2895
2907
|
setError(String(err && err.message ? err.message : err))
|
package/lib/index.js
CHANGED
|
@@ -171,7 +171,16 @@ const API_PREFIX = '/instruction-memory/api'
|
|
|
171
171
|
* unusable behind a reverse proxy that forwards the public `Host` (nginx's
|
|
172
172
|
* default `proxy_set_header Host $host`). Listing the published hostname here
|
|
173
173
|
* re-opens exactly that one name and nothing else: the loopback rule still
|
|
174
|
-
* applies to everything else
|
|
174
|
+
* applies to everything else.
|
|
175
|
+
*
|
|
176
|
+
* What it does NOT do is weaken the per-request checks — but those checks are
|
|
177
|
+
* narrower than an earlier version of this comment claimed. `Origin` and
|
|
178
|
+
* `Sec-Fetch-Site` exist only when a browser reaches the route directly. The
|
|
179
|
+
* desktop shell forwards every non-static path through `forwardWebRequest`,
|
|
180
|
+
* which deletes `origin`, `sec-fetch-site`, `host` and `cookie` and injects the
|
|
181
|
+
* host's own cookie (resources/app/lib/main.js). On a desktop the origin rule
|
|
182
|
+
* therefore never runs, and the boundary is the loopback bind plus whatever
|
|
183
|
+
* `connection` enforces.
|
|
175
184
|
*/
|
|
176
185
|
const TRUSTED_HOSTS_ENV = 'DSH_INSTRUCTION_MEMORY_TRUSTED_HOSTS'
|
|
177
186
|
/**
|
|
@@ -3152,8 +3161,12 @@ export function apply(ctx, deps = {}) {
|
|
|
3152
3161
|
const existing = await readFile(target, 'utf8').catch(() => null)
|
|
3153
3162
|
if (existing !== source) {
|
|
3154
3163
|
// Atomic like the store itself: a crash mid-copy must not leave a
|
|
3155
|
-
// truncated schema for the user's editor to validate against
|
|
3156
|
-
//
|
|
3164
|
+
// truncated schema for the user's editor to validate against. The 0600
|
|
3165
|
+
// bit matches every other file this plugin writes, and on POSIX that is
|
|
3166
|
+
// the whole story. On Windows `mode` is ignored by the filesystem: the
|
|
3167
|
+
// file simply inherits the directory's ACLs, so the bit is a POSIX
|
|
3168
|
+
// convenience, never a Windows permission boundary. See the icacls note
|
|
3169
|
+
// in the README before treating this store as private on a shared box.
|
|
3157
3170
|
const tmp = target + '.tmp-' + randomUUID()
|
|
3158
3171
|
try {
|
|
3159
3172
|
await writeFile(tmp, source, { encoding: 'utf8', mode: 0o600 })
|
|
@@ -6018,8 +6031,22 @@ export function apply(ctx, deps = {}) {
|
|
|
6018
6031
|
* Set DSH_INSTRUCTION_MEMORY_REQUIRE_AUTH_FENCE=1 to make the whole route fail
|
|
6019
6032
|
* closed instead of falling back to these two rules.
|
|
6020
6033
|
*/
|
|
6034
|
+
/**
|
|
6035
|
+
* Methods that are safe to serve with no gate in front of them: they return
|
|
6036
|
+
* what is already in memory and write nothing the user would not have
|
|
6037
|
+
* written themselves.
|
|
6038
|
+
*
|
|
6039
|
+
* 1.6.1 removed two entries that were never read-only and quietly widened the
|
|
6040
|
+
* fallback above into "any local process may do this without an origin":
|
|
6041
|
+
* `export-to-dir` creates a file in the backup directory, and `send-feedback`
|
|
6042
|
+
* sends mail through the operator's own SMTP account (throttled to one send
|
|
6043
|
+
* per cooldown, but that is a rate limit, not an authorisation). `reload` was
|
|
6044
|
+
* left in on purpose: it re-reads the store and materialises the default one
|
|
6045
|
+
* on first use, which is idempotent, and the panel needs it on a host whose
|
|
6046
|
+
* forwarding layer strips `Origin` (see TRUSTED_HOSTS above).
|
|
6047
|
+
*/
|
|
6021
6048
|
const READ_ONLY_METHODS = new Set([
|
|
6022
|
-
'state', 'history-list', 'read-source', 'export-data',
|
|
6049
|
+
'state', 'history-list', 'read-source', 'export-data',
|
|
6023
6050
|
])
|
|
6024
6051
|
|
|
6025
6052
|
const writeGateRefusal = (method, headers) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-instruction-memory",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "User-only instruction memory for DSH: long-term instructions maintained in the settings UI and auto-injected into every conversation — the plugin registers no model-facing tool, so the model has no in-plugin write path (a same-permission process can still edit the file directly). 指令记忆:只由用户在设置页维护的长期指令,自动注入此后每轮对话;插件不注册任何面向模型的工具,模型没有插件内的写入口。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"node": ">=20"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
|
-
"@deepseek-ai/dsh-system-prompt": ">=0.1.3-alpha.2 <0.1.4 || >=0.1.4-0 <0.1.5-0 || >=0.1.5-
|
|
55
|
+
"@deepseek-ai/dsh-system-prompt": ">=0.1.3-alpha.2 <0.1.4 || >=0.1.4-0 <0.1.5-0 || >=0.1.5-0 <0.1.6-0 || >=0.1.6-alpha.0 <0.1.7-0 || >=0.1.7-alpha.0 <0.2.0-0 || >=0.2.1-alpha.0 <0.3.0-0 || >=0.2.2-alpha.0 <0.3.0-0 || >=0.2.0-0 <0.3.0-0"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@deepseek-ai/dsh-system-prompt": {
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"author": "huangpeiyan",
|
|
66
66
|
"scripts": {
|
|
67
67
|
"lint": "node lint.mjs",
|
|
68
|
-
"test": "node lint.mjs && node host-range-test.mjs && node smoke-test.mjs && node contract-test.mjs && node verify.mjs && node feedback-test.mjs && node ui-test.mjs",
|
|
68
|
+
"test": "node lint.mjs && node host-range-test.mjs && node section-order-test.mjs && node smoke-test.mjs && node contract-test.mjs && node verify.mjs && node feedback-test.mjs && node ui-test.mjs",
|
|
69
69
|
"prepublishOnly": "node check-metadata.mjs && npm test",
|
|
70
70
|
"smoke:hosts": "node live-host-smoke.mjs"
|
|
71
71
|
},
|
|
@@ -81,10 +81,7 @@
|
|
|
81
81
|
"platform": "web"
|
|
82
82
|
},
|
|
83
83
|
"engines": {
|
|
84
|
-
"dsh": ">=0.1.3-alpha.2 <0.1.4 || >=0.1.4-0 <0.1.5-0 || >=0.1.5-
|
|
85
|
-
},
|
|
86
|
-
"compatibility": {
|
|
87
|
-
"dsh": ">=0.1.3-alpha.2 <0.1.4 || >=0.1.4-0 <0.1.5-0 || >=0.1.5-alpha.1 <0.1.6-0 || >=0.1.6-alpha.0 <0.1.7-0 || >=0.1.7-alpha.0 <0.2.0-0 || >=0.2.1-alpha.0 <0.3.0-0 || >=0.2.2-alpha.0 <0.3.0-0 || >=0.2.0-0 <0.3.0-0"
|
|
84
|
+
"dsh": ">=0.1.3-alpha.2 <0.1.4 || >=0.1.4-0 <0.1.5-0 || >=0.1.5-0 <0.1.6-0 || >=0.1.6-alpha.0 <0.1.7-0 || >=0.1.7-alpha.0 <0.2.0-0 || >=0.2.1-alpha.0 <0.3.0-0 || >=0.2.2-alpha.0 <0.3.0-0 || >=0.2.0-0 <0.3.0-0"
|
|
88
85
|
}
|
|
89
86
|
}
|
|
90
87
|
}
|