dsh-novel-writer 1.6.0 → 2.0.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.en.md +20 -0
- package/README.md +46 -27
- package/cordis.patch.yml +1 -0
- package/lib/client.js +367 -158
- package/lib/embedding.js +252 -0
- package/lib/index.js +267 -12
- package/lib/models/config.json +31 -0
- package/lib/models/onnx/model_quantized.onnx +0 -0
- package/lib/models/special_tokens_map.json +7 -0
- package/lib/models/tokenizer.json +21278 -0
- package/lib/models/tokenizer_config.json +15 -0
- package/package.json +8 -6
- package/skills/novel-writing/SKILL.md +16 -2
- package/INSTALL.md +0 -36
- package/test/client-test.mjs +0 -34
- package/test/e2e-test.mjs +0 -167
- package/test/pattern-test.mjs +0 -48
package/README.en.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# dsh-novel-writer — Novel Writing Assistant Plugin (v2.0.0)
|
|
2
|
+
|
|
3
|
+
A DSH (DeepSeek Harness) bundle plugin. **v2.0.0 ships a local semantic embedding engine (bge-small-zh-v1.5 ONNX, bundled, CPU inference, 0 token cost)** — semantic capabilities without any API fees.
|
|
4
|
+
|
|
5
|
+
## Tools (14, each with an independent UI switch)
|
|
6
|
+
novel_books / novel_chapters / novel_read / novel_keywords / novel_new_chapter / novel_import / novel_sentence_analysis / novel_sentence_config / novel_style_check / novel_plot / novel_settings / novel_summary / novel_continuity_check / **novel_semantic_search (new in v2.0.0)**
|
|
7
|
+
|
|
8
|
+
## v2.0.0 — Semantic Layer
|
|
9
|
+
- **Local engine** (lib/embedding.js): Xenova/bge-small-zh-v1.5 (quantized), 512-dim Chinese vectors, ~23MB, bundled; @huggingface/tokenizers + onnxruntime-web (WASM), local CPU, 0 token / 0 API cost;
|
|
10
|
+
- **Lazy load** (~0.3s first call); automatic fallback to pure-rule mode if unavailable;
|
|
11
|
+
- **Index cache**: per-book vectors at `.novel-writer/embedding/<book>.json` — repeated searches are instant;
|
|
12
|
+
- **novel_semantic_search**: natural-language search across the whole book (foreshadowing clues, emotional scenes, setting mentions) — matches by meaning even when keywords differ;
|
|
13
|
+
- **novel_style_check upgrade**: adds semantic similarity (target chapter vs rest of book) alongside rule-based fingerprint similarity;
|
|
14
|
+
- **Switch: semanticEmbedding** — default ON (probe-based: auto-enabled when the model is present); turn it off in the sidebar「写作助手功能」panel to fully return to rule-only mode.
|
|
15
|
+
|
|
16
|
+
## History (v0.3 → v1.6)
|
|
17
|
+
Sentence-pattern analysis; emotion purification + AI review (strong/weak lexicon, pollution caveat); emotion quantification (Valence sliding window: variance/slope/conflict + implicit imagery + complexity score); worldview/genre/theme detection (modern/western/eastern + 15 genres + 35 themes); pragmatic-style review; settings tables (5) + foreshadowing registry + summaries + continuity audit + style check; analysis cache & report export (`.novel-writer/analysis/`).
|
|
18
|
+
|
|
19
|
+
## Size
|
|
20
|
+
~95MB total (23MB quantized model + 70MB runtime); zip 31MB. If disk is tight, disable the semantic switch and delete `lib/models/` + `node_modules/` to go back to rule-only.
|
package/README.md
CHANGED
|
@@ -1,36 +1,55 @@
|
|
|
1
|
-
# dsh-novel-writer — 小说写作助手插件(
|
|
1
|
+
# dsh-novel-writer — 小说写作助手插件(v2.0.0)
|
|
2
2
|
|
|
3
|
-
DSH(DeepSeek Harness)小说写作助手 bundle
|
|
4
|
-
浏览器端仅依赖 Web GUI 自带的 react。
|
|
5
|
-
**v0.9.0 在 v0.8.0 基础上补全「世界观层」:第五张设定表「世界观/用语规范」、文化基准自动判断(detect)、用语风格扫描、续写用语一致性检查**:分析缓存与报告导出、风格自检、伏笔登记表、
|
|
6
|
-
关键词三字组/疑似人名、情感词典去噪、祈使句与环境分类改进、局域网开关可选放行。
|
|
3
|
+
DSH(DeepSeek Harness)小说写作助手 bundle 插件。**v2.0.0 集成本地语义嵌入引擎(bge-small-zh-v1.5 ONNX,随插件分发,本地 CPU 推理,0 token 成本)**,在不增加任何 API 费用的前提下获得语义级能力。
|
|
7
4
|
|
|
8
|
-
## 工具清单(
|
|
5
|
+
## 工具清单(14 个,全部带独立 UI 开关)
|
|
9
6
|
|
|
10
|
-
novel_books / novel_chapters / novel_read / novel_keywords / novel_new_chapter / novel_import / novel_sentence_analysis / novel_sentence_config / novel_style_check / novel_plot /
|
|
7
|
+
novel_books / novel_chapters / novel_read / novel_keywords / novel_new_chapter / novel_import / novel_sentence_analysis / novel_sentence_config / novel_style_check / novel_plot / novel_settings(设定管理)/ novel_summary(章节摘要)/ novel_continuity_check(连贯性审计)/ **novel_semantic_search(语义检索,v2.0.0 新增)**
|
|
11
8
|
|
|
12
|
-
##
|
|
13
|
-
- **novel_settings 第五张表「世界观/用语规范」(category=worldview)**:
|
|
14
|
-
- `detect`:自动判断文化基准(western/eastern/mixed/unknown)+ 置信度 + 证据(中西词表按时代错置分类:器物/称谓/计量/宗教仪式/市井风貌/服饰/食物/制度);
|
|
15
|
-
- 登记:name / basis / bannedWords(禁用词)/ recommended(替代词映射)/ ritual(仪式规范);
|
|
16
|
-
- 文化基准由 AI 自行判断,不预设东西方。
|
|
17
|
-
- **novel_continuity_check 用语风格扫描**:对照 worldview 禁用词表输出「用语冲突」候选(带建议替换词,未登记时用默认基准并提示 detect);
|
|
18
|
-
- **续写提示词**:新增世界观一致性检查步骤。
|
|
9
|
+
## v2.0.0 新增能力(语义层)
|
|
19
10
|
|
|
20
|
-
|
|
11
|
+
### 本地语义嵌入引擎(embedding.js)
|
|
12
|
+
- 模型:Xenova/bge-small-zh-v1.5(512 维中文向量,约 91MB),随插件分发,开箱即用;
|
|
13
|
+
- 运行时:**@huggingface/tokenizers**(官方轻量分词,294KB 零依赖)+ onnxruntime-web(WASM 推理),本地 CPU,0 token、0 API 费用;
|
|
14
|
+
- 懒加载:首次调用才加载(约 0.3s);加载失败自动回退纯规则,不影响任何既有功能;
|
|
15
|
+
- 索引缓存:每书向量落盘 `.novel-writer/embedding/<书>.json`,重复检索秒开(47 万字约 3100 段,首次建索引约 20-30s,之后命中缓存)。
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- **novel_continuity_check**:对照设定表扫描全书 → 数字口径/人物缺场/别名/重复条目矛盾候选;
|
|
25
|
-
- **novel_plot 字段化**:type/priority/relatedCharacters/locations/payoffCondition/mentionedIn/lastMentioned + scan 自动提及追踪;
|
|
26
|
-
- **细节密度指标**:动作链密度/物件名词/感官词(千字归一)进 novel_sentence_analysis 与 novel_style_check;
|
|
27
|
-
- **统一数据目录**:§BT§<书库根>/.novel-writer/§BT§ 下 plots/ settings/ summaries/ analysis/ audits/(伏笔旧位置自动迁移;分析缓存与关键词报告落盘到 analysis/);
|
|
28
|
-
- **UI 路径修复**:cordis 空字符串 root 回退 lastRoot、面板刷新按钮、打开/复制按钮不再禁用、显示 dataDir。
|
|
17
|
+
### 新工具:novel_semantic_search(语义检索)
|
|
18
|
+
用自然语言描述在全书中检索语义相关段落——找伏笔线索、情感场景、设定提及,**即使原文没有相同关键词也能命中**(如搜「压抑克制的时刻」能命中没有"压抑"二字的段落)。
|
|
29
19
|
|
|
30
|
-
|
|
20
|
+
### novel_style_check 升级:语义级风格对比
|
|
21
|
+
规则指纹相似度(句式/句长/情绪)之外,新增**语义相似度**(目标章 vs 全书其余部分向量余弦),双维度判定风格一致性。
|
|
31
22
|
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
-
|
|
35
|
-
|
|
23
|
+
### 功能开关:语义增强(semanticEmbedding)
|
|
24
|
+
- **默认开启(探测式)**:模型存在即自动启用;用户可在侧边栏「写作助手功能」面板关闭,关闭后语义检索返回提示、风格检查跳过语义维度;
|
|
25
|
+
- 关闭后插件完整回退到 v1.6.0 纯规则能力。
|
|
26
|
+
|
|
27
|
+
## 历史能力(v0.3 → v1.6 累积)
|
|
28
|
+
- 句式模式分析(九类句式分布/排列/段落/句长/情感曲线/风格指纹/密度);
|
|
29
|
+
- 情感净化 + AI 复核(强/弱情绪词分级、污染预警 caveat、强制抽查);
|
|
30
|
+
- 情感量化(Valence 滑动窗口:方差/斜率/矛盾指数 + 隐性意象 + 复杂度评分);
|
|
31
|
+
- 世界观/流派/题材检测(modern/western/eastern + 15 流派 + 35 题材,主副题材);
|
|
32
|
+
- 语用级审查(称谓/客套/仪式/语气,中西/现代禁用词);
|
|
33
|
+
- 设定管理五张表 + 伏笔登记 + 章节摘要 + 连贯性审计 + 风格自检;
|
|
34
|
+
- 分析缓存与报告导出(`.novel-writer/analysis/`)。
|
|
35
|
+
|
|
36
|
+
## 功能开关(侧边栏「写作助手功能」面板)
|
|
37
|
+
- 总开关 enabled;autoAnalyze;14 个工具级开关;
|
|
38
|
+
- 功能级:emotionCaveat(情感净化预警)/ genreTheme(题材与流派检测)/ emotionComplexity(情感量化)/ **semanticEmbedding(语义增强,v2.0.0)**。
|
|
39
|
+
|
|
40
|
+
## 目录结构
|
|
36
41
|
```
|
|
42
|
+
dsh-novel-writer-v2.0.0/
|
|
43
|
+
├── lib/
|
|
44
|
+
│ ├── index.js # 宿主端(14 工具 + state 路由 + 开关门禁)
|
|
45
|
+
│ ├── analysis.js # 规则引擎(句式/情感净化/情感量化/题材)
|
|
46
|
+
│ ├── embedding.js # 本地语义嵌入引擎(bge-small-zh ONNX)
|
|
47
|
+
│ ├── models/ # 模型文件(onnx/model.onnx 91MB + tokenizer)
|
|
48
|
+
│ └── client.js # 浏览器端(侧边栏面板 + 全部开关)
|
|
49
|
+
├── node_modules/ # @huggingface/tokenizers + onnxruntime-web(随插件分发)
|
|
50
|
+
├── test/ # 引擎 + client + e2e 测试
|
|
51
|
+
└── skills/novel-writing/SKILL.md # 模型使用指南
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 体积说明
|
|
55
|
+
**约 95MB**(模型 23MB + 运行时 70MB),zip 31MB;已移除 transformers.js/onnxruntime-node/sharp 全家桶(省 85%)。如磁盘紧张可在「语义增强」开关关闭后删除 `lib/models/` 与 `node_modules/`,插件回到纯规则模式。
|
package/cordis.patch.yml
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
# dsh-novel-writer v2.0.0 bundle patch: 14 tools (incl. novel_semantic_search) + local embedding engine.
|
|
1
2
|
# dsh-novel-writer bundle patch: mounts the novel-writing assistant plugin
|
|
2
3
|
# into the profile's loader tree. The entry's name is the plugin package
|
|
3
4
|
# itself, resolved from the profile's node_modules.
|