@louisultra/dsh-verymath 0.3.2 → 0.3.3
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 +45 -0
- package/README.md +8 -3
- package/README_EN.md +8 -3
- package/lib/index.d.ts +20 -0
- package/lib/index.js +20 -0
- package/lib/tool/index.d.ts +9 -0
- package/lib/tool/index.js +68 -19
- package/package.json +25 -24
- package/skills/after-ocr/tests/test_scripts.py +0 -84
- package/skills/lean-formalization/lean-runtime/tests/fixtures/after_bad.lean +0 -4
- package/skills/lean-formalization/lean-runtime/tests/fixtures/after_statement_changed.lean +0 -4
- package/skills/lean-formalization/lean-runtime/tests/fixtures/before.lean +0 -4
- package/skills/lean-formalization/lean-runtime/tests/fixtures/failure.lean +0 -7
- package/skills/lean-formalization/lean-runtime/tests/test_check_lean_project.py +0 -59
- package/skills/lean-formalization/lean-runtime/tests/test_cli.py +0 -377
- package/skills/lean-formalization/lean-runtime/tests/test_common_config.py +0 -84
- package/skills/lean-formalization/lean-runtime/tests/test_configure_lean.py +0 -138
- package/skills/lean-formalization/lean-runtime/tests/test_detect_sorry.py +0 -24
- package/skills/lean-formalization/lean-runtime/tests/test_direct_task.py +0 -69
- package/skills/lean-formalization/lean-runtime/tests/test_numina_runtime.py +0 -168
- package/skills/lean-formalization/lean-runtime/tests/test_validate_patch.py +0 -29
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,51 @@
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
|
|
5
5
|
|
|
6
|
+
## [0.3.3] - 2026-11-08
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- The package root entry did not exist: `main`, `types` and `exports["."]`
|
|
11
|
+
all pointed at `lib/index.js`, but there was no `src/index.ts`, so `tsc`
|
|
12
|
+
only ever emitted `lib/core/` and `lib/tool/`. The file was missing from the
|
|
13
|
+
published 0.3.0, 0.3.1 and 0.3.2 tarballs, so `import '@louisultra/dsh-verymath'`
|
|
14
|
+
failed for anyone using the package by name. DSH loads the `./core` and
|
|
15
|
+
`./tool` subpaths, which is why this never showed up in use. A re-export-only
|
|
16
|
+
entry is added and verified to be inside the packed tarball.
|
|
17
|
+
- `verymath_beamer_check` shelled out to `/usr/bin/which` and
|
|
18
|
+
`/Library/TeX/texbin/kpsewhich`. The former does not exist on Windows and the
|
|
19
|
+
latter is a macOS-only directory, so a Linux or Windows host reported a
|
|
20
|
+
missing TeX toolchain even with TeX installed. Binaries are now resolved
|
|
21
|
+
in-process by scanning `PATH` (honouring `PATHEXT` on Windows) and falling
|
|
22
|
+
back to the distribution's own bin directory, which is what a desktop app
|
|
23
|
+
launched from Finder needs because it does not inherit the login shell
|
|
24
|
+
`PATH`. `kpsewhich` is resolved the same way instead of assuming a fixed
|
|
25
|
+
location. Covered by five new tests.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- Development dependencies moved to DSH `0.2.2-rc.1`, cordis `4.1.0` and
|
|
30
|
+
schemastery `3.19.0`, matching the version EduWork 0.4.13 bundles. The
|
|
31
|
+
runtime probe is now the dual-version variant: it mounts
|
|
32
|
+
`dsh-tool-executor-native` when present and drives the 0.2.2 batch
|
|
33
|
+
`ctx.tools.execute` API, falling back to the 0.2.1 single-call shape
|
|
34
|
+
otherwise. `npm run test:runtime` therefore exercises the host version that
|
|
35
|
+
users actually run rather than the previous 0.2.0-rc.2 pin.
|
|
36
|
+
- Two unreferenced development dependencies that conflicted with cordis 4.1.0
|
|
37
|
+
(`cordis-plugin-include`, `cordis-plugin-loader`) are removed.
|
|
38
|
+
- `engines.node` raised to `>=24.22.1` and the peer range starts at
|
|
39
|
+
`0.2.1-rc.5`, matching what is actually tested.
|
|
40
|
+
|
|
41
|
+
### Documentation
|
|
42
|
+
|
|
43
|
+
- The skill table in both READMEs listed 15 of the 16 bundled skills; it was
|
|
44
|
+
missing `osqp-solver`, which the tool table already documented.
|
|
45
|
+
- `docs/integration-matrix.md` is repository research material that `files`
|
|
46
|
+
deliberately excludes, but the READMEs linked it by relative path, so the
|
|
47
|
+
link was broken in an installed package. It now points at the repository URL
|
|
48
|
+
and says it is not shipped.
|
|
49
|
+
- `docs/glossary-coverage-gap.md` listed 68 tests; the suite has 107.
|
|
50
|
+
|
|
6
51
|
## [0.3.2] - 2026-10-19
|
|
7
52
|
|
|
8
53
|
### Fixed
|
package/README.md
CHANGED
|
@@ -42,12 +42,13 @@
|
|
|
42
42
|
| `least-squares` | 最小二乘拟合与参数估计(OLS/WLS/正则化/非线性/贝叶斯,12 级降级链)。 | [AI4Math-Computational-Mathematics](https://github.com/VeryMath/AI4Math-Computational-Mathematics) |
|
|
43
43
|
| `invariant-computation` | 代数/拓扑/几何不变量的计算路由与证据报告(审批式环境安装)。 | [AI4Math-Computational-Mathematics](https://github.com/VeryMath/AI4Math-Computational-Mathematics) |
|
|
44
44
|
| `mixed-integer-programming` | MILP 建模求解:背包/指派等实测示例(PuLP+CBC)+ 恢复的上游 LP 示例。 | [AI4Math-Optimization](https://github.com/VeryMath/AI4Math-Optimization)(已修复错版示例) |
|
|
45
|
+
| `osqp-solver` | 凸二次规划的求解与验证:状态门、独立 KKT 检查与不可行证书(需 osqp Python 栈)。 | [AI4Math-Optimization](https://github.com/VeryMath/AI4Math-Optimization) |
|
|
45
46
|
| `matlab-runner` | MATLAB 执行路由/安全/报告层——经 MathWorks 官方 MCP server 驱动本机 MATLAB(需用户自装 MATLAB + license)。 | [AI4Math-MathTool](https://github.com/VeryMath/AI4Math-MathTool) |
|
|
46
47
|
| `math-beamer` | 数学 Beamer 幻灯片:23 模板包(中英/学科分类)、4 闸门引导流程、slide-source-ledger 溯源。 | [AI4Math-Writing](https://github.com/VeryMath/AI4Math-Writing) |
|
|
47
48
|
| `lean-formalization` | Lean 4 形式化、证明修复、sorry 补全与 patch 审查(编码代理优先,GB 级工具链留在用户机器)。 | [AI4Math-Lean-Agents](https://github.com/VeryMath/AI4Math-Lean-Agents) |
|
|
48
49
|
| `lean-setup` | Lean/elan/lake/mathlib 工作区的检测、安装引导与两级就绪度报告。 | [AI4Math-Lean-Agents](https://github.com/VeryMath/AI4Math-Lean-Agents) |
|
|
49
50
|
|
|
50
|
-
> 暂缓接入(理由与升级路径见 `docs/integration-matrix.md
|
|
51
|
+
> 暂缓接入(理由与升级路径见 [`docs/integration-matrix.md`](https://github.com/LouisUltra/dsh-verymath/blob/main/docs/integration-matrix.md),该文件是仓库内的调研材料,不随 npm 包分发):Sagemath-skill 技能本体(GPLv3;查询能力已按
|
|
51
52
|
> 评审结论以干净房间 TS 重实现,语料独立分发)、paper-to-skill 全链(MinerU 云 API 隐私考量;本地 mineru 可选)、
|
|
52
53
|
> agent-laboratory-workflow(外部 LLM API+重部署)、scientific-computing-reproduction(Codex 生态耦合,零依赖脚本按需摘取)、
|
|
53
54
|
> co-mathematician(独立 App,仅提炼概念)、textbook-copilot(Apache-2.0 独立应用)。
|
|
@@ -56,7 +57,7 @@
|
|
|
56
57
|
|
|
57
58
|
## 安装与使用
|
|
58
59
|
|
|
59
|
-
要求 Node.js `24.
|
|
60
|
+
要求 Node.js `24.22.1+` 与 DSH `0.2.x`:peer 覆盖 `0.2.1-rc.5` 到 `0.2.x` 并显式包含 `0.2.2-rc.1`,开发依赖锁定 `0.2.2-rc.1`。运行探针会检测宿主是否装载了工具执行器,据此自适应 0.2.1 的单调用与 0.2.2 的批量接口。
|
|
60
61
|
|
|
61
62
|
```sh
|
|
62
63
|
dsh plugin --profile <你的profile> add @louisultra/dsh-verymath
|
|
@@ -77,7 +78,11 @@ dsh plugin --profile <你的profile> add ./louisultra-dsh-verymath-<version>.tgz
|
|
|
77
78
|
|
|
78
79
|
- **查询与论文校验**:无需任何外部依赖。
|
|
79
80
|
- **术语库构建/导出**(`verymath_glossary_build`):需要本地 Python 3 与上游脚本依赖(`PyYAML`;Excel 导出另需 `openpyxl`,Web 管理界面另需 `Flask`)。缺失时先用 `verymath_python_check` 检查并按提示安装;插件不捆绑 Python。
|
|
80
|
-
- **平台**:仅在 macOS(Apple Silicon)验证过(DSH CLI 沙箱 + EduWork 0.4.3 桌面端实际装载)。**Windows 未测试**:代码依赖 Node 与 Python 的 PATH
|
|
81
|
+
- **平台**:仅在 macOS(Apple Silicon)验证过(DSH CLI 沙箱 + EduWork 0.4.3 桌面端实际装载)。**Windows 未测试**:代码依赖 Node 与 Python 的 PATH;外部二进制按 PATH 与 PATHEXT 解析(不再指向 macOS 固定路径),但未在 Windows 上实测,涉及 TeX、MATLAB、osqp 等外部环境的场景尤其如此。
|
|
82
|
+
|
|
83
|
+
## 持续集成
|
|
84
|
+
|
|
85
|
+
`.github/workflows/check.yml` 在每次 push / PR 时跑 `typecheck → build → test → runtime probe`(GitHub Actions,Node 24)。
|
|
81
86
|
|
|
82
87
|
## 从源码开发
|
|
83
88
|
|
package/README_EN.md
CHANGED
|
@@ -40,12 +40,13 @@
|
|
|
40
40
|
| `least-squares` | Least-squares fitting and parameter estimation (OLS/WLS/regularized/nonlinear/Bayesian, 12-tier degradation). | [AI4Math-Computational-Mathematics](https://github.com/VeryMath/AI4Math-Computational-Mathematics) |
|
|
41
41
|
| `invariant-computation` | Routing and evidence reporting for algebraic/topological/geometric invariant computation (approval-gated installs). | [AI4Math-Computational-Mathematics](https://github.com/VeryMath/AI4Math-Computational-Mathematics) |
|
|
42
42
|
| `mixed-integer-programming` | MILP modeling and solving: tested knapsack/assignment examples (PuLP+CBC) + restored upstream LP examples. | [AI4Math-Optimization](https://github.com/VeryMath/AI4Math-Optimization) (broken examples repaired) |
|
|
43
|
+
| `osqp-solver` | Convex QP solving and verification: status gate, independent KKT check and infeasibility certificates (needs the osqp Python stack). | [AI4Math-Optimization](https://github.com/VeryMath/AI4Math-Optimization) |
|
|
43
44
|
| `matlab-runner` | MATLAB execution routing/safety/reporting layer — drives local MATLAB via the official MathWorks MCP server (requires user-installed MATLAB + license). | [AI4Math-MathTool](https://github.com/VeryMath/AI4Math-MathTool) |
|
|
44
45
|
| `math-beamer` | Mathematical Beamer slide decks: 23 template packs (bilingual, per-field), 4-gate guided workflow, slide-source-ledger provenance. | [AI4Math-Writing](https://github.com/VeryMath/AI4Math-Writing) |
|
|
45
46
|
| `lean-formalization` | Lean 4 formalization, proof repair, sorry completion, and patch review (coding-agent-first; the GB-scale toolchain stays on the user machine). | [AI4Math-Lean-Agents](https://github.com/VeryMath/AI4Math-Lean-Agents) |
|
|
46
47
|
| `lean-setup` | Lean/elan/lake/mathlib workspace detection, install guidance, and two-level readiness reporting. | [AI4Math-Lean-Agents](https://github.com/VeryMath/AI4Math-Lean-Agents) |
|
|
47
48
|
|
|
48
|
-
> Deferred (rationale and upgrade paths in `docs/integration-matrix.md`): Sagemath-skill skill body (GPLv3; route-a
|
|
49
|
+
> Deferred (rationale and upgrade paths in [`docs/integration-matrix.md`](https://github.com/LouisUltra/dsh-verymath/blob/main/docs/integration-matrix.md), repository research material that is not shipped in the npm package): Sagemath-skill skill body (GPLv3; route-a
|
|
49
50
|
> clean-room TS lookup shipped, corpus distributed separately), paper-to-skill chain (MinerU cloud-API privacy; local mineru optional), agent-laboratory-workflow (external LLM API + heavy deploy),
|
|
50
51
|
> scientific-computing-reproduction (Codex ecosystem coupling; zero-dep scripts extractable on demand),
|
|
51
52
|
> co-mathematician (standalone app; concepts only), textbook-copilot (Apache-2.0 standalone app).
|
|
@@ -54,7 +55,7 @@ Skills carry the methodology; tools carry deterministic execution. The plugin co
|
|
|
54
55
|
|
|
55
56
|
## Installation and usage
|
|
56
57
|
|
|
57
|
-
Requires Node.js `24.
|
|
58
|
+
Requires Node.js `24.22.1+` and DSH `0.2.x`: the peer range covers `0.2.1-rc.5` through `0.2.x` and names `0.2.2-rc.1` explicitly, and the development dependencies pin `0.2.2-rc.1`. The runtime probe detects whether the host mounted a tool executor and adapts to the 0.2.1 single-call and 0.2.2 batch interfaces accordingly.
|
|
58
59
|
|
|
59
60
|
```sh
|
|
60
61
|
dsh plugin --profile <your-profile> add @louisultra/dsh-verymath
|
|
@@ -75,7 +76,11 @@ Then just ask in a session, e.g. "look up the Chinese term for manifold" or "rea
|
|
|
75
76
|
|
|
76
77
|
- **Query and paper validation**: no external dependencies.
|
|
77
78
|
- **Glossary build/export** (`verymath_glossary_build`): requires a local Python 3 plus the upstream script dependencies (`PyYAML`; Excel export additionally needs `openpyxl`, the web UI needs `Flask`). Check availability with `verymath_python_check` first and install per its hints; the plugin does not bundle Python.
|
|
78
|
-
- **Platforms**: verified on macOS (Apple Silicon) (DSH CLI sandbox + the EduWork 0.4.3 desktop app itself); Windows should work (Node and Python on PATH) but is not yet tested —
|
|
79
|
+
- **Platforms**: verified on macOS (Apple Silicon) (DSH CLI sandbox + the EduWork 0.4.3 desktop app itself); Windows should work (Node and Python on PATH) but is not yet tested — external binaries are now resolved through PATH and PATHEXT rather than a macOS-only path, though that has not been exercised on Windows. Feedback welcome.
|
|
80
|
+
|
|
81
|
+
## Continuous integration
|
|
82
|
+
|
|
83
|
+
`.github/workflows/check.yml` runs `typecheck → build → test → runtime probe` on every push and pull request (GitHub Actions, Node 24).
|
|
79
84
|
|
|
80
85
|
## Developing from source
|
|
81
86
|
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeryMath capability plugin for DSH — package entry.
|
|
3
|
+
*
|
|
4
|
+
* The bundle mounts two modules through `cordis.patch.yml`:
|
|
5
|
+
* `./core` (the `ctx.verymath` service: glossary, paper, graph, gates, Sage)
|
|
6
|
+
* and `./tool` (the 14 model-facing tools). This module re-exports both so an
|
|
7
|
+
* `import '@louisultra/dsh-verymath'` gets the same surface as the subpaths.
|
|
8
|
+
*
|
|
9
|
+
* Without this module the package root declared in `package.json` (`main`,
|
|
10
|
+
* `types` and `exports["."]` → `lib/index.js`) is emitted by no build and
|
|
11
|
+
* importing the package by name fails, even though DSH itself loads the
|
|
12
|
+
* `./core` and `./tool` subpaths and therefore never noticed.
|
|
13
|
+
*
|
|
14
|
+
* Upstream: VeryMath AI4Math repositories (MIT). See NOTICE.md and
|
|
15
|
+
* UPSTREAM.json for per-repository provenance.
|
|
16
|
+
*
|
|
17
|
+
* @module @louisultra/dsh-verymath
|
|
18
|
+
*/
|
|
19
|
+
export * as core from './core/index.ts';
|
|
20
|
+
export * as tool from './tool/index.ts';
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VeryMath capability plugin for DSH — package entry.
|
|
3
|
+
*
|
|
4
|
+
* The bundle mounts two modules through `cordis.patch.yml`:
|
|
5
|
+
* `./core` (the `ctx.verymath` service: glossary, paper, graph, gates, Sage)
|
|
6
|
+
* and `./tool` (the 14 model-facing tools). This module re-exports both so an
|
|
7
|
+
* `import '@louisultra/dsh-verymath'` gets the same surface as the subpaths.
|
|
8
|
+
*
|
|
9
|
+
* Without this module the package root declared in `package.json` (`main`,
|
|
10
|
+
* `types` and `exports["."]` → `lib/index.js`) is emitted by no build and
|
|
11
|
+
* importing the package by name fails, even though DSH itself loads the
|
|
12
|
+
* `./core` and `./tool` subpaths and therefore never noticed.
|
|
13
|
+
*
|
|
14
|
+
* Upstream: VeryMath AI4Math repositories (MIT). See NOTICE.md and
|
|
15
|
+
* UPSTREAM.json for per-repository provenance.
|
|
16
|
+
*
|
|
17
|
+
* @module @louisultra/dsh-verymath
|
|
18
|
+
*/
|
|
19
|
+
export * as core from "./core/index.js";
|
|
20
|
+
export * as tool from "./tool/index.js";
|
package/lib/tool/index.d.ts
CHANGED
|
@@ -17,5 +17,14 @@ export interface Config {
|
|
|
17
17
|
readonly glossaryHome?: string;
|
|
18
18
|
}
|
|
19
19
|
export declare const Config: z<Config>;
|
|
20
|
+
/**
|
|
21
|
+
* Resolve an executable name to an absolute path. Resolving in-process avoids
|
|
22
|
+
* `which`/`where`, which are not both available and which cannot see the TeX
|
|
23
|
+
* fallback directories above. On Windows the `PATHEXT` suffixes are tried.
|
|
24
|
+
* @param name - bare executable name, or a path containing a separator.
|
|
25
|
+
* @param searchDirs - directories probed for a bare name (defaults to PATH plus fallbacks).
|
|
26
|
+
* @returns the resolved absolute path, or undefined when nothing is executable.
|
|
27
|
+
*/
|
|
28
|
+
export declare function resolveExecutable(name: string, searchDirs?: readonly string[]): string | undefined;
|
|
20
29
|
/** Register the VeryMath glossary and paper tools. */
|
|
21
30
|
export declare const apply: (ctx: Context, config?: Config) => void;
|
package/lib/tool/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import z from '@deepseek-ai/schemastery';
|
|
2
2
|
import { defineTool } from '@deepseek-ai/dsh-tools';
|
|
3
3
|
import { spawn } from 'node:child_process';
|
|
4
|
-
import {
|
|
4
|
+
import { accessSync, constants } from 'node:fs';
|
|
5
|
+
import { delimiter, isAbsolute, join, resolve } from 'node:path';
|
|
5
6
|
import { VeryMathError, isVeryMathError } from '@louisultra/dsh-verymath/core';
|
|
6
7
|
import { bundledSkillsDir, checkGate, computeTopology, dependencySummary, findExcerpt, focusClosure, loadManifest, mergeBatches, parsePaperStructure, readCorpusDocWindow, renderMermaid, resolveCorpusRoot, searchSageRefs, termsFor, upsertTerms } from '@louisultra/dsh-verymath/core';
|
|
7
8
|
export const name = 'tool-verymath';
|
|
@@ -111,24 +112,67 @@ function probeCommand(executable, args, timeoutMs = 5_000) {
|
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
114
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
115
|
+
* Directories a TeX distribution installs into without adding them to the
|
|
116
|
+
* inherited PATH. Desktop applications launched from Finder or the Start menu
|
|
117
|
+
* do not read the login shell profile, so MacTeX's `/Library/TeX/texbin` is
|
|
118
|
+
* commonly invisible to a bare `spawn(name)` even when the toolchain is
|
|
119
|
+
* installed. Nothing here is required: an empty result just means PATH decides.
|
|
120
|
+
*/
|
|
121
|
+
function texBinFallbackDirs() {
|
|
122
|
+
return process.platform === 'darwin' ? ['/Library/TeX/texbin'] : [];
|
|
123
|
+
}
|
|
124
|
+
/** Executable search path: the inherited PATH first, then platform fallbacks. */
|
|
125
|
+
function executableSearchDirs() {
|
|
126
|
+
const fromEnv = (process.env.PATH ?? '').split(delimiter).filter((dir) => dir.length > 0);
|
|
127
|
+
return [...new Set([...fromEnv, ...texBinFallbackDirs()])];
|
|
128
|
+
}
|
|
129
|
+
/** Whether `candidate` exists and the current user may execute it. */
|
|
130
|
+
function isExecutableFile(candidate) {
|
|
131
|
+
try {
|
|
132
|
+
accessSync(candidate, constants.X_OK);
|
|
133
|
+
return true;
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Resolve an executable name to an absolute path. Resolving in-process avoids
|
|
141
|
+
* `which`/`where`, which are not both available and which cannot see the TeX
|
|
142
|
+
* fallback directories above. On Windows the `PATHEXT` suffixes are tried.
|
|
143
|
+
* @param name - bare executable name, or a path containing a separator.
|
|
144
|
+
* @param searchDirs - directories probed for a bare name (defaults to PATH plus fallbacks).
|
|
145
|
+
* @returns the resolved absolute path, or undefined when nothing is executable.
|
|
146
|
+
*/
|
|
147
|
+
export function resolveExecutable(name, searchDirs = executableSearchDirs()) {
|
|
148
|
+
if (isAbsolute(name) || name.includes('/') || name.includes('\\')) {
|
|
149
|
+
return isExecutableFile(name) ? name : undefined;
|
|
150
|
+
}
|
|
151
|
+
const extensions = process.platform === 'win32'
|
|
152
|
+
? ['', ...(process.env.PATHEXT ?? '.COM;.EXE;.BAT;.CMD').split(';').filter((ext) => ext.length > 0)]
|
|
153
|
+
: [''];
|
|
154
|
+
for (const dir of searchDirs) {
|
|
155
|
+
for (const extension of extensions) {
|
|
156
|
+
const candidate = join(dir, name + extension);
|
|
157
|
+
if (isExecutableFile(candidate))
|
|
158
|
+
return candidate;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Probe the math-beamer TeX toolchain: latexmk and xelatex binaries (resolved on
|
|
165
|
+
* PATH, then in the distribution's own bin directory, followed by a `--version`
|
|
166
|
+
* smoke) and the forest/ctex LaTeX packages (`kpsewhich <name>.sty`, via the
|
|
167
|
+
* `kpsewhich` found the same way). Nothing is installed, compiled, or
|
|
168
|
+
* downloaded; each probe is independent so a partial toolchain reports per-piece
|
|
169
|
+
* detail (mirrors the osqp/sage probe pattern).
|
|
118
170
|
*/
|
|
119
171
|
async function probeBeamerToolchain() {
|
|
120
|
-
const binaries = [
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
const styles = [
|
|
125
|
-
{ name: 'forest' },
|
|
126
|
-
{ name: 'ctex', note: 'required by Chinese/bilingual templates only' },
|
|
127
|
-
];
|
|
128
|
-
const binaryProbes = await Promise.all(binaries.map(async ({ name }) => {
|
|
129
|
-
const which = await probeCommand('/usr/bin/which', [name]).catch(() => undefined);
|
|
130
|
-
const resolved = which !== undefined && which.exitCode === 0 ? which.stdout.trim().split('\n')[0] : undefined;
|
|
131
|
-
const executable = resolved !== undefined && resolved.length > 0 ? resolved : undefined;
|
|
172
|
+
const binaries = ['latexmk', 'xelatex'];
|
|
173
|
+
const styles = ['forest', 'ctex'];
|
|
174
|
+
const binaryProbes = await Promise.all(binaries.map(async (name) => {
|
|
175
|
+
const executable = resolveExecutable(name);
|
|
132
176
|
if (executable === undefined)
|
|
133
177
|
return { name, kind: 'binary', available: false };
|
|
134
178
|
const smoke = await probeCommand(executable, ['--version']).catch(() => undefined);
|
|
@@ -136,8 +180,13 @@ async function probeBeamerToolchain() {
|
|
|
136
180
|
? { name, kind: 'binary', available: true, executable }
|
|
137
181
|
: { name, kind: 'binary', available: false, executable };
|
|
138
182
|
}));
|
|
139
|
-
|
|
140
|
-
|
|
183
|
+
// kpsewhich ships with the distribution, so it lives in the same bin directory
|
|
184
|
+
// as the binaries and needs the same fallback lookup rather than a fixed path.
|
|
185
|
+
const kpsewhich = resolveExecutable('kpsewhich');
|
|
186
|
+
const styleProbes = await Promise.all(styles.map(async (name) => {
|
|
187
|
+
if (kpsewhich === undefined)
|
|
188
|
+
return { name, kind: 'style', available: false };
|
|
189
|
+
const probe = await probeCommand(kpsewhich, [`${name}.sty`]).catch(() => undefined);
|
|
141
190
|
const resolved = probe !== undefined && probe.exitCode === 0 ? probe.stdout.trim().split('\n')[0] : undefined;
|
|
142
191
|
return resolved !== undefined && resolved.length > 0
|
|
143
192
|
? { name, kind: 'style', available: true, executable: resolved }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@louisultra/dsh-verymath",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "VeryMath capabilities for DSH: 16 bundled math skills and 14 tools covering paper reading, bilingual glossary, writing, Beamer, optimization, computation, Lean formalization, research workflows, Sage doc lookup and MATLAB. Community plugin for issue ECNU/EduWork#152.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
"LICENSE",
|
|
26
26
|
"NOTICE.md",
|
|
27
27
|
"UPSTREAM.json",
|
|
28
|
-
"CHANGELOG.md"
|
|
28
|
+
"CHANGELOG.md",
|
|
29
|
+
"!**/tests",
|
|
30
|
+
"!**/test"
|
|
29
31
|
],
|
|
30
32
|
"dsh": {
|
|
31
33
|
"bundle": {
|
|
@@ -38,34 +40,33 @@
|
|
|
38
40
|
"test": "vitest run",
|
|
39
41
|
"test:runtime": "node scripts/probe-runtime.mjs",
|
|
40
42
|
"check": "npm run typecheck && npm run build && npm test && npm run test:runtime",
|
|
41
|
-
"test:upstream": "python3 -m unittest discover -s
|
|
43
|
+
"test:upstream": "python3 -m unittest discover -s ../../research/AI4Math-MathTool/skills/math-glossary/tests"
|
|
42
44
|
},
|
|
43
45
|
"engines": {
|
|
44
|
-
"node": ">=24.
|
|
46
|
+
"node": ">=24.22.1"
|
|
45
47
|
},
|
|
46
48
|
"peerDependencies": {
|
|
47
|
-
"@deepseek-ai/cordis": "
|
|
48
|
-
"@deepseek-ai/dsh-fs": ">=0.2.
|
|
49
|
-
"@deepseek-ai/dsh-llm": ">=0.2.
|
|
50
|
-
"@deepseek-ai/dsh-skill": ">=0.2.
|
|
51
|
-
"@deepseek-ai/dsh-tools": ">=0.2.
|
|
52
|
-
"@deepseek-ai/schemastery": "
|
|
49
|
+
"@deepseek-ai/cordis": ">=4.0.5 <4.2.0",
|
|
50
|
+
"@deepseek-ai/dsh-fs": ">=0.2.1-rc.5 <0.3.0-0 || 0.2.2-rc.1",
|
|
51
|
+
"@deepseek-ai/dsh-llm": ">=0.2.1-rc.5 <0.3.0-0 || 0.2.2-rc.1",
|
|
52
|
+
"@deepseek-ai/dsh-skill": ">=0.2.1-rc.5 <0.3.0-0 || 0.2.2-rc.1",
|
|
53
|
+
"@deepseek-ai/dsh-tools": ">=0.2.1-rc.5 <0.3.0-0 || 0.2.2-rc.1",
|
|
54
|
+
"@deepseek-ai/schemastery": ">=3.18.5 <3.19.0 || 3.19.0"
|
|
53
55
|
},
|
|
54
56
|
"devDependencies": {
|
|
55
|
-
"@deepseek-ai/cordis": "4.0
|
|
56
|
-
"@deepseek-ai/
|
|
57
|
-
"@deepseek-ai/
|
|
58
|
-
"@deepseek-ai/dsh-
|
|
59
|
-
"@deepseek-ai/dsh-
|
|
60
|
-
"@deepseek-ai/dsh-
|
|
61
|
-
"@deepseek-ai/dsh-
|
|
62
|
-
"@deepseek-ai/dsh-
|
|
63
|
-
"@deepseek-ai/
|
|
64
|
-
"@
|
|
65
|
-
"@types/
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"vitest": "^4.1.8"
|
|
57
|
+
"@deepseek-ai/cordis": "4.1.0",
|
|
58
|
+
"@deepseek-ai/dsh-fs": "0.2.2-rc.1",
|
|
59
|
+
"@deepseek-ai/dsh-fs-local": "0.2.2-rc.1",
|
|
60
|
+
"@deepseek-ai/dsh-llm": "0.2.2-rc.1",
|
|
61
|
+
"@deepseek-ai/dsh-skill": "0.2.2-rc.1",
|
|
62
|
+
"@deepseek-ai/dsh-system-prompt": "0.2.2-rc.1",
|
|
63
|
+
"@deepseek-ai/dsh-tool-executor-native": "0.2.2-rc.1",
|
|
64
|
+
"@deepseek-ai/dsh-tools": "0.2.2-rc.1",
|
|
65
|
+
"@deepseek-ai/schemastery": "3.19.0",
|
|
66
|
+
"@types/js-yaml": "4.0.9",
|
|
67
|
+
"@types/node": "24.19.2",
|
|
68
|
+
"typescript": "6.0.3",
|
|
69
|
+
"vitest": "4.1.8"
|
|
69
70
|
},
|
|
70
71
|
"keywords": [
|
|
71
72
|
"dsh",
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""after-ocr 辅助脚本的最小回归测试。"""
|
|
3
|
-
|
|
4
|
-
from __future__ import annotations
|
|
5
|
-
|
|
6
|
-
import importlib.util
|
|
7
|
-
import tempfile
|
|
8
|
-
import unittest
|
|
9
|
-
from pathlib import Path
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
ROOT = Path(__file__).resolve().parents[1]
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def load_module(name: str, path: Path):
|
|
16
|
-
spec = importlib.util.spec_from_file_location(name, path)
|
|
17
|
-
if spec is None or spec.loader is None:
|
|
18
|
-
raise RuntimeError(f"无法加载模块:{path}")
|
|
19
|
-
module = importlib.util.module_from_spec(spec)
|
|
20
|
-
spec.loader.exec_module(module)
|
|
21
|
-
return module
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
scanner = load_module("after_ocr_scanner", ROOT / "scripts" / "scan_markdown_ocr.py")
|
|
25
|
-
merger = load_module("after_ocr_merger", ROOT / "scripts" / "merge_audit_logs.py")
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
class ScannerTests(unittest.TestCase):
|
|
29
|
-
def test_detects_core_candidate_rules(self):
|
|
30
|
-
source = """# 示例
|
|
31
|
-
$$ \\sinx + \\operatorname*{m a x} + \\text{sup} p + \\mathbb{D} + \\tilde{7} + K_{80} \\
|
|
32
|
-
\\begin{aligned} a &= b \\end{array}
|
|
33
|
-
called $tangent space$
|
|
34
|
-
"""
|
|
35
|
-
with tempfile.TemporaryDirectory() as directory:
|
|
36
|
-
path = Path(directory) / "sample.md"
|
|
37
|
-
path.write_text(source, encoding="utf-8")
|
|
38
|
-
findings, summary = scanner.scan(path)
|
|
39
|
-
|
|
40
|
-
rules = {item["rule"] for item in findings}
|
|
41
|
-
self.assertIn("operator-glued", rules)
|
|
42
|
-
self.assertIn("spaced-operator", rules)
|
|
43
|
-
self.assertIn("split-support", rules)
|
|
44
|
-
self.assertIn("distribution-space-font", rules)
|
|
45
|
-
self.assertIn("accented-digit", rules)
|
|
46
|
-
self.assertIn("epsilon-index-as-digits", rules)
|
|
47
|
-
self.assertIn("plain-words-in-inline-math", rules)
|
|
48
|
-
self.assertIn("environment-mismatch", rules)
|
|
49
|
-
self.assertIn("unclosed-display-math", rules)
|
|
50
|
-
self.assertEqual(summary["lines"], 4)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
class MergerTests(unittest.TestCase):
|
|
54
|
-
def test_preserves_canonical_category_and_merges_same_position(self):
|
|
55
|
-
template = """# 审校日志
|
|
56
|
-
|
|
57
|
-
- Markdown:`/tmp/source.md`
|
|
58
|
-
|
|
59
|
-
### AO-X-{pass_name}-001
|
|
60
|
-
|
|
61
|
-
- 位置:`/tmp/source.md:12`
|
|
62
|
-
- 类别:`MATH_OCR_SYMBOL`
|
|
63
|
-
- 严重度:中
|
|
64
|
-
- 置信度:高
|
|
65
|
-
- 当前内容:`x`
|
|
66
|
-
- 问题:符号错误
|
|
67
|
-
- 建议修复:改为 `y`
|
|
68
|
-
- 证据:上下文一致性
|
|
69
|
-
"""
|
|
70
|
-
with tempfile.TemporaryDirectory() as directory:
|
|
71
|
-
first = Path(directory) / "a.md"
|
|
72
|
-
second = Path(directory) / "b.md"
|
|
73
|
-
first.write_text(template.format(pass_name="A"), encoding="utf-8")
|
|
74
|
-
second.write_text(template.format(pass_name="B"), encoding="utf-8")
|
|
75
|
-
records = merger.parse_log(first) + merger.parse_log(second)
|
|
76
|
-
rendered = merger.render(records, [first, second])
|
|
77
|
-
|
|
78
|
-
self.assertEqual([record["category"] for record in records], ["MATH_OCR_SYMBOL"] * 2)
|
|
79
|
-
self.assertIn("多轮共同命中的位置:1", rendered)
|
|
80
|
-
self.assertIn("`MATH_OCR_SYMBOL`:2", rendered)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if __name__ == "__main__":
|
|
84
|
-
unittest.main()
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
import sys
|
|
4
|
-
import tempfile
|
|
5
|
-
import unittest
|
|
6
|
-
from pathlib import Path
|
|
7
|
-
from unittest.mock import patch
|
|
8
|
-
|
|
9
|
-
SCRIPT_DIR = Path(__file__).resolve().parents[1] / "scripts"
|
|
10
|
-
sys.path.insert(0, str(SCRIPT_DIR))
|
|
11
|
-
|
|
12
|
-
from check_lean_project import check_project, find_project_root, read_mathlib_revision, read_toolchain # noqa: E402
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
class CheckLeanProjectTests(unittest.TestCase):
|
|
16
|
-
def test_finds_project_root_and_versions(self) -> None:
|
|
17
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
18
|
-
root = (Path(tmp) / "proj").resolve()
|
|
19
|
-
nested = root / "A" / "B"
|
|
20
|
-
nested.mkdir(parents=True)
|
|
21
|
-
(root / "lean-toolchain").write_text("leanprover/lean4:v4.26.0\n", encoding="utf-8")
|
|
22
|
-
(root / "lakefile.toml").write_text(
|
|
23
|
-
'name = "proj"\n\n[[require]]\nname = "mathlib"\nscope = "leanprover-community"\nrev = "v4.26.0"\n',
|
|
24
|
-
encoding="utf-8",
|
|
25
|
-
)
|
|
26
|
-
target = nested / "T.lean"
|
|
27
|
-
target.write_text("example : True := by trivial\n", encoding="utf-8")
|
|
28
|
-
|
|
29
|
-
self.assertEqual(find_project_root(target), root)
|
|
30
|
-
self.assertEqual(read_toolchain(root), "leanprover/lean4:v4.26.0")
|
|
31
|
-
self.assertEqual(read_mathlib_revision(root), "v4.26.0")
|
|
32
|
-
|
|
33
|
-
result = check_project(root, skip_build=True)
|
|
34
|
-
self.assertTrue(result["ok"])
|
|
35
|
-
self.assertEqual(result["status"], "ok_skip_build")
|
|
36
|
-
|
|
37
|
-
def test_build_uses_discovered_lake_binary(self) -> None:
|
|
38
|
-
with tempfile.TemporaryDirectory() as tmp:
|
|
39
|
-
root = Path(tmp)
|
|
40
|
-
(root / "lean-toolchain").write_text("leanprover/lean4:v4.28.0\n", encoding="utf-8")
|
|
41
|
-
(root / "lakefile.toml").write_text('name = "proj"\n', encoding="utf-8")
|
|
42
|
-
|
|
43
|
-
with patch("check_lean_project.find_tool", return_value="/custom/bin/lake"), \
|
|
44
|
-
patch("check_lean_project.run_command", return_value={
|
|
45
|
-
"ok": True,
|
|
46
|
-
"returncode": 0,
|
|
47
|
-
"stdout": "",
|
|
48
|
-
"stderr": "",
|
|
49
|
-
"command": ["/custom/bin/lake", "build"],
|
|
50
|
-
}) as run:
|
|
51
|
-
result = check_project(root)
|
|
52
|
-
|
|
53
|
-
self.assertTrue(result["ok"])
|
|
54
|
-
run.assert_called_once()
|
|
55
|
-
self.assertEqual(run.call_args.args[0], ["/custom/bin/lake", "build"])
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
if __name__ == "__main__":
|
|
59
|
-
unittest.main()
|