@louisultra/dsh-verymath 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
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.5.0] - 2026-11-11
7
+
8
+ ### Added
9
+
10
+ - **Browser panel with a left-sidebar entry.** The plugin now ships a client half
11
+ (`dsh.client` + `lib/client.js`), so hosts that compose client plugins (DSH web,
12
+ EduWork desktop) show a 「数学科研」 row in the left sidebar; clicking it opens a
13
+ panel listing the 14 tools and how to reach the capabilities. Until now the
14
+ package was tools-and-skills only, which is why it had no entry anywhere while
15
+ a plugin with a client half (e.g. wellspring) did.
16
+ - The entry registers on `sidebar.panellist` (`kind: list`, root scope) with
17
+ `id: 'verymath'`, and the panel registers on the layout's `main` slot
18
+ (`kind: keyed`, root scope) with `key: 'verymath'` — the sidebar resolves the
19
+ panel by that id, so the two must stay in sync.
20
+ - `cordis.patch.yml` gains a **bare-package-name** entry (`verymath-client`).
21
+ The host resolves a client plugin's manifest from the loader entry name; with
22
+ only `/core` and `/tool` entries the specifier lookup returns undefined, so
23
+ `dsh.client` would never be read. The root module (`src/index.ts`) therefore
24
+ became a mountable no-op plugin alongside its existing re-exports.
25
+ - `scripts/build-client.mjs` copies `client/verymath.js` to `lib/client.js` and
26
+ fails the build when the bundle id does not match `package.json.name` or the
27
+ source does not parse — the host only shows a one-line error when a client
28
+ bundle fails to load, so this check is cheaper than debugging in the app.
29
+
6
30
  ## [0.4.0] - 2026-11-11
7
31
 
8
32
  Minor rather than patch: `verymath_glossary_upsert` changes what it does with a
package/README.md CHANGED
@@ -32,6 +32,13 @@
32
32
 
33
33
  其余 12 项能力(OCR 后校对、二次规划、混合整数规划、Lean、Sage 文档查询、MATLAB、Beamer 等)的「谁在什么情况下用、用户怎么说、需要什么输入、最后得到什么、运行条件与实测记录」逐项写在 [`docs/capability-examples.md`](docs/capability-examples.md)。
34
34
 
35
+ ## 界面
36
+
37
+ 插件带一个浏览器半侧:**左侧栏「数学科研」入口**,点开是能力面板(14 个工具清单与用法指引)。
38
+ 注册走宿主的 `sidebar.panellist`(左栏列表槽)与布局的 `main`(keyed 槽,键与入口 id 一致),
39
+ 所以 DSH web 与 EduWork 桌面端都能显示;宿主没装客户端插件机制时这部分自动不生效,
40
+ 工具与技能不受影响。
41
+
35
42
  ## 提供的能力
36
43
 
37
44
  **模型工具**(安装即用,Agent 自动调用):
