unclecode/toolshrink

插件Plugin ⭐ 10 MIT developer-toolstools

Cut large agent tool output by what it means, not by where it was cut. 13 content-aware reducers + DeepSeek Harness plugin.

编辑导读Editor's Brief

## 核心特性
- toolshrink 通过识别文本形态并保留承载信息的部分,来缩减大体量 agent 工具输出,而不是仅按头部/尾部大小截断。
- 它包含 13 种 cut,分别用于 diff、JSON、测试、构建输出、堆栈跟踪、日志、文件树、重复行、lint 输出、安装输出、CSV/TSV 表格、git log,以及大小回退。
- 每次缩减都会在标记中报告被省略的字符或行数,避免产生不完整行和拆分 UTF-16 代理对,并且在第二次处理时保持幂等。
- 它可以通过 spill store 保存完整原始输出,并追加定位标记,使被移除内容能够逐字节取回。
- 它可以作为 DeepSeek Harness 插件使用,也可以作为 JavaScript 库使用,并支持可选的 tool、command 和 path 提示。

## 使用场景
- 在 DeepSeek Harness 中使用它,在长 shell、测试、构建或日志工具结果进入 agent 上下文前进行缩减。
- 在需要带预算文本缩减,并输出 strategy、note 和统计信息的 JavaScript 工具中,将其作为库使用。
- 使用自定义 cut 文件处理特定宿主环境的输出形态,例如 kubectl 或其他结构化命令结果。

## 技术细节
- Harness 适配器可通过 dsh plugin --profile web add github:unclecode/toolshrink 安装,并以默认 50,000 字符预算挂载。
- 可以通过 YAML 配置 maxCharsmaxLinesmaxLineChars、禁用的 cut、spill 目录和日志路径。
- cut 是暴露 namedetectreduce 的纯文件,自定义 cut 可从目录加载,并会在内置 cut 之前被尝试。
- 库 API 返回 contentreducedstrategynotestats,而 spill store 接口支持基于文件或由宿主提供的存储。

## 注意事项
- 仓库将 pi 和 Codex 适配器列为待完成工作,而非已包含的集成。
- TODO 部分将 semantic、SQL 和 Docker cut 描述为计划中的功能,而非已交付功能。
- 使用默认的基于文件的 spill store 时,spill 文件会在 24 小时后清理。

## Core Features
- toolshrink reduces large agent tool output by recognizing text shape and keeping information-carrying parts instead of using only head/tail size cuts.
- It includes thirteen cuts for diff, JSON, tests, build output, stack traces, logs, file trees, repeated lines, lint output, install output, CSV/TSV tables, git log, and a size fallback.
- Every reduction reports omitted characters or lines in a marker, avoids partial lines and split UTF-16 surrogate pairs, and is idempotent on a second pass.
- It can save the complete original output through a spill store and append a locator marker so removed content can be retrieved byte for byte.
- It can be used as a DeepSeek Harness plugin or as a JavaScript library with optional hints for tool, command, and path.

## Use Cases
- Use it in DeepSeek Harness to shrink long shell, test, build, or log tool results before they enter the agent context.
- Use it as a library in JavaScript tools that need budgeted text reduction with strategy, note, and statistics output.
- Use custom cut files to handle host-specific output shapes such as kubectl or other structured command results.

## Technical Details
- The Harness adapter installs with dsh plugin --profile web add github:unclecode/toolshrink and mounts with a default 50,000-character budget.
- Configuration can set maxChars, maxLines, maxLineChars, disabled cuts, spill directory, and log path through YAML.
- Cuts are plain files exposing name, detect, and reduce, and custom cuts can be loaded from a directory and tried before built-in cuts.
- The library API returns content, reduced, strategy, note, and stats, while the spill store interface allows file-based or host-provided storage.

## Notes
- The repository lists adapters for pi and Codex as open work rather than included integrations.
- The TODO section describes semantic, SQL, and Docker cuts as planned rather than shipped features.
- Spilled files are cleaned after 24 hours when using the default file-based spill store.

安装Install

dsh plugin --profile web add github:unclecode/toolshrink

unclecode/toolshrink 加入你的 DSH 配置(web profile)即可启用。

READMEREADME

上一个 Prev dsh-better-browser 下一个 Next dsh-evolve