question-workbench-mcp 0.3.5 → 0.4.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/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: '文字自动保存在本机浏览器(按会话)', diagramNote: '图形以原图为准:打印默认附原图,文本里的「图形」一行仅作排版提示。', limit: '最多 12 张,单张 ≤15MB',
20
+ sendAsk: '发送', notesLabel: '解答 / 解析', notesPlaceholder: '把模型的思路、解答或总结粘贴到这里;会打印在题目之后', autoFilled: '已自动填入模型回复', waiting: '已发送,等待模型回复后自动填入…', autoFail: '未自动获取到回复,可用「从剪贴板粘贴」手动补充', saved: '文字自动保存在本机浏览器(按会话)', mathRule: '数学公式一律用 LaTeX:行内 $...$、独立 $$...$$;不要输出 ∠ △ ∵ ∴ ⊥ ∥ ² 之类的特殊符号,讲义会用 KaTeX 渲染。', 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', 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 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',
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.',
@@ -274,7 +274,7 @@ window.__ModuleLoader__.load({
274
274
  if (!photos.length) { say(t.needPhoto, true); return; }
275
275
  const extra = text.trim() ? t.optional + ':\n' + text.trim() + '\n\n' : '';
276
276
  const since = lastSeq();
277
- const ok = await send(extra + t.rec);
277
+ const ok = await send(t.context + '\n\n' + extra + t.rec + '\n' + t.mathRule);
278
278
  if (!ok) return;
279
279
  waitRef.current = { kind: 'text', since };
280
280
  if (timerRef.current) clearTimeout(timerRef.current);
@@ -282,7 +282,7 @@ window.__ModuleLoader__.load({
282
282
  say(t.waiting);
283
283
  setStep(2);
284
284
  }
285
- function askPrompt(ask) { return t.src + text.trim() + '\n\n' + t.rule + ask; }
285
+ function askPrompt(ask) { return t.src + text.trim() + '\n\n' + t.rule + t.mathRule + '\n\n' + ask; }
286
286
  async function doAsk(ask) {
287
287
  if (!text.trim()) { say(t.needText, true); return; }
288
288
  const full = ask === t.askF;
package/index.js CHANGED
@@ -24,6 +24,7 @@ const PROMPTS = {
24
24
  };
25
25
 
26
26
  const MODES = ['recognition', 'analysis', 'solution', 'summary', 'full'];
27
+ const MATH_RULE = '数学公式一律用 LaTeX:行内 $...$、独立 $$...$$;不要输出 ∠ △ ∵ ∴ ⊥ ∥ ² 之类的特殊符号,讲义用 KaTeX 渲染。';
27
28
  const MIME = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.gif': 'image/gif' };
28
29
 
29
30
  const escape = (v) => String(v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
@@ -40,7 +41,7 @@ export function buildPrompt(mode, text, language) {
40
41
  const lang = language === 'en' ? 'en' : 'zh';
41
42
  const body = text && String(text).trim();
42
43
  if (mode !== 'recognition' && !body) throw new Error('text is required for mode ' + mode);
43
- return PROMPTS[lang][mode].replace('{text}', body || '');
44
+ return PROMPTS[lang][mode].replace('{text}', body || '') + '\n\n' + MATH_RULE;
44
45
  }
45
46
 
46
47
  export function buildWorksheet(options = {}) {
@@ -54,9 +55,14 @@ export function buildWorksheet(options = {}) {
54
55
  if (!MIME[ext]) throw new Error('unsupported image type: ' + p);
55
56
  return { name: path.basename(p), data: `data:${MIME[ext]};base64,${fs.readFileSync(p).toString('base64')}` };
56
57
  });
57
- const lines = (v) => marked(v).split('\n').map((l) => `<div>${l || '&nbsp;'}</div>`).join('');
58
+ const lines = (v) => marked(v);
59
+ const KATEX = 'https://cdn.jsdelivr.net/npm/katex@0.16.11/dist';
60
+ const katexHead = '<link rel="stylesheet" href="' + KATEX + '/katex.min.css">'
61
+ + '<script defer src="' + KATEX + '/katex.min.js"></script>'
62
+ + '<script defer src="' + KATEX + '/contrib/auto-render.min.js" onload="renderMathInElement(document.body,{delimiters:[{left:\'$$\',right:\'$$\',display:true},{left:\'$\',right:\'$\',display:false},{left:\'\\\\[\',right:\'\\\\]\',display:true},{left:\'\\\\(\',right:\'\\\\)\',display:false}],throwOnError:false,errorColor:\'#b42318\'})"></script>';
58
63
  const html = '<!doctype html><html><head><meta charset="utf-8"><title>' + escape(title) + '</title>'
59
- + '<style>@page{size:A4;margin:16mm}body{font:12pt/1.7 system-ui,sans-serif;color:#161616}h1{font-size:18pt}h2{font-size:13pt;margin-top:16px;border-bottom:1px solid #999}section{white-space:pre-wrap;overflow-wrap:anywhere}figure{break-inside:avoid;margin:14px 0}figure img{max-width:100%;max-height:235mm;object-fit:contain}figcaption{font-size:9pt;color:#666}.bad{color:#b42318;background:#fff0ec}</style></head><body>'
64
+ + '<style>@page{size:A4;margin:16mm}body{font:12pt/1.75 system-ui,"Microsoft YaHei",sans-serif;color:#161616}h1{font-size:18pt}h2{font-size:13pt;margin-top:16px;border-bottom:1px solid #999}section{white-space:pre-wrap;overflow-wrap:anywhere}figure{break-inside:avoid;margin:14px 0}figure img{max-width:100%;max-height:235mm;object-fit:contain}figcaption{font-size:9pt;color:#666}.bad{color:#b42318;background:#fff0ec}.katex{font-size:1.05em}.katex-display{margin:.6em 0;overflow-x:auto;overflow-y:hidden}</style>'
65
+ + katexHead + '</head><body>'
60
66
  + '<h1>' + escape(title) + '</h1>'
61
67
  + (options.grade ? '<p>' + escape(options.grade) + '</p>' : '')
62
68
  + '<section>' + lines(text) + '</section>'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "question-workbench-mcp",
3
- "version": "0.3.5",
3
+ "version": "0.4.0",
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
@@ -35,6 +35,7 @@ const PROMPTS = {
35
35
  };
36
36
 
37
37
  const MODES = ['recognition', 'analysis', 'solution', 'summary', 'full'];
38
+ const MATH_RULE = '数学公式一律用 LaTeX:行内 $...$、独立 $$...$$;不要输出 ∠ △ ∵ ∴ ⊥ ∥ ² 之类的特殊符号,讲义用 KaTeX 渲染。';
38
39
 
39
40
  const TOOLS = [
40
41
  {
@@ -106,11 +107,16 @@ const marker = /([待核实[^]\n]{0,160}]|\[verify[^\]\n]{0,160}\])/gi;
106
107
  const marked = v => esc(v).replace(marker, '<b class="bad">$1</b>');
107
108
 
108
109
  function worksheet(t, state) {
109
- const lines = v => marked(v).split('\n').map(l => `<div>${l || '&nbsp;'}</div>`).join('');
110
+ const lines = v => marked(v);
110
111
  const figures = (state.images || []).map((img) => `<figure><img src="${img.data}" alt="${esc(img.name)}"><figcaption>${esc(img.name)}</figcaption></figure>`).join('');
111
112
  const notes = state.notes ? `<h2>${esc(t.labelSolution)}</h2><section>${lines(state.notes)}</section>` : '';
113
+ const KATEX = 'https://cdn.jsdelivr.net/npm/katex@0.16.11/dist';
114
+ const katexHead = '<link rel="stylesheet" href="' + KATEX + '/katex.min.css">'
115
+ + '<script defer src="' + KATEX + '/katex.min.js"></script>'
116
+ + '<script defer src="' + KATEX + '/contrib/auto-render.min.js" onload="renderMathInElement(document.body,{delimiters:[{left:\'$$\',right:\'$$\',display:true},{left:\'$\',right:\'$\',display:false},{left:\'\\\\[\',right:\'\\\\]\',display:true},{left:\'\\\\(\',right:\'\\\\)\',display:false}],throwOnError:false,errorColor:\'#b42318\'})"></script>';
112
117
  return '<!doctype html><html><head><meta charset="utf-8"><title>' + esc(state.title) + '</title>'
113
- + '<style>@page{size:A4;margin:16mm}body{font:12pt/1.7 system-ui,sans-serif;color:#161616}h1{font-size:18pt}h2{font-size:13pt;margin-top:16px;border-bottom:1px solid #999}section{white-space:pre-wrap;overflow-wrap:anywhere}figure{break-inside:avoid;margin:14px 0}figure img{max-width:100%;max-height:235mm;object-fit:contain}figcaption{font-size:9pt;color:#666}.bad{color:#b42318;background:#fff0ec}</style></head><body>'
118
+ + '<style>@page{size:A4;margin:16mm}body{font:12pt/1.75 system-ui,"Microsoft YaHei",sans-serif;color:#161616}h1{font-size:18pt}h2{font-size:13pt;margin-top:16px;border-bottom:1px solid #999}section{white-space:pre-wrap;overflow-wrap:anywhere}figure{break-inside:avoid;margin:14px 0}figure img{max-width:100%;max-height:235mm;object-fit:contain}figcaption{font-size:9pt;color:#666}.bad{color:#b42318;background:#fff0ec}.katex{font-size:1.05em}.katex-display{margin:.6em 0;overflow-x:auto;overflow-y:hidden}</style>'
119
+ + katexHead + '</head><body>'
114
120
  + '<h1>' + esc(state.title) + '</h1>'
115
121
  + (state.grade ? '<p>' + esc(state.grade) + '</p>' : '')
116
122
  + '<section>' + lines(state.text || '') + '</section>'
@@ -131,7 +137,7 @@ function callTool(name, args = {}) {
131
137
  const lang = args.language === 'en' ? 'en' : 'zh';
132
138
  const text = typeof args.text === 'string' ? args.text.trim() : '';
133
139
  if (mode !== 'recognition' && !text) throw new Error('text is required for mode ' + mode);
134
- return PROMPTS[lang][mode].replace('{text}', text);
140
+ return PROMPTS[lang][mode].replace('{text}', text) + '\n\n' + MATH_RULE;
135
141
  }
136
142
  if (name === 'build_worksheet') {
137
143
  const lang = args.language === 'en' ? 'en' : 'zh';