dsh-novel-writer 0.2.0 → 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/INSTALL.md CHANGED
@@ -1,21 +1,22 @@
1
- # dsh-novel-writer v0.2.0 — 跨设备安装指南
1
+ # dsh-novel-writer v0.3.0 — 跨设备安装指南
2
2
 
3
- 本目录是一个**完整的、自包含的插件分发件**,零第三方依赖(仅 Node 内置模块)。
4
- 将其复制到任何安装了 DSH(DeepSeek Harness)的设备即可使用,无需联网下载任何依赖。
3
+ 本目录是一个**完整的、自包含的插件分发件**,宿主端零第三方依赖(仅 Node 内置模块),
4
+ 浏览器端仅依赖 Web GUI 自带的 react。将其复制到任何安装了 DSH 的设备即可使用。
5
5
 
6
6
  ```
7
- dsh-novel-writer-v0.2.0/
8
- ├── lib/index.js # 插件本体(含全部修复,见下文"版本记录")
9
- ├── package.json # 包定义(bundle patch 指向 cordis.patch.yml)
10
- ├── cordis.patch.yml # 挂载插件到 loader 树
11
- ├── README.md # 功能与工具说明
7
+ dsh-novel-writer-v0.3.0/
8
+ ├── lib/
9
+ ├── index.js # 宿主端插件本体(novel_* 工具 + state 路由)
10
+ ├── analysis.js # 句式模式分析引擎(零依赖)
11
+ │ └── client.js # 浏览器端(侧边栏「句式分析」开关面板)
12
+ ├── package.json # 包定义(bundle patch + dsh.client 声明)
13
+ ├── cordis.patch.yml # 挂载插件到 loader 树
14
+ ├── README.md # 功能与工具说明
12
15
  └── skills/
13
16
  └── novel-writing/
14
- └── SKILL.md # 可选:小说写作技能(增强 AI 工作流)
17
+ └── SKILL.md # 可选:小说写作技能(含句式分析工作流)
15
18
  ```
16
19
 
17
- ---
18
-
19
20
  ## 一、安装插件
20
21
 
21
22
  ### 方式 A:dsh CLI(推荐)
@@ -43,24 +44,33 @@ dsh plugin --profile web add D:/tools/dsh-novel-writer
43
44
  "dsh-novel-writer"
