Repository navigation
Feature: Add skill hot-reload / refresh mechanism (skills cached forever, no way to refresh without restart) #20010
Description
Problem / 问题
When running OpenCode in Web mode (opencode web), skills are loaded once on the first request and cached forever (ScopedCache with TTL: infinity). There is no way to refresh skills without restarting the entire OpenCode process.
在 Web 模式 (opencode web) 下,skills 仅在首次请求时加载一次,之后永久缓存(ScopedCache 的 TTL 设置为 infinity)。除了重启 OpenCode 进程外,没有任何方式可以刷新 skills。
Current Behavior / 当前行为
- Skills are loaded via
loadSkills()and stored inInstanceStatebacked byScopedCache - The cache key is
Instance.directory, with capacityInfinityand TTLinfinity - All sessions within the same directory share the same
Instance, so creating a new session does NOT reload skills - The only code path that triggers cache invalidation is
Instance.reload(), which is only called fromPOST /project/git/init
- Skills 通过
loadSkills()加载,存储在由ScopedCache支持的InstanceState中 - 缓存 key 是
Instance.directory,容量为Infinity,TTL 为infinity - 同一目录下所有 session 共享同一个
Instance,因此新建会话不会重新加载 skills - 唯一触发缓存失效的代码路径是
Instance.reload(),仅在POST /project/git/init路由中被调用
Expected Behavior / 期望行为
Users should be able to refresh skills without restarting OpenCode. This is especially important during skill development, where frequent iteration requires quick feedback loops.
用户应该能够在不重启 OpenCode 的情况下刷新 skills。这在 skill 开发过程中尤其重要,频繁迭代需要快速的反馈循环。
Proposed Solutions / 建议方案
Any of the following (or a combination) would solve this:
以下任一方案(或组合)均可解决此问题:
1. API endpoint for skill refresh / Skill 刷新 API
Add a dedicated endpoint (e.g., POST /skills/reload) that invalidates the skill cache and re-runs loadSkills().
添加一个专用的 API 端点(如 POST /skills/reload),用于使 skill 缓存失效并重新执行 loadSkills()。
2. File watcher on skill directories / 监听 skill 目录变化
Use fs.watch or a similar mechanism to watch skill directories (~/.claude/skills/, ~/.config/opencode/skills/, etc.) for changes, and automatically invalidate the cache when files are added/modified/removed.
使用 fs.watch 或类似机制监听 skill 目录(~/.claude/skills/、~/.config/opencode/skills/ 等)的变化,当文件被添加/修改/删除时自动使缓存失效。
3. Reasonable TTL / 合理的 TTL
Replace infinity TTL with a reasonable duration (e.g., 30 seconds or 1 minute), so skills are periodically re-scanned.
将 infinity TTL 替换为合理的时长(如 30 秒或 1 分钟),使 skills 能够被定期重新扫描。
Environment / 环境信息
- OpenCode version: 1.3.3
- Mode: Web (
opencode web) - OS: Linux (Ubuntu 20.04)
Related Code / 相关代码
Key locations in the bundled source (from decompiled binary analysis):
src/skill/index.ts—loadSkills()function,Skill.layerwithInstanceState.make()src/effect/instance-state.ts—ScopedCachewithinfinityTTLsrc/provider/instance.ts—Instance.provide(),Instance.reload(), instance cache by directory
Activity
github-actions commentedon Mar 30, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
[FEATURE]:Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
If you believe this was flagged incorrectly, please let a maintainer know.
hy-pony commentedon Mar 30, 2026
Closing as duplicate of #8751 and #19050. Will add our source code analysis there. Thanks for pointing this out!
关闭,因为与 #8751 和 #19050 重复。会在 #8751 补充我们的源码分析。感谢指出!