feat(runtime-hooks): #494 P6-lite builtin hooks 用户可配置体验闭环(builtin-only)#551
Merged
pionxe merged 5 commits into1024XEngineer:mainfrom May 5, 2026
Merged
feat(runtime-hooks): #494 P6-lite builtin hooks 用户可配置体验闭环(builtin-only)#551pionxe merged 5 commits into1024XEngineer:mainfrom
pionxe merged 5 commits into1024XEngineer:mainfrom
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
当前 runtime hooks 已具备 P0~P5 主干能力,但从“用户可配置体验”角度仍有两个现实问题:
本 PR 聚焦 #494 的 P6-lite 最低闭环:builtin-only、安全可解释、可配置、可测试、可观测。
价值(Why this matters)
1) 降低误配与误解成本
当用户尝试写
kind: command/http/prompt/agent时,系统现在会给出明确、统一、可操作的错误:这比泛化的 “not supported” 更能解释当前阶段边界,减少反复试错。
2) 提升“用户自定义规则”可用性
补齐了全局 user hooks 示例和端到端触发测试,用户可直接按文档配置并验证:
source=user3) 保持安全边界不退化
在不开放 external hooks 的前提下,继续确保:
UserAllowed限制用户故事(User Stories)
Story A:平台使用者(全局规则)
本 PR 提供:
runtime.hooks.items)user_prompt_submit触发后事件中source=user且 message 生效Story B:仓库维护者(项目规则)
本 PR保持并增强:
Story C:安全审阅者(阶段边界)
本 PR实现:
变更范围
代码变更
internal/config/runtime_hooks.gointernal/runtime/repo_hooks.gointernal/runtime/user_hooks.go测试补强
internal/config/runtime_hooks_test.gointernal/runtime/repo_hooks_test.gosource=repo断言。internal/runtime/user_hooks_test.gouser_prompt_submit + add_context_note,断言source=user和 message。文档与示例
docs/examples/hooks.yaml(repo hooks 示例)docs/examples/user-hooks-config.yaml(全局 user hooks 示例)docs/guides/configuration.mddocs/runtime-hooks-design.md使用案例
案例 1:全局 user hook(P6-lite 推荐)
在
~/.neocode/config.yaml中配置:add_context_note挂user_prompt_submitwarn_on_tool_call挂before_tool_call参考示例:
docs/examples/user-hooks-config.yaml案例 2:仓库 repo hook(需 trust)
在仓库中配置
<workspace>/.neocode/hooks.yaml,并在~/.neocode/trusted-workspaces.json中加入工作区。参考示例:
docs/examples/hooks.yaml案例 3:误配 external kind
若配置
kind: command(或 http/prompt/agent),会被明确拒绝,不会注册、不执行。兼容性与非目标
兼容性
before_completion_decision特殊编排语义。非目标(明确不做)
测试
已执行并通过:
重点验证:
source=user)风险与回滚
风险
回滚
关联
close #494