Strip parent-name prefix and deduplicate subcommand names. LLMs sometimes return ``["git-add", "git-commit"]`` instead of ``["add", "commit"]``. This strips the ``{basename}-`` prefix when present and deduplicates while preserving order.
(basename: str, raw: list[str])
| 13 | |
| 14 | |
| 15 | def normalize_subcommands(basename: str, raw: list[str]) -> list[str]: |
| 16 | """Strip parent-name prefix and deduplicate subcommand names. |
| 17 | |
| 18 | LLMs sometimes return ``["git-add", "git-commit"]`` instead of |
| 19 | ``["add", "commit"]``. This strips the ``{basename}-`` prefix when |
| 20 | present and deduplicates while preserving order. |
| 21 | """ |
| 22 | prefix = f"{basename}-" |
| 23 | stripped = [s[len(prefix) :] if s.startswith(prefix) else s for s in raw] |
| 24 | return list(dict.fromkeys(stripped)) |
| 25 | |
| 26 | |
| 27 | def fix_invalid_escapes(s: str) -> str: |
no outgoing calls