zai-org / zai-org/feedback

[建议 / Feature] PreToolUse hook 支持改写工具输入(以适配 rtk 等命令代理)

Open
#44 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

priority: P2 status: 待评估 type: 功能建议
Dominant language
No language data
Stars
22
Forks
1
PR merge metrics
No merged PRs in 30d

Description

提交前确认 · Pre-submission checklist
  • 我已搜索过现有 issue,确认这不是重复提议 / I searched existing issues and confirmed this isn't a duplicate.
  • 我已阅读 CONTRIBUTING.md / I've read CONTRIBUTING.md.
问题类别 · Category

工具调用 / MCP · Tool use / MCP

涉及的 Agent 框架 · Agent framework

ZCode Agent(自研)

使用场景 · Use case
痛点

希望能在 ZCode 里集成 rtkhttps://github.com/rtk-ai/rtk,一个 CLI 代理,
通过在命令执行前把 git status 这类命令改写为 rtk git status,把冗长输出压缩成
精简版,给 agent 省 60–90% 的 token)。RTK 已适配 Claude Code / Codex / Gemini CLI /
opencode 等 14 个工具,但无法适配 ZCode,原因是 ZCode 的 hook 能力缺了一块。

根本原因(已在 0.14.5 后端实测)

ZCode 的 PreToolUse hook 只支持"观察 + 追加上下文 + 放行/拦截",不支持"改写即将执行的工具输入"

PreToolUse hook 的输出 schema(zod)实测为:

{
  additionalContext: string,                          // 只能追加文本上下文
  permissionDecision: "allow" | "ask" | "deny",       // 只能放行/审批/拒绝
  permissionDecisionReason: string
}

### 建议方案 · Proposal

为 PreToolUse hook 的输出 schema 增加一个可选字段,允许 hook 返回改写后的工具输入, 例如(对齐 Claude Code 的做法):

```JS
{
  additionalContext: string,
  permissionDecision: "allow" | "ask" | "deny",
  hookSpecificOutput: {
    hookEventName: "PreToolUse",
    // 新增:允许 hook 改写即将执行的工具输入
    toolInput: { /* 改写后的、符合工具 schema 的输入 */ }
  }
}

或任何等价机制,只要 hook 能在命令真正执行前替换其内容即可。

预期价值 · Expected value

No response

你认为的优先级 · Your perceived priority

None

你使用的 ZCode 版本 / 环境 · ZCode version / environment

No response

补充材料 · Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the PreToolUse hook schema and the code path that executes tool calls; the issue provides the current fields and a proposed hookSpecificOutput.toolInput shape, but no repository files or tests. Determine how rewritten input would be validated and passed to execution, then add coverage showing a hook can replace command input before the tool runs.

Written by the indexing model from the issue text.

Assessment

Domain
cli, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.