44
45
  ```
45
46
 
46
- 3. 重启 web 应用,`novel_*` 系列工具即会注册到会话。
47
+ 3. **重启 web 应用**。宿主端注册 `novel_*` 系列工具(含新增的 novel_sentence_analysis / novel_sentence_config)
48
+ 与 `/api/dsh-novel-writer/state` 路由;浏览器端加载 client half,侧边栏出现「句式分析」入口。
47
49
 
48
- > 插件的 `cordis.patch.yml` 由 bundle 自动应用(`package.json` 中
49
- > `dsh.bundle.patch` 已声明),无需手动往 profile 的 patch 文件里加条目。
50
+ > 插件的 `cordis.patch.yml` 由 bundle 自动应用(`package.json` 中 `dsh.bundle.patch` 已声明),无需手动往 profile 的 patch 文件里加条目。
50
51
 
51
52
  ## 二、(可选)安装技能 SKILL.md
52
53
 
53
- 技能用于增强 AI 的小说写作工作流提示(与插件工具配合使用):
54
+ `skills/novel-writing` 整个文件夹复制到工作区的 `.dsh/skills/` 下:
55
+
56
+ ```
57
+ <工作区>/.dsh/skills/novel-writing/SKILL.md
58
+ ```
54
59
 
55
- - `skills/novel-writing` 整个文件夹复制到工作区的 `.dsh/skills/` 下:
60
+ 新会话中即会出现 `novel-writing` 技能(含句式模式分析工作流)。
56
61
 
57
- ```
58
- <工作区>/.dsh/skills/novel-writing/SKILL.md
59
- ```
62
+ ## 三、UI 开关(v0.3.0)
60
63
 
61
- - 新会话中即会出现 `novel-writing` 技能。
64
+ Web GUI 侧边栏会出现「句式分析」入口,点击打开面板:
62
65
 
63
- ## 三、准备章节库
66
+ - **启用句式分析(enabled)**:关掉后 `novel_sentence_analysis` 返回"已关闭"状态;
67
+ - **自动分析(autoAnalyze)**:关掉后 AI 仅在用户明确要求时使用句式分析。
68
+
69
+ 状态实时写入宿主端 `~/.dsh/dsh-novel-writer/state.json`;
70
+ 也可在对话中让 AI 执行 `novel_sentence_config` 查看/修改。若浏览器无法访问宿主端路由
71
+ (例如未重启/非 web 环境),开关降级保存在浏览器 localStorage,并以提示文字告知。
72
+
73
+ ## 四、准备章节库
64
74
 
65
75
  章节库存放于**会话工作区**(或插件 config `root` 指定的目录)下的 `novels/` 文件夹:
66
76
 
@@ -76,35 +86,38 @@ dsh plugin --profile web add D:/tools/dsh-novel-writer
76
86
  - 阿拉伯数字 + 中文数字(第一章/第十四章/第三十章),自动按章号排序
77
87
  - 编码自动探测:UTF-8(含/不含 BOM)、UTF-16 LE/BE(含 BOM 或启发式)、GBK/GB18030(无 BOM)
78
88
 
79
- ## 四、验证安装
89
+ ## 五、验证安装
80
90
 
81
91
  安装并重启后,在会话中应能看到以下工具:`novel_books`、`novel_chapters`、
82
- `novel_read`、`novel_keywords`、`novel_new_chapter`。可先执行 `novel_books`
83
- 确认能列出书库。
92
+ `novel_read`、`novel_keywords`、`novel_new_chapter`、`novel_sentence_analysis`、
93
+ `novel_sentence_config`。可先执行 `novel_books` 确认能列出书库,再执行
94
+ `novel_sentence_analysis` 验证句式分析。
84
95
 
85
- 若 `root` 需要指向其他目录(默认会话工作区),在 profile 的
86
- `cordis.patch.yml` 中覆盖:
96
+ 若 `root` 需要指向其他目录(默认会话工作区),在 profile 的 `cordis.patch.yml` 中覆盖:
87
97
 
88
98
  ```yaml
89
99
  - patch:
90
100
  - id: novel-writer
91
101
  config:
92
102
  root: 'D:/我的小说库'
