question-workbench-mcp 0.4.0 → 0.4.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/client.js CHANGED
@@ -17,7 +17,7 @@ window.__ModuleLoader__.load({
17
17
  copy: '复制提示', copied: '已复制', copyFail: '复制失败,请手动选择文本',
18
18
  print: '打印', exportHtml: '导出讲义', exportHint: '已导出讲义 HTML:用浏览器打开后按 Ctrl+P 可预览 A4 分页并打印。', exportFail: '导出失败:', preview: '预览', hidePreview: '关闭预览', includeImg: '打印含原图', optimize: '优化原图(裁剪·去阴影·增强)', optimizing: '正在优化图片…', optimizeFail: '部分图片优化失败,已使用原图', showPrompt: '查看将发送的提示', printFail: '打印调用失败,请改用系统打印(Ctrl+P)', printHint: '已调用打印;若没有出现打印对话框或预览,请点「导出讲义」,用浏览器打开后按 Ctrl+P 预览并打印',
19
19
  fail: '发送失败:', noSession: '当前会话不可用,请先打开一个会话',
20
- sendAsk: '发送', notesLabel: '解答 / 解析', notesPlaceholder: '把模型的思路、解答或总结粘贴到这里;会打印在题目之后', autoFilled: '已自动填入模型回复', waiting: '已发送,等待模型回复后自动填入…', autoFail: '未自动获取到回复,可用「从剪贴板粘贴」手动补充', saved: '文字自动保存在本机浏览器(按会话)', mathRule: '数学公式一律用 LaTeX:行内 $...$、独立 $$...$$;不要输出 ∠ △ ∵ ∴ ⊥ ∥ ² 之类的特殊符号,讲义会用 KaTeX 渲染。', diagramNote: '图形以原图为准:打印默认附原图,文本里的「图形」一行仅作排版提示。', limit: '最多 12 张,单张 ≤15MB',
20
+ sendAsk: '发送', notesLabel: '解答 / 解析', notesPlaceholder: '把模型的思路、解答或总结粘贴到这里;会打印在题目之后', autoFilled: '已自动填入模型回复', waiting: '已发送,等待模型回复后自动填入…', autoFail: '未自动获取到回复,可用「从剪贴板粘贴」手动补充', saved: '文字自动保存在本机浏览器(按会话)', mathRule: '数学公式照原样用教材符号书写:∠ △ ∵ ∴ ⊥ ∥ ²、S₁、x²、√3、π;不要用 $ 包裹,也不要写 LaTeX 命令,讲义会自动把这些符号渲染成公式。', diagramNote: '图形以原图为准:打印默认附原图,文本里的「图形」一行仅作排版提示。', limit: '最多 12 张,单张 ≤15MB',
21
21
  src: '已核对题目:\n', rule: '以下内容已由用户对照原图人工核对,直接作为已知条件使用;不要重新质疑,也不要补充未确认的关系。\n\n',
22
22
  rec: '只做识别,严格输出两段,不要解释或额外分节:\n【题目】逐字转录印刷文字,保留题号、选项、符号和公式;看不清写[待核实:简短原因],不要猜。\n【图形】每张图一行,≤25字,只写可见关键元素,例如:图1 三角形ABC,P在内部,BM、CN交于P。\n【待确认】最多3条、每条≤15字;没有写“无”。',
23
23
  askA: '只给思路,不要完整计算:①考点1行 ②关键思路3-5步。≤200字。',
@@ -38,7 +38,7 @@ window.__ModuleLoader__.load({
38
38
  copy: 'Copy prompt', copied: 'Copied', copyFail: 'Copy failed; select the text manually',
39
39
  print: 'Print', exportHtml: 'Export worksheet', exportHint: 'Worksheet exported. Open it in a browser and press Ctrl+P to preview A4 pages and print.', exportFail: 'Export failed: ', preview: 'Preview', hidePreview: 'Hide preview', includeImg: 'Include photos in print', optimize: 'Clean up photos (crop, shadows, contrast)', optimizing: 'Cleaning up photos…', optimizeFail: 'Some photos could not be cleaned; originals used', showPrompt: 'Show prompt to be sent', printFail: 'Print call failed; use Ctrl+P instead', printHint: 'Print dialog opened; press Ctrl+P if it did not appear',
40
40
  fail: 'Send failed: ', noSession: 'No usable session; open a conversation first',
41
- sendAsk: 'Send', notesLabel: 'Solution', notesPlaceholder: 'Paste the reasoning or solution here; it prints after the question', autoFilled: 'Model reply filled in automatically', waiting: 'Sent. Waiting for the reply to fill in…', autoFail: 'No reply captured; use "Paste from clipboard"', saved: 'Text is saved in this browser per session', mathRule: 'Write every formula in LaTeX: $...$ inline, $$...$$ display; never emit unicode math symbols like ∠ △ ∵ ∴ ⊥ ∥ ². The worksheet renders them with KaTeX.', diagramNote: 'The original photo is the diagram source; printing includes it by default. The one-line diagram note is for layout only.', limit: 'Up to 12 photos, 15 MB each',
41
+ sendAsk: 'Send', notesLabel: 'Solution', notesPlaceholder: 'Paste the reasoning or solution here; it prints after the question', autoFilled: 'Model reply filled in automatically', waiting: 'Sent. Waiting for the reply to fill in…', autoFail: 'No reply captured; use "Paste from clipboard"', saved: 'Text is saved in this browser per session', mathRule: 'Write formulas with normal textbook symbols (∠ △ ∵ ∴ ⊥ ∥ ², S₁, x², √3, π). Do not wrap them in $ or use LaTeX commands; the worksheet renders these symbols automatically.', diagramNote: 'The original photo is the diagram source; printing includes it by default. The one-line diagram note is for layout only.', limit: 'Up to 12 photos, 15 MB each',
42
42
  src: 'Checked question:\n', rule: 'The user checked the following against the photos; use it as given. Do not re-question it or add unconfirmed relations.\n\n',
43
43
  rec: 'Transcribe only. Output exactly two sections, no extra explanation:\n[Question] literal printed text, keeping numbering, symbols and formulas; write [verify: short reason] instead of guessing.\n[Diagram] one line per figure, ≤25 words, only visible key elements, e.g. Fig.1 triangle ABC, P inside, BM and CN meet at P.\n[Checks] at most 3 items, ≤15 words each; write "none" if none.',
44
44
  askA: 'Reasoning only: 1 line of key concepts, then 3-5 steps. ≤200 words.',
package/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  /** Host half: the Client owns the worksheet UI; the Host also exposes the workbook as agent tools. */
2
2
  import fs from 'node:fs';
3
3
  import path from 'node:path';
4
+ import { latexify } from './lib/katex-unicode.mjs';
4
5
 
5
6
  const PROMPTS = {
6
7
  zh: {
@@ -24,7 +25,7 @@ const PROMPTS = {
24
25
  };
25
26
 
26
27
  const MODES = ['recognition', 'analysis', 'solution', 'summary', 'full'];
27
- const MATH_RULE = '数学公式一律用 LaTeX:行内 $...$、独立 $$...$$;不要输出 ∠ △ ∵ ∴ ⊥ ∥ ² 之类的特殊符号,讲义用 KaTeX 渲染。';
28
+ const MATH_RULE = '数学公式照原样用教材符号书写:∠ △ ∵ ∴ ⊥ ∥ ²、S₁、x²、√3、π;不要用 $ 包裹,也不要写 LaTeX 命令,讲义会自动把这些符号渲染成公式。';
28
29
  const MIME = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.gif': 'image/gif' };
29
30
 
30
31
  const escape = (v) => String(v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -55,7 +56,7 @@ export function buildWorksheet(options = {}) {
55
56
  if (!MIME[ext]) throw new Error('unsupported image type: ' + p);
56
57
  return { name: path.basename(p), data: `data:${MIME[ext]};base64,${fs.readFileSync(p).toString('base64')}` };
57
58
  });
58
- const lines = (v) => marked(v);
59
+ const lines = (v) => marked(latexify(v));
59
60
  const KATEX = 'https://cdn.jsdelivr.net/npm/katex@0.16.11/dist';
60
61
  const katexHead = '<link rel="stylesheet" href="' + KATEX + '/katex.min.css">'
61
62
  + '<script defer src="' + KATEX + '/katex.min.js"></script>'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "question-workbench-mcp",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Question workbench: photos in, checked text, reasoning or solutions, A4 worksheet out. One package, two installs: a DeepSeek Harness bundle (UI + agent tools) and an MCP stdio server for Codex, WorkBuddy and other MCP clients.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/server.js CHANGED
@@ -5,6 +5,7 @@ import readline from 'node:readline';
5
5
  import fs from 'node:fs';
6
6
  import path from 'node:path';
7
7
  import os from 'node:os';
8
+ import { latexify } from './lib/katex-unicode.mjs';
8
9
 
9
10
  const VERSION = (() => {
10
11
  try { return JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version; } catch { return '0.0.0'; }
@@ -35,7 +36,7 @@ const PROMPTS = {
35
36
  };
36
37
 
37
38
  const MODES = ['recognition', 'analysis', 'solution', 'summary', 'full'];
38
- const MATH_RULE = '数学公式一律用 LaTeX:行内 $...$、独立 $$...$$;不要输出 ∠ △ ∵ ∴ ⊥ ∥ ² 之类的特殊符号,讲义用 KaTeX 渲染。';
39
+ const MATH_RULE = '数学公式照原样用教材符号书写:∠ △ ∵ ∴ ⊥ ∥ ²、S₁、x²、√3、π;不要用 $ 包裹,也不要写 LaTeX 命令,讲义会自动把这些符号渲染成公式。';
39
40
 
40
41
  const TOOLS = [
41
42
  {
@@ -107,7 +108,7 @@ const marker = /([待核实[^]\n]{0,160}]|\[verify[^\]\n]{0,160}\])/gi;
107
108
  const marked = v => esc(v).replace(marker, '<b class="bad">$1</b>');
108
109
 
109
110
  function worksheet(t, state) {
110
- const lines = v => marked(v);
111
+ const lines = v => marked(latexify(v));
111
112
  const figures = (state.images || []).map((img) => `<figure><img src="${img.data}" alt="${esc(img.name)}"><figcaption>${esc(img.name)}</figcaption></figure>`).join('');
112
113
  const notes = state.notes ? `<h2>${esc(t.labelSolution)}</h2><section>${lines(state.notes)}</section>` : '';
113
114
  const KATEX = 'https://cdn.jsdelivr.net/npm/katex@0.16.11/dist';