{"_id":"@deeptrial/dsh-bash-rtk","name":"@deeptrial/dsh-bash-rtk","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.1":{"name":"@deeptrial/dsh-bash-rtk","description":"DeepSeek Harness bash executor plugin that routes eligible commands through rtk (Rust Token Killer) to compress tool output and save tokens. Optional overlay: install, then enable via --patch.","version":"0.1.1","type":"module","main":"lib/index.js","types":"lib/index.d.ts","exports":{".":{"types":"./lib/index.d.ts","default":"./lib/index.js"},"./wrap":{"types":"./lib/wrap.d.ts","default":"./lib/wrap.js"},"./cordis.patch.yml":"./cordis.patch.yml","./package.json":"./package.json"},"scripts":{"build":"tsdown","typecheck":"tsc -p tsconfig.json && tsc -p tsconfig.test.json --noEmit","test":"vitest run","check":"pnpm run typecheck && pnpm run test && pnpm run build"},"dsh":{"bundle":{"patch":"./cordis.patch.yml"}},"peerDependencies":{"@deepseek-ai/dsh-bash-local":"0.0.1-rc.1","@deepseek-ai/dsh-bash-sandbox":"0.0.1-rc.1","@deepseek-ai/dsh-shell":"0.0.1-rc.5"},"peerDependenciesMeta":{"@deepseek-ai/dsh-bash-local":{"optional":true},"@deepseek-ai/dsh-bash-sandbox":{"optional":true},"@deepseek-ai/dsh-shell":{"optional":true}},"devDependencies":{"@deepseek-ai/dsh-bash-local":"link:../deepseek-harness/packages/shell/bash-local","@deepseek-ai/dsh-bash-sandbox":"link:../deepseek-harness/packages/shell/bash-sandbox","@deepseek-ai/dsh-shell":"link:../deepseek-harness/packages/shell/shell","@deepseek-ai/dsh-subprocess-local":"link:../deepseek-harness/packages/subprocess/subprocess-local","@deepseek-ai/dsh-sandbox":"link:../deepseek-harness/packages/sandbox/sandbox","@deepseek-ai/dsh-sandbox-local":"link:../deepseek-harness/packages/sandbox/sandbox-local","@deepseek-ai/dsh-sandbox-policy":"link:../deepseek-harness/packages/sandbox/sandbox-policy","cordis":"link:../deepseek-harness/vendor/cordis","@types/node":"^22.0.0","typescript":"^5.9.0","tsdown":"^0.22.2","vitest":"^4.1.0"},"keywords":["deepseek","dsh","deepseek-harness","rtk","token-compression","bash","shell","cordis","plugin"],"homepage":"https://github.com/DeepTrial/dsh-bash-rtk#readme","repository":{"type":"git","url":"git+https://github.com/DeepTrial/dsh-bash-rtk.git"},"bugs":{"url":"https://github.com/DeepTrial/dsh-bash-rtk/issues"},"author":{"name":"DeepTrial"},"license":"MIT","engines":{"node":">=20.0.0"},"_id":"@deeptrial/dsh-bash-rtk@0.1.1","gitHead":"a109c766f1a644843bf25fead327aca07a203538","_nodeVersion":"22.23.1","_npmVersion":"10.9.8","dist":{"integrity":"sha512-GMrKbue2PJiSa80JfXyg+qmNAefaF02mLf2Kt2urPLahJSQxJJDKrMRe6QaO8VHVaKN1Qp6LIo6iiBn7J+ZNPg==","shasum":"d28d03ca2476a0fdf3a975d0c673d6ec4163aad5","tarball":"https://registry.npmjs.org/@deeptrial/dsh-bash-rtk/-/dsh-bash-rtk-0.1.1.tgz","fileCount":10,"unpackedSize":29312,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAMC2wjYmE4zSGLrHwsGbGHXsIQ7odZqsi3Qkq+a+FjlAiAdaDbQVqNV3AjvJnM6pjSvTfEc6tTErQm1Utmmko7NIw=="}]},"_npmUser":{"name":"karlxing","email":"karl.xing@email.cn"},"directories":{},"maintainers":[{"name":"karlxing","email":"karl.xing@email.cn"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dsh-bash-rtk_0.1.1_1787573441678_0.19670278552632992"},"_hasShrinkwrap":false}},"time":{"created":"2026-08-24T12:10:40.964Z","0.1.1":"2026-08-24T12:10:41.861Z","modified":"2026-08-24T12:10:42.532Z"},"maintainers":[{"name":"karlxing","email":"karl.xing@email.cn"}],"description":"DeepSeek Harness bash executor plugin that routes eligible commands through rtk (Rust Token Killer) to compress tool output and save tokens. Optional overlay: install, then enable via --patch.","homepage":"https://github.com/DeepTrial/dsh-bash-rtk#readme","keywords":["deepseek","dsh","deepseek-harness","rtk","token-compression","bash","shell","cordis","plugin"],"repository":{"type":"git","url":"git+https://github.com/DeepTrial/dsh-bash-rtk.git"},"author":{"name":"DeepTrial"},"bugs":{"url":"https://github.com/DeepTrial/dsh-bash-rtk/issues"},"license":"MIT","readme":"# dsh-bash-rtk\n\n[![CI](https://github.com/DeepTrial/dsh-bash-rtk/actions/workflows/ci.yml/badge.svg)](https://github.com/DeepTrial/dsh-bash-rtk/actions/workflows/ci.yml)\n[![GitHub Release](https://img.shields.io/github/v/release/DeepTrial/dsh-bash-rtk)](https://github.com/DeepTrial/dsh-bash-rtk/releases)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/DeepTrial/dsh-bash-rtk/blob/main/LICENSE)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue?logo=typescript)](https://www.typescriptlang.org/)\n[![Node.js](https://img.shields.io/badge/Node.js-%3E%3D20.0.0-339933?logo=nodedotjs)](https://nodejs.org/)\n\n> 在 DeepSeek Harness（`dsh`）的 bash 执行器里，把符合条件的 shell 命令路由给 [rtk](https://github.com/rtk-ai/rtk)（Rust Token Killer）执行 —— 压缩工具输出、省 token、其余一概不变。\n\n[English version](README.md)\n\n---\n\n## 目录\n\n- [快速示例](#快速示例)\n- [环境要求](#环境要求)\n- [为什么需要它](#为什么需要它)\n- [工作原理](#工作原理)\n- [安装与启用](#安装与启用)\n- [API / 配置](#api--配置)\n- [哪些命令会被路由](#哪些命令会被路由)\n- [开发](#开发)\n- [许可证](#许可证)\n\n---\n\n## 快速示例\n\n插件在 `resolve()` 边界重写命令 —— 在实际执行之前：\n\n| 输入 (`command`) | 解析后的输出 | 原因 |\n|---|---|---|\n| `git status` | `rtk git status` | 简单命令 + 在白名单内 |\n| `cargo build --release` | `rtk cargo build --release` | 简单命令 + 在白名单内 |\n| `git status \\| grep x` | `git status \\| grep x` | 复杂 shell —— **直接透传** |\n| `ls -la` | `ls -la` | 不在白名单 —— **直接透传** |\n| `git status`（无 rtk） | `git status` | 二进制缺失 —— **恒等回退** |\n\n其余一切 —— 工作目录、超时、环境变量、退出码、沙箱隔离 —— 均原样继承。\n\n## 环境要求\n\n- **Node.js:** >= 20.0.0\n- **rtk:** `rtk --version` 在 PATH 上退出码为 0（需单独安装，例如 `cargo install rtk`）\n\n## 为什么需要它\n\nLLM agent 在冗长的工具输出上浪费大量 token（`git log`、`cargo build`、`pytest` 输出……）。`rtk` 已知道如何把这些输出压缩 30–90%。本插件把这套过滤接到 `dsh` 的 bash 执行器上，让每个符合条件的命令自动走 `rtk` —— **且对实际运行内容零语义改动**。\n\n## 工作原理\n\n```\nmodel → dsh bash 工具 → RtkBashExecutor.resolve()\n                              │\n              ┌───────────────┴────────────────┐\n         符合条件？                        不符合条件\n   （简单命令 + 在白名单内）          （复杂 / 未知命令）\n              │                                │\n      rtk <子命令> …                  命令原样执行\n   （rtk 压缩输出）              （逐字节透传）\n```\n\n三道独立关卡决定路由（见 [`src/wrap.ts`](src/wrap.ts)）：\n\n1. **复杂度** — 任何 shell 元字符（`| & ; < > \\` $`）都会取消资格。包装这些会改变实际运行内容，故直接透传。\n2. **白名单** — 仅 `rtk` 实际实现的已知开发工具才符合资格（`wrap.ts` 中的映射表）。\n3. **可用性** — 若 `PATH` 上找不到 `rtk` 二进制，变换退化为**恒等**：部署行为与原始本地执行器完全一致。\n\n### 版本说明\n\n本插件**不捆绑、不锁定 rtk 版本**。`dsh` 启动时会探测 `PATH` 上的 `rtk --version`（见 [`src/index.ts`](src/index.ts) 的 `resolveRtk()`）。因此：\n\n- **rtk 发布新版本时**，任何在本地升级了 `rtk` 的用户会自动获得新行为 —— 无需更新本插件。\n- 本插件版本（本仓库）与 rtk 版本**相互独立**，请勿混为一谈。本说明给出的是测试所基于的*最低* rtk 版本，而非锁步版本号。\n\n> **要求：** `rtk` 在 `PATH` 上（`rtk --version` 退出码为 0）。插件**不会**安装或管理 rtk —— **你必须自行安装并更新 rtk**（例如 `cargo install rtk` 或下载发布二进制）。当 rtk 缺失时，插件静默退化为透传。\n\n## 安装与启用\n\n插件**默认禁用** —— 安装后不会生效，需手动开启。\n\n```sh\n# 1) 从本地 checkout 安装\ndsh plugin --profile web add \"<path-to-this-dir>\"\n\n# 2) 或直接用最新 GitHub release tarball 安装（无需本地 clone）\ndsh plugin --profile web add \\\n  \"https://github.com/DeepTrial/dsh-bash-rtk/releases/latest/download/dsh-bash-rtk.tar.gz\"\n\n# 通过可选 overlay 启用 —— 在你的 profile 的 cordis.patch.yml 中添加：\n#   - id: bash-sandbox\n#     disabled: true\n#   - id: bash-rtk\n#     disabled: false\n\ndsh web   # 重启以生效\n```\n\n内置的 overlay 片段位于 [`cordis.patch.yml`](cordis.patch.yml)。它会用 `RtkSandboxBashExecutor`（保留文件隔离）替换原生的沙箱执行器，并保留非隔离的 `RtkBashExecutor` 供 `danger-full-access` 场景使用。\n\n## API / 配置\n\n两个执行器均接受与其原生对应物（`LocalBashExecutor` / `SandboxBashExecutor`）相同的基础配置，外加一个可选字段：\n\n| 选项 | 类型 | 默认值 | 说明 |\n|---|---|---|---|\n| `rtkAvailable` | `boolean` | `resolveRtk()` 结果 | 强制启用或禁用 rtk 包装。适用于测试或二进制路径非标准的部署环境。 |\n\n其余选项 —— `cwd`、`timeoutMs`、`graceMs` 等 —— 均原样继承自上游执行器。\n\n## 哪些命令会被路由\n\n符合 rtk 包装条件的命令集合由 **rtk 本身**定义 —— 权威且持续维护的列表见 [rtk 命令参考](https://github.com/rtk-ai/rtk#supported-ecosystems) / [`README.md`](https://github.com/rtk-ai/rtk/blob/develop/README.md#test-runners)。本插件镜像该列表；当 rtk 新增子命令时，升级 rtk（而非本插件）即可生效。\n\n复杂命令 —— 管道、`&&`/`;`、重定向、`$( )`、环境变量赋值 —— 无论白名单如何，始终以原生方式运行。\n\n## 开发\n\n```sh\n# 1. 克隆插件及其依赖的 harness\ngit clone https://github.com/DeepTrial/dsh-bash-rtk.git\ngit clone https://github.com/deepseek-ai/deepseek-harness.git\n\n# 2. 安装 harness 依赖并构建插件所链接的库\ncd deepseek-harness && pnpm install && pnpm build:lib:host\n\n# 3. 安装插件依赖并运行检查\ncd ../dsh-bash-rtk && pnpm install --ignore-scripts\npnpm run check        # 类型检查 + 测试 + 构建\npnpm run test         # 仅测试\npnpm run typecheck    # 仅 tsc\n```\n\n`devDependencies` 通过 `link:` 指向本地 `deepseek-harness` 源码仓；测试需在该 workspace 内运行（`@deepseek-ai/dsh-*` 包必须可解析）。\n\n## 许可证\n\nMIT\n","readmeFilename":"README.zh.md","_rev":"1-8eb0f5d870714f8d211b93a93352b53e"}