Skip to content

app

Full name: tenets.cli.app

app

Tenets CLI application.

Functions

distill_placeholder

Python
distill_placeholder(ctx: Context, prompt: str = typer.Argument(..., help='Query or task to build context for'))

Distill relevant context from codebase for AI prompts.

Source code in tenets/cli/app.py
Python
@app.command(name="distill")
def distill_placeholder(
    ctx: typer.Context,
    prompt: str = typer.Argument(..., help="Query or task to build context for"),
):
    """Distill relevant context from codebase for AI prompts."""
    # Import and run the real command
    from tenets.cli.commands.distill import distill

    # Remove the placeholder and register the real command
    app.registered_commands = [c for c in app.registered_commands if c.name != "distill"]
    app.command()(distill)
    # Re-invoke with the real command
    ctx.obj = ctx.obj or {}
    return ctx.invoke(distill, prompt=prompt)

instill_placeholder

Python
instill_placeholder(ctx: Context)

Apply tenets (guiding principles) to context.

Source code in tenets/cli/app.py
Python
@app.command(name="instill")
def instill_placeholder(ctx: typer.Context):
    """Apply tenets (guiding principles) to context."""
    # Import and run the real command
    from tenets.cli.commands.instill import instill

    # Remove the placeholder and register the real command
    app.registered_commands = [c for c in app.registered_commands if c.name != "instill"]
    app.command()(instill)
    # Re-invoke with the real command
    return ctx.invoke(instill)

version

Python
version(verbose: bool = typer.Option(False, '--verbose', '-v', help='Show detailed version info'))

Show version information.

Source code in tenets/cli/app.py
Python
@app.command()
def version(
    verbose: bool = typer.Option(False, "--verbose", "-v", help="Show detailed version info"),
):
    """Show version information."""
    if verbose:
        from tenets import __version__

        console.print(f"[bold]Tenets[/bold] v{__version__}")
        console.print("Context that feeds your prompts")
        console.print("\n[dim]Features:[/dim]")
        console.print("  • Intelligent context distillation")
        console.print("  • Guiding principles (tenets) system")
        console.print("  • Git-aware code analysis")
        console.print("  • Multi-factor relevance ranking")
        console.print("  • Token-optimized aggregation")
        console.print("\n[dim]Built by manic.agency[/dim]")
    else:
        from tenets import __version__

        print(f"tenets v{__version__}")

main_callback

Python
main_callback(ctx: Context, version: bool = typer.Option(False, '--version', help='Show version and exit'), verbose: bool = typer.Option(False, '--verbose', '-v', help='Enable verbose output'), quiet: bool = typer.Option(False, '--quiet', '-q', help='Suppress non-essential output'), silent: bool = typer.Option(False, '--silent', help='Only show errors'))

Tenets - Context that feeds your prompts.

Distill relevant context from your codebase and instill guiding principles to maintain consistency across AI interactions.

Source code in tenets/cli/app.py
Python
@app.callback(invoke_without_command=True)
def main_callback(
    ctx: typer.Context,
    version: bool = typer.Option(False, "--version", help="Show version and exit"),
    verbose: bool = typer.Option(False, "--verbose", "-v", help="Enable verbose output"),
    quiet: bool = typer.Option(False, "--quiet", "-q", help="Suppress non-essential output"),
    silent: bool = typer.Option(False, "--silent", help="Only show errors"),
):
    """
    Tenets - Context that feeds your prompts.

    Distill relevant context from your codebase and instill guiding principles
    to maintain consistency across AI interactions.
    """
    # Handle --version flag
    if version:
        from tenets import __version__

        print(f"tenets v{__version__}")
        raise typer.Exit()

    # If no command is specified and not version, show help
    if ctx.invoked_subcommand is None and not version:
        print(ctx.get_help())
        raise typer.Exit()

    # Store options in context for commands to access
    ctx.ensure_object(dict)
    ctx.obj["verbose"] = verbose
    ctx.obj["quiet"] = quiet or silent
    ctx.obj["silent"] = silent

    # Check git availability and warn if needed
    _check_git_availability(ctx)

    # Configure logging level
    import logging

    from tenets.utils.logger import get_logger

    # Configure both root logger and tenets logger
    if verbose:
        logging.basicConfig(level=logging.DEBUG)
        logging.getLogger("tenets").setLevel(logging.DEBUG)
        # Show debug output immediately
        logger = get_logger(__name__)
        logger.debug("Verbose mode enabled")
    elif quiet or silent:
        logging.basicConfig(level=logging.ERROR)
        logging.getLogger("tenets").setLevel(logging.ERROR)
    else:
        # Default to INFO for tenets, WARNING for others
        logging.basicConfig(level=logging.WARNING)
        logging.getLogger("tenets").setLevel(logging.INFO)

run

Python
run()

Run the CLI application.

Source code in tenets/cli/app.py
Python
def run():
    """Run the CLI application."""
    try:
        app()
    except KeyboardInterrupt:
        console.print("\n[yellow]Operation cancelled by user.[/yellow]")
        sys.exit(0)
    except Exception as e:
        console.print(f"\n[red]Error:[/red] {e!s}")
        if "--verbose" in sys.argv or "-v" in sys.argv:
            console.print_exception()
        sys.exit(1)