package/README_EN.md CHANGED
@@ -32,6 +32,15 @@ The repo does not redistribute paper full texts (third-party license); follow [`
32
32
 
33
33
  Per-capability detail for the remaining 12 (OCR post-review, QP, MILP, Lean, Sage doc lookup, MATLAB, Beamer, ...) — who uses it, what to say, what input is needed, what you get, run conditions and recorded runs — is in [`docs/capability-examples.md`](docs/capability-examples.md).
34
34
 
35
+ ## Interface
36
+
37
+ The plugin ships a browser half: a **「数学科研」 entry in the left sidebar** that
38
+ opens a panel listing the 14 tools and how to reach each capability. The entry
39
+ registers on the host's `sidebar.panellist` list slot and the panel on the
40
+ layout's `main` keyed slot under the same id, so both DSH web and the EduWork
41
+ desktop show it. Hosts without the client-plugin mechanism simply skip this half;
42
+ tools and skills are unaffected.
43
+
35
44
  ## What it provides
36
45
 
37
46
  **Model-facing tools** (available right after install; the Agent calls them automatically):
package/cordis.patch.yml CHANGED
@@ -10,3 +10,12 @@
10
10
 
11
11
  - id: tool-verymath
12
12
  name: '@louisultra/dsh-verymath/tool'
13
+
14
+ # 浏览器半侧(左栏入口 + 面板)需要一个**裸包名**条目。
15
+ # 实测依据(问渠踩过同一个坑):宿主组合客户端插件时用
16
+ # `exactPackageSpecifier(entryName)` 去找包清单,带 `/core`、`/tool` 子路径的
17
+ # entryName 会被判为 undefined → 读不到 package.json → `dsh.client` 声明
18
+ # 永远不被读取 → 浏览器 bundle 不会被提供。包根导出只有 apply 空壳,
19
+ # 它的作用就是让这个解析成功。
20
+ - id: verymath-client
21
+ name: '@louisultra/dsh-verymath'
package/lib/client.js ADDED
@@ -0,0 +1,117 @@
1
+ /**
2
+ * VeryMath 的浏览器面板(左侧栏独立入口)。
3
+ *
4
+ * 为什么手写 CJS 而不接打包链:DSH 的客户端插件产物就是
5
+ * `window.__ModuleLoader__.load({ id, factory })` 包一层 CJS 工厂,平台表已提供
6
+ * react / react-dom / ui-primitives。本包没有 tsdown/vite,为一个面板引入构建链
7
+ * 只会让"能不能跑"取决于构建环境。这里用 `React.createElement`,产物即源码。
8
+ *
9
+ * 入口机制(读宿主包源码确认,不是猜):
10
+ * - `@deepseek-ai/dsh-client-ui-sidebar` 在 root 作用域声明 `sidebar.panellist`
11
+ * (kind: list):插件注册 `{ id, order, label }` + 图标组件,左栏就多一行;
12
+ * - 点开时按**同一 id** 去 `@deepseek-ai/dsh-client-ui-layout` 的 `main`
13
+ * (kind: keyed,root 作用域)取组件,所以主面板注册必须带 `key: <同一 id>`;
14
+ * - 注册 API:`ctx.slots.inject(slot, () => ctx.slots.register(options, Component))`,
15
+ * `ctx.effect(...)` 保证插件卸载时一并移除。
16
+ */
17
+ window.__ModuleLoader__.load({
18
+ id: '@louisultra/dsh-verymath',
19
+ factory: (require) => {
20
+ const module = { exports: {} }
21
+ const exports = module.exports
22
+ const react = require('react')
23
+ const h = react.createElement
24
+
25
+ const PANEL_ID = 'verymath'
26
+
27
+ /** 左栏图标:一个极简的求和符号,避免额外资源文件。 */
28
+ function VeryMathIcon(props) {
29
+ const size = (props && props.size) || 16
30
+ return h('svg', {
31
+ width: size,
32
+ height: size,
33
+ viewBox: '0 0 16 16',
34
+ fill: 'none',
35
+ stroke: 'currentColor',
36
+ strokeWidth: 1.6,
37
+ strokeLinecap: 'round',
38
+ 'aria-hidden': 'true',
39
+ },
40
+ h('path', { d: 'M12 3H4l4 5-4 5h8' }),
41
+ )
42
+ }
43
+
44
+ /** 一行小标题 */
45
+ function Section(props) {
46
+ return h('div', {
47
+ style: {
48
+ fontSize: 11,
49
+ letterSpacing: '.08em',
50
+ textTransform: 'uppercase',
51
+ color: 'var(--dsh-text-tertiary, #888)',
52
+ margin: '14px 0 6px',
53
+ },
54
+ }, props.children)
55
+ }
56
+
57
+ const TOOLS = [
58
+ ['verymath_glossary_query', '查双语术语库'],
59
+ ['verymath_glossary_upsert', '存词 / 纠正译名'],
60
+ ['verymath_glossary_build', '从 CSV 建库(Python)'],
61
+ ['verymath_python_check', 'Python 可用性'],
62
+ ['verymath_paper_validate', '论文结构 JSON 校验'],
63
+ ['verymath_paper_graph', '定理依赖图'],
64
+ ['verymath_ocr_scan', 'OCR 后错误定位'],
65
+ ['verymath_osqp_check', 'OSQP 求解栈探测'],
66
+ ['verymath_osqp_solve', '凸二次规划求解'],
67
+ ['verymath_lean_detect_sorry', 'Lean 禁用词扫描'],
68
+ ['verymath_sage_check', 'SageMath 探测'],
69
+ ['verymath_sage_search', 'Sage 文档反幻觉查询'],
70
+ ['verymath_research_gate', '研究工作区三道闸门'],
71
+ ['verymath_beamer_check', 'Beamer TeX 工具链'],
72
+ ]
73
+
74
+ /** 主面板:能力清单与当前状态。 */
75
+ function VeryMathPanel() {
76
+ return h('div', { style: { padding: '16px 18px', fontSize: 13, lineHeight: 1.6 } },
77
+ h('div', { style: { fontSize: 15, fontWeight: 600 } }, 'VeryMath 数学科研'),
78
+ h('div', { style: { color: 'var(--dsh-text-secondary, #666)', marginTop: 2 } },
79
+ 'VeryMath 能力接入:14 个工具 · 16 个技能'),
80
+ h(Section, null, '工具'),
81
+ h('div', { style: { display: 'grid', gap: 2 } },
82
+ ...TOOLS.map(([name, desc]) => h('div', {
83
+ key: name,
84
+ style: { display: 'flex', gap: 8, alignItems: 'baseline' },
85
+ },
86
+ h('code', { style: { fontSize: 11.5, color: 'var(--dsh-text-secondary, #666)' } }, name),
87
+ h('span', { style: { fontSize: 12 } }, desc),
88
+ )),
89
+ ),
90
+ h(Section, null, '怎么用'),
91
+ h('div', { style: { color: 'var(--dsh-text-secondary, #666)' } },
92
+ '全部能力都在对话里调用:「帮我查一下 manifold 的中文术语」「读这篇论文的定理依赖」。',
93
+ '这个面板只是入口与状态指示,不做计算——计算都在工具里,结果写进会话工作区。'),
94
+ )
95
+ }
96
+
97
+ function apply(ctx) {
98
+ // 左栏入口(list 槽,每个插件一行)
99
+ ctx.effect(() => ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
100
+ name: 'sidebar.panellist',
101
+ id: PANEL_ID,
102
+ order: 40,
103
+ label: 'VeryMath 数学科研',
104
+ }, VeryMathIcon)), 'verymath: sidebar entry')
105
+
106
+ // 主面板(keyed 槽,键必须与上面 id 一致)
107
+ ctx.effect(() => ctx.slots.inject('main', () => ctx.slots.register({
108
+ name: 'main',
109
+ key: PANEL_ID,
110
+ }, VeryMathPanel)), 'verymath: main panel')
111
+ }
112
+
113
+ exports.apply = apply
114
+ exports.inject = ['slots']
115
+ return module.exports
116
+ },
117
+ })
package/lib/index.d.ts CHANGED
@@ -1,20 +1,34 @@
1
1
  /**
2
2
  * VeryMath capability plugin for DSH — package entry.
3
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.
4
+ * The bundle mounts three entries through `cordis.patch.yml`:
5
+ * `./core` (the `ctx.verymath` service: glossary, paper, graph, gates, Sage),
6
+ * `./tool` (the 14 model-facing tools), and this root module under its **bare
7
+ * package name**. The root entry exists because the host resolves a client
8
+ * plugin's package manifest from the loader entry name: with only `/core` and
9
+ * `/tool` entries the specifier lookup returns undefined, so `dsh.client` is
10
+ * never read and the browser bundle is never served. Its `apply` is therefore
11
+ * the whole reason this module is mountable.
8
12
  *
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
+ * This module also re-exports both halves so `import '@louisultra/dsh-verymath'`
14
+ * gets the same surface as the subpaths.
13
15
  *
14
16
  * Upstream: VeryMath AI4Math repositories (MIT). See NOTICE.md and
15
17
  * UPSTREAM.json for per-repository provenance.
16
18
  *
17
19
  * @module @louisultra/dsh-verymath
18
20
  */
21
+ import type { Context } from '@deepseek-ai/cordis';
19
22
  export * as core from './core/index.ts';
20
23
  export * as tool from './tool/index.ts';
24
+ export declare const name = "verymath-client";
25
+ /** The root entry needs no services of its own; it only anchors the client bundle. */
26
+ export declare const inject: string[];
27
+ /**
28
+ * Mount point for the bare-name loader entry. Deliberately empty: the service and
29
+ * the tools are mounted from `./core` and `./tool`, and the browser half is
30
+ * served by the host from `dsh.client`. Keeping the function (rather than a
31
+ * module without `apply`) means the host mounts an ordinary plugin instead of
32
+ * warning about a module it cannot apply.
33
+ */
34
+ export declare const apply: (_ctx: Context) => void;
package/lib/index.js CHANGED
@@ -1,20 +1,15 @@
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
1
  export * as core from "./core/index.js";
20
2
  export * as tool from "./tool/index.js";
3
+ export const name = 'verymath-client';
4
+ /** The root entry needs no services of its own; it only anchors the client bundle. */
5
+ export const inject = [];
6
+ /**
7
+ * Mount point for the bare-name loader entry. Deliberately empty: the service and
8
+ * the tools are mounted from `./core` and `./tool`, and the browser half is
9
+ * served by the host from `dsh.client`. Keeping the function (rather than a
10
+ * module without `apply`) means the host mounts an ordinary plugin instead of
11
+ * warning about a module it cannot apply.
12
+ */
13
+ export const apply = (_ctx) => {
14
+ // Intentionally empty — see the doc comment above.
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@louisultra/dsh-verymath",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
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",
@@ -9,7 +9,8 @@
9
9
  ".": "./lib/index.js",
10
10
  "./core": "./lib/core/index.js",
11
11
  "./tool": "./lib/tool/index.js",
12
- "./package.json": "./package.json"
12
+ "./package.json": "./package.json",
13
+ "./client": "./lib/client.js"
13
14
  },
14
15
  "files": [
15
16
  "lib/**/*.js",
@@ -32,10 +33,19 @@
32
33
  "dsh": {
33
34
  "bundle": {
34
35
  "patch": "./cordis.patch.yml"
36
+ },
37
+ "client": {
38
+ "platform": "web",
39
+ "inject": [
40
+ "@deepseek-ai/dsh-client-ui-slots",
41
+ "@deepseek-ai/dsh-client-ui-sidebar",
42
+ "@deepseek-ai/dsh-client-ui-layout"
43
+ ],
44
+ "immediately": true
35
45
  }
36
46
  },
37
47
  "scripts": {
38
- "build": "tsc -p tsconfig.json",
48
+ "build": "tsc -p tsconfig.json && node scripts/build-client.mjs",
39
49
  "typecheck": "tsc -p tsconfig.json --noEmit",
40
50
  "test": "vitest run",
41
51
  "test:runtime": "node scripts/probe-runtime.mjs",