{"_id":"@agent-context/opencode-sift","_rev":"7-196bf0239a599e56708665e521ac102f","name":"@agent-context/opencode-sift","dist-tags":{"latest":"0.0.7"},"versions":{"0.0.1":{"name":"@agent-context/opencode-sift","version":"0.0.1","keywords":["opencode","opencode-plugin","sift","context-compression"],"license":"Apache-2.0","_id":"@agent-context/opencode-sift@0.0.1","maintainers":[{"name":"liangshuai","email":"509856256@qq.com"}],"dist":{"shasum":"cdb88885167f67cc341346cf5c772d4d57aa960d","tarball":"https://registry.npmjs.org/@agent-context/opencode-sift/-/opencode-sift-0.0.1.tgz","fileCount":13,"integrity":"sha512-tLeUKTdwFvj7HOnVIAHS7qKOA//gZOKtAuysyQ0uBMkt0ou2uFUhwnlSAHdNZNH8pEhoA6dgNdetGbnFbfguAA==","signatures":[{"sig":"MEUCIQCxTJxpgAMAfWJs7DRdGT6avs88seMLR6wxAsC+En1u6wIgJZ0Cb+ey9MuMJp8v3Rft8TkhbRMat4JuiIPts9tw1XE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":34510},"main":"./index.ts","type":"module","engines":{"opencode":">=1.18.26 <2"},"exports":{".":"./index.ts","./server":"./index.ts"},"gitHead":"ac87dcf68c96f2a922d6ffc15e7e5b88122bb84b","scripts":{"test":"node --test --experimental-strip-types test/*.test.ts"},"_npmUser":{"name":"liangshuai","email":"509856256@qq.com"},"_npmVersion":"11.19.0","description":"OpenCode plugin that compresses tool results with @agent-context/sift","directories":{},"_nodeVersion":"26.7.0","dependencies":{"@agent-context/sift":"0.0.1-alpha.7","@opencode-ai/plugin":"1.18.26"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"^22.15.0"},"_npmOperationalInternal":{"tmp":"tmp/opencode-sift_0.0.1_1788415954683_0.4954103256131184","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@agent-context/opencode-sift","version":"0.0.2","keywords":["opencode","opencode-plugin","sift","context-compression"],"license":"Apache-2.0","_id":"@agent-context/opencode-sift@0.0.2","maintainers":[{"name":"liangshuai","email":"509856256@qq.com"}],"dist":{"shasum":"0928e33da759b72759db8910657bd37de95b3ee0","tarball":"https://registry.npmjs.org/@agent-context/opencode-sift/-/opencode-sift-0.0.2.tgz","fileCount":13,"integrity":"sha512-woOwfxxD6j/X4EaAik2t1QbQo5DiHBCxMeTJxvttSb+uk42HL++3yHuidjj4aB6g9t98wYPfQMTyKbofeajNUw==","signatures":[{"sig":"MEUCIGjpQbFS9F9lVXxoXh2dshxOMR6anmnCRO5kdEYA8RyzAiEAxxMw3/HJ9B3k4pJFlTIF6iuc98nb9oycdrOdslyOuV0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":33252},"main":"./index.ts","type":"module","engines":{"opencode":">=1.18.26 <2"},"exports":{".":"./index.ts","./server":"./index.ts"},"gitHead":"f82b93145ade36bff689c8c51d516c968b614e19","scripts":{"test":"node --test --experimental-strip-types test/*.test.ts"},"_npmUser":{"name":"liangshuai","email":"509856256@qq.com"},"_npmVersion":"11.3.0","description":"OpenCode plugin that compresses tool results with @agent-context/sift","directories":{},"_nodeVersion":"24.0.2","dependencies":{"@agent-context/sift":"0.0.1","@opencode-ai/plugin":"1.18.26"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"^22.15.0"},"_npmOperationalInternal":{"tmp":"tmp/opencode-sift_0.0.2_1788701995172_0.2607432938109753","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@agent-context/opencode-sift","version":"0.0.3","keywords":["opencode","opencode-plugin","sift","context-compression"],"license":"Apache-2.0","_id":"@agent-context/opencode-sift@0.0.3","maintainers":[{"name":"liangshuai","email":"509856256@qq.com"}],"dist":{"shasum":"85ea5f3062e7b85a50df9ac4dc8ceadf3b389a14","tarball":"https://registry.npmjs.org/@agent-context/opencode-sift/-/opencode-sift-0.0.3.tgz","fileCount":15,"integrity":"sha512-s4wXF7xASkphga4XNoqBBK+isLQo7AfOx4nhBnlV9uRqwTVARqwuT03WeKhFZYaN5+xV58dSskTvsC0Swd7xuQ==","signatures":[{"sig":"MEYCIQDWLRYkYBveasHzI/3LoZhi1fAkQa+dYZ29R2y3wUwjHAIhAK8WLiDVHsj2h71kCYduuzencpTo5+NxGs0SNjgj1i65","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36313},"main":"./index.ts","type":"module","engines":{"opencode":">=1.18.26 <2"},"exports":{".":"./index.ts","./tui":"./tui.tsx","./server":"./index.ts"},"gitHead":"46f9f79ba3fc307ae2b9e1d398717365bbb631da","scripts":{"test":"node --test --experimental-strip-types test/*.test.ts"},"_npmUser":{"name":"liangshuai","email":"509856256@qq.com"},"_npmVersion":"11.19.0","description":"OpenCode plugin that compresses tool results with @agent-context/sift","directories":{},"_nodeVersion":"26.7.0","dependencies":{"@agent-context/sift":"0.0.1","@opencode-ai/plugin":"1.18.26"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"^22.15.0"},"peerDependencies":{"solid-js":">=1.9.0","@opentui/core":">=0.4.5","@opentui/solid":">=0.4.5"},"_npmOperationalInternal":{"tmp":"tmp/opencode-sift_0.0.3_1789117005723_0.24786418446630964","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@agent-context/opencode-sift","version":"0.0.4","keywords":["opencode","opencode-plugin","sift","context-compression"],"license":"Apache-2.0","_id":"@agent-context/opencode-sift@0.0.4","maintainers":[{"name":"liangshuai","email":"509856256@qq.com"}],"dist":{"shasum":"e6d53426447131e75532a9c299a03e63de991636","tarball":"https://registry.npmjs.org/@agent-context/opencode-sift/-/opencode-sift-0.0.4.tgz","fileCount":15,"integrity":"sha512-pw9TdlmvK3xPJsy2qQga+PPEDbMp5VKmDPtYGcyxUsEH45LZonNKN8yfBBe/Ys+Eot02iBZpELb3yVlPqBfNVw==","signatures":[{"sig":"MEUCIB3Lgu8pvH2PRaEjXc70NcwOuXICLzbAIvdBT9EZPHi0AiEAguTMYsqm+qJh1cjKLlDwE54kXDr/cZGQC/e4z0mJxjc=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38862},"main":"./index.ts","type":"module","engines":{"opencode":">=1.18.26 <2"},"exports":{".":"./index.ts","./tui":"./tui.tsx","./server":"./index.ts"},"gitHead":"9895cbb4899e29767fdcb0e1a6403b2b4f5217df","scripts":{"test":"node --test --experimental-strip-types test/*.test.ts"},"_npmUser":{"name":"liangshuai","email":"509856256@qq.com"},"_npmVersion":"11.19.0","description":"OpenCode plugin that compresses tool results with @agent-context/sift","directories":{},"_nodeVersion":"26.7.0","dependencies":{"@agent-context/sift":"0.0.1","@opencode-ai/plugin":"1.18.26"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"^22.15.0"},"peerDependencies":{"solid-js":">=1.9.0","@opentui/core":">=0.4.5","@opentui/solid":">=0.4.5"},"_npmOperationalInternal":{"tmp":"tmp/opencode-sift_0.0.4_1789119756788_0.7113220879968187","host":"s3://npm-registry-packages-npm-production"}},"0.0.5":{"name":"@agent-context/opencode-sift","version":"0.0.5","keywords":["opencode","opencode-plugin","sift","context-compression"],"license":"Apache-2.0","_id":"@agent-context/opencode-sift@0.0.5","maintainers":[{"name":"liangshuai","email":"509856256@qq.com"}],"dist":{"shasum":"4eead2e7637de56e5243f75b7b8055b980b843a7","tarball":"https://registry.npmjs.org/@agent-context/opencode-sift/-/opencode-sift-0.0.5.tgz","fileCount":15,"integrity":"sha512-BbYX1BbsUpSR/upFZJ2eaXI195XN9banxJLmZNunuPxWeGY3jlddEv4aZ1HvXcU+V1PWPBQVtOv4vxhdNME5SQ==","signatures":[{"sig":"MEUCIHRol5OXKi3owKQUBZti7mvN0KZcQMQo7a1QAKqeFT0eAiEAyoYosUilkhvl+9YbEXB/YbsQmC8SVYCXyZHlS3cNsvI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":39136},"main":"./index.ts","type":"module","engines":{"opencode":">=1.18.26 <2"},"exports":{".":"./index.ts","./tui":"./tui.tsx","./server":"./index.ts"},"gitHead":"e613b883382a4550613173ee88174ca077ae9c16","scripts":{"test":"node --test --experimental-strip-types test/*.test.ts"},"_npmUser":{"name":"liangshuai","email":"509856256@qq.com"},"_npmVersion":"11.19.0","description":"OpenCode plugin that compresses tool results with @agent-context/sift","directories":{},"_nodeVersion":"26.7.0","dependencies":{"@agent-context/sift":"0.0.1","@opencode-ai/plugin":"1.18.26"},"_hasShrinkwrap":false,"devDependencies":{"solid-js":"1.9.12","@types/node":"^22.15.0","@opentui/core":"0.4.5","@opentui/solid":"0.4.5"},"peerDependencies":{"solid-js":">=1.9.0","@opentui/core":">=0.4.5","@opentui/solid":">=0.4.5"},"peerDependenciesMeta":{"solid-js":{"optional":true},"@opentui/core":{"optional":true},"@opentui/solid":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/opencode-sift_0.0.5_1789121997626_0.39662295782768897","host":"s3://npm-registry-packages-npm-production"}},"0.0.6":{"name":"@agent-context/opencode-sift","version":"0.0.6","keywords":["opencode","opencode-plugin","sift","context-compression"],"license":"Apache-2.0","_id":"@agent-context/opencode-sift@0.0.6","maintainers":[{"name":"liangshuai","email":"509856256@qq.com"}],"dist":{"shasum":"d6faf4272a95121fca04e2791822c9a2d81b229e","tarball":"https://registry.npmjs.org/@agent-context/opencode-sift/-/opencode-sift-0.0.6.tgz","fileCount":15,"integrity":"sha512-EJ+4yoU3whyFqf7uDgOmQtgpFV93FAGG+kS0J/lf0y+hJFTz/+0Q/388Oz0ODl/Z5QsVuyflzH6W0khGF5TK8Q==","signatures":[{"sig":"MEUCIQC7vpnaVpWe7on1A7/3OgybrrNvb0H4sAYX7R6zRI7yyAIgMM5jGL/3cev/FzbKKtDaNbas4RnqCMR5x0Fj6QKtqMk=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38974},"main":"./index.ts","type":"module","engines":{"opencode":">=1.18.26 <2"},"exports":{".":"./index.ts","./tui":"./tui.tsx","./server":"./index.ts"},"gitHead":"e613b883382a4550613173ee88174ca077ae9c16","scripts":{"test":"node --test --experimental-strip-types test/*.test.ts"},"_npmUser":{"name":"liangshuai","email":"509856256@qq.com"},"_npmVersion":"11.3.0","description":"OpenCode plugin that compresses tool results with @agent-context/sift","directories":{},"_nodeVersion":"24.0.2","dependencies":{"solid-js":"1.9.12","@opentui/core":"0.4.5","@opentui/solid":"0.4.5","@agent-context/sift":"0.0.1","@opencode-ai/plugin":"1.18.26"},"_hasShrinkwrap":false,"devDependencies":{"@types/node":"^22.15.0"},"_npmOperationalInternal":{"tmp":"tmp/opencode-sift_0.0.6_1789186330390_0.7025292268941921","host":"s3://npm-registry-packages-npm-production"}},"0.0.7":{"name":"@agent-context/opencode-sift","version":"0.0.7","description":"OpenCode plugin that compresses tool results with @agent-context/sift","license":"Apache-2.0","type":"module","main":"./index.ts","exports":{".":"./index.ts","./server":"./index.ts","./tui":"./tui.tsx"},"keywords":["opencode","opencode-plugin","sift","context-compression"],"scripts":{"test":"node --test --experimental-strip-types test/*.test.ts"},"dependencies":{"@agent-context/sift":"0.0.1","@opencode-ai/plugin":"1.18.26","@opentui/core":"0.4.5","@opentui/solid":"0.4.5","solid-js":"1.9.12"},"devDependencies":{"@types/node":"^22.15.0"},"engines":{"opencode":">=1.18.26 <2"},"_id":"@agent-context/opencode-sift@0.0.7","gitHead":"e613b883382a4550613173ee88174ca077ae9c16","_nodeVersion":"24.0.2","_npmVersion":"11.3.0","dist":{"integrity":"sha512-qIzc0yXDJaMcM6fPXNsTa1E3LAyE0nIDtu2qaIyye2q6kF6cCjfj2JRVC1SggPyZRDF32pfDBq3IgJUuAKZdag==","shasum":"6749b1447256efb92f1b9b3d22e981acd45b90e9","tarball":"https://registry.npmjs.org/@agent-context/opencode-sift/-/opencode-sift-0.0.7.tgz","fileCount":15,"unpackedSize":39387,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIE1fIMB6XFYsLCheOvJyd4S6cKOoljGkDAggLlNJZJ1CAiAKFpH8nLF+plXQXr353XmDGZnBMVu7YFJEsbIMrPi62Q=="}]},"_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/opencode-sift_0.0.7_1789187016890_0.791638668913142"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-03T06:12:34.439Z","modified":"2026-09-12T04:23:37.185Z","0.0.1":"2026-09-03T06:12:34.842Z","0.0.2":"2026-09-06T13:39:55.294Z","0.0.3":"2026-09-11T08:56:45.844Z","0.0.4":"2026-09-11T09:42:36.901Z","0.0.5":"2026-09-11T10:19:57.790Z","0.0.6":"2026-09-12T04:12:10.523Z","0.0.7":"2026-09-12T04:23:37.022Z"},"license":"Apache-2.0","keywords":["opencode","opencode-plugin","sift","context-compression"],"description":"OpenCode plugin that compresses tool results with @agent-context/sift","maintainers":[{"name":"liangshuai","email":"509856256@qq.com"}],"readme":"# `@agent-context/opencode-sift`\n\nOpenCode **插件**：用 [`@agent-context/sift`](https://www.npmjs.com/package/@agent-context/sift) 自动压缩工具结果，并注册 `sift_retrieve` 供模型取回原文。TUI 会在右侧栏的 Context 下方显示累计节省的 token 数。\n\n本插件是社区项目，并非 OpenCode 或 Anomaly 官方项目，也未获得其官方背书。\n\n这不是检索、记忆或 MCP，也不会改写整包模型请求；它只处理工具输出。\n\n要求 OpenCode `>=1.18.26 <2`。\n\n## 安装\n\n推荐使用 CLI 安装，它会识别并注册包里的 server 和 TUI 两个入口：\n\n```bash\nopencode plugin @agent-context/opencode-sift\n```\n\n手动安装时，把 server 入口写入用户 / 全局 `~/.config/opencode/opencode.json`：\n\n```json\n{\n  \"$schema\": \"https://opencode.ai/config.json\",\n  \"plugin\": [\n    [\"@agent-context/opencode-sift\", { \"minLength\": 200 }]\n  ]\n}\n```\n\n并把 TUI 入口写入 `~/.config/opencode/tui.json`，这样右侧栏才会显示 token 统计：\n\n```json\n{\n  \"$schema\": \"https://opencode.ai/tui.json\",\n  \"plugin\": [\"@agent-context/opencode-sift\"]\n}\n```\n\n项目级 server 配置放在项目根 `opencode.json`，TUI 配置放在 `.opencode/tui.json`。CLI 命令的别名是 `opencode plug`。\n\n## 配置（plugin 元组 options）\n\n| 字段 | 类型 | 默认 |\n| --- | --- | --- |\n| `enabled` | boolean | `true` |\n| `minLength` | number | `200`（UTF-8 字节；非法值回退 200） |\n| `excludedTools` | string[] | 始终与 `sift_retrieve` 做并集 |\n\n`enabled: false` 后既不压缩，也不注册 `sift_retrieve`。\n\n## TUI token 统计\n\n包的 `./tui` entrypoint 会注册到可叠加的 `sidebar_content` slot，并排在内置 Context 与 MCP 区块之间。显示格式为 `Sift` / `1.2k tokens saved`。\n\n统计值来自当前会话及其 subagent 子会话已完成工具结果里的 `siftTokensSaved` metadata，因此会随工具结果实时更新，也能在重新打开会话时从历史消息恢复；未被 Sift 压缩的工具结果不会计入。\n\n## 压缩规则\n\n以下情况跳过压缩，原文原样保留：\n\n- 工具在排除列表中\n- 执行失败，或输出已被 OpenCode 截断\n- 文本短于 `minLength`\n- 文本已含合法 `<<stash:24-hex>>` 标记\n- 压缩没有收益\n\n## `sift_retrieve`\n\n参数为输出中的 `stashKey`，可以传入裸 key 或完整的 `<<stash:KEY>>` 标记。成功时返回原文，失败时返回原因和建议操作。内容按 OpenCode session 隔离，重启进程后仍可取回。\n\n非法 key（长度不对、非十六进制、路径穿越）会被直接拒绝。\n\nstash TTL（1800 秒）过期后，重跑原工具。不要对 retrieve 死循环。\n\n## Stash\n\n| | |\n| --- | --- |\n| 位置 | `{XDG_DATA_HOME or ~/.local/share}/opencode/sift/{sessionID}/` |\n| 隔离 | 按 OpenCode `sessionID` |\n| 权限 | `0700` |\n| 项目文件 | stash 不会写入当前项目目录 |\n| 清理 | TTL 1800 秒；过期内容在启动、会话删除和定期扫描时清理 |\n\n原文以**明文**落盘。把 stash 目录当作敏感数据。\n\nOpenCode 自身截断过的输出（如超长 bash 输出）不会被恢复：这类结果会直接跳过压缩，`sift_retrieve` 也无法还原已被 OpenCode 丢掉的内容。\n\n## 故障排查\n\n| 现象 | 检查 |\n| --- | --- |\n| 插件未加载 | 检查 `opencode.json` 语法与 OpenCode 版本（`>=1.18.26 <2`），然后重新安装插件 |\n| 右侧栏没有 Sift | 使用 `opencode plugin @agent-context/opencode-sift` 安装并重启 TUI；CLI 会同时注册 server 和 TUI 入口 |\n| Sift 始终显示 0 | 升级到 `>=0.0.7` 并重启 TUI；旧版的响应式文本在 OpenCode 插件运行环境中不会刷新 |\n| 找不到 sift 原生模块 | 重新安装插件，并确认包管理器允许安装适用于当前平台的 optional dependencies |\n| 没有压缩 | `minLength` 过大；执行失败或已被 OpenCode 截断；输出过短 |\n| 项目目录出现 `.sift` | stash 应位于 XDG data 目录；请检查 `XDG_DATA_HOME` 配置 |\n","readmeFilename":"README.md"}