Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix: set shell to bash on Qwen hooks so commands work on Windows

Cursor Agent38ea119f207e
diff --git a/cli/beacon/internal/endpoint/hooks/qwen.go b/cli/beacon/internal/endpoint/hooks/qwen.go
index ff02d541..a690b695 100644
--- a/cli/beacon/internal/endpoint/hooks/qwen.go
+++ b/cli/beacon/internal/endpoint/hooks/qwen.go
@@ -105,17 +105,22 @@ func qwenStatusFromRuntime(status runtimeStatus) QwenStatus {
// text Beacon does not otherwise retain would cost more than it tells anyone.
func installQwenSettings(path, binaryPath, logPath, configPath string) error {
prefix := endpointCommandPrefix("qwen", binaryPath, logPath, configPath)
+ // Shell is set to "bash" on every hook. The commands use POSIX single-quote quoting
+ // (via hookCommandQuote), which is correct for bash but invalid in cmd.exe and PowerShell.
+ // Unlike Claude Code, which always runs hooks through Git Bash even on Windows, Qwen Code
+ // selects cmd/PowerShell by default and only uses bash when the hook config says so.
+ const shell = "bash"
endpointHooks := map[string]settingsHookGroup{
- "SessionStart": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " session-start"}}},
- "UserPromptSubmit": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " prompt-submit", Timeout: qwenPromptSubmitTimeoutMS}}},
- "PreToolUse": {Matcher: qwenAllToolsMatcher, Hooks: []settingsHookRef{{Type: "command", Command: prefix + " pre-tool", Timeout: qwenToolTimeoutMS}}},
- "PostToolUse": {Matcher: qwenAllToolsMatcher, Hooks: []settingsHookRef{{Type: "command", Command: prefix + " post-tool", Timeout: qwenToolTimeoutMS}}},
- "PostToolUseFailure": {Matcher: qwenAllToolsMatcher, Hooks: []settingsHookRef{{Type: "command", Command: prefix + " post-tool", Timeout: qwenToolTimeoutMS}}},
- "PermissionRequest": {Matcher: qwenAllToolsMatcher, Hooks: []settingsHookRef{{Type: "command", Command: prefix + " permission-request", Timeout: qwenToolTimeoutMS}}},
- "Stop": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " stop", Timeout: qwenStopTimeoutMS}}},
- "SubagentStart": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " subagent-start"}}},
- "SubagentStop": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " subagent-stop"}}},
- "SessionEnd": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " session-end"}}},
+ "SessionStart": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " session-start", Shell: shell}}},
+ "UserPromptSubmit": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " prompt-submit", Timeout: qwenPromptSubmitTimeoutMS, Shell: shell}}},
+ "PreToolUse": {Matcher: qwenAllToolsMatcher, Hooks: []settingsHookRef{{Type: "command", Command: prefix + " pre-tool", Timeout: qwenToolTimeoutMS, Shell: shell}}},
+ "PostToolUse": {Matcher: qwenAllToolsMatcher, Hooks: []settingsHookRef{{Type: "command", Command: prefix + " post-tool", Timeout: qwenToolTimeoutMS, Shell: shell}}},
+ "PostToolUseFailure": {Matcher: qwenAllToolsMatcher, Hooks: []settingsHookRef{{Type: "command", Command: prefix + " post-tool", Timeout: qwenToolTimeoutMS, Shell: shell}}},
+ "PermissionRequest": {Matcher: qwenAllToolsMatcher, Hooks: []settingsHookRef{{Type: "command", Command: prefix + " permission-request", Timeout: qwenToolTimeoutMS, Shell: shell}}},
+ "Stop": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " stop", Timeout: qwenStopTimeoutMS, Shell: shell}}},
+ "SubagentStart": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " subagent-start", Shell: shell}}},
+ "SubagentStop": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " subagent-stop", Shell: shell}}},
+ "SessionEnd": {Hooks: []settingsHookRef{{Type: "command", Command: prefix + " session-end", Shell: shell}}},
}
return installSettingsEndpointHooks(path, "qwen", endpointHooks)
}
diff --git a/cli/beacon/internal/endpoint/hooks/qwen_test.go b/cli/beacon/internal/endpoint/hooks/qwen_test.go
index c75f5acf..a6aa5d2e 100644
--- a/cli/beacon/internal/endpoint/hooks/qwen_test.go
+++ b/cli/beacon/internal/endpoint/hooks/qwen_test.go
@@ -19,6 +19,7 @@ func decodeQwenHooks(t *testing.T, path string) map[string][]struct {
Type string `json:"type"`
Command string `json:"command"`
Timeout int `json:"timeout"`
+ Shell string `json:"shell"`
} `json:"hooks"`
} {
t.Helper()
@@ -33,6 +34,7 @@ func decodeQwenHooks(t *testing.T, path string) map[string][]struct {
Type string `json:"type"`
Command string `json:"command"`
Timeout int `json:"timeout"`
+ Shell string `json:"shell"`
} `json:"hooks"`
} `json:"hooks"`
}
@@ -95,6 +97,27 @@ func TestQwenTimeoutsAreMillisecondsNotSeconds(t *testing.T) {
}
}
+// Qwen Code does not run hooks through Git Bash the way Claude Code does. On Windows it defaults to
+// cmd.exe or PowerShell, where the POSIX single-quote quoting in the command string is invalid. Every
+// hook must set shell to "bash" so Qwen uses a shell that understands the quoting.
+func TestQwenHooksSpecifyBashShell(t *testing.T) {
+ path := filepath.Join(t.TempDir(), "settings.json")
+ if err := installQwenSettings(path, "/tmp/beacon-hooks", "/tmp/runtime.jsonl", "/tmp/config.json"); err != nil {
+ t.Fatalf("installQwenSettings returned error: %v", err)
+ }
+
+ hooks := decodeQwenHooks(t, path)
+ for event, groups := range hooks {
+ if len(groups) == 0 || len(groups[0].Hooks) == 0 {
+ t.Fatalf("%s hook was not installed", event)
+ }
+ if got := groups[0].Hooks[0].Shell; got != "bash" {
+ t.Errorf("%s shell = %q, want \"bash\"; without it Qwen uses cmd/PowerShell on "+
+ "Windows where the single-quoted command is invalid", event, got)
+ }
+ }
+}
+
// Every Qwen hook event Beacon claims to collect has to actually be registered, wired to the right
// subcommand, and carry the --platform value the adapter branches on.
func TestInstallQwenRegistersEveryCollectedEvent(t *testing.T) {
diff --git a/cli/beacon/internal/endpoint/hooks/settings_hooks.go b/cli/beacon/internal/endpoint/hooks/settings_hooks.go
index 1b1062bb..d42b9793 100644
--- a/cli/beacon/internal/endpoint/hooks/settings_hooks.go
+++ b/cli/beacon/internal/endpoint/hooks/settings_hooks.go
@@ -15,6 +15,7 @@ type settingsHookRef struct {
Type string `json:"type,omitempty"`
Command string `json:"command"`
Timeout int `json:"timeout,omitempty"`
+ Shell string `json:"shell,omitempty"`
ShowOutput *bool `json:"show_output,omitempty"`
}