dsh-web
zhu1090093659/dsh-webDeepSeek Harness(DSH)Web 插件聚合生态包 · 一切皆插件,创意工坊分发(dsh-market.com)
DeepSeek Harness (DSH) tool plugin: count the body word count of novel chapter files — chapter_words_count(files) -> [counts]
DeepSeek Harness (DSH) 章节字数统计工具插件(Cordis 插件)。 DSH tool plugin: count the body word count of novel chapter text files.
注册一个模型可直接调用的工具 chapter_words_count:传入章节文件路径列表,返回与输入顺序一致的正文字数列表。
chapter_words_count(file1, file2, ...) -> [3156, 3349, ...]
lib/count.js 纯计数逻辑(零依赖,可独立测试、独立 import)
lib/index.js Cordis 插件本体:name / inject / Config / apply
test/ node:test 单元测试(npm test)
插件按 Cordis/DSP 惯例导出 { Config, apply, inject, name }:
name = "dsh-chapter-word-counter"(加载器补丁行按此名引用)inject = ["tools", "fs"](工具注册表 + 沙箱化文件系统服务)ctx.tools.register(defineTool({...})) 注册,工具名 chapter_words_countctx.fs(与内置 read/write 工具同一沙箱与观测链路)在 profile 的补丁层($DSH_HOME/profiles/<name>/cordis.patch.yml)插入一行:
- insert:
- id: dsh-chapter-word-counter
name: 'dsh-chapter-word-counter'
并把本包安装到插件解析路径。两种方式:
方式 A(推荐,标准):在 profile 目录用 pnpm 安装本包后,按包名引用:
dsh plugin --profile web add dsh-chapter-word-counter@github:Tinger-X/dsh-chapter-word-counter
# 或先克隆到本地后:dsh plugin --profile web add file:D:\...\dsh-chapter-word-counter
方式 B(手动):把整个包目录复制到 DSH 安装目录的 node_modules 下(加载器从安装目录解析裸包名):
$src = '<本仓库目录>'
$dst = '<DSH 安装目录>\node_modules\dsh-chapter-word-counter'
Copy-Item $src $dst -Recurse
profile 补丁层会被运行中的服务热加载(watchUserPatches),通常无需重启;若未生效,重启 dsh web 即可。
npm install # 安装 schemastery 及 @deepseek-ai/* 开发依赖
npm test # node --test test/
计数规则自检样例:
| 输入 | 正文字数 |
|---|---|
第001章 开篇\n晨光落进窗来,檐角有风。\n猫在打盹。\n | 17 |
第999章 测试\nABC123,。!?\n | 10 |
| 空文件 / 只有标题行 | 0 |
MIT © Tinger-X