Skip to main content

Command-line interface for the Codicent API

Project description

Codicent CLI

Codicent CLI is a command-line interface for interacting with the Codicent API. It provides both one-shot command execution and interactive chat sessions with comprehensive error handling and user-friendly features.

Features

  • One-shot mode: Execute single commands and get responses
  • Interactive mode: Continuous chat sessions with conversation tracking
  • Message types: Support for regular chat and @-prefixed info messages
  • Input flexibility: Command arguments, stdin pipes, or interactive prompts
  • Rich output: Markdown-formatted responses with beautiful terminal UI
  • Error handling: Comprehensive error messages and graceful failure handling
  • Logging: Configurable logging levels for debugging

Installation

Prerequisites

  • Python 3.6 or higher
  • pip (Python package installer)

Quick Installation

# Install from PyPI
pip install codicent-py codicent-cli

Development Installation

Steps

  1. Clone the repository:

    git clone https://github.com/izaxon/codicent-cli.git
    cd codicent-cli
    
  2. Install in development mode:

    pip install -e .
    

Direct Installation from GitHub

You can also install directly from GitHub:

# Install the latest version
pip install git+https://github.com/izaxon/codicent-cli.git

# Install a specific version
pip install git+https://github.com/izaxon/codicent-cli.git@v0.4.6

Usage

Basic Setup

  1. Set the CODICENT_TOKEN environment variable with your Codicent API token:
    export CODICENT_TOKEN="YOUR_API_TOKEN"
    

Command Options

codicent [OPTIONS] [QUESTION]

OPTIONS:
  -t, --interactive    Start interactive chat mode
  -h, --help          Show help message
  -v, --version       Show version information
  --verbose           Enable verbose logging
  --quiet             Suppress non-essential output

Examples

One-shot questions:

codicent "What can you help me with?"
codicent "Explain Python decorators"

Interactive mode:

codicent -t
# or
codicent --interactive

Piped input:

echo "What is machine learning?" | codicent
codicent < questions.txt
cat code.py | codicent "Review this code"

Info messages (@ prefix):

codicent "@mention This is an info message"

With logging:

codicent --verbose "Debug this issue"
codicent --quiet "Silent operation"

Interactive Mode

In interactive mode, you can have ongoing conversations with enhanced visual clarity:

$ codicent -t
๐Ÿค– Codicent CLI Interactive Mode
Type your questions or use Ctrl+C to exit.
Prefix with @ for info messages.
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
ยค What is Python?

Python is a high-level, interpreted programming language known for its 
simplicity and readability. It was created by Guido van Rossum and first 
released in 1991.

Key features:
โ€ข Easy to learn and use
โ€ข Extensive standard library
โ€ข Cross-platform compatibility
โ€ข Strong community support
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
ยค Can you give me an example?

Here's a simple Python example:

# Hello World in Python
print("Hello, World!")

# Working with variables
name = "Alice"
age = 25
print(f"My name is {name} and I am {age} years old.")

Python's syntax is clean and intuitive!
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
ยค @mention Save this conversation
โœ… Message posted successfully.
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
ยค ^C
๐Ÿ‘‹ Goodbye!

Visual Features:

  • Colored messages: User input appears in cyan, bot responses in green
  • Clean prompting: Original ยค prompt character maintained
  • Visual separators: Clear lines between conversations
  • Rich formatting: Markdown responses with syntax highlighting
  • Status indicators: Animated thinking indicators and success messages
  • Emojis: Friendly visual cues throughout the interface

Error Handling

The CLI provides helpful error messages for common issues:

  • Missing token: Clear instructions on setting up CODICENT_TOKEN
  • Network errors: Graceful handling of connection issues
  • API errors: Detailed error messages from the Codicent API
  • Input validation: Prevents empty or overly long inputs
  • Keyboard interrupts: Clean exit handling

Development

Running Tests

python -m pytest test_app.py -v

Project Structure

  • app.py - Main application logic (single-file architecture)
  • test_app.py - Comprehensive test suite
  • setup.py - Package configuration
  • requirements.txt - Dependencies (now uses PyPI packages)

Dependencies

  • codicent-py: Core API client for Codicent services (now available on PyPI)
  • rich: Terminal formatting, markdown rendering, and animations

Troubleshooting

Common Issues

  1. "CODICENT_TOKEN environment variable is not set"

    • Set the token: export CODICENT_TOKEN="your_token"
    • Verify it's set: echo $CODICENT_TOKEN
  2. "Network error: Unable to connect to Codicent API"

    • Check your internet connection
    • Verify the Codicent API is accessible
    • Try again with --verbose for more details
  3. "Failed to initialize Codicent API client"

    • Verify your token is valid
    • Check if the codicent-py package is properly installed

Getting Help

  • Use codicent --help for usage information
  • Use codicent --verbose for detailed logging
  • Check the Codicent documentation for API details

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codicent_cli-0.4.6.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codicent_cli-0.4.6-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file codicent_cli-0.4.6.tar.gz.

File metadata

  • Download URL: codicent_cli-0.4.6.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for codicent_cli-0.4.6.tar.gz
Algorithm Hash digest
SHA256 99254f3547f24fe53f64b3f99704c688bf37e579d3c5a03ee52f07c596232ff7
MD5 2182df181f7049301402dde18c250cbc
BLAKE2b-256 6532820bd3b304aa7c7ac9336cf9af479bf962173b2311139dc13454b5a2ee9f

See more details on using hashes here.

File details

Details for the file codicent_cli-0.4.6-py3-none-any.whl.

File metadata

  • Download URL: codicent_cli-0.4.6-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for codicent_cli-0.4.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3c4eac16a8673d36567e8c4d3e0d867f6e9ed358c84632660bc9a5f8c6ed3d7b
MD5 ad7b5980e00da7e84ea7a2eaaebe4541
BLAKE2b-256 4dbff8de9d7393cfe7d98eca7b38a0dd921588e760bc4ae0a791e1524c5c09f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page