dsh-novel-writer 1.6.0 → 2.0.1
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 +104 -0
- package/README.md +95 -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 +9 -7
- 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,104 @@
|
|
|
1
|
+
# 📚 dsh-novel-writer — Novel Writing Assistant
|
|
2
|
+
|
|
3
|
+
English | [**中文**](./README.md)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-novel-writer)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/siweina/dsh-novel-writer/stargazers)
|
|
8
|
+
[](https://github.com/siweina/dsh-novel-writer/releases)
|
|
9
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
10
|
+
|
|
11
|
+
A novel-writing assistant plugin for **DeepSeek Harness (DSH)**: chapter library management, sentence-pattern analysis, emotion purification & quantification, style checking, plot tracking, settings management, worldview/pragmatics detection, **local semantic search (0 token)**, batch import, and AI-assisted continuation writing. Zero third-party dependencies on host.
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
**Option 1: npm (recommended)**
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
dsh plugin --profile web add dsh-novel-writer
|
|
21
|
+
# or
|
|
22
|
+
npm install dsh-novel-writer
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Option 2: From GitHub**
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
dsh plugin --profile web add github:siweina/dsh-novel-writer#main
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
After installing, **restart the web app** to activate (host registers 14 tools + state/reveal routes; browser mounts the "Writing Assistant" sidebar toggle panel).
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## v2.0.0 New: Local Semantic Engine (0 token)
|
|
36
|
+
|
|
37
|
+
- 🧠 **Built-in Chinese semantic model** (bge-small-zh-v1.5 quantized, 23MB, shipped with the plugin): 512-dim vectors, local CPU inference, **zero API cost**;
|
|
38
|
+
- 🔍 **novel_semantic_search**: search the whole book with natural language for semantically related passages (foreshadowing/emotional scenes/settings), even without matching keywords;
|
|
39
|
+
- 📊 **Semantic style comparison**: novel_style_check adds a semantic-similarity dimension beyond rule-based fingerprints;
|
|
40
|
+
- 💭 **Semantic implicit emotion**: emotion prototype sentences scan the book index to find "imagery passages outside the word list";
|
|
41
|
+
- 🪶 Lazy loading + automatic fallback to pure-rule mode (never breaks existing features).
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Features
|
|
46
|
+
|
|
47
|
+
1. **Chapter library**: chapters in `novels/<book>/第N章.md` (or .txt/.markdown); auto encoding detection (UTF-8/UTF-16/GBK).
|
|
48
|
+
2. **Sentence-pattern analysis**: 9 categories, arrangement patterns, rhythm, emotion curve, style fingerprint + guidance, with cache & report export.
|
|
49
|
+
3. **Emotion purification**: strong/weak emotion-word grading, pollution-source detection, caveat warning + AI re-verification, cleanDominant true baseline.
|
|
50
|
+
4. **Emotion quantification** (v1.6.0): Valence mapping + sliding window → variance V / delta Δ / conflict index C; implicit imagery carriers + explicit-implicit conflict; complexity score + composite emotion pairs.
|
|
51
|
+
5. **Style check**: chapter vs book → similarity + deviation list + advice.
|
|
52
|
+
6. **Plot tracking**: foreshadowing/plot-hook registry (open/done), typed fields + auto mention tracking.
|
|
53
|
+
7. **Settings management**: five tables — characters / locations / items / timeline / worldview.
|
|
54
|
+
8. **Worldview & pragmatics detection**: auto cultural-baseline detection with confidence; speechStyle title/honorifics/rituals/tone norms.
|
|
55
|
+
9. **Genre & theme detection**: primary/secondary themes + genre, low-frequency noise filtered.
|
|
56
|
+
10. **Chapter summaries**: per-chapter digest + key events for long-book continuation.
|
|
57
|
+
11. **Continuity audit**: settings conflicts + pragmatics conflicts with replacement suggestions.
|
|
58
|
+
12. **Batch import**: auto-detect book names & chapter numbers, classified import.
|
|
59
|
+
13. **Continuation writing**: read-first workflow; keeps style/foreshadowing/worldview consistent.
|
|
60
|
+
14. **Per-tool UI toggles**: "Writing Assistant" sidebar panel (master + per-tool + feature toggles).
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## Provided Tools (14)
|
|
65
|
+
|
|
66
|
+
| Tool | Description |
|
|
67
|
+
|------|-------------|
|
|
68
|
+
| `novel_books` | List all books in library |
|
|
69
|
+
| `novel_chapters` | List a book's chapters |
|
|
70
|
+
| `novel_read` | Read a chapter (paginated) |
|
|
71
|
+
| `novel_keywords` | Keywords: bigram/trigram/name candidates |
|
|
72
|
+
| `novel_new_chapter` | Create new chapter file |
|
|
73
|
+
| `novel_import` | Batch import manuscripts |
|
|
74
|
+
| `novel_sentence_analysis` | Sentence-pattern analysis |
|
|
75
|
+
| `novel_sentence_config` | View/set tool & feature toggles |
|
|
76
|
+
| `novel_style_check` | Style check (rule + semantic) |
|
|
77
|
+
| `novel_plot` | Plot/foreshadowing tracker |
|
|
78
|
+
| `novel_settings` | Settings management (+worldview) |
|
|
79
|
+
| `novel_summary` | Chapter summaries |
|
|
80
|
+
| `novel_continuity_check` | Continuity audit |
|
|
81
|
+
| `novel_semantic_search` | **Semantic search** (v2.0.0, local embedding, 0 token) |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## Configuration
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
- id: novel-writer
|
|
89
|
+
config:
|
|
90
|
+
root: 'D:/my-novel-library'
|
|
91
|
+
allowLanState: false # true = allow state save from LAN GUI access
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## Data Directory
|
|
97
|
+
|
|
98
|
+
Under `<library-root>/.novel-writer/`: `plots` / `settings` / `summaries` / `analysis` / `audits` / `embedding` (semantic index cache).
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
[MIT](./LICENSE)
|
package/README.md
CHANGED
|
@@ -1,36 +1,104 @@
|
|
|
1
|
-
# dsh-novel-writer —
|
|
1
|
+
# 📚 dsh-novel-writer — 小说写作助手
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
浏览器端仅依赖 Web GUI 自带的 react。
|
|
5
|
-
**v0.9.0 在 v0.8.0 基础上补全「世界观层」:第五张设定表「世界观/用语规范」、文化基准自动判断(detect)、用语风格扫描、续写用语一致性检查**:分析缓存与报告导出、风格自检、伏笔登记表、
|
|
6
|
-
关键词三字组/疑似人名、情感词典去噪、祈使句与环境分类改进、局域网开关可选放行。
|
|
3
|
+
[**English**](./README.en.md) | 中文
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/dsh-novel-writer)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/siweina/dsh-novel-writer/stargazers)
|
|
8
|
+
[](https://github.com/siweina/dsh-novel-writer/releases)
|
|
9
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
为 **DeepSeek Harness (DSH)** 打造的小说写作助手插件:章节库管理、句式模式分析、情感净化与量化、风格自检、伏笔登记、设定管理、世界观/语用检测、**本地语义检索(0 token)**、批量导入与 AI 续写辅助。宿主端零第三方依赖,浏览器端仅依赖 Web GUI 自带的 react。
|
|
11
12
|
|
|
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
|
-
- **续写提示词**:新增世界观一致性检查步骤。
|
|
13
|
+
---
|
|
19
14
|
|
|
20
|
-
##
|
|
15
|
+
## 安装
|
|
21
16
|
|
|
22
|
-
|
|
23
|
-
- **novel_summary**:模型生成、插件存储的每章摘要(长书续写先读摘要);
|
|
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
|
+
**方式一:npm(推荐)**
|
|
29
18
|
|
|
30
|
-
|
|
19
|
+
```sh
|
|
20
|
+
dsh plugin --profile web add dsh-novel-writer
|
|
21
|
+
# 或
|
|
22
|
+
npm install dsh-novel-writer
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**方式二:从 GitHub 安装**
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
dsh plugin --profile web add github:siweina/dsh-novel-writer#main
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
安装后**重启 web 应用**生效(宿主端注册 14 个工具与 state/reveal 路由,浏览器端挂载侧边栏「写作助手功能」开关面板)。
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## v2.0.0 新增:本地语义引擎(0 token)
|
|
36
|
+
|
|
37
|
+
- 🧠 **内置中文语义模型**(bge-small-zh-v1.5 quantized,23MB,随插件分发):512 维向量,本地 CPU 推理,**零 API 费用**;
|
|
38
|
+
- 🔍 **novel_semantic_search**:用自然语言搜全书语义相关段落(伏笔/情感场景/设定提及),即使原文没有相同关键词也能命中;
|
|
39
|
+
- 📊 **语义级风格对比**:novel_style_check 在规则指纹之外新增语义相似度维度;
|
|
40
|
+
- 💭 **语义隐性情感**:情感原型句扫全书索引,发现"词表外疑似意象段落";
|
|
41
|
+
- 🪶 懒加载 + 失败自动回退纯规则(不影响任何既有功能)。
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 功能
|
|
46
|
+
|
|
47
|
+
1. **章节库管理**:章节存放于 `novels/<书名>/第N章.md`(或 .txt/.markdown),编码自动探测(UTF-8/UTF-16/GBK)。
|
|
48
|
+
2. **句式模式分析**:九类句式分布、排列规律、句长节奏、情感曲线、风格指纹与节奏建议,带缓存与报告导出。
|
|
49
|
+
3. **情感净化**:强/弱情绪词分级、污染源检测、caveat 预警 + AI 复核闭环、cleanDominant 真实基调。
|
|
50
|
+
4. **情感量化**(v1.6.0):Valence 效价映射 + 滑动窗口 → 方差 V / 斜率 Δ / 矛盾指数 C;隐性意象载体 + 显隐冲突;复杂度评分 + 复合情感共现。
|
|
51
|
+
5. **风格自检**:章节 vs 全书 → 相似度 + 偏差清单 + 续写建议。
|
|
52
|
+
6. **伏笔登记表**:open/done 状态、字段化登记、章节提及自动追踪。
|
|
53
|
+
7. **设定管理**:人物/地点/道具/时间线/世界观 五张表。
|
|
54
|
+
8. **世界观与语用检测**:自动判断文化基准(西/东/混合)+ 置信度;speechStyle 称谓/客套/仪式/语气规范。
|
|
55
|
+
9. **题材与流派检测**:主副题材 + 流派识别,低频噪音自动过滤。
|
|
56
|
+
10. **章节摘要**:每章摘要 + 关键事件,长书续写先读摘要。
|
|
57
|
+
11. **连贯性审计**:设定矛盾 + 语用冲突候选,带建议替换。
|
|
58
|
+
12. **批量导入**:原稿件自动识别书名与章节号分类导入。
|
|
59
|
+
13. **续写辅助**:先读后写、保持文风/伏笔/世界观一致。
|
|
60
|
+
14. **全工具 UI 开关**:侧边栏「写作助手功能」面板(总开关 + 每工具开关 + 功能开关)。
|
|
31
61
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## 提供的工具(14 个)
|
|
65
|
+
|
|
66
|
+
| 工具 | 说明 |
|
|
67
|
+
|------|------|
|
|
68
|
+
| `novel_books` | 列出章节库全部作品 |
|
|
69
|
+
| `novel_chapters` | 列出某作品章节清单 |
|
|
70
|
+
| `novel_read` | 阅读某章正文(分段) |
|
|
71
|
+
| `novel_keywords` | 关键词:二字组/三字组/疑似人名 |
|
|
72
|
+
| `novel_new_chapter` | 创建新章节文件 |
|
|
73
|
+
| `novel_import` | 原稿件批量导入/分类 |
|
|
74
|
+
| `novel_sentence_analysis` | 句式模式分析(九类/情感净化/量化/曲线/指纹) |
|
|
75
|
+
| `novel_sentence_config` | 查看/修改工具与功能开关 |
|
|
76
|
+
| `novel_style_check` | 风格自检(规则+语义双维度) |
|
|
77
|
+
| `novel_plot` | 伏笔/剧情线登记表 |
|
|
78
|
+
| `novel_settings` | 设定管理(人物/地点/道具/时间线/世界观) |
|
|
79
|
+
| `novel_summary` | 章节摘要(长书续写辅助) |
|
|
80
|
+
| `novel_continuity_check` | 连贯性审计(设定矛盾+语用冲突候选) |
|
|
81
|
+
| `novel_semantic_search` | **语义检索**(v2.0.0,本地 embedding,0 token) |
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 配置
|
|
86
|
+
|
|
87
|
+
```yaml
|
|
88
|
+
- id: novel-writer
|
|
89
|
+
config:
|
|
90
|
+
root: 'D:/我的小说库'
|
|
91
|
+
allowLanState: false # true=局域网访问 GUI 时也允许保存开关
|
|
36
92
|
```
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
## 数据目录
|
|
97
|
+
|
|
98
|
+
`<书库根>/.novel-writer/`:`plots`(伏笔)/ `settings`(设定)/ `summaries`(摘要)/ `analysis`(分析报告)/ `audits`(审计)/ `embedding`(语义索引缓存)。
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## 许可证
|
|
103
|
+
|
|
104
|
+
[MIT](./LICENSE)
|
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.
|