103
+ sentenceAnalysis:
104
+ enabled: true
105
+ autoAnalyze: true
93
106
  ```
94
107
 
95
108
  ---
96
109
 
97
110
  ## 版本记录
98
111
 
99
- ### v0.2.0(本分发件)
100
- - **修复**:章节序号提取支持任意位置(含中文数字"第一章/第十四章/第三十章"),
101
- 修复 `原稿件-单章-…第N章` 命名下章号全部丢失、排序混乱、
102
- `novel_read(book,"1")` 误命中"第31章"、`novel_new_chapter` 自动取号错乱的问题。
103
- - **新增**:文件编码自动探测(UTF-8 / UTF-16 LE/BE / GBK),
104
- 修复 UTF-16/GBK 章节文件读取乱码与字数统计错误的问题。
105
- - 通过 37 章全量压力测试(463,475 字 / 13,231 行,全书读取+关键词统计 < 200ms)。
106
-
107
- ### v0.1.0(初始)
108
- - 章节库管理:novel_books / novel_chapters / novel_read
109
- - 分析:novel_keywords(中文二字词组 + 英文词)
110
- - 续写:novel_new_chapter(自动取下一个章号)
112
+ ### v0.3.0(本分发件)
113
+ - **新增**:句式模式分析引擎(lib/analysis.js):陈述/对话/心理/疑问/反问/感叹/祈使/省略留白 的分布、
114
+ 排列规律(转移/模板/段首段尾)、句长节奏、情感曲线(喜/怒/哀/惧/惊)与风格指纹;
115
+ - **新增**:novel_sentence_analysis / novel_sentence_config 工具;
116
+ - **新增**:Web UI 开关(侧边栏「句式分析」面板,client half)+ 宿主端 /api/dsh-novel-writer/state 路由;
117
+ - 更新系统提示词与 SKILL.md 的句式分析工作流。
118
+
119
+ ### v0.2.0
120
+ - 修复章节序号提取(任意位置、中文数字);UTF-8/UTF-16/GBK 编码自动探测;37 章全量压力测试通过。
121
+
122
+ ### v0.1.0
123
+ - 章节库管理、novel_keywords、novel_new_chapter
package/README.md CHANGED
@@ -1,132 +1,79 @@
1
- # 📚 dsh-novel-writer — 小说写作助手 / Novel Writing Assistant
2
-
3
- **中文** | [**English**](#english)
4
-
5
- 一个零第三方依赖(仅 Node 内置模块)的 **DeepSeek Harness (DSH / Cordis) 插件**,为 AI 提供小说章节库管理、剧情分析与续写辅助的能力。
6
-
7
- A **zero-dependency** (Node built-ins only) **DeepSeek Harness (DSH / Cordis) plugin** that gives the AI novel-chapter-library management, plot analysis, and continuation-writing assistance.
8
-
9
- ---
10
-
11
- ## 功能 / Features
12
-
13
- ### 🇨🇳 中文
14
-
15
- 1. **章节库管理**:章节存放于 `novels/<书名>/第N章.md`(也支持 `.txt` / `.markdown`),
16
- 插件提供 `novel_books` / `novel_chapters` / `novel_read` 让你(AI)浏览库、列出章节并逐章阅读。
17
- 2. **智能章号识别**:章节文件名中的序号支持**任意位置**与多种写法,
18
- 例如 `第01章.md`、`01-标题.md`、`原稿件-单章-…第一章.txt`,
19
- 阿拉伯数字与中文数字(第一章/第十四章/第三十章)均可识别,并自动按章号排序。
20
- 3. **编码自动探测**:UTF-8(含/不含 BOM)、UTF-16 LE/BE(含 BOM 或启发式)、GBK/GB18030(无 BOM)均可直接读取,无需手动转码(如记事本另存的 Unicode 文本)。
21
- 4. **关键词分析**:`novel_keywords` 确定性提取全书/单章高频关键词(中文相邻二字词组 + 高频单字 + 英文词),
22
- 配合系统提示词引导 AI 分析剧情脉络、写作手法、词汇偏好与意象母题。
23
- 5. **续写辅助**:系统提示词规定续写工作流(先读后写、保持文风与伏笔一致),
24
- `novel_new_chapter` 自动创建下一章文件。
25
-
26
- ### 🇬🇧 English
27
-
28
- 1. **Chapter-library management**: chapters live under `novels/<book>/第N章.md` (also `.txt` / `.markdown`).
29
- `novel_books` / `novel_chapters` / `novel_read` let the AI browse, list, and read chapters.
30
- 2. **Smart chapter numbering**: chapter numbers may appear **anywhere** in the filename and in many forms,
31
- e.g. `第01章.md`, `01-title.md`, `raw-…Chapter-1.txt`. Both Arabic and **Chinese numerals**
32
- (第一章 / 第十四章 / 第三十章) are recognized and chapters are sorted by number automatically.
33
- 3. **Automatic encoding detection**: UTF-8 (with/without BOM), UTF-16 LE/BE (BOM or heuristic), and
34
- GBK/GB18030 (no BOM) are decoded on the fly — no manual transcoding needed.
35
- 4. **Keyword analysis**: `novel_keywords` deterministically extracts high-frequency words from a whole book
36
- or one chapter (Chinese bigrams + characters + English words), guiding the AI to analyze plot,
37
- writing style, vocabulary preferences, and imagery motifs.
38
- 5. **Continuation writing**: a system prompt enforces the workflow (read first, then write; keep style and
39
- foreshadowing consistent). `novel_new_chapter` creates the next chapter file automatically.
40
-
41
- ---
42
-
43
- ## 提供的工具 / Provided Tools
44
-
45
- | Tool | 中文说明 | English |
46
- |------|----------|---------|
47
- | `novel_books` | 列出章节库全部作品(章节数、总字数) | List all books in the library (chapter count, total chars) |
48
- | `novel_chapters` | 列出某作品章节清单(章号/标题/字数/行数/更新时间) | List a book's chapters (number/title/chars/lines/updated) |
49
- | `novel_read` | 阅读某章正文(行号 + 字数统计,offset/limit 分段) | Read a chapter's body (line numbers + char count, paginated) |
50
- | `novel_keywords` | 提取高频关键词(可单章或全书) | Extract high-frequency keywords (chapter or whole book) |
51
- | `novel_new_chapter` | 创建新章节文件(自动取下一个章号) | Create a new chapter file (auto-next number) |
52
-
53
- ---
54
-
55
- ## 安装 / Installation
56
-
57
- > 现代安装请优先参考 `INSTALL.md`,或使用 DSH CLI:
58
-
59
- > Preferred install via DSH CLI, see also `INSTALL.md`:
1
+ # dsh-novel-writer — 小说写作助手插件(v0.3.0)
2
+
3
+ DSH(DeepSeek Harness)小说写作助手 bundle 插件。宿主端零第三方依赖(仅 Node 内置模块),
4
+ 浏览器端仅依赖 Web GUI 自带的 react。为 AI 提供小说章节库管理、分析与续写辅助能力;
5
+ v0.3.0 新增**句式模式分析**扩展与 **Web UI 开关**。
6
+
7
+ ## 功能
8
+
9
+ 1. **章节库**:章节存于 `novels/<书名>/第N章.md`(或 `.txt`/`.markdown`),
10
+ 插件提供 `novel_books` / `novel_chapters` / `novel_read` 让 AI 浏览并读取每一章内容。
11
+ 章节文件名中的序号支持任意位置与多种写法,例如:
12
+ `第01章.md`、`01-标题.md`、`原稿件-单章-…第一章.txt`、`原稿件-单章-第25章 .txt`
13
+ (阿拉伯数字与中文数字"第一章/第十四章/第三十章"均可识别,自动按章号排序)。
14
+ 文件编码自动探测:UTF-8(含/不含 BOM)、UTF-16 LE/BE(含 BOM 或启发式识别)、GBK/GB18030(无 BOM)。
15
+ 2. **分析**:`novel_keywords` 确定性提取全书/单章高频关键词(中文相邻二字词组 + 高频单字 + 英文词)。
16
+ 3. **句式模式分析(v0.3.0 新增)**:`novel_sentence_analysis` 对全书/单章输出——
17
+ - 句式分布:陈述 / 对话 / 心理 / 疑问 / 反问 / 感叹 / 祈使 / 省略留白(比例、句数、均长、例句);
18
+ - 排列规律:句式转移、2/3 连句高频模板、段首/段尾句式、纯对话段/纯心理段/混合段统计;
19
+ - 句长节奏:均值/中位数、短句/长句占比;
20
+ - 主观情感:轻量情感词典(喜/怒/哀/惧/惊)+ 强度副词加权 主导情绪、情绪分布、情感曲线、主观性指数;
21
+ - 风格指纹:一维紧凑签名,方便 AI 快速比对与复刻作者的句式习惯。
22
+ 4. **UI 开关(v0.3.0 新增)**:Web GUI 侧边栏出现「句式分析」入口,面板内两个开关:
23
+ - **启用句式分析(enabled)**:控制 novel_sentence_analysis 是否可用;
24
+ - **自动分析(autoAnalyze)**:控制 AI 分析作品时是否主动附带句式报告。
25
+ 开关实时写入宿主端 `~/.dsh/dsh-novel-writer/state.json`,与 `novel_sentence_config` 工具双向同步;
26
+ 宿主端不可达时降级保存在浏览器 localStorage。
27
+ 5. **续写**:系统提示词规定续写工作流(先读后写、保持文风与伏笔一致),
28
+ `novel_new_chapter` 创建新章节文件。
29
+
30
+ ## 提供的工具
31
+
32
+ | 工具 | 说明 |
33
+ |---|---|
34
+ | `novel_books` | 列出章节库全部作品(章节数、总字数) |
35
+ | `novel_chapters` | 列出某作品章节清单(章号/标题/字数/行数/更新时间) |
36
+ | `novel_read` | 阅读某章正文(行号 + 字数统计,offset/limit 分段) |
37
+ | `novel_keywords` | 提取高频关键词(可单章或全书) |
38
+ | `novel_new_chapter` | 创建新章节文件(自动取下一个章号) |
39
+ | `novel_sentence_analysis` | **句式模式分析**(句式分布/排列规律/段落结构/句长/情感曲线/风格指纹) |
40
+ | `novel_sentence_config` | 查看/修改句式分析开关(与 Web UI 开关同步) |
41
+
42
+ ## 安装(web profile)
60
43
 
61
44
  ```sh
