def build_parser() -> argparse.ArgumentParser:
"""Build CLI argument parser."""
parser = argparse.ArgumentParser(prog="ztxexp", description="ztxexp command line tools")
subparsers = parser.add_subparsers(dest="command", required=True)
common_rw = argparse.ArgumentParser(add_help=False)
common_rw.add_argument(
"--project-root",
type=str,
default=None,
help="Target project root directory. Default: current working directory.",
)
common_rw.add_argument(
"--agents-file",
type=str,
default=None,
help="Explicit AGENTS file path. Relative paths are resolved from project root.",
)
common_rw.add_argument(
"--dry-run",
action="store_true",
help="Preview changes only and do not write files.",
)
init_parser = subparsers.add_parser(
"init-vibe",
parents=[common_rw],
help="Initialize or update ztxexp managed agent block.",
)
init_parser.add_argument(
"--profile",
choices=SUPPORTED_PROFILES,
default="webcoding",
help="Agent profile. Default: webcoding.",
)
init_parser.add_argument(
"--language",
choices=SUPPORTED_LANGUAGES,
default="bilingual",
help="Rendered block language. Default: bilingual.",
)
show_parser = subparsers.add_parser(
"show-vibe",
help="Show the managed agent block content.",
)
show_parser.add_argument(
"--profile",
choices=SUPPORTED_PROFILES,
default="webcoding",
help="Agent profile. Default: webcoding.",
)
show_parser.add_argument(
"--language",
choices=SUPPORTED_LANGUAGES,
default="bilingual",
help="Rendered block language. Default: bilingual.",
)
subparsers.add_parser(
"remove-vibe",
parents=[common_rw],
help="Remove ztxexp managed agent block from AGENTS file.",
)
skill_common = argparse.ArgumentParser(add_help=False)
skill_common.add_argument(
"--project-root",
type=str,
default=None,
help="Target project root directory. Default: current working directory.",
)
skill_common.add_argument(
"--target",
choices=SUPPORTED_SKILL_TARGETS,
default=None,
help="Skill install target: skills/codex/both.",
)
skill_common.add_argument(
"--dry-run",
action="store_true",
help="Preview changes only and do not write files.",
)
skill_common.add_argument(
"--force",
action="store_true",
help="Allow overwrite/remove unmanaged target directories.",
)
init_skill_parser = subparsers.add_parser(
"init-skill",
parents=[skill_common],
help="Install or update built-in ztx-exp-manager skill in target project.",
)
init_skill_parser.add_argument(
"--language",
choices=SUPPORTED_SKILL_LANGUAGES,
default="bilingual",
help="Skill markdown language. Default: bilingual.",
)
init_skill_parser.add_argument(
"--no-interactive",
action="store_true",
help="Disable interactive target selection and fall back to default target.",
)
show_skill_parser = subparsers.add_parser(
"show-skill",
help="Show built-in ztx-exp-manager skill content.",
)
show_skill_parser.add_argument(
"--language",
choices=SUPPORTED_SKILL_LANGUAGES,
default="bilingual",
help="Skill markdown language. Default: bilingual.",
)
show_skill_parser.add_argument(
"--with-openai",
action="store_true",
help="Also print agents/openai.yaml preview.",
)
subparsers.add_parser(
"remove-skill",
parents=[skill_common],
help="Remove installed ztx-exp-manager skill from target project.",
)
init_template_parser = subparsers.add_parser(
"init-template",
help="Interactive command-line template wizard for experiment scaffold generation.",
)
init_template_parser.add_argument(
"--project-root",
type=str,
default=None,
help="Target project root directory. Default: current working directory.",
)
init_template_parser.add_argument(
"--name",
type=str,
default=None,
help="Experiment template name. If omitted, interactive mode asks for it.",
)
init_template_parser.add_argument(
"--output-dir",
type=str,
default=None,
help="Output root directory. Default: <project-root>/experiments.",
)
init_template_parser.add_argument(
"--dry-run",
action="store_true",
help="Preview generated scaffold without writing files.",
)
init_template_parser.add_argument(
"--no-interactive",
action="store_true",
help="Disable questionnaire prompts. Requires --name.",
)
init_template_parser.add_argument(
"--force",
action="store_true",
help="Allow overwrite when target template directory exists and is unmanaged.",
)
init_template_parser.add_argument(
"--yes",
action="store_true",
help="Use recommended defaults for all wizard questions.",
)
return parser