question-workbench-skill 0.0.0-stage → 0.1.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 ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ 首个发布版本。
6
+
7
+ **识别**
8
+ - 只做识别,输出两段:【题目】【图形】,识别阶段不解题。
9
+ - 【题目】以完整转录为准,不设总字数上限(长阅读、完形也能整段录入)。
10
+ - 【图形】每图一行、≤25 字,只写可见元素,避免把图示推断混进题干。
11
+ - 取消【待确认】段:看不清处直接在原文写 `[待核实:简短原因]`,不再单独列清单。
12
+
13
+ **解题**
14
+ - 提供 思路 / 完整解题 / 总结 / 全流程 四种模式,均带“已人工核对,不再质疑”的前缀。
15
+ - 各模式有篇幅建议(200 / 400 / 150 / 600 字),用于控制啰嗦,不截断内容。
16
+
17
+ **讲义**
18
+ - 附带 `scripts/make-worksheet.mjs`:生成 A4 讲义 HTML,支持题目、解答、嵌入本地原图。
19
+ - 兼容旧输出:文本中若仍有【待确认】段会自动剥离。
20
+ - 输出 JSON,给出生成的 `.html` 绝对路径,浏览器 Ctrl+P 预览分页并打印。
21
+
22
+ **安装**
23
+ - 提供 CLI:`npx question-workbench-skill`,默认安装到 `./.dsh/skills/question-workbench`。
24
+ - 支持 `--user`(`~/.dsh/skills`)、`--target .agents`、`--dir <path>`,便于 Codex / WorkBuddy 等客户端复用。
25
+ - 无运行时依赖,安装即复制 `SKILL.md` 与脚本。
26
+
27
+ **已知限制**
28
+ - 不做本地 OCR,也不做照片去阴影/裁剪(这部分属于 DSH 插件形态)。
29
+ - 图形细节依赖模型观察,需要精确图形时把原图通过 `images` 嵌入讲义。
30
+ - Skill 是文字指令,格式稳定性弱于带 JSON Schema 的工具。
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 question-workbench-skill contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,65 @@
1
- # Temporary Holding Version
1
+ # question-workbench-skill
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 题目工作台的 **Skill** 版本:识别题目图片(【题目】【图形】)、思路与完整解答、(可选)生成 A4 讲义 HTML 打印。不依赖任何插件运行时,凡支持 skill / 自定义指令的客户端都能用。
4
+
5
+ ## 安装
6
+
7
+ ```powershell
8
+ # 当前项目(生成 ./.dsh/skills/question-workbench)
9
+ npx question-workbench-skill
10
+
11
+ # 用户级(~/.dsh/skills/question-workbench)
12
+ npx question-workbench-skill --user
13
+
14
+ # 其他客户端的技能目录
15
+ npx question-workbench-skill --target .agents # ./.agents/skills/question-workbench
16
+ npx question-workbench-skill --dir D:\skills # 任意目录
17
+ ```
18
+
19
+ 安装就是复制 `SKILL.md` 和 `scripts/make-worksheet.mjs` 两个条目到目标目录,无依赖、无构建。
20
+
21
+ DSH 会扫描 `<项目>/.dsh/skills`、`<项目>/.agents/skills`、`~/.dsh/skills`;装好后新会话即可在技能列表看到 `question-workbench`。
22
+
23
+ ## 用法
24
+
25
+ 1. 发题目图片,让模型按 skill 输出【题目】【图形】两段(只识别,不解题)。
26
+ 2. 你确认或改正题目。
27
+ 3. 让模型按“思路 / 完整解题 / 总结 / 全流程”之一作答。
28
+ 4. 需要打印时,让模型调用讲义脚本:
29
+
30
+ ```powershell
31
+ node .dsh/skills/question-workbench/scripts/make-worksheet.mjs input.json
32
+ ```
33
+
34
+ `input.json`:
35
+
36
+ ```json
37
+ {
38
+ "text": "题目全文",
39
+ "notes": "解答全文",
40
+ "outputPath": "D:/下载/讲义.html",
41
+ "images": ["D:/题目.jpg"]
42
+ }
43
+ ```
44
+
45
+ 脚本输出生成的 HTML 绝对路径,浏览器打开后 Ctrl+P 打印。
46
+
47
+ ## 与另外两种形态的区别
48
+
49
+ | 形态 | 界面 | 自动回填 | 安装 |
50
+ |---|---|---|---|
51
+ | 本 Skill | 无 | 无 | 复制文件 / npx |
52
+ | `question-workbench-mcp`(DSH 插件) | 有面板 | 有 | 插件管理器 |
53
+ | `question-workbench-mcp`(MCP) | 无 | 无 | npx / MCP 配置 |
54
+
55
+ Skill 胜在零运行时、跨客户端;代价是只有指令,没有 UI,也没有 schema 校验。
56
+
57
+ ## 限制
58
+
59
+ - 不做本地 OCR;识别质量取决于客户端模型与图片清晰度。
60
+ - 图形细节不可靠,需要精确图形时把原图通过 `images` 嵌入讲义。
61
+ - 字数:识别以完整转录优先,不设总上限;图形每行 ≤25 字。
62
+
63
+ ## License
64
+
65
+ MIT
package/SKILL.md ADDED
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: question-workbench
3
+ description: 处理题目图片:识别(【题目】【图形】)、思路分析与完整解答、生成 A4 讲义 HTML 供打印。当用户发来题目照片,或要求识题、解题、整理题目、打印讲义时使用。
4
+ whenToUse: 用户提供题目图片/截图,或要求识别、解答、排版、打印题目。
5
+ ---
6
+
7
+ # 题目工作台
8
+
9
+ 把一次“拍照 → 识别 → 解题 → 打印”固定成可重复的流程。识图由当前模型完成;本 skill 只提供提示与讲义生成脚本。
10
+
11
+ ## 一、识别(这一步只做识别)
12
+
13
+ 用户发来图片后,**只做识别**,严格输出两段,不要解释:
14
+
15
+ - 【题目】逐字转录印刷文字,保留题号、选项、符号和公式;看不清写 `[待核实:简短原因]`,不要猜。**以完整转录为准,不设总字数上限**;长文(阅读填空、完形)也要转录完。
16
+ - 【图形】每张图一行,≤25 字,只写可见关键元素,例如:图1 三角形ABC,P在内部,BM、CN交于P。
17
+
18
+ 不要在这一步解题,也不要补全图中看不清的内容。输出后停下来等用户确认。
19
+
20
+ ## 二、解题(用户确认题目之后)
21
+
22
+ 用户确认或改正题目后,以下列前缀开始,再按所选模式作答:
23
+
24
+ ```
25
+ 以下内容已由用户对照原图人工核对,直接作为已知条件使用;不要重新质疑,也不要补充未确认的关系。
26
+
27
+ 已核对题目:
28
+ <用户的题目文本>
29
+ ```
30
+
31
+ 可选模式:
32
+
33
+ - 思路:只给思路,不要完整计算:①考点 1 行 ②关键思路 3-5 步。≤200 字。
34
+ - 完整解题:给完整解题过程:分步推导+最终答案,公式简洁。≤400 字。
35
+ - 总结:只总结:3-5 条知识点与易错点,每条一行。≤150 字。
36
+ - 全流程:先给 3-5 步思路,再给完整解答和最终答案,最后 1-2 句易错点提醒;不重复题目。≤600 字。
37
+
38
+ ## 三、生成讲义
39
+
40
+ 需要打印时,把题目与解答写成 JSON 交给脚本:
41
+
42
+ ```bash
43
+ node <本 skill 目录>/scripts/make-worksheet.mjs input.json
44
+ ```
45
+
46
+ `input.json` 示例:
47
+
48
+ ```json
49
+ {
50
+ "text": "题目全文",
51
+ "notes": "解答全文",
52
+ "outputPath": "D:/下载/讲义.html",
53
+ "images": ["D:/题目.jpg"]
54
+ }
55
+ ```
56
+
57
+ - `text` 必填;`notes` 可选(打印在题目之后)
58
+ - `images` 可选:本地图片绝对路径数组,会嵌入讲义
59
+ - `outputPath` 默认当前目录;脚本输出 JSON,含生成的 `.html` 绝对路径
60
+ - 用浏览器打开后 Ctrl+P 预览分页并打印
61
+
62
+ ## 注意
63
+
64
+ - 不把图片里的推断写进“题干原文”;点在某条边上属于图示观察,要放在【图形】里。
65
+ - 不做本地 OCR,也不做照片增强;识别质量取决于模型与图片清晰度。
66
+ - 图形细节不可靠时保留原图(`images` 传入),以原图为准。
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ // Install the question-workbench skill into a skill directory.
3
+ // npx question-workbench-skill -> ./.dsh/skills/question-workbench
4
+ // npx question-workbench-skill --target .agents -> ./.agents/skills/question-workbench
5
+ // npx question-workbench-skill --user -> <home>/.dsh/skills/question-workbench
6
+ // npx question-workbench-skill --dir <path> -> <path>
7
+ import fs from 'node:fs';
8
+ import os from 'node:os';
9
+ import path from 'node:path';
10
+ import { fileURLToPath } from 'node:url';
11
+
12
+ const here = path.dirname(fileURLToPath(import.meta.url));
13
+ const pkgRoot = path.resolve(here, '..');
14
+ const args = process.argv.slice(2);
15
+
16
+ function flag(name) { return args.includes('--' + name); }
17
+ function value(name) {
18
+ const i = args.indexOf('--' + name);
19
+ return i >= 0 && args[i + 1] && !args[i + 1].startsWith('--') ? args[i + 1] : undefined;
20
+ }
21
+
22
+ const targetRoot = value('dir')
23
+ ? path.resolve(value('dir'))
24
+ : flag('user')
25
+ ? path.join(os.homedir(), '.dsh', 'skills')
26
+ : path.join(process.cwd(), value('target') || '.dsh', 'skills');
27
+
28
+ const dest = path.join(targetRoot, 'question-workbench');
29
+
30
+ if (flag('help') || flag('h')) {
31
+ console.log('用法: question-workbench-skill [--user | --target <dir> | --dir <path>]');
32
+ process.exit(0);
33
+ }
34
+
35
+ fs.mkdirSync(dest, { recursive: true });
36
+ for (const item of ['SKILL.md', 'scripts']) {
37
+ const from = path.join(pkgRoot, item);
38
+ const to = path.join(dest, item);
39
+ if (!fs.existsSync(from)) { console.error('missing file in package: ' + item); process.exit(1); }
40
+ fs.cpSync(from, to, { recursive: true });
41
+ }
42
+
43
+ console.log('已安装 skill 到: ' + dest);
44
+ console.log('SKILL.md: ' + path.join(dest, 'SKILL.md'));
45
+ console.log('讲义脚本: ' + path.join(dest, 'scripts', 'make-worksheet.mjs'));
46
+ console.log('提示: DSH 会扫描 <项目>/.dsh/skills 与 ~/.dsh/skills;重启或等待目录监听后出现在技能列表。');
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "question-workbench-skill",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "题目工作台 Skill:识别题目图片、思路与解答、生成 A4 讲义 HTML。一条命令安装到 DSH / Codex / WorkBuddy 等支持 skill 的客户端。",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "keywords": ["skill", "dsh", "codex", "workbuddy", "worksheet", "education"],
8
+ "bin": { "question-workbench-skill": "./bin/install.mjs" },
9
+ "files": ["SKILL.md", "scripts/make-worksheet.mjs", "bin/install.mjs", "README.md", "CHANGELOG.md", "LICENSE"],
10
+ "engines": { "node": ">=18" }
6
11
  }
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ // Build an A4 worksheet HTML. Usage:
3
+ // node make-worksheet.mjs '{"text":"...","notes":"...","outputPath":"D:/x.html"}'
4
+ // Prints JSON: { path, bytes, images }
5
+ import fs from 'node:fs';
6
+ import path from 'node:path';
7
+
8
+ const MIME = { '.png': 'image/png', '.jpg': 'image/jpeg', '.jpeg': 'image/jpeg', '.webp': 'image/webp', '.gif': 'image/gif' };
9
+ const esc = (v) => String(v).replace(/[&<>"']/g, (c) => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' }[c]));
10
+ const marker = /([待核实[^]\n]{0,160}]|\[verify[^\]\n]{0,160}\])/gi;
11
+ const marked = (v) => esc(v).replace(marker, '<b class="bad">$1</b>');
12
+ const stripChecks = (v) => String(v)
13
+ .replace(/(?:^|\n)\s*【(?:待确认|待核实)】[\s\S]*?(?=\n\s*【|$)/g, '')
14
+ .replace(/(?:^|\n)\s*\[(?:Checks|Items to verify)\][\s\S]*?(?=\n\s*\[|$)/gi, '')
15
+ .replace(/\n{3,}/g, '\n\n')
16
+ .trim();
17
+
18
+ const raw = (() => {
19
+ const arg = process.argv[2];
20
+ if (!arg) return '';
21
+ try { if (fs.existsSync(arg) && fs.statSync(arg).isFile()) return fs.readFileSync(arg, 'utf8'); } catch (e) {}
22
+ return arg;
23
+ })();
24
+ if (!raw) { console.error('usage: node make-worksheet.mjs <json-or-file>'); process.exit(2); }
25
+ let options;
26
+ try { options = JSON.parse(raw); } catch (e) { console.error('invalid JSON: ' + e.message); process.exit(2); }
27
+
28
+ const text = options.skipChecks === false ? String(options.text || '') : stripChecks(options.text || '');
29
+ if (!String(text).trim()) { console.error('text is required'); process.exit(2); }
30
+ const figures = (Array.isArray(options.images) ? options.images : []).map((file) => {
31
+ const p = path.resolve(file);
32
+ const ext = path.extname(p).toLowerCase();
33
+ if (!MIME[ext]) throw new Error('unsupported image type: ' + p);
34
+ return { name: path.basename(p), data: 'data:' + MIME[ext] + ';base64,' + fs.readFileSync(p).toString('base64') };
35
+ });
36
+ const lines = (v) => marked(v).split('\n').map((l) => '<div>' + (l || '&nbsp;') + '</div>').join('');
37
+ const title = (options.title && String(options.title).trim()) || '题目讲义';
38
+ const notes = options.notes && String(options.notes).trim()
39
+ ? '<h2>解答 / 解析</h2><section>' + lines(options.notes) + '</section>' : '';
40
+ const html = '<!doctype html><html><head><meta charset="utf-8"><title>' + esc(title) + '</title>'
41
+ + '<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>'
42
+ + '<h1>' + esc(title) + '</h1>'
43
+ + (options.grade ? '<p>' + esc(options.grade) + '</p>' : '')
44
+ + '<section>' + lines(text) + '</section>'
45
+ + figures.map((f) => '<figure><img src="' + f.data + '" alt="' + esc(f.name) + '"><figcaption>' + esc(f.name) + '</figcaption></figure>').join('')
46
+ + notes + '</body></html>';
47
+
48
+ const target = options.outputPath ? path.resolve(options.outputPath) : path.join(process.cwd(), 'question-worksheet-' + Date.now() + '.html');
49
+ if (path.extname(target).toLowerCase() !== '.html') { console.error('outputPath must end with .html'); process.exit(2); }
50
+ const dir = path.dirname(target);
51
+ if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
52
+ fs.writeFileSync(target, html, 'utf8');
53
+ console.log(JSON.stringify({ path: target, bytes: Buffer.byteLength(html), images: figures.length }, null, 2));