@@ -307,6 +307,67 @@ has_jq() {
307307 command -v jq > /dev/null 2>&1
308308}
309309
310+ get_invoke_separator () {
311+ local repo_root=" ${1:- $(get_repo_root)} "
312+ local integration_json=" $repo_root /.specify/integration.json"
313+ local separator=" ."
314+
315+ if [[ ! -f " $integration_json " ]]; then
316+ printf ' %s\n' " $separator "
317+ return 0
318+ fi
319+
320+ if command -v jq > /dev/null 2>&1 ; then
321+ if separator=$( jq -r ' (.default_integration // .integration // "") as $k | if $k == "" then "." else (.integration_settings[$k].invoke_separator // ".") end' " $integration_json " 2> /dev/null) ; then
322+ case " $separator " in
323+ " ." |" -" ) printf ' %s\n' " $separator " ; return 0 ;;
324+ esac
325+ fi
326+ fi
327+
328+ if command -v python3 > /dev/null 2>&1 ; then
329+ if separator=$( python3 - " $integration_json " << 'PY ' 2>/dev/null
330+ import json
331+ import sys
332+
333+ try:
334+ with open(sys.argv[1], encoding="utf-8") as fh:
335+ state = json.load(fh)
336+ key = state.get("default_integration") or state.get("integration") or ""
337+ settings = state.get("integration_settings")
338+ separator = "."
339+ if isinstance(key, str) and isinstance(settings, dict):
340+ entry = settings.get(key)
341+ if isinstance(entry, dict) and entry.get("invoke_separator") in {".", "-"}:
342+ separator = entry["invoke_separator"]
343+ print(separator)
344+ except Exception:
345+ print(".")
346+ PY
347+ ) ; then
348+ case " $separator " in
349+ " ." |" -" ) printf ' %s\n' " $separator " ; return 0 ;;
350+ esac
351+ fi
352+ fi
353+
354+ printf ' .\n'
355+ }
356+
357+ format_speckit_command () {
358+ local command_name=" $1 "
359+ local repo_root=" ${2:- $(get_repo_root)} "
360+ local separator
361+ separator=$( get_invoke_separator " $repo_root " )
362+
363+ command_name=" ${command_name#/ } "
364+ command_name=" ${command_name# speckit.} "
365+ command_name=" ${command_name# speckit-} "
366+ command_name=" ${command_name// ./ $separator } "
367+
368+ printf ' /speckit%s%s\n' " $separator " " $command_name "
369+ }
370+
310371# Escape a string for safe embedding in a JSON value (fallback when jq is unavailable).
311372# Handles backslash, double-quote, and JSON-required control character escapes (RFC 8259).
312373json_escape () {
@@ -642,4 +703,3 @@ except Exception:
642703 printf ' %s' " $content "
643704 return 0
644705}
645-
0 commit comments