codicent-cli


Namecodicent-cli JSON
Version 0.4.7 PyPI version JSON
download
home_pagehttps://github.com/izaxon/codicent-cli
SummaryCommand-line interface for the Codicent API
upload_time2025-08-08 08:49:48
maintainerNone
docs_urlNone
authorJohan Isaksson
requires_python>=3.6
licenseNone
keywords codicent cli api chat ai
VCS
bugtrack_url
requirements rich codicent-py prompt_toolkit requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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

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

### Development Installation

#### Steps

1. Clone the repository:
   ```bash
   git clone https://github.com/izaxon/codicent-cli.git
   cd codicent-cli
   ```

2. Install in development mode:
   ```bash
   pip install -e .
   ```

### Direct Installation from GitHub

You can also install directly from GitHub:

```bash
# 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.7
```

## Usage

### Basic Setup

1. Set the `CODICENT_TOKEN` environment variable with your Codicent API token:
   ```bash
   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:**
```bash
codicent "What can you help me with?"
codicent "Explain Python decorators"
```

**Interactive mode:**
```bash
codicent -t
# or
codicent --interactive
```

**Piped input:**
```bash
echo "What is machine learning?" | codicent
codicent < questions.txt
cat code.py | codicent "Review this code"
```

**Info messages (@ prefix):**
```bash
codicent "@mention This is an info message"
```

**With logging:**
```bash
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

