{"_id":"@agent-context/dsh-sift","_rev":"2-81f1f7a14013b551320e060661b963ac","name":"@agent-context/dsh-sift","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@agent-context/dsh-sift","version":"0.0.1","keywords":["deepseek-harness","dsh","sift","context-compression"],"license":"Apache-2.0","_id":"@agent-context/dsh-sift@0.0.1","maintainers":[{"name":"liangshuai","email":"509856256@qq.com"}],"dsh":{"bundle":{"patch":"./cordis.patch.yml"}},"dist":{"shasum":"0ab3cddecfcc7291ff0a6503b900e21058be24a2","tarball":"https://registry.npmjs.org/@agent-context/dsh-sift/-/dsh-sift-0.0.1.tgz","fileCount":12,"integrity":"sha512-j5Kv9msxIC/10VuQNOfRFwYEFVgi2SD4XkV6jpljk3iRJEwjR4JXxG6nsdvkeccUFotPD3QqEE9/uw/Vm7ntnQ==","signatures":[{"sig":"MEYCIQCDIRPkNo9XcH5nSbi77QKN0KzCPJFvBD1L2w+o8hvk3QIhAKPZu0Tg2nQOmKuSk/boC9Cv6nnZSdB5UvCCYFCyRU50","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19100},"main":"./index.js","type":"module","engines":{"node":"^22.19 || >=24"},"exports":{".":"./index.js"},"gitHead":"3431c56f7e84ea8fa6d959064b86c250b21ae06c","scripts":{"test":"node --test test/*.test.js"},"_npmUser":{"name":"liangshuai","email":"509856256@qq.com"},"_npmVersion":"11.3.0","description":"DeepSeek Harness plugin that compresses tool results with @agent-context/sift","directories":{},"_nodeVersion":"24.0.2","dependencies":{"@agent-context/sift":"0.0.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"peerDependencies":{"@deepseek-ai/dsh-tools":">=0.1.5-rc.2 <0.2"},"_npmOperationalInternal":{"tmp":"tmp/dsh-sift_0.0.1_1789212315927_0.3154744577713249","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@agent-context/dsh-sift","version":"0.0.2","description":"DeepSeek Harness plugin that compresses tool results with @agent-context/sift","license":"Apache-2.0","publishConfig":{"access":"public"},"type":"module","main":"./index.js","exports":{".":"./index.js"},"keywords":["deepseek-harness","dsh","sift","context-compression"],"scripts":{"test":"node --test test/*.test.js"},"dependencies":{"@agent-context/sift":"0.0.1"},"peerDependencies":{"@deepseek-ai/dsh-tools":">=0.1.5-rc.2 <0.2"},"engines":{"node":"^22.19 || >=24.2"},"dsh":{"bundle":{"patch":"./cordis.patch.yml"}},"gitHead":"7103d3684648abce51c183170b86b84d6ee47da0","_id":"@agent-context/dsh-sift@0.0.2","_nodeVersion":"24.21.0","_npmVersion":"11.19.0","dist":{"integrity":"sha512-0Oaqds4Pnwpbku2VdRGNId78Wa6ev/oiN8QLdFU1coz7bdEEZY5ZiRkI8pRvZ1tUUjt2jMSd7c7Sz4wxGSAPdA==","shasum":"70addc9471e5b7f66f7383fd0a67b9355354c56e","tarball":"https://registry.npmjs.org/@agent-context/dsh-sift/-/dsh-sift-0.0.2.tgz","fileCount":12,"unpackedSize":19482,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEtmwmpYLQr7XjnbxZQLj6mwJUGeXujE9MhK1FGTATpsAiEAohA2eFOmnazKevyn/6tQP147YCrhz9StR3QBl6iuEs4="}]},"_npmUser":{"name":"liangshuai","email":"509856256@qq.com"},"directories":{},"maintainers":[{"name":"liangshuai","email":"509856256@qq.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/dsh-sift_0.0.2_1789213253012_0.04207900881977156"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-12T11:25:15.736Z","modified":"2026-09-12T11:40:53.290Z","0.0.1":"2026-09-12T11:25:16.063Z","0.0.2":"2026-09-12T11:40:53.157Z"},"license":"Apache-2.0","keywords":["deepseek-harness","dsh","sift","context-compression"],"description":"DeepSeek Harness plugin that compresses tool results with @agent-context/sift","maintainers":[{"name":"liangshuai","email":"509856256@qq.com"}],"readme":"# @agent-context/dsh-sift\n\nDeepSeek Harness（dsh）的 Sift 工具结果压缩插件。它通过原生 `tools/post-execute` waterfall 在工具结果写入会话并进入下一次模型请求前压缩纯文本内容；有损压缩会把原文暂存到本地，并注册 `sift_retrieve` 工具供 Agent 按 `<<stash:KEY>>` 取回。\n\n要求 Node.js `^22.19 || >=24.2`，以及 DeepSeek Harness `0.1.5-rc.2` 或兼容的 `0.1.x` 版本。Node 24.0–24.1 尚无 dsh CLI 入口使用的 `import.meta.main`，会导致命令静默退出。先确认 `dsh --version` 可用；尚未安装时，先安装当前 developer preview CLI：\n\n```bash\nnpm install -g @deepseek-ai/dsh@next\ndsh --version\n```\n\n使用 Volta 且 Node 版本低于要求时，可先运行 `volta install node@24`；使用 nvm 时运行 `nvm install 24 && nvm use 24`，并确认得到的版本不低于 24.2。\n\n## 安装\n\n从 npm 安装到所需 profile：\n\n```bash\ndsh plugin --profile web add @agent-context/dsh-sift\ndsh web\n```\n\n其他 profile 同理：\n\n```bash\ndsh plugin --profile tui add @agent-context/dsh-sift\ndsh --profile tui\n```\n\n`dsh plugin` 会读取 `package.json` 的 `dsh.bundle.patch`，自动把本包加入 profile 的 bundle 列表。安装、删除或更新 bundle 后需要重启该 profile。可在启动前检查组合结果：\n\n```bash\ndsh --profile web --dump-config\n```\n\n## 配置\n\n安装即启用。默认配置位于 `cordis.patch.yml`：\n\n```yaml\n- insert:\n    - id: sift\n      name: '@agent-context/dsh-sift'\n      config:\n        enabled: true\n        minLength: 200\n        excludedTools: []\n        showSavings: command\n```\n\n在 `$DSH_HOME/profiles/<profile>/cordis.patch.yml` 中用同一个 `id: sift` 覆盖整行即可修改配置。dsh 的 patch 会替换整段 `config`，因此请重写所有需要保留的字段。\n\n| 字段 | 默认值 | 说明 |\n| --- | --- | --- |\n| `enabled` | `true` | 是否启用压缩与取回工具 |\n| `minLength` | `200` | 尝试压缩的最小 UTF-8 字节数；Sift 核心仍会透传不值得压缩的短内容 |\n| `excludedTools` | `[]` | 跳过的工具名；`sift_retrieve` 始终自动排除 |\n| `showSavings` | `command` | `command`、`log`、`both` 或 `off` |\n\n`showSavings: command` 注册 `/sift`，返回当前会话以及当前 dsh 进程累计节省的 token。`log` 会在每次成功压缩时写一条日志；`both` 同时启用两者。\n\n## 生命周期与兼容性\n\n- **tool / middleware**：`tools/post-execute` 是压缩入口；监听器先调用 `next()`，因此会压缩下游插件最终接受的纯文本投影，并保留其附加上下文。\n- **tool**：`ctx.tools.register()` 注册 `sift_retrieve`。\n- **session / context**：会话由 `exec.agent.session.id` 隔离；原文位于 `${DSH_HOME:-~/.dsh}/sift/<sessionId>/`，目录权限为 `0700`，文件 TTL 为 30 分钟。\n- **message**：插件不改写历史消息，也不注入额外模型消息；只替换新工具结果的 `content`。\n- **PTC**：跳过 `run_code` 的内部子调用（`exec.parent`），因为其值只供程序使用；顶层模型可见结果仍可压缩。\n- **混合内容与失败**：包含图片等非文本 block、失败结果、已含 stash marker、排除工具及无实际收益的内容均原样保留。\n\n## TUI 展示限制\n\nDeepSeek Harness 核心把 UI 作为插件，但目前没有像 OpenCode `tui.tsx` 的跨 TUI 状态栏或 slot API。官方仓库的 UI 扩展点是事件流，以及 Web Client 的 `ConversationNodeDefinition`；第三方 TUI 各自拥有渲染层，不能由普通 Host 插件可靠注入状态栏。\n\n因此本插件采用宿主无关的最近替代方案：在 profile 提供 command registry 时注册标准 `/sift` 命令，Web/TUI 客户端可直接展示；没有 command registry 的 headless 组合仍可压缩，需要自动提示时使用 `showSavings: log` 或 `both`。统计保存在当前进程内，不写入会话日志，重启或恢复会话后从零开始；这样不会为了 UI 统计增加模型 token 或改变已发布的 session format。\n\n## 开发验证\n\n```bash\ncd dsh-sift-plugin\nnpm install\nnpm test\nnpm pack --dry-run\n```\n\n插件使用 dsh 原生结果变换接口，不修改 DeepSeek Harness 源码。DeepSeek Harness 仍处于 developer preview，若 `tools/post-execute`、命令注册或 bundle manifest 在后续版本变化，需要同步适配。\n","readmeFilename":"README.md"}