@taxueseek/dsh-lexicon 0.0.0-stage → 0.3.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/README.md CHANGED
@@ -1,3 +1,54 @@
1
- # Temporary Holding Version
1
+ # dsh-lexicon
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
+ IME lexicon manager for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (`dsh`): it bundles the `ime_lexicon.py` engine and exposes it to the model as tools for managing **Doubao(豆包)** and **WeType(微信输入法)** personal word libraries — detect, export, backup, industry-term search, build, optimize, harvest, Doubao slot dedup, and staging import.
4
+
5
+ The Python engine ships inside this package (`vendor/ime-lexicon/`) and stays the single source of truth for all file-layer operations; the plugin only shells out with validated args and bounded timeouts. **Import never applies to a live IME** — `apply` is deliberately not exposed as a tool and remains a manual, user-confirmed step.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ dsh plugin add @taxueseek/dsh-lexicon
11
+ # or straight from GitHub
12
+ dsh plugin add taxueseek/dsh-lexicon
13
+ ```
14
+
15
+ Requires `python3` on PATH (the engine is pure-stdlib Python; no pip installs).
16
+
17
+ ## Tools
18
+
19
+ | Tool | Purpose |
20
+ |---|---|
21
+ | `ime_detect` | Report Doubao / WeType library status and used slots. |
22
+ | `ime_export` | Export word libraries to TSV (read-only snapshot). |
23
+ | `ime_backup` | Timestamped backup of the word libraries. |
24
+ | `ime_search` | Industry terminology search — prints a plan by default; `run: true` executes the actual search (argo first, generic fallback). |
25
+ | `ime_build` | Build an industry word-list TSV from a raw term list; optional THUOCL domain seeds (`seed: "thuocl:财经"`) and prose extraction (`prose: true`). |
26
+ | `ime_optimize` | Merge / dedupe / correct word lists across sources. |
27
+ | `ime_import` | Stage an optimized TSV into the staging area (set `replace` to rebuild from this TSV only, dropping corrected/removed words) — never touches the live library. |
28
+ | `ime_dedup` | One-shot dedup of duplicated Doubao slots: winner keeps its exact bytes and slot, duplicates cleared, staging only — writing live stays manual. |
29
+ | `ime_harvest` | Harvest candidate words from local material: curated files (default), voice transcriptions, session-digger conversations, old-PC word lists. Tables only, never applies. |
30
+
31
+ ## Discipline rules
32
+
33
+ - Copy before read, staging before apply; the input method must be exited before any apply.
34
+ - Doubao slot count is read from the live header (`ime_detect` reports it): 5000 / 7500 / 10000 by version; imports default to a header-derived budget.
35
+ - Core words need pinyin; polyphones go to the extended list; pinyin-less terms go to the general list and are never applied.
36
+ - Error-fix replace: `ime_import` with `replace` rebuilds the staged library from only this TSV (not merged into live), dropping words optimize rewrote/removed; pinyin-less terms are still never applied.
37
+ - `ime_search --run` uses network (argo → generic fallback); it may take a couple of minutes.
38
+
39
+ ## Config
40
+
41
+ | Key | Default | Meaning |
42
+ |---|---|---|
43
+ | `scriptPath` | bundled `vendor/ime-lexicon/ime_lexicon.py` | Path to the engine script (override to use your own copy) |
44
+ | `scriptTimeoutMs` | 120000 | Timeout for local commands |
45
+ | `searchTimeoutMs` | 300000 | Timeout for `search --run` (network) |
46
+
47
+ ## Security notes
48
+
49
+ - Nothing leaves the machine except `ime_search --run` network calls; exports and backups stay local.
50
+ - The plugin never applies changes to a live IME — that stays a manual step.
51
+
52
+ ## License
53
+
54
+ MIT
package/README.zh.md ADDED
@@ -0,0 +1,54 @@
1
+ # dsh-lexicon
2
+
3
+ 面向 [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness)(`dsh`)的词库管家:自带 `ime_lexicon.py` 引擎,并把它桥接成模型工具,管理**豆包 / 微信输入法**个人词库——检测、导出、备份、行业术语搜索、建库、修正、素材收词、豆包重复槽去重、staging 导入。
4
+
5
+ Python 引擎随包分发(`vendor/ime-lexicon/`),仍然是文件层操作的唯一真源;本插件只做参数校验与超时控制的调用。**导入永远不会写入正在使用的输入法**——`apply` 刻意不作为工具暴露,始终是用户手动确认的步骤。
6
+
7
+ ## 安装
8
+
9
+ ```sh
10
+ dsh plugin add @taxueseek/dsh-lexicon
11
+ # 或直接从 GitHub 安装
12
+ dsh plugin add taxueseek/dsh-lexicon
13
+ ```
14
+
15
+ 要求 PATH 里有 `python3`(引擎是纯标准库 Python,无需 pip 装依赖)。
16
+
17
+ ## 工具
18
+
19
+ | 工具 | 用途 |
20
+ |---|---|
21
+ | `ime_detect` | 报告豆包 / 微信输入法词库状态与已用槽位。 |
22
+ | `ime_export` | 导出词库为 TSV(只读快照)。 |
23
+ | `ime_backup` | 带时间戳的词库备份。 |
24
+ | `ime_search` | 行业术语搜索——默认只出计划;`run: true` 才真正执行搜索(argo 优先,通用搜索兜底)。 |
25
+ | `ime_build` | 从原始术语清单生成行业词库 TSV;`seed: "thuocl:财经"` 可选 THUOCL 领域种子,`prose: true` 按正文抽短词。 |
26
+ | `ime_optimize` | 跨来源合并、去重、纠错词表。 |
27
+ | `ime_import` | 把优化后的 TSV 写入 staging 区(加 `replace` 整表替换,剔除已被改写/删除的旧词)——绝不触碰正在使用的词库。 |
28
+ | `ime_dedup` | 豆包重复槽一键去重:赢家槽原样保留、重复槽清零,只写 staging——写 live 始终是手动步骤。 |
29
+ | `ime_harvest` | 从本地素材收候选词:素材文件(默认)、语音转写、session-digger 会话语料、旧电脑词库四种来源,只出表不 apply。 |
30
+
31
+ ## 纪律规则
32
+
33
+ - 先拷后读后写,staging 先行,apply 前输入法必须退出。
34
+ - 豆包槽数以 `ime_detect` 实读 header 为准(5000 / 7500 / 10000 随版本变),导入默认按槽数带预算。
35
+ - 核心词必须有拼音;多音进扩展;无拼音进大词库且禁止 apply。
36
+ - 消错替换:`ime_import` 加 `replace` 用优化表整表替换(不并入 live),剔除 optimize 已改写/删除的错误词;无拼音词仍禁止 apply。
37
+ - `ime_search --run` 走网络(argo → 通用兜底),可能需要几分钟。
38
+
39
+ ## 配置
40
+
41
+ | 键 | 默认值 | 含义 |
42
+ |---|---|---|
43
+ | `scriptPath` | 随包的 `vendor/ime-lexicon/ime_lexicon.py` | 引擎脚本路径(可覆盖为自备副本) |
44
+ | `scriptTimeoutMs` | 120000 | 本地命令超时 |
45
+ | `searchTimeoutMs` | 300000 | `search --run`(网络)超时 |
46
+
47
+ ## 安全说明
48
+
49
+ - 除 `ime_search --run` 的网络调用外,所有操作都在本机;导出和备份留在本地。
50
+ - 插件绝不 apply 到正在使用的输入法——这始终是手动步骤。
51
+
52
+ ## License
53
+
54
+ MIT
@@ -0,0 +1,10 @@
1
+ # dsh-lexicon bundle patch: one insert registering the IME lexicon toolkit.
2
+ # The row id must match the node half's exported cordis `name`.
3
+ # scriptPath is intentionally omitted — the node half defaults to the bundled
4
+ # copy under vendor/ime-lexicon; override it in settings to point elsewhere.
5
+ - insert:
6
+ - id: lexicon-toolkit
7
+ name: 'dsh-lexicon'
8
+ config:
9
+ scriptTimeoutMs: 120000
10
+ searchTimeoutMs: 300000
package/lib/index.js ADDED
@@ -0,0 +1,34 @@
1
+ // dsh-lexicon — a DeepSeek Harness plugin bridging ime_lexicon.py (Doubao /
2
+ // WeType input-method word libraries) into model tools. The Python script
3
+ // stays the single source of truth for file-layer operations; this plugin
4
+ // only shells out with validated args and bounded timeouts.
5
+ import z from '@deepseek-ai/schemastery';
6
+ import { defineLexiconTools } from "./tools.js";
7
+ import { BUNDLED_SCRIPT, expandHome, runScript } from "./runtime.js";
8
+ /** Cordis plugin name — must match the row id in cordis.patch.yml. */
9
+ export const name = 'dsh-lexicon';
10
+ /** Services required by this plugin. */
11
+ export const inject = ['tools', 'systemPrompt'];
12
+ export const Config = z.object({
13
+ scriptPath: z.string().default(BUNDLED_SCRIPT),
14
+ scriptTimeoutMs: z.number().default(120_000),
15
+ searchTimeoutMs: z.number().default(300_000)
16
+ });
17
+ export function apply(ctx, config) {
18
+ const script = expandHome(config.scriptPath);
19
+ ctx.systemPrompt.section({
20
+ name: 'tool:ime-lexicon',
21
+ order: 110,
22
+ text: 'The dsh-lexicon plugin manages Doubao / WeType (微信输入法) personal word libraries through the ime_lexicon.py CLI. ' +
23
+ 'Use ime_detect to check IME state, ime_export/ime_backup for safe snapshots, ime_search/ime_build/ime_harvest/ime_optimize to craft word lists, ' +
24
+ 'ime_dedup to clean duplicated Doubao slots (staging only), and ime_import to stage them. ' +
25
+ 'NEVER apply staged changes to a live IME without the user explicitly confirming — apply is a manual step outside this plugin.'
26
+ });
27
+ const exec = (args, timeoutMs) => runScript(script, args, timeoutMs);
28
+ for (const tool of defineLexiconTools(exec, {
29
+ scriptTimeoutMs: config.scriptTimeoutMs,
30
+ searchTimeoutMs: config.searchTimeoutMs
31
+ })) {
32
+ ctx.tools.register(tool);
33
+ }
34
+ }
package/lib/runtime.js ADDED
@@ -0,0 +1,34 @@
1
+ // Process plumbing for shelling out to the bundled ime_lexicon.py engine.
2
+ // Kept out of the plugin entry (src/index.ts) so the Loader sees exactly the
3
+ // four expected exports (name / inject / Config / apply); tests and tools
4
+ // import from this module instead.
5
+ import { spawn } from 'node:child_process';
6
+ import { homedir } from 'node:os';
7
+ import { dirname, join } from 'node:path';
8
+ import { fileURLToPath } from 'node:url';
9
+ /** Bundled ime_lexicon.py engine shipped under vendor/ime-lexicon (lib/runtime.js → ../vendor). */
10
+ export const BUNDLED_SCRIPT = join(dirname(fileURLToPath(import.meta.url)), '..', 'vendor', 'ime-lexicon', 'ime_lexicon.py');
11
+ export function runScript(scriptPath, args, timeoutMs, cwd = process.cwd()) {
12
+ return new Promise((resolve) => {
13
+ const child = spawn('python3', [scriptPath, ...args], { cwd });
14
+ let stdout = '';
15
+ let stderr = '';
16
+ const timer = setTimeout(() => {
17
+ child.kill('SIGKILL');
18
+ resolve({ code: -1, stdout, stderr: `ime_lexicon.py timed out after ${timeoutMs}ms (SIGKILL)` });
19
+ }, timeoutMs);
20
+ child.stdout.on('data', (d) => (stdout += d.toString('utf8')));
21
+ child.stderr.on('data', (d) => (stderr += d.toString('utf8')));
22
+ child.on('error', (err) => {
23
+ clearTimeout(timer);
24
+ resolve({ code: -1, stdout: '', stderr: String(err.message) });
25
+ });
26
+ child.on('close', (code) => {
27
+ clearTimeout(timer);
28
+ resolve({ code: code ?? -1, stdout, stderr });
29
+ });
30
+ });
31
+ }
32
+ export function expandHome(p) {
33
+ return p === '~' ? homedir() : p.startsWith('~/') ? join(homedir(), p.slice(2)) : p;
34
+ }
package/lib/tools.js ADDED
@@ -0,0 +1,245 @@
1
+ // The model-facing IME lexicon tools. Every tool shells out to ime_lexicon.py
2
+ // with validated arguments. The script's own discipline rules are preserved:
3
+ // imports/dedup only write a staging area, never a live IME; `apply` (and
4
+ // dedup's --apply flag) is deliberately not exposed as a tool.
5
+ import { defineTool } from '@deepseek-ai/dsh-tools';
6
+ function renderJson(_args, value) {
7
+ return [{ type: 'text', text: JSON.stringify(value, null, 2) }];
8
+ }
9
+ /** Run the script and return { stdout, stderr } or throw with the tail of stderr. */
10
+ async function call(run, args, timeoutMs, okCodes = [0]) {
11
+ const r = await run(args, timeoutMs);
12
+ if (!okCodes.includes(r.code)) {
13
+ const tail = (r.stderr.trim() || r.stdout.trim()).split('\n').slice(-8).join('\n');
14
+ throw new Error(`ime_lexicon.py ${args[0]} failed (${r.code}): ${tail}`);
15
+ }
16
+ return r.stdout.trim();
17
+ }
18
+ function nonEmpty(value, label) {
19
+ if (typeof value !== 'string' || value.trim() === '')
20
+ throw new Error(`${label} must be a non-empty string`);
21
+ return value.trim();
22
+ }
23
+ function posInt(value, label, def, max = 1_000_000) {
24
+ if (value === undefined)
25
+ return def;
26
+ const n = Math.trunc(Number(value));
27
+ if (!Number.isInteger(n) || n < 1 || n > max)
28
+ throw new Error(`${label} must be an integer in [1, ${max}]`);
29
+ return n;
30
+ }
31
+ export function defineLexiconTools(run, opts) {
32
+ return [
33
+ defineTool({
34
+ name: 'ime_detect',
35
+ description: 'Detect the status of the Doubao and WeType (微信输入法) personal word libraries: which engines are running and how many slots are used. Slot counts are read from the library header and vary by version (5000/7500/10000).',
36
+ parameters: {},
37
+ output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
38
+ isConcurrencySafe: () => true,
39
+ async execute() {
40
+ return { result: await call(run, ['detect'], opts.scriptTimeoutMs) };
41
+ }
42
+ }),
43
+ defineTool({
44
+ name: 'ime_export',
45
+ description: 'Export IME word libraries to TSV files (intermediate table: word \\t pinyin \\t freq \\t source \\t syll \\t note). Nothing is modified — this is a read-only snapshot.',
46
+ parameters: {
47
+ engine: {
48
+ type: 'string',
49
+ enum: ['all', 'doubao', 'wechat', 'wetype'],
50
+ description: 'Which engine(s) to export. Defaults to all.'
51
+ }
52
+ },
53
+ output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
54
+ isConcurrencySafe: () => true,
55
+ async execute(args) {
56
+ const argv = ['export'];
57
+ if (args.engine !== undefined && args.engine !== 'all')
58
+ argv.push('--engine', args.engine);
59
+ return { result: await call(run, argv, opts.scriptTimeoutMs) };
60
+ }
61
+ }),
62
+ defineTool({
63
+ name: 'ime_backup',
64
+ description: 'Back up the IME word libraries to a timestamped snapshot. Returns the backup location.',
65
+ parameters: {},
66
+ output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
67
+ isConcurrencySafe: () => true,
68
+ async execute() {
69
+ return { result: await call(run, ['backup'], opts.scriptTimeoutMs) };
70
+ }
71
+ }),
72
+ defineTool({
73
+ name: 'ime_search',
74
+ description: 'Search for industry/domain terminology to build a word list. WITHOUT --run it only prints a search plan (no network). ' +
75
+ 'WITH run=true it actually searches (argo first, generic fallback) and may take a couple of minutes.',
76
+ parameters: {
77
+ topic: { type: 'string', required: true, description: 'Topic or industry, e.g. 锂电池, 投资理财.' },
78
+ run: { type: 'boolean', description: 'Actually execute the search (network). Defaults to false.' },
79
+ out: { type: 'string', description: 'Optional output file for the raw term list.' },
80
+ engine: { type: 'string', enum: ['auto', 'argo', 'generic'], description: 'Search engine. auto prefers argo when available. Defaults to auto.' }
81
+ },
82
+ output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
83
+ isConcurrencySafe: () => true,
84
+ async execute(args) {
85
+ const argv = ['search', '--topic', nonEmpty(args.topic, 'topic')];
86
+ if (args.run === true)
87
+ argv.push('--run');
88
+ if (args.out !== undefined && args.out.trim() !== '')
89
+ argv.push('--out', args.out.trim());
90
+ if (args.engine !== undefined && args.engine.trim() !== '')
91
+ argv.push('--engine', args.engine.trim());
92
+ return { result: await call(run, argv, args.run === true ? opts.searchTimeoutMs : opts.scriptTimeoutMs) };
93
+ }
94
+ }),
95
+ defineTool({
96
+ name: 'ime_build',
97
+ description: 'Build an industry word-list TSV from a raw term list. Terms without pinyin go to the general list (never applied). Optionally seed from a THUOCL domain word list (seed="thuocl:财经") or extract short words from prose text (prose=true).',
98
+ parameters: {
99
+ topic: { type: 'string', required: true, description: 'Topic label for the word list.' },
100
+ from: { type: 'string', required: true, description: 'Path to the raw term list file (one term per line or TSV).' },
101
+ term: { type: 'string', description: 'Optional key:value override, e.g. "材料:磷酸铁锂". Repeatable via comma.' },
102
+ seed: { type: 'string', description: 'THUOCL domain seeds, e.g. "thuocl:财经,thuocl:IT". Repeatable via comma.' },
103
+ prose: { type: 'boolean', description: 'Extract short words from prose text instead of one-term-per-line. Defaults to false.' }
104
+ },
105
+ output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
106
+ isConcurrencySafe: () => true,
107
+ async execute(args) {
108
+ const argv = ['build', '--topic', nonEmpty(args.topic, 'topic'), '--from', nonEmpty(args.from, 'from')];
109
+ if (args.term !== undefined && args.term.trim() !== '') {
110
+ for (const t of args.term.split(',')) {
111
+ if (t.trim() !== '')
112
+ argv.push('--term', t.trim());
113
+ }
114
+ }
115
+ if (args.seed !== undefined && args.seed.trim() !== '') {
116
+ for (const s of args.seed.split(',')) {
117
+ if (s.trim() !== '')
118
+ argv.push('--seed', s.trim());
119
+ }
120
+ }
121
+ if (args.prose === true)
122
+ argv.push('--prose');
123
+ return { result: await call(run, argv, opts.scriptTimeoutMs) };
124
+ }
125
+ }),
126
+ defineTool({
127
+ name: 'ime_optimize',
128
+ description: 'Merge/dedupe/correct word lists: fix obvious pinyin/spelling issues, remove noise, dedupe across sources. Writes to --out, never in place.',
129
+ parameters: {
130
+ from: {
131
+ type: 'string',
132
+ required: true,
133
+ description: 'Comma-separated input TSV paths (repeatable sources are merged).'
134
+ },
135
+ profile: {
136
+ type: 'string',
137
+ enum: ['personal', 'industry'],
138
+ description: 'Optimization profile: personal (merges into your lexicon) or industry (keeps terms for sharing).'
139
+ },
140
+ budget: { type: 'number', description: 'Max entries to keep (default: engine-appropriate budget).' },
141
+ out: { type: 'string', description: 'Output directory for the optimized TSV.' }
142
+ },
143
+ output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
144
+ isConcurrencySafe: () => true,
145
+ async execute(args) {
146
+ const argv = ['optimize'];
147
+ for (const f of nonEmpty(args.from, 'from').split(',')) {
148
+ if (f.trim() !== '')
149
+ argv.push('--from', f.trim());
150
+ }
151
+ if (args.profile !== undefined && args.profile.trim() !== '')
152
+ argv.push('--profile', args.profile.trim());
153
+ if (args.budget !== undefined)
154
+ argv.push('--budget', String(posInt(args.budget, 'budget', 5000)));
155
+ if (args.out !== undefined && args.out.trim() !== '')
156
+ argv.push('--out', args.out.trim());
157
+ return { result: await call(run, argv, opts.scriptTimeoutMs) };
158
+ }
159
+ }),
160
+ defineTool({
161
+ name: 'ime_import',
162
+ description: 'Stage an optimized TSV into the IME staging area WITHOUT touching the live library (import never applies; the input method must be exited before any apply, and apply stays a manual step). ' +
163
+ 'Set replace to rebuild the staged library from ONLY this TSV, dropping live words that were corrected/removed by optimize (e.g. typos like agnet, noise). ' +
164
+ 'Report the staged entry count back to the user and ask before anything further.',
165
+ parameters: {
166
+ engine: {
167
+ type: 'string',
168
+ enum: ['doubao', 'wechat', 'wetype'],
169
+ required: true,
170
+ description: 'Target engine. doubao budgets against the live header slot count (5000/7500/10000 by version — detect reports it); wechat/wetype use their own file format.'
171
+ },
172
+ from: { type: 'string', required: true, description: 'Path to the optimized TSV.' },
173
+ budget: { type: 'number', description: 'Entry budget for the staging write (defaults to the engine slot limit read from the header).' },
174
+ replace: { type: 'boolean', description: '整表替换(消错):用优化表重建 staging,不并入 live,去掉已被改写/删除的旧词。' }
175
+ },
176
+ output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
177
+ isConcurrencySafe: () => true,
178
+ async execute(args) {
179
+ const argv = ['import', '--engine', nonEmpty(args.engine, 'engine'), '--from', nonEmpty(args.from, 'from')];
180
+ if (args.budget !== undefined)
181
+ argv.push('--budget', String(posInt(args.budget, 'budget', 5000)));
182
+ if (args.replace)
183
+ argv.push('--replace');
184
+ return { result: await call(run, argv, opts.scriptTimeoutMs) };
185
+ }
186
+ }),
187
+ defineTool({
188
+ name: 'ime_dedup',
189
+ description: 'One-shot cleanup of duplicated Doubao slots: the winning entry keeps its exact bytes and slot, duplicates are cleared, and the trimmed table is written to the STAGING area only. ' +
190
+ 'The live library is never touched (writing live requires the input method to be exited and stays a manual step). Run ime_detect first; duplicate rate above ~15% suggests running this.',
191
+ parameters: {
192
+ engine: {
193
+ type: 'string',
194
+ enum: ['doubao'],
195
+ description: 'Target engine. Only doubao supports slot dedup. Defaults to doubao.'
196
+ },
197
+ staging: { type: 'string', description: 'Optional explicit staging path override (defaults to the detected one).' },
198
+ live: { type: 'string', description: 'Optional live path override for comparison only — never written.' }
199
+ },
200
+ output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
201
+ isConcurrencySafe: () => true,
202
+ async execute(args) {
203
+ const argv = ['dedup', '--engine', args.engine ?? 'doubao'];
204
+ if (args.staging !== undefined && args.staging.trim() !== '')
205
+ argv.push('--staging', args.staging.trim());
206
+ if (args.live !== undefined && args.live.trim() !== '')
207
+ argv.push('--live', args.live.trim());
208
+ // --apply is deliberately never passed: writing the live IME stays manual.
209
+ return { result: await call(run, argv, opts.scriptTimeoutMs) };
210
+ }
211
+ }),
212
+ defineTool({
213
+ name: 'ime_harvest',
214
+ description: 'Harvest candidate words from local material into a TSV (never applies). Modes: material (default: curated 金句/洞见 files → 创作词库), speech (voice transcription/corrections → 语音词库), sessions (session-digger conversation index → 会话语料), legacy (old PC Win Sogou/Xunfei/ms-pinyin dicts → 旧电脑词库). ' +
215
+ 'Exit code 2 means "no material found" and is a normal outcome, not an error.',
216
+ parameters: {
217
+ mode: {
218
+ type: 'string',
219
+ enum: ['material', 'speech', 'sessions', 'legacy'],
220
+ description: 'Harvest source. Defaults to material (curated files; use from to point at specific files).'
221
+ },
222
+ from: { type: 'string', description: 'Comma-separated source file paths (material mode; one term per line or prose).' },
223
+ out: { type: 'string', description: 'Optional output TSV path (defaults to the engine-standard filename per mode).' }
224
+ },
225
+ output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
226
+ isConcurrencySafe: () => true,
227
+ async execute(args) {
228
+ const argv = ['harvest'];
229
+ const mode = args.mode ?? 'material';
230
+ if (mode !== 'material')
231
+ argv.push(`--${mode}`);
232
+ if (mode === 'material' && args.from !== undefined && args.from.trim() !== '') {
233
+ for (const f of args.from.split(',')) {
234
+ if (f.trim() !== '')
235
+ argv.push('--from', f.trim());
236
+ }
237
+ }
238
+ if (args.out !== undefined && args.out.trim() !== '')
239
+ argv.push('--out', args.out.trim());
240
+ // Exit 2 = "no material, skipped" printed on stdout — a normal outcome.
241
+ return { result: await call(run, argv, opts.scriptTimeoutMs, [0, 2]) };
242
+ }
243
+ })
244
+ ];
245
+ }
package/package.json CHANGED
@@ -1,6 +1,53 @@
1
1
  {
2
2
  "name": "@taxueseek/dsh-lexicon",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.3.0",
4
+ "description": "IME lexicon manager for DeepSeek Harness: bundles the ime_lexicon.py engine (Doubao / WeType word libraries) as model tools — detect, export, backup, industry-term search, build (THUOCL seeds), optimize, harvest, Doubao slot dedup, and staging import. Never applies to a live IME without explicit user confirmation.",
5
+ "keywords": [
6
+ "deepseek",
7
+ "harness",
8
+ "dsh",
9
+ "cordis",
10
+ "plugin",
11
+ "ime",
12
+ "lexicon",
13
+ "doubao",
14
+ "wetype",
15
+ "input-method"
16
+ ],
17
+ "type": "module",
18
+ "main": "lib/index.js",
19
+ "exports": {
20
+ ".": "./lib/index.js",
21
+ "./package.json": "./package.json"
22
+ },
23
+ "files": [
24
+ "lib",
25
+ "vendor",
26
+ "!**/__pycache__",
27
+ "cordis.patch.yml",
28
+ "README.md",
29
+ "README.zh.md"
30
+ ],
31
+ "license": "MIT",
32
+ "dsh": {
33
+ "bundle": {
34
+ "patch": "./cordis.patch.yml"
35
+ }
36
+ },
37
+ "peerDependencies": {
38
+ "@deepseek-ai/cordis": "*",
39
+ "@deepseek-ai/dsh-tools": "^0.1.0-rc.6 || ^0.2.0-rc.1 || ^0.2.3-alpha.2",
40
+ "@deepseek-ai/schemastery": "^3.18.1"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^26.2.0",
44
+ "typescript": "^5.7.2"
45
+ },
46
+ "scripts": {
47
+ "build": "tsc -p tsconfig.build.json",
48
+ "typecheck": "tsc -p tsconfig.json --noEmit",
49
+ "prepare": "npm run build",
50
+ "test": "node --test",
51
+ "prepublishOnly": "npm run build && npm test"
52
+ }
53
+ }