npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-chapter-word-counter

v1.0.0

Published

DeepSeek Harness (DSH) tool plugin: count the body word count of novel chapter files. chapter_words_count(files) -> [counts]

Readme

dsh-chapter-word-counter

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, ...]

统计规则(Counting rule)

  1. 忽略第一行(章节号 + 标题,如「第001章 开篇」);
  2. 去除换行符(以及空格、制表符、全角空格等一切空白字符)——只统计正文中的文字和标点;
  3. 其余每个字符(汉字、标点、数字、字母)计 1 字,按码点计数。
  • 路径由 DSH 文件系统后端解析(绝对路径或工作区相对路径),受当前沙箱权限约束;
  • 文件不存在或不是普通文件时报错;
  • 空文件或只有标题行的文件计 0。

包结构(Layout)

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_count
  • 读取文件一律走 ctx.fs(与内置 read/write 工具同一沙箱与观测链路)

安装到 DeepSeek Harness(Install & activate)

在 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 即可。

开发与测试(Develop & test)

npm install     # 安装 schemastery 及 @deepseek-ai/* 开发依赖
npm test        # node --test test/

计数规则自检样例:

| 输入 | 正文字数 | |---|---| | 第001章 开篇\n晨光落进窗来,檐角有风。\n猫在打盹。\n | 17 | | 第999章 测试\nABC123,。!?\n | 10 | | 空文件 / 只有标题行 | 0 |

License

MIT © Tinger-X