```bash
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](https://github.com/izaxon/codicent-py) for API details

## License

This project is licensed under the MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/izaxon/codicent-cli",
    "name": "codicent-cli",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "codicent cli api chat ai",
    "author": "Johan Isaksson",
    "author_email": "johan@izaxon.com",
    "download_url": "https://files.pythonhosted.org/packages/2b/38/c01c6e810d3cbaf5ba3f1c212aeccea06065bcc36ef3d13e0b4e76c96efc/codicent_cli-0.4.7.tar.gz",
    "platform": null,
    "description": "# Codicent CLI\n\nCodicent 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.\n\n## Features\n\n- **One-shot mode**: Execute single commands and get responses\n- **Interactive mode**: Continuous chat sessions with conversation tracking\n- **Message types**: Support for regular chat and @-prefixed info messages\n- **Input flexibility**: Command arguments, stdin pipes, or interactive prompts\n- **Rich output**: Markdown-formatted responses with beautiful terminal UI\n- **Error handling**: Comprehensive error messages and graceful failure handling\n- **Logging**: Configurable logging levels for debugging\n\n## Installation\n\n### Prerequisites\n\n- Python 3.6 or higher\n- `pip` (Python package installer)\n\n### Quick Installation\n\n```bash\n# Install from PyPI\npip install codicent-py codicent-cli\n```\n\n### Development Installation\n\n#### Steps\n\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/izaxon/codicent-cli.git\n   cd codicent-cli\n   ```\n\n2. Install in development mode:\n   ```bash\n   pip install -e .\n   ```\n\n### Direct Installation from GitHub\n\nYou can also install directly from GitHub:\n\n```bash\n# Install the latest version\npip install git+https://github.com/izaxon/codicent-cli.git\n\n# Install a specific version\npip install git+https://github.com/izaxon/codicent-cli.git@v0.4.7\n```\n\n## Usage\n\n### Basic Setup\n\n1. Set the `CODICENT_TOKEN` environment variable with your Codicent API token:\n   ```bash\n   export CODICENT_TOKEN=\"YOUR_API_TOKEN\"\n   ```\n\n### Command Options\n\n```\ncodicent [OPTIONS] [QUESTION]\n\nOPTIONS:\n  -t, --interactive    Start interactive chat mode\n  -h, --help          Show help message\n  -v, --version       Show version information\n  --verbose           Enable verbose logging\n  --quiet             Suppress non-essential output\n```\n\n### Examples\n\n**One-shot questions:**\n```bash\ncodicent \"What can you help me with?\"\ncodicent \"Explain Python decorators\"\n```\n\n**Interactive mode:**\n```bash\ncodicent -t\n# or\ncodicent --interactive\n```\n\n**Piped input:**\n```bash\necho \"What is machine learning?\" | codicent\ncodicent < questions.txt\ncat code.py | codicent \"Review this code\"\n```\n\n**Info messages (@ prefix):**\n```bash\ncodicent \"@mention This is an info message\"\n```\n\n**With logging:**\n```bash\ncodicent --verbose \"Debug this issue\"\ncodicent --quiet \"Silent operation\"\n```\n\n## Interactive Mode\n\nIn interactive mode, you can have ongoing conversations with enhanced visual clarity:\n\n```\n$ codicent -t\n\ud83e\udd16 Codicent CLI Interactive Mode\nType your questions or use Ctrl+C to exit.\nPrefix with @ for info messages.\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u00a4 What is Python?\n\nPython is a high-level, interpreted programming language known for its \nsimplicity and readability. It was created by Guido van Rossum and first \nreleased in 1991.\n\nKey features:\n\u2022 Easy to learn and use\n\u2022 Extensive standard library\n\u2022 Cross-platform compatibility\n\u2022 Strong community support\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u00a4 Can you give me an example?\n\nHere's a simple Python example:\n\n# Hello World in Python\nprint(\"Hello, World!\")\n\n# Working with variables\nname = \"Alice\"\nage = 25\nprint(f\"My name is {name} and I am {age} years old.\")\n\nPython's syntax is clean and intuitive!\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u00a4 @mention Save this conversation\n\u2705 Message posted successfully.\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\u00a4 ^C\n\ud83d\udc4b Goodbye!\n```\n\n**Visual Features:**\n- **Colored messages**: User input appears in cyan, bot responses in green\n- **Clean prompting**: Original `\u00a4` prompt character maintained\n- **Visual separators**: Clear lines between conversations\n- **Rich formatting**: Markdown responses with syntax highlighting\n- **Status indicators**: Animated thinking indicators and success messages\n- **Emojis**: Friendly visual cues throughout the interface\n\n## Error Handling\n\nThe CLI provides helpful error messages for common issues:\n\n- **Missing token**: Clear instructions on setting up `CODICENT_TOKEN`\n- **Network errors**: Graceful handling of connection issues\n- **API errors**: Detailed error messages from the Codicent API\n- **Input validation**: Prevents empty or overly long inputs\n- **Keyboard interrupts**: Clean exit handling\n\n## Development\n\n### Running Tests\n\n```bash\npython -m pytest test_app.py -v\n```\n\n### Project Structure\n\n- `app.py` - Main application logic (single-file architecture)\n- `test_app.py` - Comprehensive test suite\n- `setup.py` - Package configuration\n- `requirements.txt` - Dependencies (now uses PyPI packages)\n\n### Dependencies\n\n- **codicent-py**: Core API client for Codicent services (now available on PyPI)\n- **rich**: Terminal formatting, markdown rendering, and animations\n\n## Troubleshooting\n\n### Common Issues\n\n1. **\"CODICENT_TOKEN environment variable is not set\"**\n   - Set the token: `export CODICENT_TOKEN=\"your_token\"`\n   - Verify it's set: `echo $CODICENT_TOKEN`\n\n2. **\"Network error: Unable to connect to Codicent API\"**\n   - Check your internet connection\n   - Verify the Codicent API is accessible\n   - Try again with `--verbose` for more details\n\n3. **\"Failed to initialize Codicent API client\"**\n   - Verify your token is valid\n   - Check if the codicent-py package is properly installed\n\n### Getting Help\n\n- Use `codicent --help` for usage information\n- Use `codicent --verbose` for detailed logging\n- Check the [Codicent documentation](https://github.com/izaxon/codicent-py) for API details\n\n## License\n\nThis project is licensed under the MIT License.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Command-line interface for the Codicent API",
    "version": "0.4.7",
    "project_urls": {
        "Bug Reports": "https://github.com/izaxon/codicent-cli/issues",
        "Homepage": "https://github.com/izaxon/codicent-cli",
        "Source": "https://github.com/izaxon/codicent-cli"
    },
    "split_keywords": [
        "codicent",
        "cli",
        "api",
        "chat",
        "ai"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "31cf2f23a8ce7b178f9315ae0f20be3c64c2fefb837ed78e07150f663d100f67",
                "md5": "90bc2785d17cdde58be79b40db70c88b",
                "sha256": "bd7844097070fd1f8571890b7d0b265a24f3f44a7f8c459500523b20d4a0b064"
            },
            "downloads": -1,
            "filename": "codicent_cli-0.4.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "90bc2785d17cdde58be79b40db70c88b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 10888,
            "upload_time": "2025-08-08T08:49:46",
            "upload_time_iso_8601": "2025-08-08T08:49:46.305864Z",
            "url": "https://files.pythonhosted.org/packages/31/cf/2f23a8ce7b178f9315ae0f20be3c64c2fefb837ed78e07150f663d100f67/codicent_cli-0.4.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "2b38c01c6e810d3cbaf5ba3f1c212aeccea06065bcc36ef3d13e0b4e76c96efc",
                "md5": "e4bbd7817f2862c1c84e5caec2461a66",
                "sha256": "9603d220f461bd7fde7ba8ecafb3eaec2471e4249aa6ae743087fc9b48fb0670"
            },
            "downloads": -1,
            "filename": "codicent_cli-0.4.7.tar.gz",
            "has_sig": false,
            "md5_digest": "e4bbd7817f2862c1c84e5caec2461a66",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12229,
            "upload_time": "2025-08-08T08:49:48",
            "upload_time_iso_8601": "2025-08-08T08:49:48.684600Z",
            "url": "https://files.pythonhosted.org/packages/2b/38/c01c6e810d3cbaf5ba3f1c212aeccea06065bcc36ef3d13e0b4e76c96efc/codicent_cli-0.4.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-08 08:49:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "izaxon",
    "github_project": "codicent-cli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "rich",
            "specs": []
        },
        {
            "name": "codicent-py",
            "specs": []
        },
        {
            "name": "prompt_toolkit",
            "specs": []
        },
        {
            "name": "requests",
            "specs": []
        }
    ],
    "lcname": "codicent-cli"
}
        
Elapsed time: 1.84916s