Skip to main content
M

pro-202611 (context-broom)

moluotianshen/pro-202611/plugins/context-broom

A broom button beside the context-usage readout under the web composer. Its frame draws the current occupancy, shifting green to yellow to red as the session fills, with stronger wording and a faster pulse as pressure rises; clicking it compacts the session, preferring a native compact or compress command when one is registered and otherwise folding the oldest ranges that contain no user message through the plugin host route.

Install

dsh plugin --profile web add github:moluotianshen/pro-202611

This plugin lives in the plugins/context-broom subdirectory of the repository.

README

pro-202611

2026 年 11 月开的坑,方向还没定。先放一个零依赖、能跑能测的最小骨架, 之后想到要做什么,直接把 src/index.js 换成真正的业务逻辑即可。

环境

  • Node.js >= 18(项目用 ESM,"type": "module")
  • 不需要 npm install,没有任何第三方依赖

快速开始

npm test          # 跑测试,等价于 node --test
npm start         # 从 stdin 读文本
node src/cli.js README.md   # 统计某个文件

也可以当库用:

import { textStats, formatStats, topWord } from './src/index.js';

console.log(formatStats(textStats('Hello 世界 hello')));
// chars=17 words=3 lines=1 uniqueWords=2

现在有什么

文件作用
src/index.js纯函数核心:textStats / formatStats / topWord
src/cli.js命令行入口,读文件或 stdin
test/index.test.jsnode:test 单元测试,覆盖空文本、Unicode、CRLF、高频词
.gitignoreNode / 编辑器 / 本地环境忽略规则

目录约定

  • src/ — 源码
  • test/ — 测试,文件名 *.test.js
  • 新增功能请顺手在 test/ 里加一条断言

关于「还没想好」

骨架故意保持很小:不引入框架、不接数据库、不写构建流程。 等目标明确后,再决定是长成 CLI 工具、库、服务还是别的东西。

Related plugins