codicent-cli


Namecodicent-cli JSON
Version 0.4.3 PyPI version JSON
download
home_pagehttps://github.com/izaxon/codicent-cli
SummaryCommand-line interface for the Codicent API
upload_time2025-07-12 17:27:44
maintainerNone
docs_urlNone
authorJohan Isaksson
requires_python>=3.6
licenseNone
keywords codicent cli api chat ai
VCS
bugtrack_url
requirements rich None
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 both dependencies with one command
pip install git+https://github.com/izaxon/codicent-py.git git+https://github.com/izaxon/codicent-cli.git@v0.4.3
```

### Development Installation

#### Steps

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

2. Install the Git dependency:
   ```bash
   pip install git+https://github.com/izaxon/codicent-py.git
   ```

3. Install the CLI application:
   ```bash
   pip install .
   ```

   For development mode:
   ```bash
   pip install -e .
   ```

### Direct Installation from GitHub

You can also install directly from GitHub without cloning:

```bash
# Install the latest release
pip install git+https://github.com/izaxon/codicent-py.git
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.3
```

## 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 including git packages

### Dependencies

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