()
| 254 | |
| 255 | |
| 256 | def _build_parser() -> argparse.ArgumentParser: |
| 257 | parser = argparse.ArgumentParser( |
| 258 | prog="clawcodex", |
| 259 | description="ClawCodex - Claude Code Python Implementation", |
| 260 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 261 | epilog="""\ |
| 262 | Examples: |
| 263 | clawcodex --version Show version |
| 264 | clawcodex login Configure API keys |
| 265 | clawcodex config Show current configuration |
| 266 | clawcodex Start the interactive Ink TUI |
| 267 | clawcodex tui Start the interactive Ink TUI (explicit) |
| 268 | clawcodex -p "hello" Non-interactive mode (text output) |
| 269 | clawcodex -p "hi" --output-format json |
| 270 | clawcodex -p --output-format stream-json --input-format stream-json < input.ndjson |
| 271 | """, |
| 272 | ) |
| 273 | |
| 274 | parser.add_argument('prompt', nargs='?', help='Prompt to send in non-interactive mode') |
| 275 | parser.add_argument('--version', action='store_true', help='Show version information') |
| 276 | parser.add_argument('--config', action='store_true', help='Show current configuration') |
| 277 | |
| 278 | # ---- Interactive UI ---- |
| 279 | # |
| 280 | # The sole interactive UI is the TypeScript Ink TUI — ``clawcodex`` with no |
| 281 | # mode flags, or the explicit ``clawcodex tui`` subcommand. It spawns + owns |
| 282 | # a Python agent-server child (see :mod:`src.entrypoints.tui_launcher`). The |
| 283 | # former in-process Textual TUI (``--tui``) and Rich REPL (``--legacy-repl`` / |
| 284 | # ``--no-tui`` / ``--stream``) were removed in favor of this single client. |
| 285 | |
| 286 | # ---- Non-interactive / print mode (Phase 1 parity) ---- |
| 287 | noninteractive = parser.add_argument_group("non-interactive mode") |
| 288 | noninteractive.add_argument( |
| 289 | '-p', '--print', |
| 290 | action='store_true', |
| 291 | help='Print response and exit (useful for pipes)', |
| 292 | ) |
| 293 | noninteractive.add_argument( |
| 294 | '--output-format', |
| 295 | choices=('text', 'json', 'stream-json'), |
| 296 | default='text', |
| 297 | help='Output format for --print mode (default: text)', |
| 298 | ) |
| 299 | noninteractive.add_argument( |
| 300 | '--input-format', |
| 301 | choices=('text', 'stream-json'), |
| 302 | default='text', |
| 303 | help='Input format for --print mode (default: text)', |
| 304 | ) |
| 305 | noninteractive.add_argument( |
| 306 | '--include-partial-messages', |
| 307 | action='store_true', |
| 308 | help='Include incremental assistant text chunks in stream-json output', |
| 309 | ) |
| 310 | noninteractive.add_argument( |
| 311 | '--max-turns', |
| 312 | type=int, |
| 313 | default=20, |
no outgoing calls