codicent-cli 0.4.4__tar.gz → 0.4.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {codicent_cli-0.4.4 → codicent_cli-0.4.6}/LICENSE +0 -0
- {codicent_cli-0.4.4/codicent_cli.egg-info → codicent_cli-0.4.6}/PKG-INFO +258 -257
- {codicent_cli-0.4.4 → codicent_cli-0.4.6}/README.md +1 -1
- {codicent_cli-0.4.4 → codicent_cli-0.4.6}/app.py +26 -2
- {codicent_cli-0.4.4 → codicent_cli-0.4.6/codicent_cli.egg-info}/PKG-INFO +258 -257
- {codicent_cli-0.4.4 → codicent_cli-0.4.6}/codicent_cli.egg-info/SOURCES.txt +0 -0
- {codicent_cli-0.4.4 → codicent_cli-0.4.6}/codicent_cli.egg-info/dependency_links.txt +0 -0
- {codicent_cli-0.4.4 → codicent_cli-0.4.6}/codicent_cli.egg-info/entry_points.txt +0 -0
- {codicent_cli-0.4.4 → codicent_cli-0.4.6}/codicent_cli.egg-info/requires.txt +1 -0
- {codicent_cli-0.4.4 → codicent_cli-0.4.6}/codicent_cli.egg-info/top_level.txt +0 -0
- {codicent_cli-0.4.4 → codicent_cli-0.4.6}/setup.cfg +4 -4
- {codicent_cli-0.4.4 → codicent_cli-0.4.6}/setup.py +2 -1
|
File without changes
|
|
@@ -1,257 +1,258 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: codicent-cli
|
|
3
|
-
Version: 0.4.
|
|
4
|
-
Summary: Command-line interface for the Codicent API
|
|
5
|
-
Home-page: https://github.com/izaxon/codicent-cli
|
|
6
|
-
Author: Johan Isaksson
|
|
7
|
-
Author-email: johan@izaxon.com
|
|
8
|
-
Project-URL: Bug Reports, https://github.com/izaxon/codicent-cli/issues
|
|
9
|
-
Project-URL: Source, https://github.com/izaxon/codicent-cli
|
|
10
|
-
Keywords: codicent cli api chat ai
|
|
11
|
-
Classifier: Development Status :: 4 - Beta
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
-
Requires-Python: >=3.6
|
|
24
|
-
Description-Content-Type: text/markdown
|
|
25
|
-
License-File: LICENSE
|
|
26
|
-
Requires-Dist: rich
|
|
27
|
-
Requires-Dist: codicent-py
|
|
28
|
-
|
|
29
|
-
Dynamic: author
|
|
30
|
-
Dynamic:
|
|
31
|
-
Dynamic:
|
|
32
|
-
Dynamic: description
|
|
33
|
-
Dynamic:
|
|
34
|
-
Dynamic:
|
|
35
|
-
Dynamic:
|
|
36
|
-
Dynamic:
|
|
37
|
-
Dynamic:
|
|
38
|
-
Dynamic: requires-
|
|
39
|
-
Dynamic:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- **
|
|
49
|
-
- **
|
|
50
|
-
- **
|
|
51
|
-
- **
|
|
52
|
-
- **
|
|
53
|
-
- **
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
--
|
|
115
|
-
--
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
codicent "
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
codicent --
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
•
|
|
170
|
-
•
|
|
171
|
-
•
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
- **
|
|
197
|
-
- **
|
|
198
|
-
- **
|
|
199
|
-
- **
|
|
200
|
-
- **
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
- **
|
|
208
|
-
- **
|
|
209
|
-
- **
|
|
210
|
-
- **
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
- `
|
|
224
|
-
- `
|
|
225
|
-
- `
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
- **
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
- Use `codicent --
|
|
253
|
-
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codicent-cli
|
|
3
|
+
Version: 0.4.6
|
|
4
|
+
Summary: Command-line interface for the Codicent API
|
|
5
|
+
Home-page: https://github.com/izaxon/codicent-cli
|
|
6
|
+
Author: Johan Isaksson
|
|
7
|
+
Author-email: johan@izaxon.com
|
|
8
|
+
Project-URL: Bug Reports, https://github.com/izaxon/codicent-cli/issues
|
|
9
|
+
Project-URL: Source, https://github.com/izaxon/codicent-cli
|
|
10
|
+
Keywords: codicent cli api chat ai
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Requires-Python: >=3.6
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: rich
|
|
27
|
+
Requires-Dist: codicent-py
|
|
28
|
+
Requires-Dist: prompt_toolkit
|
|
29
|
+
Dynamic: author
|
|
30
|
+
Dynamic: author-email
|
|
31
|
+
Dynamic: classifier
|
|
32
|
+
Dynamic: description
|
|
33
|
+
Dynamic: description-content-type
|
|
34
|
+
Dynamic: home-page
|
|
35
|
+
Dynamic: keywords
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
Dynamic: project-url
|
|
38
|
+
Dynamic: requires-dist
|
|
39
|
+
Dynamic: requires-python
|
|
40
|
+
Dynamic: summary
|
|
41
|
+
|
|
42
|
+
# Codicent CLI
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
- **One-shot mode**: Execute single commands and get responses
|
|
49
|
+
- **Interactive mode**: Continuous chat sessions with conversation tracking
|
|
50
|
+
- **Message types**: Support for regular chat and @-prefixed info messages
|
|
51
|
+
- **Input flexibility**: Command arguments, stdin pipes, or interactive prompts
|
|
52
|
+
- **Rich output**: Markdown-formatted responses with beautiful terminal UI
|
|
53
|
+
- **Error handling**: Comprehensive error messages and graceful failure handling
|
|
54
|
+
- **Logging**: Configurable logging levels for debugging
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
### Prerequisites
|
|
59
|
+
|
|
60
|
+
- Python 3.6 or higher
|
|
61
|
+
- `pip` (Python package installer)
|
|
62
|
+
|
|
63
|
+
### Quick Installation
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Install from PyPI
|
|
67
|
+
pip install codicent-py codicent-cli
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Development Installation
|
|
71
|
+
|
|
72
|
+
#### Steps
|
|
73
|
+
|
|
74
|
+
1. Clone the repository:
|
|
75
|
+
```bash
|
|
76
|
+
git clone https://github.com/izaxon/codicent-cli.git
|
|
77
|
+
cd codicent-cli
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
2. Install in development mode:
|
|
81
|
+
```bash
|
|
82
|
+
pip install -e .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Direct Installation from GitHub
|
|
86
|
+
|
|
87
|
+
You can also install directly from GitHub:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Install the latest version
|
|
91
|
+
pip install git+https://github.com/izaxon/codicent-cli.git
|
|
92
|
+
|
|
93
|
+
# Install a specific version
|
|
94
|
+
pip install git+https://github.com/izaxon/codicent-cli.git@v0.4.6
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Usage
|
|
98
|
+
|
|
99
|
+
### Basic Setup
|
|
100
|
+
|
|
101
|
+
1. Set the `CODICENT_TOKEN` environment variable with your Codicent API token:
|
|
102
|
+
```bash
|
|
103
|
+
export CODICENT_TOKEN="YOUR_API_TOKEN"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Command Options
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
codicent [OPTIONS] [QUESTION]
|
|
110
|
+
|
|
111
|
+
OPTIONS:
|
|
112
|
+
-t, --interactive Start interactive chat mode
|
|
113
|
+
-h, --help Show help message
|
|
114
|
+
-v, --version Show version information
|
|
115
|
+
--verbose Enable verbose logging
|
|
116
|
+
--quiet Suppress non-essential output
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Examples
|
|
120
|
+
|
|
121
|
+
**One-shot questions:**
|
|
122
|
+
```bash
|
|
123
|
+
codicent "What can you help me with?"
|
|
124
|
+
codicent "Explain Python decorators"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Interactive mode:**
|
|
128
|
+
```bash
|
|
129
|
+
codicent -t
|
|
130
|
+
# or
|
|
131
|
+
codicent --interactive
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Piped input:**
|
|
135
|
+
```bash
|
|
136
|
+
echo "What is machine learning?" | codicent
|
|
137
|
+
codicent < questions.txt
|
|
138
|
+
cat code.py | codicent "Review this code"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Info messages (@ prefix):**
|
|
142
|
+
```bash
|
|
143
|
+
codicent "@mention This is an info message"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**With logging:**
|
|
147
|
+
```bash
|
|
148
|
+
codicent --verbose "Debug this issue"
|
|
149
|
+
codicent --quiet "Silent operation"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Interactive Mode
|
|
153
|
+
|
|
154
|
+
In interactive mode, you can have ongoing conversations with enhanced visual clarity:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
$ codicent -t
|
|
158
|
+
🤖 Codicent CLI Interactive Mode
|
|
159
|
+
Type your questions or use Ctrl+C to exit.
|
|
160
|
+
Prefix with @ for info messages.
|
|
161
|
+
──────────────────────────────────────────────────
|
|
162
|
+
¤ What is Python?
|
|
163
|
+
|
|
164
|
+
Python is a high-level, interpreted programming language known for its
|
|
165
|
+
simplicity and readability. It was created by Guido van Rossum and first
|
|
166
|
+
released in 1991.
|
|
167
|
+
|
|
168
|
+
Key features:
|
|
169
|
+
• Easy to learn and use
|
|
170
|
+
• Extensive standard library
|
|
171
|
+
• Cross-platform compatibility
|
|
172
|
+
• Strong community support
|
|
173
|
+
──────────────────────────────────────────────────
|
|
174
|
+
¤ Can you give me an example?
|
|
175
|
+
|
|
176
|
+
Here's a simple Python example:
|
|
177
|
+
|
|
178
|
+
# Hello World in Python
|
|
179
|
+
print("Hello, World!")
|
|
180
|
+
|
|
181
|
+
# Working with variables
|
|
182
|
+
name = "Alice"
|
|
183
|
+
age = 25
|
|
184
|
+
print(f"My name is {name} and I am {age} years old.")
|
|
185
|
+
|
|
186
|
+
Python's syntax is clean and intuitive!
|
|
187
|
+
──────────────────────────────────────────────────
|
|
188
|
+
¤ @mention Save this conversation
|
|
189
|
+
✅ Message posted successfully.
|
|
190
|
+
──────────────────────────────────────────────────
|
|
191
|
+
¤ ^C
|
|
192
|
+
👋 Goodbye!
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Visual Features:**
|
|
196
|
+
- **Colored messages**: User input appears in cyan, bot responses in green
|
|
197
|
+
- **Clean prompting**: Original `¤` prompt character maintained
|
|
198
|
+
- **Visual separators**: Clear lines between conversations
|
|
199
|
+
- **Rich formatting**: Markdown responses with syntax highlighting
|
|
200
|
+
- **Status indicators**: Animated thinking indicators and success messages
|
|
201
|
+
- **Emojis**: Friendly visual cues throughout the interface
|
|
202
|
+
|
|
203
|
+
## Error Handling
|
|
204
|
+
|
|
205
|
+
The CLI provides helpful error messages for common issues:
|
|
206
|
+
|
|
207
|
+
- **Missing token**: Clear instructions on setting up `CODICENT_TOKEN`
|
|
208
|
+
- **Network errors**: Graceful handling of connection issues
|
|
209
|
+
- **API errors**: Detailed error messages from the Codicent API
|
|
210
|
+
- **Input validation**: Prevents empty or overly long inputs
|
|
211
|
+
- **Keyboard interrupts**: Clean exit handling
|
|
212
|
+
|
|
213
|
+
## Development
|
|
214
|
+
|
|
215
|
+
### Running Tests
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
python -m pytest test_app.py -v
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Project Structure
|
|
222
|
+
|
|
223
|
+
- `app.py` - Main application logic (single-file architecture)
|
|
224
|
+
- `test_app.py` - Comprehensive test suite
|
|
225
|
+
- `setup.py` - Package configuration
|
|
226
|
+
- `requirements.txt` - Dependencies (now uses PyPI packages)
|
|
227
|
+
|
|
228
|
+
### Dependencies
|
|
229
|
+
|
|
230
|
+
- **codicent-py**: Core API client for Codicent services (now available on PyPI)
|
|
231
|
+
- **rich**: Terminal formatting, markdown rendering, and animations
|
|
232
|
+
|
|
233
|
+
## Troubleshooting
|
|
234
|
+
|
|
235
|
+
### Common Issues
|
|
236
|
+
|
|
237
|
+
1. **"CODICENT_TOKEN environment variable is not set"**
|
|
238
|
+
- Set the token: `export CODICENT_TOKEN="your_token"`
|
|
239
|
+
- Verify it's set: `echo $CODICENT_TOKEN`
|
|
240
|
+
|
|
241
|
+
2. **"Network error: Unable to connect to Codicent API"**
|
|
242
|
+
- Check your internet connection
|
|
243
|
+
- Verify the Codicent API is accessible
|
|
244
|
+
- Try again with `--verbose` for more details
|
|
245
|
+
|
|
246
|
+
3. **"Failed to initialize Codicent API client"**
|
|
247
|
+
- Verify your token is valid
|
|
248
|
+
- Check if the codicent-py package is properly installed
|
|
249
|
+
|
|
250
|
+
### Getting Help
|
|
251
|
+
|
|
252
|
+
- Use `codicent --help` for usage information
|
|
253
|
+
- Use `codicent --verbose` for detailed logging
|
|
254
|
+
- Check the [Codicent documentation](https://github.com/izaxon/codicent-py) for API details
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
This project is licensed under the MIT License.
|
|
@@ -50,7 +50,7 @@ You can also install directly from GitHub:
|
|
|
50
50
|
pip install git+https://github.com/izaxon/codicent-cli.git
|
|
51
51
|
|
|
52
52
|
# Install a specific version
|
|
53
|
-
pip install git+https://github.com/izaxon/codicent-cli.git@v0.4.
|
|
53
|
+
pip install git+https://github.com/izaxon/codicent-cli.git@v0.4.6
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
## Usage
|
|
@@ -4,6 +4,10 @@ import logging
|
|
|
4
4
|
from codicentpy import Codicent
|
|
5
5
|
from rich.console import Console
|
|
6
6
|
from rich.markdown import Markdown
|
|
7
|
+
from prompt_toolkit import prompt
|
|
8
|
+
from prompt_toolkit.key_binding import KeyBindings
|
|
9
|
+
from prompt_toolkit.keys import Keys
|
|
10
|
+
from prompt_toolkit.filters import Condition
|
|
7
11
|
|
|
8
12
|
# Configure logging
|
|
9
13
|
logging.basicConfig(level=logging.WARNING, format='%(levelname)s: %(message)s')
|
|
@@ -41,7 +45,7 @@ For more information, visit: https://github.com/izaxon/codicent-cli
|
|
|
41
45
|
|
|
42
46
|
def show_version():
|
|
43
47
|
"""Display version information."""
|
|
44
|
-
print("Codicent CLI v0.4.
|
|
48
|
+
print("Codicent CLI v0.4.6")
|
|
45
49
|
|
|
46
50
|
def validate_input(question):
|
|
47
51
|
"""Validate user input."""
|
|
@@ -189,11 +193,31 @@ def main():
|
|
|
189
193
|
console.print("\n[bold green]🤖 Codicent CLI Interactive Mode[/bold green]")
|
|
190
194
|
console.print("[dim]Type your questions or use Ctrl+C to exit.[/dim]")
|
|
191
195
|
console.print("[dim]Prefix with @ for info messages.[/dim]")
|
|
196
|
+
console.print("[dim]Enter: send | Alt+Enter: new line | Paste: multi-line supported[/dim]")
|
|
192
197
|
console.print("─" * 50)
|
|
193
198
|
|
|
199
|
+
# Create custom key bindings
|
|
200
|
+
bindings = KeyBindings()
|
|
201
|
+
|
|
202
|
+
@bindings.add(Keys.Enter)
|
|
203
|
+
def _(event):
|
|
204
|
+
"""Enter submits the input."""
|
|
205
|
+
event.current_buffer.validate_and_handle()
|
|
206
|
+
|
|
207
|
+
@bindings.add(Keys.Escape, Keys.Enter) # Alt+Enter
|
|
208
|
+
def _(event):
|
|
209
|
+
"""Alt+Enter inserts a newline."""
|
|
210
|
+
event.current_buffer.insert_text('\n')
|
|
211
|
+
|
|
194
212
|
while True:
|
|
195
213
|
try:
|
|
196
|
-
|
|
214
|
+
# Use prompt_toolkit's prompt instead of input()
|
|
215
|
+
question = prompt(
|
|
216
|
+
"¤ ",
|
|
217
|
+
multiline=True,
|
|
218
|
+
key_bindings=bindings,
|
|
219
|
+
prompt_continuation="" # No continuation prompt for clean look
|
|
220
|
+
)
|
|
197
221
|
except KeyboardInterrupt:
|
|
198
222
|
console.print("\n[yellow]👋 Goodbye![/yellow]")
|
|
199
223
|
break
|
|
@@ -1,257 +1,258 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: codicent-cli
|
|
3
|
-
Version: 0.4.
|
|
4
|
-
Summary: Command-line interface for the Codicent API
|
|
5
|
-
Home-page: https://github.com/izaxon/codicent-cli
|
|
6
|
-
Author: Johan Isaksson
|
|
7
|
-
Author-email: johan@izaxon.com
|
|
8
|
-
Project-URL: Bug Reports, https://github.com/izaxon/codicent-cli/issues
|
|
9
|
-
Project-URL: Source, https://github.com/izaxon/codicent-cli
|
|
10
|
-
Keywords: codicent cli api chat ai
|
|
11
|
-
Classifier: Development Status :: 4 - Beta
|
|
12
|
-
Classifier: Intended Audience :: Developers
|
|
13
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
-
Requires-Python: >=3.6
|
|
24
|
-
Description-Content-Type: text/markdown
|
|
25
|
-
License-File: LICENSE
|
|
26
|
-
Requires-Dist: rich
|
|
27
|
-
Requires-Dist: codicent-py
|
|
28
|
-
|
|
29
|
-
Dynamic: author
|
|
30
|
-
Dynamic:
|
|
31
|
-
Dynamic:
|
|
32
|
-
Dynamic: description
|
|
33
|
-
Dynamic:
|
|
34
|
-
Dynamic:
|
|
35
|
-
Dynamic:
|
|
36
|
-
Dynamic:
|
|
37
|
-
Dynamic:
|
|
38
|
-
Dynamic: requires-
|
|
39
|
-
Dynamic:
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
- **
|
|
49
|
-
- **
|
|
50
|
-
- **
|
|
51
|
-
- **
|
|
52
|
-
- **
|
|
53
|
-
- **
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
-
|
|
113
|
-
-
|
|
114
|
-
--
|
|
115
|
-
--
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
codicent "
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
codicent --
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
•
|
|
170
|
-
•
|
|
171
|
-
•
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
- **
|
|
197
|
-
- **
|
|
198
|
-
- **
|
|
199
|
-
- **
|
|
200
|
-
- **
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
- **
|
|
208
|
-
- **
|
|
209
|
-
- **
|
|
210
|
-
- **
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
- `
|
|
224
|
-
- `
|
|
225
|
-
- `
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
- **
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
-
|
|
243
|
-
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
- Use `codicent --
|
|
253
|
-
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: codicent-cli
|
|
3
|
+
Version: 0.4.6
|
|
4
|
+
Summary: Command-line interface for the Codicent API
|
|
5
|
+
Home-page: https://github.com/izaxon/codicent-cli
|
|
6
|
+
Author: Johan Isaksson
|
|
7
|
+
Author-email: johan@izaxon.com
|
|
8
|
+
Project-URL: Bug Reports, https://github.com/izaxon/codicent-cli/issues
|
|
9
|
+
Project-URL: Source, https://github.com/izaxon/codicent-cli
|
|
10
|
+
Keywords: codicent cli api chat ai
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.7
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Requires-Python: >=3.6
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: rich
|
|
27
|
+
Requires-Dist: codicent-py
|
|
28
|
+
Requires-Dist: prompt_toolkit
|
|
29
|
+
Dynamic: author
|
|
30
|
+
Dynamic: author-email
|
|
31
|
+
Dynamic: classifier
|
|
32
|
+
Dynamic: description
|
|
33
|
+
Dynamic: description-content-type
|
|
34
|
+
Dynamic: home-page
|
|
35
|
+
Dynamic: keywords
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
Dynamic: project-url
|
|
38
|
+
Dynamic: requires-dist
|
|
39
|
+
Dynamic: requires-python
|
|
40
|
+
Dynamic: summary
|
|
41
|
+
|
|
42
|
+
# Codicent CLI
|
|
43
|
+
|
|
44
|
+
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.
|
|
45
|
+
|
|
46
|
+
## Features
|
|
47
|
+
|
|
48
|
+
- **One-shot mode**: Execute single commands and get responses
|
|
49
|
+
- **Interactive mode**: Continuous chat sessions with conversation tracking
|
|
50
|
+
- **Message types**: Support for regular chat and @-prefixed info messages
|
|
51
|
+
- **Input flexibility**: Command arguments, stdin pipes, or interactive prompts
|
|
52
|
+
- **Rich output**: Markdown-formatted responses with beautiful terminal UI
|
|
53
|
+
- **Error handling**: Comprehensive error messages and graceful failure handling
|
|
54
|
+
- **Logging**: Configurable logging levels for debugging
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
### Prerequisites
|
|
59
|
+
|
|
60
|
+
- Python 3.6 or higher
|
|
61
|
+
- `pip` (Python package installer)
|
|
62
|
+
|
|
63
|
+
### Quick Installation
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Install from PyPI
|
|
67
|
+
pip install codicent-py codicent-cli
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Development Installation
|
|
71
|
+
|
|
72
|
+
#### Steps
|
|
73
|
+
|
|
74
|
+
1. Clone the repository:
|
|
75
|
+
```bash
|
|
76
|
+
git clone https://github.com/izaxon/codicent-cli.git
|
|
77
|
+
cd codicent-cli
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
2. Install in development mode:
|
|
81
|
+
```bash
|
|
82
|
+
pip install -e .
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Direct Installation from GitHub
|
|
86
|
+
|
|
87
|
+
You can also install directly from GitHub:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Install the latest version
|
|
91
|
+
pip install git+https://github.com/izaxon/codicent-cli.git
|
|
92
|
+
|
|
93
|
+
# Install a specific version
|
|
94
|
+
pip install git+https://github.com/izaxon/codicent-cli.git@v0.4.6
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Usage
|
|
98
|
+
|
|
99
|
+
### Basic Setup
|
|
100
|
+
|
|
101
|
+
1. Set the `CODICENT_TOKEN` environment variable with your Codicent API token:
|
|
102
|
+
```bash
|
|
103
|
+
export CODICENT_TOKEN="YOUR_API_TOKEN"
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Command Options
|
|
107
|
+
|
|
108
|
+
```
|
|
109
|
+
codicent [OPTIONS] [QUESTION]
|
|
110
|
+
|
|
111
|
+
OPTIONS:
|
|
112
|
+
-t, --interactive Start interactive chat mode
|
|
113
|
+
-h, --help Show help message
|
|
114
|
+
-v, --version Show version information
|
|
115
|
+
--verbose Enable verbose logging
|
|
116
|
+
--quiet Suppress non-essential output
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Examples
|
|
120
|
+
|
|
121
|
+
**One-shot questions:**
|
|
122
|
+
```bash
|
|
123
|
+
codicent "What can you help me with?"
|
|
124
|
+
codicent "Explain Python decorators"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Interactive mode:**
|
|
128
|
+
```bash
|
|
129
|
+
codicent -t
|
|
130
|
+
# or
|
|
131
|
+
codicent --interactive
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
**Piped input:**
|
|
135
|
+
```bash
|
|
136
|
+
echo "What is machine learning?" | codicent
|
|
137
|
+
codicent < questions.txt
|
|
138
|
+
cat code.py | codicent "Review this code"
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Info messages (@ prefix):**
|
|
142
|
+
```bash
|
|
143
|
+
codicent "@mention This is an info message"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**With logging:**
|
|
147
|
+
```bash
|
|
148
|
+
codicent --verbose "Debug this issue"
|
|
149
|
+
codicent --quiet "Silent operation"
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Interactive Mode
|
|
153
|
+
|
|
154
|
+
In interactive mode, you can have ongoing conversations with enhanced visual clarity:
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
$ codicent -t
|
|
158
|
+
🤖 Codicent CLI Interactive Mode
|
|
159
|
+
Type your questions or use Ctrl+C to exit.
|
|
160
|
+
Prefix with @ for info messages.
|
|
161
|
+
──────────────────────────────────────────────────
|
|
162
|
+
¤ What is Python?
|
|
163
|
+
|
|
164
|
+
Python is a high-level, interpreted programming language known for its
|
|
165
|
+
simplicity and readability. It was created by Guido van Rossum and first
|
|
166
|
+
released in 1991.
|
|
167
|
+
|
|
168
|
+
Key features:
|
|
169
|
+
• Easy to learn and use
|
|
170
|
+
• Extensive standard library
|
|
171
|
+
• Cross-platform compatibility
|
|
172
|
+
• Strong community support
|
|
173
|
+
──────────────────────────────────────────────────
|
|
174
|
+
¤ Can you give me an example?
|
|
175
|
+
|
|
176
|
+
Here's a simple Python example:
|
|
177
|
+
|
|
178
|
+
# Hello World in Python
|
|
179
|
+
print("Hello, World!")
|
|
180
|
+
|
|
181
|
+
# Working with variables
|
|
182
|
+
name = "Alice"
|
|
183
|
+
age = 25
|
|
184
|
+
print(f"My name is {name} and I am {age} years old.")
|
|
185
|
+
|
|
186
|
+
Python's syntax is clean and intuitive!
|
|
187
|
+
──────────────────────────────────────────────────
|
|
188
|
+
¤ @mention Save this conversation
|
|
189
|
+
✅ Message posted successfully.
|
|
190
|
+
──────────────────────────────────────────────────
|
|
191
|
+
¤ ^C
|
|
192
|
+
👋 Goodbye!
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**Visual Features:**
|
|
196
|
+
- **Colored messages**: User input appears in cyan, bot responses in green
|
|
197
|
+
- **Clean prompting**: Original `¤` prompt character maintained
|
|
198
|
+
- **Visual separators**: Clear lines between conversations
|
|
199
|
+
- **Rich formatting**: Markdown responses with syntax highlighting
|
|
200
|
+
- **Status indicators**: Animated thinking indicators and success messages
|
|
201
|
+
- **Emojis**: Friendly visual cues throughout the interface
|
|
202
|
+
|
|
203
|
+
## Error Handling
|
|
204
|
+
|
|
205
|
+
The CLI provides helpful error messages for common issues:
|
|
206
|
+
|
|
207
|
+
- **Missing token**: Clear instructions on setting up `CODICENT_TOKEN`
|
|
208
|
+
- **Network errors**: Graceful handling of connection issues
|
|
209
|
+
- **API errors**: Detailed error messages from the Codicent API
|
|
210
|
+
- **Input validation**: Prevents empty or overly long inputs
|
|
211
|
+
- **Keyboard interrupts**: Clean exit handling
|
|
212
|
+
|
|
213
|
+
## Development
|
|
214
|
+
|
|
215
|
+
### Running Tests
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
python -m pytest test_app.py -v
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Project Structure
|
|
222
|
+
|
|
223
|
+
- `app.py` - Main application logic (single-file architecture)
|
|
224
|
+
- `test_app.py` - Comprehensive test suite
|
|
225
|
+
- `setup.py` - Package configuration
|
|
226
|
+
- `requirements.txt` - Dependencies (now uses PyPI packages)
|
|
227
|
+
|
|
228
|
+
### Dependencies
|
|
229
|
+
|
|
230
|
+
- **codicent-py**: Core API client for Codicent services (now available on PyPI)
|
|
231
|
+
- **rich**: Terminal formatting, markdown rendering, and animations
|
|
232
|
+
|
|
233
|
+
## Troubleshooting
|
|
234
|
+
|
|
235
|
+
### Common Issues
|
|
236
|
+
|
|
237
|
+
1. **"CODICENT_TOKEN environment variable is not set"**
|
|
238
|
+
- Set the token: `export CODICENT_TOKEN="your_token"`
|
|
239
|
+
- Verify it's set: `echo $CODICENT_TOKEN`
|
|
240
|
+
|
|
241
|
+
2. **"Network error: Unable to connect to Codicent API"**
|
|
242
|
+
- Check your internet connection
|
|
243
|
+
- Verify the Codicent API is accessible
|
|
244
|
+
- Try again with `--verbose` for more details
|
|
245
|
+
|
|
246
|
+
3. **"Failed to initialize Codicent API client"**
|
|
247
|
+
- Verify your token is valid
|
|
248
|
+
- Check if the codicent-py package is properly installed
|
|
249
|
+
|
|
250
|
+
### Getting Help
|
|
251
|
+
|
|
252
|
+
- Use `codicent --help` for usage information
|
|
253
|
+
- Use `codicent --verbose` for detailed logging
|
|
254
|
+
- Check the [Codicent documentation](https://github.com/izaxon/codicent-py) for API details
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
This project is licensed under the MIT License.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
|
@@ -9,7 +9,7 @@ except FileNotFoundError:
|
|
|
9
9
|
|
|
10
10
|
setup(
|
|
11
11
|
name='codicent-cli',
|
|
12
|
-
version='0.4.
|
|
12
|
+
version='0.4.6',
|
|
13
13
|
author='Johan Isaksson',
|
|
14
14
|
author_email='johan@izaxon.com',
|
|
15
15
|
description='Command-line interface for the Codicent API',
|
|
@@ -40,6 +40,7 @@ setup(
|
|
|
40
40
|
install_requires=[
|
|
41
41
|
'rich',
|
|
42
42
|
'codicent-py',
|
|
43
|
+
'prompt_toolkit'
|
|
43
44
|
],
|
|
44
45
|
entry_points={
|
|
45
46
|
'console_scripts': [
|