opencode-skill-deduper
v0.1.4
Published
OpenCode plugin that elides older duplicate skill content before model requests
Maintainers
Readme
OpenCode Skill Deduper
Latest in v0.1.4 | v0.1.4 最近更新
- Atomically records notified elisions so the same skill block is only logged and toasted once across plugin reloads or concurrent plugin instances | 原子记录已提示的压缩记录,插件重载或并发插件实例下同一个 skill 块也只记录和提示一次
- Keeps file logs and TUI notifier quiet unless a newly elided skill part appears | 只有出现新的已压缩 skill 片段时才写文件日志并显示 TUI notifier
- Continues avoiding terminal/stdout output from
console.*,client.app.log, and session-message paths | 继续避免console.*、client.app.log和 session 消息路径产生终端/stdout 输出
中文
在 OpenCode 中自动压缩重复加载的 skill 正文。同一个 skill 多次进入上下文时,插件会在发送模型请求前保留最新完整副本,并把更早的重复副本替换成短提示,减少长会话里的上下文浪费。
它只作用于 OpenCode 的 experimental.chat.messages.transform 请求转换阶段:不会改写本地 session 历史,也不会删除最新的 skill 指令。
功能一览
- 保留最新副本 — 每个 skill 只保留最新一次完整内容
- 压缩旧副本 — 旧的重复 skill 正文会被替换成短占位文本
- 兼容原生 OpenCode — 支持
<skill_content name="...">形式的 skill 输出 - 兼容 OmO / Oh My OpenCode — 支持
## Skill: ...形式的 skill 输出 - 兼容 slash 注入 — 当
<skill-instruction>内容中包含 skill 路径时,也能识别对应 skill 名 - 可观察记录 — 真的压缩内容时写入文件日志并通过 TUI notifier 显示摘要;不会写入 stdout、不会调用 OpenCode app log,也不会追加 session 消息
安装
选项 A:让 LLM 帮你安装
把下面这段话丢给任意 LLM(OpenCode / Claude Code / Cursor 等):
请先查看 opencode-skill-deduper 最新 GitHub Release 正文里的“升级方式”,然后严格执行其中带明确版本号的安装/升级命令。默认应使用带 `-g/--global` 的全局命令来更新你平时实际在用的 OpenCode 实例;只有你明确想改当前项目目录下的 `.opencode` 时,才省略 `-g`。不要手动编辑 OpenCode 配置,也不要使用裸包名或 latest。参考说明:https://github.com/jiwangyihao/opencode-skill-deduper/releases/latest选项 B:手动安装
先查看最新 GitHub Release 的
## 升级方式小节。执行其中带明确版本号的全局命令。例如当前版本是:
opencode plugin [email protected] --force -g如果你是刻意只想改当前项目目录下的
.opencode,才使用不带-g的局部命令;否则默认不要省略-g。如果升级后看起来仍然没有变化,先清理 OpenCode 插件缓存,再重新执行同一条带版本号命令。
rm -rf ~/.cache/opencode/packages/opencode-skill-deduper@*如果 OpenCode 已在运行,重启后再验证。
步骤指引
先读取本仓库最新 GitHub Release 正文,提取其中
## 升级方式给出的带明确版本号命令。直接执行那条命令。默认应使用带
-g/--global的全局命令来更新用户平时实际在用的 OpenCode 实例;如果用户明确只想改当前项目目录下的.opencode,才省略-g。例如当前版本:opencode plugin [email protected] --force -g不要手动编辑 OpenCode 配置来安装或升级这个插件,也不要使用裸包名或
latest。如果执行后版本看起来仍然没更新,先清理 OpenCode 插件缓存,再重新执行同一条带版本号命令:
rm -rf ~/.cache/opencode/packages/opencode-skill-deduper@*如果 OpenCode 已在运行,重启后再验证。
验证
加载同一个长 skill 两次后,文件日志中应出现类似记录:
~/.config/opencode/logs/skill-deduper/daily/YYYY-MM-DD.log2026-05-05T00:00:00.000Z INFO skill-deduper: elided duplicate skill content | {"elided":1,"savedChars":4099,"skills":[{"name":"using-superpowers","elided":1,"savedChars":4099}]}同时,TUI notifier 会显示一条不进入 session 消息历史的通知,文本类似:
[skill-deduper] Elided duplicate skill content before this request.
Elided blocks: 1
Saved characters: 4099
Skills:
- using-superpowers: 1 elided, 4099 chars saved说明:最新 OpenCode 当前不会总是主动刷新已缓存的 npm 插件。安装或升级时优先以最新 GitHub Release 正文里的
## 升级方式为准;默认应走带-g的全局命令,只有明确想改当前项目.opencode时才省略-g。
使用方式
安装后无需额外命令。插件会在 OpenCode 发起模型请求前检查消息内容:
Message 1: full using-superpowers skill content
Message 2: full using-superpowers skill content转换后:
Message 1: [skill-deduper] Skill using-superpowers was reloaded later; older copy elided (... chars).
Message 2: full using-superpowers skill content最新副本仍保持完整,所以模型仍能看到当前有效的 skill 指令。
适合谁使用
- 经常在同一个 OpenCode 会话里重复加载 Superpowers、OmO skills 或其他长 skill 的用户
- 经常使用 slash command、原生
skill工具或多代理工作流的用户 - 希望减少重复 skill 正文挤占上下文窗口的用户
注意事项
- 插件只识别以明确 skill 标记或 skill 路径开头的内容,不会压缩任意重复文本。
- 用户粘贴的对话转录或任务说明即使包含 slash command、
## Skill:等字样,也会按普通用户内容保留。 - 插件只影响发往模型的请求,不改写 OpenCode 存储的 session 历史。
- OpenCode 的
experimental.chat.messages.transformhook 仍是实验接口,后续 OpenCode 版本可能调整插件 API。
English
Automatically elide repeated skill bodies in OpenCode. When the same skill appears more than once in the request context, this plugin keeps the newest full copy and replaces older copies with a compact marker before the model request is sent.
It only runs in OpenCode's experimental.chat.messages.transform phase. It does not rewrite stored session history and does not remove the newest skill instructions.
What You Get
- Newest copy kept — each skill keeps its latest full body
- Older copies elided — repeated earlier skill bodies become compact placeholders
- Native OpenCode support — recognizes
<skill_content name="...">skill output - OmO / Oh My OpenCode support — recognizes
## Skill: ...skill output - Slash-injected support — recognizes
<skill-instruction>blocks when the skill path exposes the skill name - Observable records — writes elided duplicate counts and saved characters to a file log and shows a TUI notifier summary without using stdout, OpenCode app log, or appended session messages
Installation
Option A: Let an LLM do it
Paste this into any LLM agent (OpenCode, Claude Code, Cursor, etc.):
First read the latest GitHub Release for opencode-skill-deduper and execute the exact versioned install/upgrade command from its "Upgrade / 升级方式" section. By default, use the global command with `-g/--global` so you update the OpenCode instances you actually run; omit `-g` only if you intentionally want to change the current project's `.opencode`. Do not manually edit the OpenCode config, and do not use a bare package name or latest. Reference: https://github.com/jiwangyihao/opencode-skill-deduper/releases/latestOption B: Manual setup
Read the latest GitHub Release and look for the
## Upgradesection.Run the exact versioned global command from that section. For the current version, the command is:
opencode plugin [email protected] --force -gOnly omit
-gif you intentionally want to update the current project's.opencodeinstead of the global OpenCode config.If an upgrade still looks stale, clear the OpenCode plugin cache and rerun the same versioned command:
rm -rf ~/.cache/opencode/packages/opencode-skill-deduper@*If OpenCode is already running, restart it before verification.
Step-by-Step Instructions
Read the latest GitHub Release body for this repository and extract the exact versioned command from
## Upgrade / 升级方式.Execute that command directly. By default, use the global command with
-g/--global; only omit-gif you intentionally want to update the current project's.opencode. For the current version:opencode plugin [email protected] --force -gDo not install or upgrade this plugin by hand-editing the OpenCode config, and do not use a bare package name or
latest.If the installed version still does not change, clear the OpenCode plugin cache and rerun the same versioned command:
rm -rf ~/.cache/opencode/packages/opencode-skill-deduper@*If OpenCode is already running, restart it before verification.
Verification
After loading the same long skill twice, the file log should include a record similar to:
~/.config/opencode/logs/skill-deduper/daily/YYYY-MM-DD.log2026-05-05T00:00:00.000Z INFO skill-deduper: elided duplicate skill content | {"elided":1,"savedChars":4099,"skills":[{"name":"using-superpowers","elided":1,"savedChars":4099}]}The TUI notifier also shows a notification that does not enter session message history, similar to:
[skill-deduper] Elided duplicate skill content before this request.
Elided blocks: 1
Saved characters: 4099
Skills:
- using-superpowers: 1 elided, 4099 chars savedNote: Current OpenCode does not always refresh cached npm plugins automatically. Prefer the exact versioned command from the latest GitHub Release. By default, that command should include
-g; without-g, you are only changing the current project's.opencode.
Usage
No extra command is required after installation. The plugin checks outgoing OpenCode model requests:
Message 1: full using-superpowers skill content
Message 2: full using-superpowers skill contentAfter transform:
Message 1: [skill-deduper] Skill using-superpowers was reloaded later; older copy elided (... chars).
Message 2: full using-superpowers skill contentThe newest copy remains intact, so the model still receives the current skill instructions.
Who Should Use This
- Users who repeatedly load Superpowers, OmO skills, or other long skills in one OpenCode session
- Users who rely on slash commands, native
skillcalls, or multi-agent workflows - Users who want to reduce duplicated skill text in the request context
Notes
- The plugin only detects content that starts with recognizable skill markers or skill directory paths.
- It does not deduplicate arbitrary repeated prose.
- User-pasted transcripts or task prompts stay intact even when they mention slash commands,
## Skill:, or similar skill-looking text. - It only affects outgoing model requests, not stored OpenCode session history.
- OpenCode's
experimental.chat.messages.transformhook is experimental, so future OpenCode versions may change the plugin API.
License
MPL-2.0 License. See LICENSE for details.
