PraisonAI picks one of five paths based on what you type — and adding a new subcommand means it Just Works.Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
Quick Start
How It Works
| Component | Purpose | Route Decision |
|---|---|---|
main() | Entry router | Applies 5 rules in order |
_find_first_command() | Positional finder | Skips flags, finds command |
_get_typer_commands() | Auto-discovery | Cached command introspection |
| Typer | Subcommand handler | Registered commands only |
| Legacy | Fallback handler | Everything else |
Routing Rules
| # | What you type | Route | Notes |
|---|---|---|---|
| 1 | praisonai --version / praisonai -V | Version short-circuit | Prints version and returns. Does not import praisonai.cli.* — stays fast even with broken optional deps. Pinned by TestVersionShortCircuit. |
| 2 | praisonai --help / praisonai -h | Typer | Typer’s auto-generated help lists every registered subcommand (auto-discovered, no manual list). |
| 3 | praisonai (no argv) | Typer | Drops into Typer’s interactive TUI. |
| 4 | praisonai --verbose / praisonai -o json (only flags) | Typer | _find_first_command returns None → Typer handles global-flag-only cases. |
| 5 | praisonai chat ... (first positional ∈ registered commands) | Typer | Auto-discovered via Click introspection of app. Adding a new subcommand to cli/app.py makes it routable here with zero dispatcher changes. |
| 6 | praisonai "Build a weather agent" (free-text — token contains a space) | Legacy PraisonAI().main() | Free-text prompts always fall through to legacy. |
| 7 | praisonai agents.yaml (filename, not a registered command) | Legacy PraisonAI().main() | Routing decision is by command-set membership, NOT by os.path.isfile(). A typo’d YAML path also routes to legacy and surfaces there. |
| 8 | praisonai totally-unknown (unknown positional) | Legacy PraisonAI().main() | Same as row 7 — anything not in the discovered command set falls through. |
Auto-Discovery
Commands registered inpraisonai/cli/app.py become routable automatically through Click introspection.
Adding a new subcommand? Register it in
praisonai/cli/app.py (e.g. app.add_typer(my_app, name="mycmd")) and the dispatcher picks it up automatically — praisonai mycmd ... routes to Typer with no changes to __main__.py. The command set is discovered once via click.Context.list_commands() and cached behind a thread-safe lock._get_typer_commands()) works by:
- Importing the Typer app and calling
register_commands() - Using Click’s introspection to list all registered commands
- Caching the result in
_typer_commands_cachewith thread safety - Returning an empty set on failure (cache not poisoned for retry)
Common Patterns
Bare Prompt
YAML File
Subcommand with Global Flags
Best Practices
Why --version is fast
Why --version is fast
The
--version flag takes a fast path that prints version information without importing any praisonai.cli.* modules. This keeps the command responsive even if optional dependencies are broken or missing. The version check happens before any heavy imports or command discovery.Adding a new subcommand
Adding a new subcommand
To add a new subcommand, simply register it in
praisonai/cli/app.py using app.add_typer(). The dispatcher automatically discovers it through Click introspection with no manual updates needed to routing logic. The command becomes available immediately after registration.Free-text prompts vs. typo'd command names
Free-text prompts vs. typo'd command names
When you mistype a command name, it routes to legacy mode instead of showing a Typer “command not found” error. This design choice ensures that typo’d commands behave like free-text prompts, maintaining backward compatibility while still allowing auto-discovery of new commands.
Failure visibility
Failure visibility
Registration errors from
register_commands() propagate directly to the user — the dispatcher does not swallow them. If an optional dependency is missing or a command fails to register, you see the real error instead of silent fallback behavior. This fail-loud approach aids debugging.Related
CLI Reference
Complete command reference
CLI Commands
Basic CLI usage guide
Gateway
Multi-bot WebSocket gateway
Version
Version management

