Skip to content

docs(hooks): add OpenCode hooks config tools design and clarify Runti… - #2332

Open
JohnLee1243 wants to merge 1 commit into
GCWing:mainfrom
JohnLee1243:lzh/hook-docs
Open

docs(hooks): add OpenCode hooks config tools design and clarify Runti…#2332
JohnLee1243 wants to merge 1 commit into
GCWing:mainfrom
JohnLee1243:lzh/hook-docs

Conversation

@JohnLee1243

Copy link
Copy Markdown

docs(hooks): add OpenCode hooks config tools design and clarify RuntimeHookRegistry wrapping

Summary

新增 docs/architecture/extensions/opencode-hooks-config-tools-design.md,作为 BitFun 接入 OpenCode 插件 Hooks / Config / Tool 的正式归档设计;同步在 docs/architecture/agent-runtime-services-design.md 标注 RuntimeHookRegistry 自身已是内部共享的可克隆句柄,AgentRuntime 不再外套 Arc

Fixes #

Type and Areas

Type: docs

Areas: docs (architecture / extensions)

Motivation / Impact

BitFun 已有 command Hook 与 builtin Hook,但缺少 OpenCode 插件 JavaScript function Hook 的接入路径,也没有将插件 config / tool 结果投影到 Agent、Permission、Tool、Skill 业务模块的端到端设计。本 PR 沉淀这一设计,作为后续实现、评审与兼容性演进的依据,统一以下核心决策:

  1. 统一 Hook Runtime 只有 Command / Builtin / Plugin 三种 Handler;Plugin 通过 host.hook.call 调用插件侧 JavaScript function。
  2. RuntimeHookRegistry 是注册事实的唯一 owner,由 AgentRuntime 长期持有。
  3. AgentHookEngine 不长期持有注册状态,每次 dispatch 基于 Registry clone 与一次不可变 snapshot 创建。
  4. Config / Tool / Agent / Permission / Skill 是统一 Hook Runtime 之后的业务投影或消费者,仍由既有业务模块拥有。

同步的 1 行注释修正了 AgentRuntimehooks 字段的包装语义,与上述第 2 条决策一致:RuntimeHookRegistry 本身已是共享可克隆句柄,无需再外套 Arc

No direct user-facing change — 本 PR 仅新增 / 调整设计文档,不改变任何运行时行为。

Verification

Docs-only change,按 AGENTS.md「Verification」第 3 条选择最轻量检查:

  • 提交前已 git diff --cached --stat 确认变更范围:2 个文件、+1122 / -1 行,无意外文件混入。
  • 新增文档内部引用路径 opencode-plugin-complete-compatibility-backlog.zh-CN.md 指向已存在的未跟踪同目录文档(属同一 hook-docs 工作流,将在后续 PR 跟进),未引入指向仓库外资源的链接。
  • 未触碰 Rust / TS / locale 资源,无需 pnpm run fmt:rsi18n:audittheme:color-audit:all 等运行时 / 契约检查。

Reviewer Notes

  • 新增设计文档为 1121 行,覆盖设计基线、待解决问题、统一 Hook Runtime、Config / Tool / Agent / Permission / Skill 投影、生命周期与兼容性演进;它是后续实现的 single source of truth,评审时建议重点看 §1(范围与核心决策)、§2(设计基线)、§3 起的 Runtime 边界。
  • agent-runtime-services-design.md 的修改为单行注释,与既有结构等价,不影响 AgentRuntime 的字段布局或语义合同。
  • 兼容性风险:无。本 PR 不引入持久化形状变化、不新增 Tauri 命令、不触及远端 / Peer / Dispatch 路径。
  • 回滚:直接 revert 该提交即可,无迁移、无副作用。

Checklist

  • This PR is focused and does not include secrets, temporary prompts, generated scratch files, or unrelated artifacts.
  • Relevant verification is recorded above, or skipped checks are explained.
  • User-facing strings, docs, and locales are updated where applicable.

@GCWing
GCWing requested a review from limityan August 17, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant