146
近 30 天 +5
1,725
近 7 天 802
61.7
生态多维模型
3 天前
2026-10-01
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-snip@2.0.0"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-snip@2.0.0"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D opencode-snipOpenCode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
OpenCode plugin that automatically prefixes shell commands with snip to reduce LLM token consumption by 60-90%.
What is snip?
snip is a CLI proxy that filters shell output before it reaches your LLM context window.
| Command | Before | After | Savings |
|---|---|---|---|
go test ./... |
689 tokens | 16 tokens | 97.7% |
git log |
371 tokens | 53 tokens | 85.7% |
cargo test |
591 tokens | 5 tokens | 99.2% |
Installation
1. Install snip
brew install edouard-claude/tap/snip
# or
go install github.com/edouard-claude/snip/cmd/snip@latest
2. Configure OpenCode
Add the plugin to your OpenCode config (~/.config/opencode/opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["opencode-snip@latest"]
}
How It Works
The plugin uses the tool.execute.before hook to forward each bash command to snip hook, the same rewrite engine snip uses for Claude Code and other agents (tested with snip v0.25.2):
- only commands snip has a filter for are rewritten to
snip run -- <command>, each segment of&&,||,;chains separately - commands whose output feeds a pipe or a file redirection, heredocs, shell blocks and command substitutions are left untouched
- if
snip hookfails, the command runs unchanged
Development
This package uses semantic-release for automated releases. Commit messages should follow the Conventional Commits format:
fix:→ patch releasefeat:→ minor releasefeat!:,fix!:→ major release
License
MIT
同类生态推荐
Smartsnip
opencode-smartsnip
Cuts shell-output tokens in opencode. Wraps only what snip can filter — everything else runs byte-identical.
Usage
@1930dev/opencode-usage
Usage tracking, budget percentages and model ranking for opencode — CLI plus a /usage TUI plugin
Auto Permissions
opencode-auto-permissions
Automatic, context-aware permission review for OpenCode