#!/usr/bin/env node // Regression test for issue #19: on Windows the lifecycle hooks run via // PowerShell, which does NOT expand cmd.exe-style %VAR% — it needs $env:VAR. // The hook also has to point at a script that actually ships in hooks/. // This guards both failure modes: the original %CLAUDE_PLUGIN_ROOT% bug, and // the "switch to a .ps1 that doesn't exist" mistake. const test = require('node:test'); const assert = require('node:assert/strict'); const fs = require('fs'); const path = require('path'); const root = path.join(__dirname, '..'); const HOOKS_JSON = 'hooks/claude-codex-hooks.json'; const HOST_PLUGIN_MANIFESTS = [ '.claude-plugin/plugin.json', '.codex-plugin/plugin.json', ]; // cmd.exe variable syntax (%FOO%); PowerShell leaves it literal, breaking the path. const CMD_VAR_SYNTAX = /%[A-Za-z_][A-Za-z0-9_]*%/; // PowerShell 5.1 rejects these POSIX shell guards when a host runs `command`. const POSIX_GUARD_SYNTAX = /\bcommand\s+-v\b|&&|\|\||>\/dev\/null|2>&1/; // Pull the hooks/