62
- dsh plugin --profile web add D:/path/to/dsh-novel-writer
63
- ```
64
-
65
- 或手动等价操作:在 profile 的 `package.json` 的 `dsh.profile.bundles` 中加入 `dsh-novel-writer`,
66
- 并在 profile `node_modules` 中链接本包(Windows 可建 junction:`mklink /J`)。安装后重启 web 应用生效。
67
-
68
- Or the manual equivalent: add `dsh-novel-writer` to the `dsh.profile.bundles` array in the profile's
69
- `package.json`, and link this package into the profile `node_modules` (on Windows, `mklink /J`).
70
- Restart the web app after installing.
71
-
72
- ### (可选)安装技能 / (Optional) Install the Skill
73
-
74
- 把 `skills/novel-writing` 整个文件夹复制到工作区 `.dsh/skills/` 下,新会话即出现 `novel-writing` 技能:
75
-
76
- Copy the whole `skills/novel-writing` folder into your workspace `.dsh/skills/`; a new session will surface the `novel-writing` skill:
77
-
45
+ dsh plugin --profile web add D:/tools/dsh-novel-writer-v0.3.0
78
46
  ```
79
- <workspace>/.dsh/skills/novel-writing/SKILL.md
80
- ```
81
-
82
- ---
83
47
 
84
- ## 配置 / Configuration
48
+ 或手动等价操作:把本文件夹放入 profile `node_modules`,并在 profile `package.json` 的
49
+ `dsh.profile.bundles` 中加入 `dsh-novel-writer`。安装后**重启 web 应用**生效:
50
+ 宿主端注册新工具与 `/api/dsh-novel-writer/state` 路由,浏览器端挂载侧边栏「句式分析」开关。
85
51
 
86
- 插件 `config` 支持 `root`:章节库根目录(默认取**会话工作区**,即 `novels/` 所在位置)。
87
- 在 profile 的 `cordis.patch.yml` 中可覆盖:
52
+ ## 配置
88
53
 
89
- The plugin `config` supports `root`: the library root directory (defaults to the **session workspace** where `novels/` lives). Override it in the profile's `cordis.patch.yml`:
54
+ 插件 config 支持 `root`(章节库根目录)与 `sentenceAnalysis`(默认开关):
90
55
 
91
56
  ```yaml
