Skip to content

v1.1.50:shell.env Hook、Skills 路径扩展、内存泄漏修复

发布日期:2026年02月04日


一句话总结

这次更新新增了 shell.env Hook 让插件可以注入环境变量,Skills 系统支持从 .agents/skills 目录读取,修复了 AbortController 内存泄漏,并大幅改进桌面端体验。


新功能:shell.env Hook

这次更新了什么?

新增 shell.env 插件钩子,可以在所有 shell 执行环境中注入自定义环境变量。

shell.env Hook 是什么?

这是一个插件事件钩子,让你可以通过插件向 AI 工具调用和用户终端注入环境变量。比如你可以注入 API Key、项目路径等信息,让 AI 在执行命令时自动获取这些变量。

如何使用?

在项目中创建插件文件:

js
// .opencode/plugins/inject-env.js
export const InjectEnvPlugin = async () => {
  return {
    "shell.env": async (input, output) => {
      output.env.MY_API_KEY = "secret"
      output.env.PROJECT_ROOT = input.cwd
    },
  }
}

注入的环境变量对 AI 工具执行和用户终端都生效。

👉 完整教程插件进阶


新功能:Skills 支持 .agents/skills 目录

这次更新了什么?

Skills 系统现在支持从 .agents/skills 目录读取 SKILL.md 文件,兼容更多 Agent 框架的目录结构。

有什么用?

如果你使用其他 Agent 框架(如 Claude Code),可以把 Skills 放在 .agents/skills/ 目录下,OpenCode 也能识别。

完整搜索路径

级别路径
项目级 OpenCode 原生.opencode/skills/<name>/SKILL.md
全局 OpenCode 原生~/.config/opencode/skills/<name>/SKILL.md
项目级 Claude 兼容.claude/skills/<name>/SKILL.md
全局 Claude 兼容~/.claude/skills/<name>/SKILL.md
项目级 Agent 兼容.agents/skills/<name>/SKILL.md
全局 Agent 兼容~/.agents/skills/<name>/SKILL.md

👉 完整教程Skill 基��


新功能:Agent 自定义主题色

这次更新了什么?

现在可以在自定义 Agent 时设置主题颜色,让不同 Agent 在界面上更容易区分。


问题修复:AbortController 内存泄漏

之前的问题

长时间使用 OpenCode 时,AbortController 的闭包会导致内存泄漏,占用越来越多内存。

现在的情况

修复了 AbortController 闭包的内存泄漏问题,长时间使用不再出现内存持续增长。


问题修复:插件重复安装

之前的问题

每次启动 OpenCode 时,插件都会被重新安装,即使已经安装过了。

现在的情况

插件安装状态正确缓存,不再重复安装。


改进:桌面端体验

会话标签恢复

重启桌面应用后,之前打开的会话标签页会自动恢复。

命令面板搜索

会话搜索功能移到了命令面板中,操作更统一。

空提示词提交

桌面端现在允许在有 review comments 时提交空提示词。

项目编辑图标

编辑项目对话框的图标现在在悬停时才显示,界面更简洁。


其他改进

  • TUI 新增 --thinking 标志,可在 run 命令中显示推理过程
  • TUI 剪贴板在 OSC52 失败后自动回退到原生剪贴板
  • CLI run 命令改为非交互模式
  • Gemini schema 验证支持嵌套数组和非对象类型
  • Cloudflare AI Gateway 改用官方 ai-gateway-provider 包
  • 排除 k2p5 模型的推理变体
  • Provider 配置的 headers 现在正确应用到 fetch 请求

要不要升级?

情况建议
遇到内存泄漏问题✅ 强烈推荐
使用插件系统✅ 推荐升级
桌面端用户✅ 推荐升级
用得好好的可以等下次

升级命令

bash
opencode upgrade

技术细节(可跳过)

点击展开完整更新列表

Core

  • Prevent memory leaks from AbortController closures (@MaxLeiter)
  • Revert addition of Trinity model system prompt support
  • Add Trinity model system prompt support (@mariamjabara)
  • Add shell.env hook for manipulating environment in tools and shell (@tylergannon)
  • Use official ai-gateway-provider package for Cloudflare AI Gateway (@elithrar)
  • Allow theme colors in agent customization (@IdrisGit)
  • Add support for reading skills from .agents/skills directories
  • Provider headers from config not applied to fetch requests (@cloudyan)
  • Ensure MCP tools are sanitized
  • Add .slnx to C#/F# LSP root detection (@workedbeforepush)
  • Improve skills system with better prompting, fix permission requests after skill invocation, and ensure agents can locate scripts and resources
  • Exclude k2p5 from reasoning variants (@neavo)
  • Handle nested array items for Gemini schema validation (@mugnimaestra)
  • Plugins are always reinstalled (@neriousy)
  • Strip properties and required fields from non-object types in Gemini schema (@ChickenBreast-ky)
  • Make CLI run command non-interactive

TUI

  • Add --thinking flag to show reasoning blocks in run command
  • Always fall back to native clipboard after OSC52 (@MartinWie)

Desktop

  • Faster end-to-end tests (@neriousy)
  • Update command palette placeholder text
  • Model selector truncating too soon
  • Improve spacing in application UI
  • Allow empty prompt with review comments in desktop (@dbpolito)
  • Fixed terminal serialization bug in app
  • Don't force mount tooltips in the app
  • Restore previously opened session tabs on app restart (@ProdigyRahul)
  • Edit project dialog icon now shows on hover (@ProdigyRahul)
  • Move session search to command palette
  • Fix custom providers overflow in app (@DNGriffin)

← 返回更新日志