Repository navigation
feat(plugins): 增加可选的 VeryMath 数学科研插件 - #301
LouisUltra wants to merge 22 commits into
Conversation
e9ea0e4 to
aebf7b0
Compare
按 `docs/proposals/gateway-auth` 的结构重写中英两份提案:状态行开头,然后 目标、接入形态与边界、许可与溯源、验收与证据、收录与待定事项。去掉表格与 加粗堆叠,从 96 行压到 39 行。 同时修正与代码 PR 的口径差异:提案原写 `@louisultra/[email protected]`, 而实现已按 `packages/dsh-verymath` 提交在 ECNU#301(Draft),包名 `@eduwork/ dsh-verymath`、版本 `0.1.0-dev`。现版本说明插件此前以个人 scope 发布、收录后 按本仓库约定迁移并弃用旧包,指向 ECNU#301。 `node scripts/check-source-docs.mjs` 通过,断链与双语配对问题均为零。
以独立包 `packages/dsh-verymath`(`@eduwork/dsh-verymath`)接入 VeryMath 的数学 科研能力,形态参照已合并的 `packages/dsh-external-agents`,不改变发行版默认装配。 包含 16 个技能与 14 个工具:论文结构化阅读与定理依赖图、双语术语库、数学写作与 Beamer 幻灯片、混合整数规划与二次规划(含独立 KKT 与不可行证书验证)、最小二乘、 不变量计算、Lean 补丁验收、研究工作流闸门,以及 Sage 文档查询与 MATLAB 执行。 Python、SageMath、TeX Live、Lean、MATLAB 只做探测,不随包捆绑,缺失时返回结构化 安装提示。 登记与边界: - `scripts/packages/catalog.mjs`、`manage.mjs`:登记包并执行 `check`,包矩阵可安装、 检查、打包。 - `tests/package-maintenance.test.mjs`:包数 12 改为 13;本包与同类 DSH 0.2 包一样 不进入 0.1.x 装配。 - `docs/plugin-catalog.json`:新增目录条目。 - `scripts/check-source-docs.mjs`:3 个逐字节来自上游 MIT 仓库的技能 README 加入既有 的上游白名单;就地翻译会破坏与 `UPSTREAM.json` 所记 commit 的一致。 许可为 `MulanPSL-2.0 AND MIT`,按组件分别适用:原创胶水代码走木兰,改编自上游的 技能内容保持 MIT。`LICENSING.md` 给出路径到许可的映射,`NOTICE.md` 记录逐项改动。 Beamer 模板只调用用户本机 TeX Live 的主题,不分发第三方 `.sty`、`.cls` 或字体。 验证(macOS arm64、本机 Node 24.21.0):`manage.mjs` 的 install 与 check 通过,含 102 项 vitest 测试与 8 项 runtime probe(真实 DSH 插件 API,不调模型);pack 通过 archive 检查(278 个文件、1,440,170 字节,许可齐全、导出产物完整、无禁止路径与机器 路径);包维护与变更选择测试、源码文档检查均通过。 未覆盖:Windows 未测试;MATLAB 与 Sage 执行需用户自备环境;示例仅中文。 对应提案 ECNU#162。
按仓库现有包的写法压缩文档,去掉表格与行内加粗: - 包 README 从 113 行压到 23 行,改为简介、安装与使用、能力边界三段,与 `packages/dsh-external-agents` 的结构一致;详细能力对应关系留在 `docs/capability-examples.md`。 - `DEVELOPMENT.md`、`LICENSING.md` 同样改为散文与要点,去掉表格与加粗, 许可范围按「原创代码走木兰、改编技能保持 MIT」分段说明。 - `docs/PACKAGES.md` 与 `PACKAGES_EN.md` 的源码布局表补上本包。 能力示例文档去掉 46 处行内加粗标签,并把其中记录的 DSH 版本更新为 `0.2.1-rc.5`;示例内容与验证结论未改。 草稿阶段已在本机复跑 `manage.mjs` 的 check 与 pack、包维护测试与源码文档检查, 均通过。
终审指出 NOTICE.md 与包声明冲突:末段写「其余源文件为原创、MIT 许可(见 LICENSE)」,但 LICENSE 是木兰全文、LICENSING.md 也写明原创文件按木兰授权, 两者直接矛盾;此外 NOTICE 仅列了两个上游仓库,与「记录逐项改编」的说法不符。 重写 NOTICE.md:按 7 个 MIT 上游仓库逐项列出收录路径与改编说明,Sagemath-skill 单独说明为 GPLv3 且未收录任何代码,原创文件改标 MulanPSL-2.0 并列出具体目录。 同时删掉「per the review decision」这类评审过程措辞。 其余按终审意见调整:README 首段压缩到五类能力并写明 peer 覆盖 0.2.2-rc.1 但未 在该版本实测、安装步骤合并重复段落、引号改为弯引号、「术语库存写」改为「写入」; DEVELOPMENT 代码块去掉与 check 重复的 build;LICENSING 澄清 test 不含 skills 下 上游自带的 tests;js-yaml 由范围改为精确锁 4.3.2,与仓库锁版本习惯一致。 改后复跑 manage check、manage pack、check-source-docs 均通过。
EduWork 0.4.13 内嵌的 DSH 已到 0.2.2-rc.1,原先对齐的 0.2.1-rc.5 落后。本轮
在 Node 24.22.2 + DSH 0.2.2-rc.1 上重装并逐项验证,同时修掉两处真实不兼容。
依赖:devDependencies 升到 `0.2.2-rc.1`,cordis 4.1.0(0.2.2 要求 ~4.1.0),
schemastery 3.19.0;peer 保持并集写法,覆盖 0.2.1-rc.5 与后续 0.2.x。
不兼容修复(不修则运行探针直接失败):
1. 0.2.2 把工具执行从注册表解耦,执行前必须装载 executor,否则抛
`ToolExecutorUnavailableError`。探针现在挂载 `dsh-tool-executor-native`。
2. 0.2.2 的 `ctx.tools.execute` 改为批量接口:入参 `calls: [{ id, name,
arguments: JSON 字符串 }]`,返回 `{ results: [{ result }] }`;0.2.1.x 仍用
`{ callId, name, arguments }` 单调用。探针按是否装载了 executor 自适应两代
接口,因此两个版本都能跑。
验证(Node 24.22.2):
- DSH 0.2.2-rc.1:类型检查、构建、102 项 vitest、8 项 runtime probe 通过;
archive 检查通过,278 文件、1,434,405 字节。
- DSH 0.2.1-rc.5:runtime probe 同样 8 项通过(回退路径生效)。
- 包维护、变更选择、源码文档三组检查通过。
README 与 DEVELOPMENT 的兼容声明改为实测事实,并写明探针为何需要装载
executor。
beamer 探测原先直接调 `/usr/bin/which` 与 `/Library/TeX/texbin/kpsewhich`: 前者在 Windows 上不存在,后者是 macOS 专有目录,因此 Linux 与 Windows 上 即使装了 TeX 也会把这个工具报成缺件。 改为在进程内解析:先按 PATHEXT 展开后逐个搜 PATH 里的目录,再退回发行版 自己的 bin 目录(macOS 为 `/Library/TeX/texbin`,夹具与 Finder 启动的桌面 应用不继承登录 shell 的 PATH,这一步是它实际生效的场景)。`kpsewhich` 用 同一套解析取到路径后再查 `.sty`,不再假定它与二进制在固定位置。 新增 `test/tool/texprobe.spec.ts` 5 项:命中、缺失、跳过不可执行文件、 多目录取首个、绝对路径直通。实测把 PATH 收窄到 `/usr/bin:/bin` 后, latexmk、xelatex、kpsewhich 三个仍能从兜底目录解析出来。 README 的中英双语「能力边界」同步改成:发现逻辑按 PATH 与 PATHEXT 解析、 不再指向平台固定路径,但仍未在 Windows 上实测。DEVELOPMENT 的测试数 102 更新为 107。
06b95f1 to
ae25123
Compare
提案里的验收证据仍写 102 项 vitest 测试;ECNU#301 上一轮修外部二进制发现时新增 5 项测试,现为 107,两份文件改成同一数字,避免与代码 PR 的口径不一致。 末尾的 Windows 说明一并改准:外部二进制已按 PATH 与 PATHEXT 解析、不再指向 平台固定路径,但 Windows 仍未实测——原文写成「路径与发现逻辑未验证」,与实现 现状不符,也不再说明「未验证到什么程度」。
|
谢谢你把 VeryMath 带到 EduWork!这次补的场景示例很直观。比如从 CSV 建一份课题组术语库、读论文时找出某个定理依赖哪些引理,用户拿到样例就知道可以怎么试了。 关于 PR 里提的几个收录和维护问题,我们的意见是:
整体收录方向我们赞成,目录、技能和示例就按目前的布局继续。 |
|
@freedomkk-qfeng 老师好,谢谢这么快给了明确答复。五条我们都按您说的办:
另外两件情况:
还有一件想确认:这个 PR 现在还是 Draft。如果方向就这么定,我这边可以把它转成 Ready for review,等您那边排期。 |
1) `docs/examples/README.md` 的下载命令用 `mkdir -p papers && cd papers`,产出的是 `papers/fulltext.txt` 与 `papers/paper-treewidth.txt`;但 README 的快速示例与 `capability-examples.md` 的提示词引用的是 `papers/maynard/fulltext.txt` 与 `paper/paper-treewidth.txt`。既然 README 承诺「下面两段可以直接复制到对话里跑」, 路径必须对得上。命令改为直接产出提示词引用的那两个路径(中英两份同步)。 2) `verymath_python_check` 只确认 `python3` 可用,不检查 `PyYAML`。原文 「`verymath_python_check` 会先探测并给安装提示」把探测解释器与探测依赖混为一谈。 改为写明缺 `PyYAML` 时的真实症状(`No module named 'yaml'`)与补救方式 (`pip install PyYAML`)。
术语库写入此前只用「小写英文」当唯一身份,从不生成契约要求的 en__N 别名行: 同一英文的第二种译法会覆盖主译名(实测「群」被「分组」吃掉,两行同义)。 现在按 term_id(纠正)→ 精确 (en, cn) 对(幂等重加)→ 新增别名行 的顺序解析 身份,id 从该英文已知的最大后缀继续分配,且分配器只产出自己读得回来的 id。 同时修掉: - 批量论文结构:单文件校验先拒跨批依赖、Mermaid 只渲染首个文件;只在 main_theorems 里出现的主定理被 top-down 方向丢弃 - 中文精确命中被标成 matchedBy: 'en' - 写入路径复用查询缓存;非 ENOENT 的读失败被当成「空库」,随后写入会覆盖真文档 - 写锁按裸路径加锁,相对/绝对路径并发失效(改用 fs 解析后的 canonical 身份) - upsert 与脚本执行后的缓存失效不覆盖路径别名(同一文档经 symlink 查询会读到旧值) - Sage 探测漏掉 named conda env(新增 VERYMATH_SAGE 覆盖与 <root>/envs/*/bin 扫描) - 探针定时器未清理 测试 107 → 146,runtime probe 8 → 16:新增真实工具路径的 upsert(别名、按 term_id 纠正、整批回滚、路径别名缓存与并发)与 verymath_paper_graph 的跨批 合并、metadata-only 主定理、悬空依赖拒绝。 行为变更:不带 term_id 且换了译名时不再覆盖原译名,而是新增别名行;要改译名 请先查询该行拿到 term_id 再提交。CHANGELOG 与 DEVELOPMENT 已同步说明。
|
@freedomkk-qfeng 老师好,补一轮自查后的修复(提交 修了什么1. 多义术语的译名会被覆盖(数据丢失) 包内 现在:给出 2. 带 3. 其余 中文精确命中曾报 验证
需要留意的一点行为变化不带 另外三条 workflow 仍停在 |
此前本包只有工具与技能,没有任何 client 产物,所以在 DSH web / EduWork 里
看不到入口;带 client 半侧的插件(如 packages 里的问渠)能在侧栏出页签。
机制(读宿主包源码确认):
- `dsh-client-ui-sidebar` 在 root 作用域声明 `sidebar.panellist`(kind: list),
注册 { id, order, label } + 图标组件即多一行;
- 点开时按同一 id 去 `dsh-client-ui-layout` 的 `main`(kind: keyed,root 作用域)
取面板,故主面板注册必须带 key: <同一 id>。
另有一条绕不过的宿主约束:client 插件的包清单按 loader 条目名解析,只有
`/core`、`/tool` 子路径条目时 specifier 解析为 undefined,`dsh.client` 不会被
读取。因此 cordis.patch.yml 增加裸包名条目 `verymath-client`,根入口
src/index.ts 相应变成可挂载的空 apply(保留原有 re-export)。
`scripts/build-client.mjs` 在 bundle id 与包名不一致或语法不通过时让构建失败。
测试:新增 test/client/bundle.spec.ts(4 项)钉住契约——按包名加载、声明
slots 依赖、panellist 与 main 用同一 id 且 main 带 key、只注册这两条。
全量 146 → 150(在 EduWork 0.4.13 / DSH 0.2.2-rc.1 上实测左栏入口与面板均正常)。
上一版面板只能看:环境清单、术语列表、静态依赖图。那对 verymath 没有价值——这些
信息在对话里一句话就能拿到。这一版只做「对话里做起来烦」的事。
术语库
- 可编辑 cn / 词性 / 子领域 / 来源 / 例句,可新增、可删除
- 规则与工具一致:带 term_id 纠正该行(英文必须一致),不带则新增;同一英文的另一
种译法落成 en__N 别名行而不是覆盖;歧义与未知目标按核心报错原样返回;删除后重排
保持 idx 连续
- 新增 POST /api/verymath/glossary/{upsert,delete}:限定工作区、逐文档串行(两次快速
编辑不互相丢更新)、失败一律结构化 JSON
论文图
- 路由返回布局坐标与边,前端用真实元素绘制:点节点看陈述、出入度、是否枢纽/支撑主
定理、直接关系;去掉面板里唯一的 dangerouslySetInnerHTML
环境
- 每条安装提示可一键复制,整套探测结果可导出 Markdown
测试:150 → 172(新增 test/client/panel.spec.tsx 7 项 jsdom 渲染测试、
test/tool/http.spec.ts 15 项路由测试,含写回的编辑/别名/删除/越界/核心拒绝)
顾问两轮审查(服务端/前端)共 7 条,全部修复。 服务端(前两条是真 bug): 1. 面板写入与工具写入用两把独立的锁,同一份 glossary 的并发读改运会互相丢更新。 HttpContext 新增 withWrite,由根入口从 ctx.verymath.withGlossaryWrite 注入; 没有该服务时退回本地链(headless 与测试仍可跑)。 2. 面板写完不失效 ctx.verymath 的查询缓存,对话里的 verymath_glossary_query 会继续读旧值。现在写后调用 invalidateGlossaryCache。 3. python3/latexmk/xelatex/lean 仍是裸名 spawn(只有 sage 走解析),Finder 启动时 面板报 TeX 缺失而工具报可用。现在四项都先解析再 spawn。 4. withinWorkspace 对不存在的目标只做词法比较,链接目录下的新文件可穿出工作区; 改为解析最深的已存在祖先再重拼缺失段。 前端: 5. 删除按钮用了不存在的 S.deleteBtn(样式表只有 S.btnDanger),危险操作没有提示。 6. 刷新时 status 转 loading 会卸载整个术语列表(连带编辑表单),重新挂载时用服务器值 重建草稿、丢掉用户输入。改为 stale-while-revalidate;草稿重置依赖也从 props.term 对象改为 term_id。 7. 补 2 项渲染测试,并做过反向验证(改坏任一处测试会变红)。 验证:typecheck / build / 179 项 vitest / 13 项 runtime probe 全绿(本副本同样 179 项)。
|
@freedomkk-qfeng 老师好,补一轮面板与写入路径的修复(提交 修了什么1. 面板与工具的写入互不相同步(会丢更新、读到旧值) 上一版给插件加了浏览器面板,面板写术语库时用的是自己的一条串行链,而对话里的 现在面板与工具共用同一把锁( 2. 面板与工具对同一台机器给出不同结论 术语库构建需要 TeX / Python / OSQP / Sage / Lean。工具的探测走的是「PATH + 发行版目录 + conda 命名环境」的进程内解析,而面板里这几项仍是裸名 spawn——从 Finder 启动的桌面应用不继承登录 shell 的 PATH,于是面板显示 TeX 缺失、工具却报可用。现在两处共用同一份解析( 3. 面板刷新会丢掉正在编辑的内容 术语库列表在「刷新中」状态时被整个卸载(连带正在编辑的表单),重新挂载时用服务器值重建草稿——用户打到一半的内容就没了。改为 stale-while-revalidate:有旧数据就继续显示,只在首次加载时显示 loading。 4. 工作区路径校验有两个漏洞(面板的写入路由)
5. 面板做成可用编辑器(相对上一版的实质变化)
验证
一点说明这轮改动经顾问两轮独立审查(服务端 / 前端各一轮),共提出 7 条问题,全部修复并复核闭环后才提交。审查里有一条是我自己没想到的:面板与工具对同一台机器结论不一致——因为我在两个地方各写了一份可执行文件解析。 另外三条 workflow 仍停在 |
上游这几天新增了 calendar 三包、windows 安装布局、DSH 运行时升到 0.2.2-rc.3 等 27 个提交,
与本分支在 `scripts/packages/catalog.mjs` 与 `tests/package-maintenance.test.mjs` 上冲突。
两处冲突都与本插件的功能无关,只是同一张包装配表的相邻行与计数:
catalog.mjs
保留上游新增的三个 calendar 条目,把 `dsh-verymath` 追加在数组末尾
(末尾而非中间:下次别人加包时更不容易撞车)。
package-maintenance.test.mjs
计数不能"合数字",必须按上游当前的数组重算:
changedGroups(['scripts/packages/release.mjs']).length 15(上游 14 + 本插件 1)
唯一包名数 16(上游 15 + 1)
测试标题沿用上游去掉数字词的写法,以后加包不必再改标题。
`assembly.externalPackages` 的「不加入 0.1.x 产品」白名单补上 dsh-verymath
(与 dsh-decision、dsh-side-chat 等 DSH 0.2 插件同列)。
本地实测(在合并后的树上):
179 项单元测试全过、typecheck 干净、运行时探针通过;
另外用上游自己的 `scripts/packages/archive.mjs:inspectArchive` 校验了打包产物
(283 个文件,仓库地址/目录/许可三件套/全部 exports 均符合当前门禁),
16 个技能都以 `skills/<name>/SKILL.md` 随包。
…ntext (ECNU#338) Node's WebSocket can take over an idle connection of the global fetch pool, and its events then run in the async context of the request that opened that connection. With the relay on the model gateway's origin that is a model call, made inside dsh-oidc's authorization scope. Every request of a remote device inherited the scope, and once the member signed in again the device's model picker failed with "Gateway authorization changed; start a new model request" (ECNU#333). Open the relay sockets as a WebSocket that dispatches its events in the context it was opened in. Co-authored-by: Feng_Qi <[email protected]>
* feat(auto-approval): review shell sandbox escalations with rules and a decision model
Add the @eduwork/dsh-auto-approval plugin. Under a dedicated permission preset
it reviews bash/pwsh sandbox escalation requests before the client's
confirmation card: fixed rules flag operations the user must have asked for,
and a SystemOne-compatible decision model scores the request. Approved
requests are allowed once; everything else reaches the user unchanged.
Reviews are time-limited, retried once on network errors, 429 and 5xx, and
paused for a session after three failures in a row. The plugin ships
disabled and is not yet part of desktop assembly.
* fix(auto-approval): address first review round
- Record a shell call only after the other pre-execute policies allow it, so a
call a hook asks the user about is never reviewed; skip subagent sessions.
- Track calls per session and drop them on their result; two calls in flight
under one ID are ambiguous and go to the user, and the approval must name
the recorded tool.
- End a review that waits on a stalled Host service within the time limit.
- Take created files from successful write and apply_patch results instead of
call arguments, and read the session up to the last log entry of the
pending call ID.
- Cover these paths with mounted tests and the real Runtime with fs tools.
* fix(auto-approval): address second review round
- Keep the deploy-script pattern linear: the name after the keyword stops at
the next keyword. Rule results are unchanged on the evaluated requests.
- Find a heredoc's end from its own line instead of rescanning the command.
- Hand commands over 16000 characters to the user; the longest evaluated
command had 13010, and the limit bounds the rules' running time.
- Attach a script only when an interpreter runs the file, not for inline code
(node -e, python3 -c, bash -c) or a syntax check (bash -n).
- Track every shell execution by its token: while more than one call with an
ID is in flight, none is reviewed, and a call started during a review stops
its approval.
* fix(auto-approval): address third review round
- Take the workspace from the sandbox policy, whose boundary stays at the
session's starting directory, and keep the current directory (moved by /cd)
as the base for workdir and script paths.
- Do not attach a script run by bare name without an interpreter: the shell
finds it on PATH, not in the current directory.
- Cover both with mounted tests and a real-Runtime test that moves the
session's directory outside the workspace.
* fix(auto-approval): address fourth review round
- Start from the directory the shell tool uses: bash appends workdir and lets
the file system resolve '..' after links, pwsh resolves it; show the real
directory.
- Open a script by its path as written under that directory, so a '..' after
a link reaches the file the shell runs.
- Leave the script out after 'cd -' or cd options; a bare 'cd' goes home.
- Test both with real links; note in the READMEs what the workspace and
current directory fields mean.
* fix(auto-approval): attach a script only for a plain command sequence
The fifth review found more shell forms the directory walk misread: cd with
options and quoted paths, a quoted file name with a space, and cd inside a
pipe or after ||. Instead of modeling each, follow only a plain sequence:
- no script when the command has a pipe or ||;
- cd is followed only to one plain path (quotes must pair); any other cd,
pushd/popd, source, eval, exec, builtin, command, compound commands and
function definitions stop the walk;
- a quoted script name must close its quote.
Other programs before the script still do not move the shell.
* fix(auto-approval): infer a script only from a single bash invocation
The sixth review showed that excluding known shell forms still followed
commands it could not read: variables, comments, unparsed cd arguments,
commands after exit or false, heredoc bodies, and PowerShell's Set-Location.
Replace the directory walk with one positive pattern: the whole bash command
runs a literal path, directly or through an interpreter whose options take no
code, with plain arguments and redirections. Every other form, and every
pwsh command, attaches no script; the command itself is still reviewed. Of
the 693 evaluated requests only 7 carried a script.
* fix(auto-approval): address seventh review round
- Count a decision service abstention (choice: null) as a failure instead of
reading its probabilities; the evaluated answers had none.
- Attach a directly run script only when it has an execute bit; without one
the shell refuses it and nothing runs.
* fix(auto-approval): address eighth review round
- Re-check the session's preset before approving: a session that left the
preset during the review is asked as usual.
- Attach a directly run script only when this process may execute it.
- Keep a quoted ~ literal, as the shell does.
- Attach no script after assignments before the command, such as BASH_ENV,
which can run code before the script.
* fix(auto-approval): attach no script with redirections or '..' in the path
- A redirection can empty the script before the interpreter reads it.
- Node resolves '..' before links while bash and the file system follow the
link first; rather than model each interpreter, a path with '..' attaches
no script.
* fix(auto-approval): attach no script for bash -l, which reads profiles first
* fix(auto-approval): keep carriage returns and Unicode spaces in script names
trim() also removed characters bash treats as part of a word, so a command
naming 'task.sh\r' attached task.sh. Trim only spaces, tabs and newlines.
* fix(auto-approval): attach no script whose name starts with +
bash, sh and zsh parse a leading + as an option, so 'bash +task.sh' runs
nothing.
* fix(auto-approval): approve only while the request is live
Re-check the review's signal with the other conditions before approving, so
a request withdrawn or timed out as the review returns is not answered.
* feat(auto-approval): leave a trajectory notice for each review
Each request reviewed under the preset adds a notice to its call's
result. The trajectory shows its summary with the outcome and score;
the model reads only whether the escalation was allowed automatically
or the user was asked, so it no longer reports an automatic approval as
the user's. The preset name in the examples drops "experimental".
* fix(auto-approval): write the notice in Chinese and stop reviewing after a rejection
The trajectory lists a notice by its text, so the text now says in
Chinese who decided and ends with the call ID; the score stays in the
summary under the notice's source. After the user rejects an
escalation, later escalations in the session go straight to the user
until the user writes again, so a retry is never approved behind a
rejection.
* fix(auto-approval): mark the notice as runtime context, not the user's words
Context reaches the model as a user message, and in a desktop run the
model took the Chinese notice for something the user said. The notice
is now wrapped in reminder tags, as DSH does for its own runtime
context, and says it is not a message from the user.
* fix(auto-approval): keep the model's call ID out of the notice text
The call ID comes from the model and was written inside the reminder
tags as is, so an ID holding a closing tag could move text out of them
and into the user message the model reads. The notice follows its
call's result, so the text now names only the tool.
* fix(auto-approval): flag compact curl send options and PowerShell secret reads
curl lets a short option carry its value directly (-dvalue, -Tfile),
which the upload rule missed, and the credential rule did not see
PowerShell reading a secret environment variable ($env:X_KEY,
Get-Item Env:X_TOKEN). On the 68003 distinct real commands of the
research data only 2 change, neither in the evaluated samples.
* fix(auto-approval): flag a shell expanding a secret variable
The credential rule saw printenv and PowerShell reads of secret
variables but not the plain shell form ("$X_API_KEY", "${X_TOKEN}").
Only upper-case names count: lower-case ones are mostly loop and
template variables. On the 68003 distinct real commands of the research
data 35 more are flagged, none of them in the labeled samples.
* fix(auto-approval): check command substitutions in unquoted heredocs
The rules skipped the body of a heredoc written to a file as text, but
with an unquoted delimiter the shell runs any $(...) or backtick
substitution in it, so an ssh or upload there went unflagged. Such a
body is now checked; plain text and quoted heredocs are still skipped.
No rule result changes on the 68003 distinct real commands of the
research data.
* fix(auto-approval): flag PowerShell's braced secret-variable reads
${env:X_API_KEY} reads an environment variable like $env:X_API_KEY but
was not seen by the credential rule. No rule result changes on the
research data, whose only braced reads are ${env:ProgramFiles}.
* fix(auto-approval): check a heredoc body when text follows its delimiter
The body of a heredoc fed to cat was skipped unless a pipe followed the
delimiter, but only a target written before the delimiter is tracked:
with `cat <<'EOF' > a.sh` the script that was then run went unchecked.
Any shell text after the delimiter now keeps the body. No rule result
changes on the 68003 distinct real commands of the research data.
* fix(auto-approval): say in the notice when a review timed out
A review that runs out of time was recorded as failed like any other
error. In a desktop run the decision service slowed to several seconds
and both reviews timed out; the notice now says so, so the user can
tell a slow service from a sign-in or configuration problem.
* feat(auto-approval): review file-tool escalations and question-card answers
DSH 0.2.2's write, edit and apply_patch request sandbox escalation too, and
those requests went straight to the user. They are now reviewed, shown in
the form the review was evaluated on: write as a quoted heredoc, edit and
apply_patch as a patch, long contents cut. A target-files field gives each
file's real path through the Host file system, whether it exists, the
change, and whether this session created it. The rules judge each change
as the shell command with the same effect on the real path.
A change to a file that was there before the session is approved only
when the model also judges it requested: its score is at most P(approve),
so a small unrequested edit is not let through for being easy to undo.
Answers on ask_user_question cards, in time or after the call timed out,
count as the user's replies to that card.
Writing a login item to ~/Library/LaunchAgents counts as changing
software configuration.
* fix(auto-approval): tie card answers, created files and paths to what runs
- A question card's ID stands for the card only until its first result:
a later call reusing the ID cannot pass its output off as an answer.
- Only a write that made a new file counts as created by the session; a
patch's Add File may replace an existing file and its empty diff basis
does not say otherwise.
- A file counts as the session's own by its real path only, so a path
swapped for a link to an older file is judged as that file.
- The review reads the session directory through ensure, as the tools do
once approved, so a directory that no longer exists resolves to where
the session started in the review as well.
- A move is judged as writing its destination, which flags a login item
or config file whatever characters its name holds.
* feat(auto-approval): keep the opening and the end of a long user message
A user replying to quoted text usually writes their own words last, and the
first 300 characters can hold only the quote. A message over 300
characters now keeps its first 100 and its last 200, with the length left
out noted between them. On the 113 evaluated requests that hold a long
message, this allowed 78 of the 91 that should be allowed (75 with the
first 300 or the last 300 alone) and none of the 22 that should be asked.
* fix(auto-approval): ask when the directory goes during a review; cut by character
- If the session's directory goes while the review waits, the tool will
resolve its paths from where the session started, and a relative path
with `..` can then lead somewhere other than what was reviewed. The
directory is read again before approving; a change goes to the user.
- A long user message is cut by character, so an emoji is neither split
nor counted twice.
* fix(auto-approval): read the directory last inside the review
The directory read added in 70f48f6 came after the timed review: a stalled
file system could hold the approval past the time limit, a failure there
reset the failure count before it was counted, and the preset and the
call ID were checked before it rather than after. The read is now the
last step of review(), inside the race with the time limit and the
failure count, and the checks that follow it are synchronous.
* fix(auto-approval): give a review 10 seconds by default
The decision service at times takes 3-6 s for one review; with a 5 s limit,
half of the reviews on a slow afternoon went to the user only for timing out.
* feat(auto-approval): show an icon for the preset in the permission menu
DSH draws icons only for its four built-in presets, from a fixed table
(0.2.2-rc.3 too). A client part adds one for the auto-approval preset on
the page: on the permission control while the preset is selected, and in
the composer's permission menu, told from other menus by its items, one
for each preset in DSH's permission catalog, as a copy of a sibling
item's icon slot. It changes nothing of DSH's, and adds no icon where the
page is not as expected, DSH draws one of its own, or another preset has
the same name.
* fix(auto-approval): say when sign-in or a key is missing
Without organization sign-in or a decision service key, a review was
recorded as a plain failure, and three of them paused review for five
minutes, so the trajectory showed neither the cause nor, once signed in,
any review for a while. Nothing is asked of the service then: the notice
now names the missing sign-in or key, and neither counts towards the
pause.
* revert(auto-approval): leave the preset's icon to the desktop assembly
The client part added the preset's icon to the page: it watched the
whole document and told the permission menu by its items, its places
and its labels. DSH's permission menu and control take their icons
from one table, so a product that assembles DSH's permission UI can add
the preset to that table instead, with its build failing when the table
changes. The icon moves to the desktop assembly, and the plugin is back
to reviewing escalations only.
This reverts commit 819a75b.
* chore(auto-approval): check against the DSH 0.2.2-rc.3 Runtime
Main now locks DSH 0.2.2-rc.3, and the package workflows install that
Runtime, so the plugin's checks, including the approval flow on the
real Runtime, run on it too and pass.
* fix(auto-approval): read scripts by drive-letter paths on Windows
DSH mounts the bash tool only on POSIX hosts by default, but the plugins
page can enable it on Windows, where Git Bash then runs the command. There
scriptOf() missed a path with a drive letter, so the model saw
`bash D:/scripts/report.py` without the script. A drive letter is now part
of the path. A path starting with `/`, or with `~` outside quotes, depends
on the bash that PATH finds (Git Bash's own root and home, or WSL's): read
as a Windows path it can name another file, so none is attached there.
On Windows 6 of the 38 checks failed: expected paths hard-coded "/",
where the plugin joins a bash workdir with the platform separator as the
bash tool does and the file system returns paths with "\"; two directory
links needed a privilege Windows grants only to administrators or in
developer mode. The checks now expect the separator the code uses, link
with a junction, which needs no privilege, and expect Windows to drop
`link\..` from a workdir before following the link, as it does when it
starts the shell. The execute-bit check runs only where files have one;
a Windows check covers the paths left out there.
* ci(packages): also check dsh-auto-approval on Windows
The plugin resolves the host's paths for the files a call changes, for
the directory a shell starts in and for the script a command runs, so a
Linux run alone does not show whether it works on Windows. The selection
now lists each check job with its runner, and the package check matrix
runs dsh-auto-approval on windows-latest as well. Packing and the
uploaded archive stay on Linux, as for publication.
* chore: refresh the source receipt
* fix(auto-approval): approve nothing once the user rejects, even mid-review
A request whose review started before the user rejected another escalation
was still approved when its score came back. Check for the rejection again
before approving, as for the other conditions, so that until the user writes
again every escalation goes to them.
* fix(auto-approval): ask the user when a target file cannot be checked
Any lstat error counted as a missing file, so a file behind a permission
error was reviewed as a new one, without the stricter score for changing an
existing file. Only ENOENT now means missing; any other error hands the
request to the user, with the reason in the notice, and like a missing
sign-in it does not count towards a pause.
* chore: refresh the source receipt
* fix(auto-approval): ask the user when the file system cannot resolve a target
The file system resolves a path through realpath before the plugin checks
the file, so a directory the Host cannot enter fails there (FS_PERMISSION_DENIED
on rc.3, EACCES on rc.1) and was counted as a review failure towards a pause.
A resolution failure now hands the request to the user like a failed check,
tested on the locked Runtime's own file system. Permission tests are skipped
for root, which directory permissions do not bind.
* fix(auto-approval): hold back on every rejection, even one during a review
A rejection was recorded only for requests the plugin had reviewed, so one
rejected under another preset, or from a tool it does not review such as a
program's own escalation, left the next request to be approved. Every
rejection in the session now counts. Each is a new record taken before the
review and compared before approving, so a request under review when the
user rejects another goes to them even if they have written since.
* chore: refresh the source receipt
* fix(auto-approval): ignore a rejection that comes after the request was withdrawn
DSH returns `cancelled` once a request is withdrawn, but the answerer's own
reply can still arrive later, for example over ACP, which passes no signal
to the client. Such a rejection answered nothing, yet it held back the
reviews after the user's next message. Only a rejection of a request still
open now counts. The README now says that requests the plugin does not
review still go through DSH's approval, and that rejecting them counts too.
* chore: refresh the source receipt
* docs(auto-approval): name who rejects when a rejection holds back the review
* chore: refresh the source receipt
* feat(bootstrap): adopt Skills defaults when retiring a configuration-only feed * build: refresh verified source receipt for Skills migration * fix(content): keep configuration updates usable when Skills are opted out
本 PR 增加可选包
@eduwork/dsh-verymath,提供 VeryMath 的 16 个数学科研技能与 14 个工具。对应提案 #162,目前为 Draft,收录形式见文末。提供的能力
16 个技能与 14 个工具,按方向分七组:
每个技能的完整名称与工具对应关系写在包内 README。
架构与边界
packages/dsh-verymath,形态参照已合并的packages/dsh-external-agents。lib/与node_modules/不入库,构建由npm run check产出。cordis.patch.yml只做独立挂载,不改变发行版默认装配。同步在scripts/packages/catalog.mjs、manage.mjs登记,包矩阵可安装、检查、打包;源码布局表补进docs/PACKAGES.md与PACKAGES_EN.md。docs/plugin-catalog.json不改:该目录要求与公版实际 npm 装配输入一一对应,本包与同类 DSH 0.2 包一样不进入 0.1.x 装配,登记进去会与scripts/project-plugin-catalog.test.mjs的断言冲突。MulanPSL-2.0 AND MIT,表示按组件分别适用:原创胶水代码走木兰;改编自 VeryMath 的技能内容保持 MIT,UPSTREAM.json记录的 8 个上游仓库中 7 个为 MIT,另有 1 个 GPLv3 仓库只作接口参考、未收录任何代码。LICENSING.md给出路径到许可的映射,NOTICE.md记录逐项改动。math-beamer的.tex模板只调用用户本机 TeX Live 的 Beamer 主题,不随包分发第三方.sty、.cls或字体。验证
本轮在 macOS(Apple Silicon)、Node 24.22.2 上完成。依赖为 DSH
0.2.2-rc.1(EduWork 0.4.13 内嵌版本)、cordis4.1.0、schemastery3.19.0,DSH 的 peer 范围为>=0.2.1-rc.5 <0.3.0-0 || 0.2.2-rc.1,并在0.2.1-rc.5上回退验证过。manage.mjs install后跑check:类型检查、构建、107 项 vitest 测试、runtime probe 通过。probe 挂载真实的服务、工具与技能注册表,用合成工作区执行全部工具,不调用模型、不访问网络,8 项检查全部通过。manage.mjs pack:archive 检查通过,278 个文件、1,436,432 字节;许可文件齐全,每个导出产物都在包内,无禁止路径、机器路径与凭据形态内容。scripts/project-plugin-catalog.test.mjs)保持通过;新包按同类 DSH 0.2 包处理,不进入 0.1.x 装配。升级到 0.2.2-rc.1 时修掉两处真实不兼容,不修则运行探针直接失败:
ToolExecutorUnavailableError;探针现在挂载dsh-tool-executor-native。ctx.tools.execute改为批量接口(入参calls数组、arguments为 JSON 字符串,返回results),0.2.1.x 仍是单调用。探针按是否装载 executor 自适应两代接口,因此两个版本都能跑。此前还有三处:两个与 cordis 冲突且未被引用的开发依赖、源码里旧作用域的自引用别名、目录调整后失效的测试导入路径。
另外修掉一处会造成跨平台误报的实现问题:
verymath_beamer_check原先直接调/usr/bin/which与/Library/TeX/texbin/kpsewhich。前者在 Windows 上不存在,后者是 macOS 专有目录,结果是 Linux 与 Windows 上即使装了 TeX,这个工具也会把工具链报成缺件。现改为在进程内解析:按PATHEXT展开后逐个搜PATH里的目录,再退回发行版自己的 bin 目录(macOS 为/Library/TeX/texbin;从 Finder 启动的桌面应用不继承登录 shell 的PATH,这一步是它实际生效的场景)。kpsewhich用同一套解析取到路径后再查.sty,不再假定它与二进制在固定位置。新增 5 项测试锁定解析行为(命中、缺失、跳过不可执行文件、多目录取首个、绝对路径直通);把PATH收窄到/usr/bin:/bin后,latexmk、xelatex、kpsewhich 三个仍能从兜底目录解析出来。未覆盖:Windows 仍未测试——二进制发现已按
PATH与PATHEXT实现、不再指向平台固定路径,但未在 Windows 上实测,README 的中英双语「能力边界」按此措辞写明;MATLAB 执行需要用户自备环境,未做实际执行验收;能力示例目前只有中文。CI 工作流尚未运行(fork PR 待维护者批准),以上本地检查通过不代表远端 CI 已通过。兼容性与后续事项
以下需要维护者给方向,代码里按最保守的默认实现:
packages/dsh-verymath,还是应放dsh-plugins/@eduwork的 npm 发布由谁执行、需要什么权限skills/(打包后 1.37 MB),还是迁到仓库dsh-skills/docs/capability-examples.md)放包内还是仓库文档树@louisultra/dsh-verymath已在 npm 公开(当前0.3.3,含本轮的包根入口与跨平台二进制发现修复),何时 deprecate 并指向新包0.1.0-dev是否合适