92
57
  - patch:
93
58
  - id: novel-writer
94
59
  config:
95
60
  root: 'D:/我的小说库'
61
+ sentenceAnalysis:
62
+ enabled: true # 默认启用(UI 开关优先于此处)
63
+ autoAnalyze: true # 默认自动附带句式分析
96
64
  ```
97
65
 
98
- ---
99
-
100
- ## 章节库约定 / Library Convention
101
-
102
- ```
103
- <workspace or root>/novels/<书名>/
104
- ├── 第01章.md # 或 .txt / .markdown
105
- └── 原稿件-单章-…第一章.txt # 序号在任意位置、中文数字均可识别
106
- ```
107
-
108
- 支持的命名与编码 / Supported naming & encoding:
109
-
110
- - 章号任意位置:`第01章.md`、`01-标题.md`、`原稿件-单章-…第一章.txt`、`原稿件-单章-第25章 .txt`
111
- - 阿拉伯数字 + 中文数字(第一章/第十四章/第三十章),自动按章号排序
112
- - 编码自动探测:UTF-8(含/不含 BOM)、UTF-16 LE/BE(含 BOM 或启发式)、GBK/GB18030(无 BOM)
113
-
114
- ---
115
-
116
- ## 安全说明 / Security Notes
117
-
118
- - 仅使用 Node 内置模块,无第三方运行时依赖、无网络请求、无 shell 执行。
119
- - 所有文件读写均限定在章节库根目录下,并通过 `sanitizeSegment` 阻止路径穿越(拒绝 `.`/`..` 与 `\`/`/`)。
120
- - 读取设有上限(单次最多 400 行 / 2 万字符),保护模型上下文。
121
-
122
- - Uses only Node built-in modules: no third-party runtime deps, no network calls, no shell execution.
123
- - All file reads/writes are confined to the library root, with `sanitizeSegment` blocking path traversal (rejects `.`/`..` and `\`/`/`).
124
- - Reads are capped (400 lines / 20k chars per call) to protect the model's context window.
125
-
126
- ---
66
+ ## 版本记录
127
67
 
128
- <!-- ENGLISH -->
68
+ ### v0.3.0(本版本)
69
+ - **新增**:句式模式分析(novel_sentence_analysis):句式分布、排列规律、段落结构、句长节奏、情感曲线、风格指纹;
70
+ - **新增**:Web UI 开关(侧边栏「句式分析」面板):enabled / autoAnalyze,宿主端 state 文件持久化 + 浏览器降级;
71
+ - **新增**:novel_sentence_config 工具,与 UI 开关双向同步;
72
+ - **新增**:宿主端 `/api/dsh-novel-writer/state` 路由(loopback 围栏);
73
+ - 更新 SKILL.md / 系统提示词中的句式分析工作流。
129
74
 
130
- ## English
75
+ ### v0.2.0
76
+ - 修复章节序号提取(任意位置、中文数字);新增 UTF-8/UTF-16/GBK 编码自动探测;通过 37 章全量压力测试。
131
77
 
132
- `dsh-novel-writer` is a self-contained **DSH (Cordis) bundle plugin** for novel-writing assistance, with **no third-party dependencies** (Node built-ins only). See the sections above for features, tools, install, config, and security notes. MIT licensed.
78
+ ### v0.1.0
79
+ - 章节库管理、novel_keywords、novel_new_chapter。
package/cordis.patch.yml CHANGED
@@ -1,6 +1,12 @@
1
1
  # dsh-novel-writer bundle patch: mounts the novel-writing assistant plugin
2
- # into the profile's loader tree. The entry's `name` is the plugin package
2
+ # into the profile's loader tree. The entry's name is the plugin package
3
3
  # itself, resolved from the profile's node_modules.
4
+ #
5
+ # v0.3.0: the same row now carries BOTH halves — the node half (exports ".")
6
+ # runs in the host process (novel_* tools + /api/dsh-novel-writer/state
7
+ # routes for the UI switch), and the dsh.client declaration in package.json
8
+ # makes the browser half (exports "./client") load in the web GUI, mounting
9
+ # the 「句式分析」 sidebar entry with the enable switch.
4
10
  - insert:
5
11
  - id: novel-writer
6
12
  name: 'dsh-novel-writer'