From c4f6b345068f0baefaed98825de3505f6f4d4956 Mon Sep 17 00:00:00 2001 From: "Dongmin, Yu" Date: Sat, 12 Sep 2026 18:40:31 +0900 Subject: [PATCH] fix(hooks): quote plugin paths with spaces --- plugins/orchestration/hooks/hooks.json | 10 ++++----- plugins/warp/hooks/hooks.json | 10 ++++----- tests/test-hooks.sh | 29 +++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/plugins/orchestration/hooks/hooks.json b/plugins/orchestration/hooks/hooks.json index 165b7cf..57a9bbf 100644 --- a/plugins/orchestration/hooks/hooks.json +++ b/plugins/orchestration/hooks/hooks.json @@ -5,7 +5,7 @@ "hooks": [ { "type": "command", - "command": "${PLUGIN_ROOT}/scripts/on-session-start.sh" + "command": "\"${PLUGIN_ROOT}/scripts/on-session-start.sh\"" } ] } @@ -15,7 +15,7 @@ "hooks": [ { "type": "command", - "command": "${PLUGIN_ROOT}/scripts/drain-mailbox.sh UserPromptSubmit" + "command": "\"${PLUGIN_ROOT}/scripts/drain-mailbox.sh\" UserPromptSubmit" } ] } @@ -26,7 +26,7 @@ "hooks": [ { "type": "command", - "command": "${PLUGIN_ROOT}/scripts/drain-mailbox.sh PostToolUse" + "command": "\"${PLUGIN_ROOT}/scripts/drain-mailbox.sh\" PostToolUse" } ] } @@ -36,7 +36,7 @@ "hooks": [ { "type": "command", - "command": "${PLUGIN_ROOT}/scripts/on-stop.sh" + "command": "\"${PLUGIN_ROOT}/scripts/on-stop.sh\"" } ] } @@ -46,7 +46,7 @@ "hooks": [ { "type": "command", - "command": "${PLUGIN_ROOT}/scripts/on-session-end.sh" + "command": "\"${PLUGIN_ROOT}/scripts/on-session-end.sh\"" } ] } diff --git a/plugins/warp/hooks/hooks.json b/plugins/warp/hooks/hooks.json index ce26297..d0aa964 100644 --- a/plugins/warp/hooks/hooks.json +++ b/plugins/warp/hooks/hooks.json @@ -5,7 +5,7 @@ "hooks": [ { "type": "command", - "command": "${PLUGIN_ROOT}/scripts/on-session-start.sh" + "command": "\"${PLUGIN_ROOT}/scripts/on-session-start.sh\"" } ] } @@ -15,7 +15,7 @@ "hooks": [ { "type": "command", - "command": "${PLUGIN_ROOT}/scripts/on-stop.sh" + "command": "\"${PLUGIN_ROOT}/scripts/on-stop.sh\"" } ] } @@ -25,7 +25,7 @@ "hooks": [ { "type": "command", - "command": "${PLUGIN_ROOT}/scripts/on-permission-request.sh" + "command": "\"${PLUGIN_ROOT}/scripts/on-permission-request.sh\"" } ] } @@ -35,7 +35,7 @@ "hooks": [ { "type": "command", - "command": "${PLUGIN_ROOT}/scripts/on-prompt-submit.sh" + "command": "\"${PLUGIN_ROOT}/scripts/on-prompt-submit.sh\"" } ] } @@ -45,7 +45,7 @@ "hooks": [ { "type": "command", - "command": "${PLUGIN_ROOT}/scripts/on-post-tool-use.sh" + "command": "\"${PLUGIN_ROOT}/scripts/on-post-tool-use.sh\"" } ] } diff --git a/tests/test-hooks.sh b/tests/test-hooks.sh index e54738c..e99f110 100755 --- a/tests/test-hooks.sh +++ b/tests/test-hooks.sh @@ -231,9 +231,36 @@ assert_json_field "oz plugin name" "$(cat "$REPO_ROOT/plugins/orchestration/.cod assert_contains "warp hooks use PLUGIN_ROOT" "$(cat "$REPO_ROOT/plugins/warp/hooks/hooks.json")" '${PLUGIN_ROOT}/scripts/on-session-start.sh' assert_contains "warp hooks include prompt submit" "$(cat "$REPO_ROOT/plugins/warp/hooks/hooks.json")" '${PLUGIN_ROOT}/scripts/on-prompt-submit.sh' assert_contains "warp hooks include post tool use" "$(cat "$REPO_ROOT/plugins/warp/hooks/hooks.json")" '${PLUGIN_ROOT}/scripts/on-post-tool-use.sh' -assert_contains "oz hooks use PLUGIN_ROOT" "$(cat "$REPO_ROOT/plugins/orchestration/hooks/hooks.json")" '${PLUGIN_ROOT}/scripts/drain-mailbox.sh UserPromptSubmit' +assert_contains "oz hooks quote PLUGIN_ROOT" "$(cat "$REPO_ROOT/plugins/orchestration/hooks/hooks.json")" '\"${PLUGIN_ROOT}/scripts/drain-mailbox.sh\" UserPromptSubmit' assert_contains "oz hooks include session end" "$(cat "$REPO_ROOT/plugins/orchestration/hooks/hooks.json")" '${PLUGIN_ROOT}/scripts/on-session-end.sh' +echo "" +echo "=== plugin roots with spaces ===" +for plugin_name in warp orchestration; do + plugin_root="$TEST_TMP/$plugin_name plugin" + ln -s "$REPO_ROOT/plugins/$plugin_name" "$plugin_root" + + while IFS=$'\t' read -r event_name hook_command; do + command_output=$(printf '%s' "$HOOK_INPUT" | env \ + -u WARP_CLI_AGENT_PROTOCOL_VERSION \ + -u WARP_CLIENT_VERSION \ + -u OZ_PARENT_RUN_ID \ + PLUGIN_ROOT="$plugin_root" \ + sh -c "$hook_command" 2>&1) + command_exit=$? + assert_eq "$plugin_name $event_name resolves a plugin root containing spaces" "0" "$command_exit" + assert_eq "$plugin_name $event_name stays silent outside its host" "" "$command_output" + done < <(jq -r ' + .hooks + | to_entries[] + | .key as $event + | .value[] + | .hooks[] + | select(.type == "command") + | [$event, .command] + | @tsv + ' "$REPO_ROOT/plugins/$plugin_name/hooks/hooks.json") +done echo "" echo "=== Results: $PASSED passed, $FAILED failed ==="