@taxueseek/dsh-lexicon 0.0.0-stage → 0.2.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 +51 -2
- package/README.zh.md +52 -0
- package/cordis.patch.yml +10 -0
- package/lib/index.js +62 -0
- package/lib/tools.js +178 -0
- package/package.json +50 -4
- package/vendor/ime-lexicon/bridge.py +1072 -0
- package/vendor/ime-lexicon/budget.py +88 -0
- package/vendor/ime-lexicon/build.py +218 -0
- package/vendor/ime-lexicon/clean_dict.py +75 -0
- package/vendor/ime-lexicon/codec.py +96 -0
- package/vendor/ime-lexicon/doubao.py +260 -0
- package/vendor/ime-lexicon/ime_lexicon.py +817 -0
- package/vendor/ime-lexicon/ms_pinyin.py +54 -0
- package/vendor/ime-lexicon/optimize.py +235 -0
- package/vendor/ime-lexicon/paths.py +288 -0
- package/vendor/ime-lexicon/search.py +323 -0
- package/vendor/ime-lexicon/tsvutil.py +116 -0
- package/vendor/ime-lexicon/wetype.py +307 -0
package/README.md
CHANGED
|
@@ -1,3 +1,52 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-lexicon
|
|
2
2
|
|
|
3
|
-
|
|
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, 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. |
|
|
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
|
+
|
|
29
|
+
## Discipline rules
|
|
30
|
+
|
|
31
|
+
- Copy before read, staging before apply; the input method must be exited before any apply.
|
|
32
|
+
- Doubao personal library has ~7500 slots (Doubao 0.9.7+ expansion; one word per slot) — always budget imports (`--budget`).
|
|
33
|
+
- Core words need pinyin; polyphones go to the extended list; pinyin-less terms go to the general list and are never applied.
|
|
34
|
+
- 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.
|
|
35
|
+
- `ime_search --run` uses network (argo → generic fallback); it may take a couple of minutes.
|
|
36
|
+
|
|
37
|
+
## Config
|
|
38
|
+
|
|
39
|
+
| Key | Default | Meaning |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| `scriptPath` | bundled `vendor/ime-lexicon/ime_lexicon.py` | Path to the engine script (override to use your own copy) |
|
|
42
|
+
| `scriptTimeoutMs` | 120000 | Timeout for local commands |
|
|
43
|
+
| `searchTimeoutMs` | 300000 | Timeout for `search --run` (network) |
|
|
44
|
+
|
|
45
|
+
## Security notes
|
|
46
|
+
|
|
47
|
+
- Nothing leaves the machine except `ime_search --run` network calls; exports and backups stay local.
|
|
48
|
+
- The plugin never applies changes to a live IME — that stays a manual step.
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
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。 |
|
|
26
|
+
| `ime_optimize` | 跨来源合并、去重、纠错词表。 |
|
|
27
|
+
| `ime_import` | 把优化后的 TSV 写入 staging 区(加 `replace` 整表替换,剔除已被改写/删除的旧词)——绝不触碰正在使用的词库。 |
|
|
28
|
+
|
|
29
|
+
## 纪律规则
|
|
30
|
+
|
|
31
|
+
- 先拷后读后写,staging 先行,apply 前输入法必须退出。
|
|
32
|
+
- 豆包个人库约 7500 槽(豆包 0.9.7 起扩容;一词一槽),导入必须带预算(`--budget`)。
|
|
33
|
+
- 核心词必须有拼音;多音进扩展;无拼音进大词库且禁止 apply。
|
|
34
|
+
- 消错替换:`ime_import` 加 `replace` 用优化表整表替换(不并入 live),剔除 optimize 已改写/删除的错误词;无拼音词仍禁止 apply。
|
|
35
|
+
- `ime_search --run` 走网络(argo → 通用兜底),可能需要几分钟。
|
|
36
|
+
|
|
37
|
+
## 配置
|
|
38
|
+
|
|
39
|
+
| 键 | 默认值 | 含义 |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| `scriptPath` | 随包的 `vendor/ime-lexicon/ime_lexicon.py` | 引擎脚本路径(可覆盖为自备副本) |
|
|
42
|
+
| `scriptTimeoutMs` | 120000 | 本地命令超时 |
|
|
43
|
+
| `searchTimeoutMs` | 300000 | `search --run`(网络)超时 |
|
|
44
|
+
|
|
45
|
+
## 安全说明
|
|
46
|
+
|
|
47
|
+
- 除 `ime_search --run` 的网络调用外,所有操作都在本机;导出和备份留在本地。
|
|
48
|
+
- 插件绝不 apply 到正在使用的输入法——这始终是手动步骤。
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
package/cordis.patch.yml
ADDED
|
@@ -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,62 @@
|
|
|
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 { 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
|
+
import z from '@deepseek-ai/schemastery';
|
|
10
|
+
import { defineLexiconTools } from "./tools.js";
|
|
11
|
+
/** Cordis plugin name — must match the row id in cordis.patch.yml. */
|
|
12
|
+
export const name = 'dsh-lexicon';
|
|
13
|
+
/** Services required by this plugin. */
|
|
14
|
+
export const inject = ['tools', 'systemPrompt'];
|
|
15
|
+
/** Bundled ime_lexicon.py engine shipped under vendor/ime-lexicon (lib/index.js → ../vendor). */
|
|
16
|
+
export const BUNDLED_SCRIPT = join(dirname(fileURLToPath(import.meta.url)), '..', 'vendor', 'ime-lexicon', 'ime_lexicon.py');
|
|
17
|
+
export const Config = z.object({
|
|
18
|
+
scriptPath: z.string().default(BUNDLED_SCRIPT),
|
|
19
|
+
scriptTimeoutMs: z.number().default(120_000),
|
|
20
|
+
searchTimeoutMs: z.number().default(300_000)
|
|
21
|
+
});
|
|
22
|
+
export function runScript(scriptPath, args, timeoutMs, cwd = process.cwd()) {
|
|
23
|
+
return new Promise((resolve) => {
|
|
24
|
+
const child = spawn('python3', [scriptPath, ...args], { cwd });
|
|
25
|
+
let stdout = '';
|
|
26
|
+
let stderr = '';
|
|
27
|
+
const timer = setTimeout(() => {
|
|
28
|
+
child.kill('SIGKILL');
|
|
29
|
+
resolve({ code: -1, stdout, stderr: `ime_lexicon.py timed out after ${timeoutMs}ms (SIGKILL)` });
|
|
30
|
+
}, timeoutMs);
|
|
31
|
+
child.stdout.on('data', (d) => (stdout += d.toString('utf8')));
|
|
32
|
+
child.stderr.on('data', (d) => (stderr += d.toString('utf8')));
|
|
33
|
+
child.on('error', (err) => {
|
|
34
|
+
clearTimeout(timer);
|
|
35
|
+
resolve({ code: -1, stdout: '', stderr: String(err.message) });
|
|
36
|
+
});
|
|
37
|
+
child.on('close', (code) => {
|
|
38
|
+
clearTimeout(timer);
|
|
39
|
+
resolve({ code: code ?? -1, stdout, stderr });
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export function expandHome(p) {
|
|
44
|
+
return p === '~' ? homedir() : p.startsWith('~/') ? join(homedir(), p.slice(2)) : p;
|
|
45
|
+
}
|
|
46
|
+
export function apply(ctx, config) {
|
|
47
|
+
const script = expandHome(config.scriptPath);
|
|
48
|
+
ctx.systemPrompt.section({
|
|
49
|
+
name: 'tool:ime-lexicon',
|
|
50
|
+
order: 110,
|
|
51
|
+
text: 'The dsh-lexicon plugin manages Doubao / WeType (微信输入法) personal word libraries through the ime_lexicon.py CLI. ' +
|
|
52
|
+
'Use ime_detect to check IME state, ime_export/ime_backup for safe snapshots, ime_search/ime_build/ime_optimize to craft industry word lists, ' +
|
|
53
|
+
'and ime_import to stage them. NEVER apply staged changes to a live IME without the user explicitly confirming — apply is a manual step outside this plugin.'
|
|
54
|
+
});
|
|
55
|
+
const exec = (args, timeoutMs) => runScript(script, args, timeoutMs);
|
|
56
|
+
for (const tool of defineLexiconTools(exec, {
|
|
57
|
+
scriptTimeoutMs: config.scriptTimeoutMs,
|
|
58
|
+
searchTimeoutMs: config.searchTimeoutMs
|
|
59
|
+
})) {
|
|
60
|
+
ctx.tools.register(tool);
|
|
61
|
+
}
|
|
62
|
+
}
|
package/lib/tools.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
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 only write a staging area, never a live IME; `apply` is deliberately
|
|
4
|
+
// 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) {
|
|
11
|
+
const r = await run(args, timeoutMs);
|
|
12
|
+
if (r.code !== 0) {
|
|
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.',
|
|
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', description: 'Optional engine hint (argo/generic).' }
|
|
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).',
|
|
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
|
+
},
|
|
103
|
+
output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
|
|
104
|
+
isConcurrencySafe: () => true,
|
|
105
|
+
async execute(args) {
|
|
106
|
+
const argv = ['build', '--topic', nonEmpty(args.topic, 'topic'), '--from', nonEmpty(args.from, 'from')];
|
|
107
|
+
if (args.term !== undefined && args.term.trim() !== '') {
|
|
108
|
+
for (const t of args.term.split(',')) {
|
|
109
|
+
if (t.trim() !== '')
|
|
110
|
+
argv.push('--term', t.trim());
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return { result: await call(run, argv, opts.scriptTimeoutMs) };
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
116
|
+
defineTool({
|
|
117
|
+
name: 'ime_optimize',
|
|
118
|
+
description: 'Merge/dedupe/correct word lists: fix obvious pinyin/spelling issues, remove noise, dedupe across sources. Writes to --out, never in place.',
|
|
119
|
+
parameters: {
|
|
120
|
+
from: {
|
|
121
|
+
type: 'string',
|
|
122
|
+
required: true,
|
|
123
|
+
description: 'Comma-separated input TSV paths (repeatable sources are merged).'
|
|
124
|
+
},
|
|
125
|
+
profile: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
enum: ['personal', 'industry'],
|
|
128
|
+
description: 'Optimization profile: personal (merges into your lexicon) or industry (keeps terms for sharing).'
|
|
129
|
+
},
|
|
130
|
+
budget: { type: 'number', description: 'Max entries to keep (default: engine-appropriate budget).' },
|
|
131
|
+
out: { type: 'string', description: 'Output directory for the optimized TSV.' }
|
|
132
|
+
},
|
|
133
|
+
output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
|
|
134
|
+
isConcurrencySafe: () => true,
|
|
135
|
+
async execute(args) {
|
|
136
|
+
const argv = ['optimize'];
|
|
137
|
+
for (const f of nonEmpty(args.from, 'from').split(',')) {
|
|
138
|
+
if (f.trim() !== '')
|
|
139
|
+
argv.push('--from', f.trim());
|
|
140
|
+
}
|
|
141
|
+
if (args.profile !== undefined && args.profile.trim() !== '')
|
|
142
|
+
argv.push('--profile', args.profile.trim());
|
|
143
|
+
if (args.budget !== undefined)
|
|
144
|
+
argv.push('--budget', String(posInt(args.budget, 'budget', 5000)));
|
|
145
|
+
if (args.out !== undefined && args.out.trim() !== '')
|
|
146
|
+
argv.push('--out', args.out.trim());
|
|
147
|
+
return { result: await call(run, argv, opts.scriptTimeoutMs) };
|
|
148
|
+
}
|
|
149
|
+
}),
|
|
150
|
+
defineTool({
|
|
151
|
+
name: 'ime_import',
|
|
152
|
+
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). ' +
|
|
153
|
+
'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). ' +
|
|
154
|
+
'Report the staged entry count back to the user and ask before anything further.',
|
|
155
|
+
parameters: {
|
|
156
|
+
engine: {
|
|
157
|
+
type: 'string',
|
|
158
|
+
enum: ['doubao', 'wechat', 'wetype'],
|
|
159
|
+
required: true,
|
|
160
|
+
description: 'Target engine. doubao budgets to ~7500 slots (Doubao 0.9.7+); wechat uses usr.dat.'
|
|
161
|
+
},
|
|
162
|
+
from: { type: 'string', required: true, description: 'Path to the optimized TSV.' },
|
|
163
|
+
budget: { type: 'number', description: 'Entry budget for the staging write (doubao slot limit).' },
|
|
164
|
+
replace: { type: 'boolean', description: '整表替换(消错):用优化表重建 staging,不并入 live,去掉已被改写/删除的旧词。' }
|
|
165
|
+
},
|
|
166
|
+
output: { schema: { type: 'object', additionalProperties: true, properties: {} }, render: renderJson },
|
|
167
|
+
isConcurrencySafe: () => true,
|
|
168
|
+
async execute(args) {
|
|
169
|
+
const argv = ['import', '--engine', nonEmpty(args.engine, 'engine'), '--from', nonEmpty(args.from, 'from')];
|
|
170
|
+
if (args.budget !== undefined)
|
|
171
|
+
argv.push('--budget', String(posInt(args.budget, 'budget', 5000)));
|
|
172
|
+
if (args.replace)
|
|
173
|
+
argv.push('--replace');
|
|
174
|
+
return { result: await call(run, argv, opts.scriptTimeoutMs) };
|
|
175
|
+
}
|
|
176
|
+
})
|
|
177
|
+
];
|
|
178
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taxueseek/dsh-lexicon",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.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, optimize, 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",
|
|
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
|
+
"prepare": "npm run build",
|
|
49
|
+
"test": "node --test",
|
|
50
|
+
"prepublishOnly": "npm run build && npm test"
|
|
51
|
+
}
|
|
52
|
+
}
|