@@ -35,6 +35,15 @@ rewrite_paths() {
3535 -e ' s@(/?)hooks/@.specify/hooks/@g'
3636}
3737
38+ get_hook_extension () {
39+ local script_variant=$1
40+ if [[ " $script_variant " == " ps" ]]; then
41+ echo " .ps1"
42+ else
43+ echo " "
44+ fi
45+ }
46+
3847generate_commands () {
3948 local agent=$1 ext=$2 arg_format=$3 output_dir=$4 script_variant=$5
4049 mkdir -p " $output_dir "
@@ -55,11 +64,8 @@ generate_commands() {
5564 script_command=" (Missing script command for $script_variant )"
5665 fi
5766
58- # Replace {SCRIPT} placeholder with the script command and {EXT} with extension
59- local ext=" "
60- if [[ " $script_variant " == " ps" ]]; then
61- ext=" .ps1"
62- fi
67+ # Replace {SCRIPT} placeholder with the script command and {HOOK_EXT} with extension
68+ local ext=$( get_hook_extension " $script_variant " )
6369 body=$( printf ' %s\n' " $file_content " | sed " s|{SCRIPT}|${script_command} |g" | sed " s|{HOOK_EXT}|${ext} |g" )
6470
6571 # Remove the scripts: section from frontmatter while preserving YAML structure
@@ -143,11 +149,8 @@ build_variant() {
143149 if [[ -n $script_command ]]; then
144150 # Always prefix with .specify/ for plan usage
145151 script_command=" .specify/$script_command "
146- # Replace {SCRIPT} placeholder with the script command, {EXT} with extension, and __AGENT__ with agent name
147- local ext=" "
148- if [[ " $script " == " ps" ]]; then
149- ext=" .ps1"
150- fi
152+ # Replace {SCRIPT} placeholder with the script command, {HOOK_EXT} with extension, and __AGENT__ with agent name
153+ local ext=$( get_hook_extension " $script " )
151154 substituted=$( sed " s|{SCRIPT}|${script_command} |g" " $plan_tpl " | tr -d ' \r' | sed " s|__AGENT__|${agent} |g" | sed " s|{HOOK_EXT}|${ext} |g" )
152155 # Strip YAML frontmatter from plan template output (keep body only)
153156 stripped=$( printf ' %s\n' " $substituted " | awk ' BEGIN{fm=0;dash=0} /^---$/ {dash++; if(dash==1){fm=1; next} else if(dash==2){fm=0; next}} {if(!fm) print}' )
0 commit comments