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-line-ops

v0.1.0

Published

Line-level text operations plugin for DeepSeek Harness: extract lines by selector or regex, and apply ordered transform chains (dedupe, sort, number, prefix, trim, head/tail).

Readme

dsh-line-ops

行级文本操作插件(dsh / DeepSeek Harness 工具集)。提供两个工具:按行号选择器或正则提取行、对行应用有序变换链。零依赖,输入上限 1MB。

安装

npm install dsh-line-ops

cordis.patch.yml 已随包声明,dsh 宿主加载后自动注册以下工具。

工具

1. extract_lines — 按行号或正则提取行

| 参数 | 类型 | 说明 | |---|---|---| | text / file | string | 文本内容或文件路径,二选一 | | lines | string | 行号选择器(与 pattern 二选一) | | pattern | string | 正则表达式(与 lines 二选一) | | invert | boolean | 可选,反选(输出未选中的行) |

选择器语法(1 基行号):"1,3,5-10"、负数从尾数(-1 = 最后一行)、范围端点自动归一(4-2 等价 2-4)、-5--2 表示倒数第 5 到第 2 行。完全越界的条目自动跳过。

extract_lines { file: "app.js", lines: "1,10-20,-3" }
extract_lines { text: "...", pattern: "^def |class ", invert: false }

输出格式(带原始行号,便于后续定位修改):

提取 3 行(共 42 行,选择器 1,10-20,-3):
  1 | import ...
 10 | function parse() {
 40 | }

2. transform_lines — 有序变换链

| 参数 | 类型 | 说明 | |---|---|---| | text / file | string | 文本内容或文件路径,二选一 | | ops | string[] | 变换操作列表,按序执行(必填) |

可用操作:

| 操作 | 说明 | |---|---| | dedupe | 去重(保留首次出现) | | sort / sort:desc | 排序(zh-CN locale) | | reverse | 行序反转 | | number / number:# | 加行号,默认 1. ,冒号后自定义分隔符 | | prefix:X / suffix:X | 每行加前缀 / 后缀 | | trim | 去首尾空白 | | nonempty | 去空行 | | head:N / tail:N | 截取前 / 后 N 行 |

transform_lines { file: "hosts.txt", ops: ["trim", "nonempty", "dedupe", "sort"] }
transform_lines { text: "...\n...\n", ops: ["nonempty", "sort", "number"] }

输出第一行为统计(变换完成: 12 行 -> 9 行(4 步操作)),随后是变换结果。

与其他插件配合

  • dsh-text-diff 找出两文件差异 → extract_lines 定位上下文 → dsh-diff-writer 修复。
  • dsh-csv-explorer / dsh-json-yaml-toolkit 输出的列表可经 transform_lines 排序编号。

测试

npm test

Roadmap(v0.2 候选)

  • transform_lines 增加 replace:A->B(逐行文本替换)、slice:A-B(范围截取)
  • extract_lines 支持上下文行(命中行 ±N)
  • filter_regex 按正则保留/剔除行(与 invert 组合)
  • 选择器支持步进(1-10:2 隔行)