feat(hooks): follow Qwen Code per-hook fields#2094
Merged
Conversation
…Message/headers/allowedEnvVars/once) Qwen Code PR #2827 added per-hook fields that rulesync's qwencode hooks adapter dropped on generation: command hooks gained async/env/shell/statusMessage and http hooks gained headers/allowedEnvVars/once (statusMessage applies to both). Add these fields to the canonical HookDefinitionSchema (following the existing precedent of url/failClosed/sequential being modeled as canonical per-hook fields) and emit/parse them in canonicalToQwencodeHooks and qwencodeMatcherEntryToCanonical. Command-only fields are emitted only on command hooks and http-only fields only on http hooks, matching upstream. Because copilotcli's hooks adapter passes through non-canonical keys by filtering out HookDefinitionSchema.shape, promoting env/headers/allowedEnvVars to canonical required copilotcli to emit those natively-supported fields explicitly; do so to keep its round-trip intact. Both project and global scope are covered (the converter is scope-agnostic). Adds round-trip tests for each field and updates the file-formats docs. Resolves #2069 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…pact helper Address PR review: gate command-only fields (async/env/shell) on the command hook type explicitly instead of not-http (so prompt/function hooks don't get them), apply safeString to env/headers values and shell to block control-character injection into generated env vars/HTTP headers, and extract the duplicated undefined/null-stripping helper into src/utils/object.ts (compact) used by both qwencode and copilotcli adapters. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
Follow-up for Qwen Code upstream updates (#2069). Qwen Code's HTTP/Function/Async hooks (QwenLM/qwen-code#2827) added per-hook fields that rulesync's qwencode adapter dropped on generation. This adds them to the canonical hook schema and round-trips them through the qwencode adapter, type-gated by hook type.
Changes
src/types/hooks.ts: addedasync,env,shell,statusMessage,headers,allowedEnvVars,onceto the canonicalHookDefinitionSchema(modeling approach: extend the canonical looseObject schema, matching how existing per-hook fields likeurl/timeout/sequentialare modeled;env/headers/allowedEnvVarsare also shared with Copilot CLI, not qwencode-only).src/features/hooks/qwencode-hooks.ts: emit (type-gated) incanonicalToQwencodeHooksand parse inqwencodeMatcherEntryToCanonical. Command-only fields (async/env/shell/statusMessage) never appear on http hooks and vice-versa for http-only fields (headers/allowedEnvVars/once);statusMessageapplies to both per the docs.src/features/hooks/copilotcli-hooks.ts: sinceenv/headers/allowedEnvVarsbecame canonical, copilotcli (which previously relied on non-canonical passthrough) now emits these natively-supported fields explicitly — no behavior regression.Tests & docs
docs/reference/file-formats.md(+ synced skill copy).Verification
pnpm cicheckfully green: 295 test files, 6601 tests; lint/typecheck, sync-skill-docs, gitignore, supported-tools, cspell, secretlint all pass.References
Closes #2069