cxc 1.26.4__tar.gz → 2.0.0__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.
- cxc-2.0.0/PKG-INFO +248 -0
- cxc-2.0.0/README.md +226 -0
- {cxc-1.26.4 → cxc-2.0.0}/chat.py +90 -14
- cxc-2.0.0/config_loader.py +236 -0
- cxc-2.0.0/cxc.egg-info/PKG-INFO +248 -0
- {cxc-1.26.4 → cxc-2.0.0}/cxc.egg-info/SOURCES.txt +3 -1
- cxc-2.0.0/cxc.egg-info/requires.txt +8 -0
- {cxc-1.26.4 → cxc-2.0.0}/cxc.egg-info/top_level.txt +2 -0
- cxc-2.0.0/cxc.py +251 -0
- cxc-2.0.0/downloader.py +206 -0
- cxc-2.0.0/mpx.py +305 -0
- cxc-2.0.0/pyproject.toml +37 -0
- cxc-2.0.0/statelib.py +65 -0
- cxc-1.26.4/PKG-INFO +0 -55
- cxc-1.26.4/README.md +0 -31
- cxc-1.26.4/cxc.egg-info/PKG-INFO +0 -55
- cxc-1.26.4/cxc.egg-info/requires.txt +0 -3
- cxc-1.26.4/cxc.py +0 -164
- cxc-1.26.4/downloader.py +0 -105
- cxc-1.26.4/mpx.py +0 -95
- cxc-1.26.4/setup.py +0 -25
- {cxc-1.26.4 → cxc-2.0.0}/LICENSE +0 -0
- {cxc-1.26.4 → cxc-2.0.0}/colors.py +0 -0
- {cxc-1.26.4 → cxc-2.0.0}/cxc.egg-info/dependency_links.txt +0 -0
- {cxc-1.26.4 → cxc-2.0.0}/cxc.egg-info/entry_points.txt +0 -0
- {cxc-1.26.4 → cxc-2.0.0}/setup.cfg +0 -0
cxc-2.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cxc
|
|
3
|
+
Version: 2.0.0
|
|
4
|
+
Summary: CodeX Core, AI Tools For Terminal.
|
|
5
|
+
Author: Xyrion
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/XyrionMD/cxc
|
|
8
|
+
Keywords: cli,music,ai,yt-dlp,terminal
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.11
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: requests
|
|
15
|
+
Requires-Dist: textual
|
|
16
|
+
Requires-Dist: yt-dlp
|
|
17
|
+
Requires-Dist: rapidfuzz
|
|
18
|
+
Requires-Dist: python-vlc
|
|
19
|
+
Provides-Extra: dev
|
|
20
|
+
Requires-Dist: build; extra == "dev"
|
|
21
|
+
Dynamic: license-file
|
|
22
|
+
|
|
23
|
+
**CodeX Core CXC**
|
|
24
|
+
|
|
25
|
+
Hello everyone, my name is Rion. This is my boredom project, which might be useful for you. This tool has several features such as:
|
|
26
|
+
|
|
27
|
+
**Features**
|
|
28
|
+
|
|
29
|
+
- Download Music with yt-dlp
|
|
30
|
+
- Search Music with yt-dlp
|
|
31
|
+
- Video Downloader (DV)
|
|
32
|
+
- Local Search (typo-tolerant)
|
|
33
|
+
- mpx Music Player X (VLC / mpv)
|
|
34
|
+
- AI Chat — full terminal UI built with Textual
|
|
35
|
+
- Send images and text files to the AI from chat (`/file`)
|
|
36
|
+
- Theme picker with automatic saving
|
|
37
|
+
- Config manager (`path`, `edit`, `reset`, `set`, `list-theme`)
|
|
38
|
+
- System state report (`state`)
|
|
39
|
+
- About screen (`about`)
|
|
40
|
+
- Self Update (checks PyPI, upgrades via pipx)
|
|
41
|
+
|
|
42
|
+
**How to use**
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
cxc help
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Commands**
|
|
49
|
+
|
|
50
|
+
| Command | Alias | Description |
|
|
51
|
+
| ------------------------------ | ----- | ------------------------------------ |
|
|
52
|
+
| `cxc search "<title>"` | `-S` | Search music information |
|
|
53
|
+
| `cxc search --local "<title>"` | | Search your downloaded files locally |
|
|
54
|
+
| `cxc download "<title>"` | `-D` | Search and download music to MP3 |
|
|
55
|
+
| `cxc DV -r "<res>" "<URL>"` | | Download a video at a chosen quality |
|
|
56
|
+
| `cxc mpx` | | Open Music Player X |
|
|
57
|
+
| `cxc chat` | | Open the AI chat UI |
|
|
58
|
+
| `cxc state` | | Display current system state |
|
|
59
|
+
| `cxc about` | | Show information about cxc |
|
|
60
|
+
| `cxc config <subcommand>` | | Manage the cxc configuration |
|
|
61
|
+
| `cxc time` | `-t` | Show time, day, month, and year |
|
|
62
|
+
| `cxc update` | `-U` | Check PyPI and update via `pipx` |
|
|
63
|
+
| `cxc version` | `-v` | Show the current version |
|
|
64
|
+
| `cxc help` | `h` | Display the help menu |
|
|
65
|
+
|
|
66
|
+
**mpx (Music Player X)**
|
|
67
|
+
|
|
68
|
+
`cxc mpx` opens an interactive player. It uses **python-vlc** when available and automatically falls back to **mpv** otherwise.
|
|
69
|
+
|
|
70
|
+
| Command | Description |
|
|
71
|
+
| ----------------- | --------------------------------- |
|
|
72
|
+
| `play <n>` | Play track number `<n>` |
|
|
73
|
+
| `play all` | Play every track in the folder |
|
|
74
|
+
| `play <filename>` | Play a file by name |
|
|
75
|
+
| `pause` | Pause / resume |
|
|
76
|
+
| `resume` | Resume playback |
|
|
77
|
+
| `stop` | Stop playback |
|
|
78
|
+
| `next` / `prev` | Next / previous track |
|
|
79
|
+
| `volume <0-100>` | Set volume (no argument shows it) |
|
|
80
|
+
| `now` | Show the current track |
|
|
81
|
+
| `list` | List all tracks |
|
|
82
|
+
| `help` | Show the mpx help |
|
|
83
|
+
| `quit` | Exit mpx |
|
|
84
|
+
|
|
85
|
+
> Note: python-vlc needs the native **libvlc** library. On systems without it, `cxc mpx` falls back to **mpv** (with limited controls: no pause/next/prev/volume).
|
|
86
|
+
|
|
87
|
+
**AI Chat**
|
|
88
|
+
|
|
89
|
+
`cxc chat` opens a Textual-based chat UI with Markdown rendering and streamed "typing" feedback.
|
|
90
|
+
|
|
91
|
+
| Input / Key | Description |
|
|
92
|
+
| ---------------------------- | -------------------------------------------------------- |
|
|
93
|
+
| `<message>` | Send a message to the AI |
|
|
94
|
+
| `/file <path> <prompt>` | Send a file to the AI, with an optional prompt |
|
|
95
|
+
| `help` | Open the in-app help screen |
|
|
96
|
+
| `quit` | Leave the chat |
|
|
97
|
+
| `Ctrl+Q` | Quit the app |
|
|
98
|
+
| `Ctrl+H` | Open the help screen |
|
|
99
|
+
| `Ctrl+P` | Open the Textual command palette (theme picker, etc.) |
|
|
100
|
+
|
|
101
|
+
File support:
|
|
102
|
+
|
|
103
|
+
- **Images** — `.jpg`, `.jpeg`, `.png`, `.webp` are sent inline as base64 so the model can see them.
|
|
104
|
+
```
|
|
105
|
+
/file ~/photo.png Look at this.
|
|
106
|
+
```
|
|
107
|
+
- **Text files** — any other extension is read as UTF-8 and appended to your prompt.
|
|
108
|
+
```
|
|
109
|
+
/file ~/notes.txt Summarize this.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
The theme is saved to `~/.config/cxc/config.toml` automatically when you change it, so your choice sticks between sessions.
|
|
113
|
+
|
|
114
|
+
**Configuration**
|
|
115
|
+
|
|
116
|
+
cxc stores its settings in `~/.config/cxc/config.toml` (TOML format). The file is created automatically on first run — just edit it and restart cxc.
|
|
117
|
+
|
|
118
|
+
```toml
|
|
119
|
+
# CodeX Core (cxc) configuration
|
|
120
|
+
# Edit this file then restart cxc.
|
|
121
|
+
|
|
122
|
+
[ai]
|
|
123
|
+
API = "PASTE_YOUR_API_KEY"
|
|
124
|
+
MODEL = "gemini-2.5-flash"
|
|
125
|
+
# AI_PROMPT may reference other keys, e.g. {AI_NAME}
|
|
126
|
+
AI_PROMPT = "You Are {AI_NAME}"
|
|
127
|
+
|
|
128
|
+
[appearance]
|
|
129
|
+
LOADING_STYLES = "#"
|
|
130
|
+
AI_NAME = "Your_Ai_Name"
|
|
131
|
+
THEME = "catppuccin-mocha"
|
|
132
|
+
|
|
133
|
+
[folders]
|
|
134
|
+
MUSIC_DIR = "Music"
|
|
135
|
+
VIDEO_DIR = "Videos"
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
| Key | Description |
|
|
139
|
+
| ---------------- | -------------------------------------------------------------- |
|
|
140
|
+
| `API` | Your Gemini API key (required for `cxc chat`). |
|
|
141
|
+
| `MODEL` | The AI model to use, e.g. `gemini-2.5-flash`. |
|
|
142
|
+
| `AI_PROMPT` | The system prompt. May reference other keys, e.g. `{AI_NAME}`. |
|
|
143
|
+
| `LOADING_STYLES` | Character used for the animated "typing" indicator in chat. |
|
|
144
|
+
| `AI_NAME` | The name shown for the AI in chat. |
|
|
145
|
+
| `THEME` | Textual theme used by the chat UI (see `list-theme`). |
|
|
146
|
+
| `MUSIC_DIR` | Folder for downloaded music, relative to your home directory. |
|
|
147
|
+
| `VIDEO_DIR` | Folder for downloaded videos, relative to your home directory. |
|
|
148
|
+
|
|
149
|
+
**Managing the config**
|
|
150
|
+
|
|
151
|
+
| Command | Description |
|
|
152
|
+
| ------------------------------ | -------------------------------------------- |
|
|
153
|
+
| `cxc config` | Show the config help |
|
|
154
|
+
| `cxc config path` | Show the config directory |
|
|
155
|
+
| `cxc config edit` | Open `config.toml` in `$EDITOR`/nano/vim |
|
|
156
|
+
| `cxc config reset` | Reset the config to defaults |
|
|
157
|
+
| `cxc config set <KEY> <VALUE>` | Set a single value in `config.toml` |
|
|
158
|
+
| `cxc config list-theme` | List available Textual themes |
|
|
159
|
+
|
|
160
|
+
Examples:
|
|
161
|
+
|
|
162
|
+
```
|
|
163
|
+
cxc config path
|
|
164
|
+
cxc config set THEME catppuccin-mocha
|
|
165
|
+
cxc config set AI_NAME Nova
|
|
166
|
+
cxc config list-theme
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
> `cxc config reset` wipes **all** settings, including your API key. Back up first.
|
|
170
|
+
|
|
171
|
+
**State**
|
|
172
|
+
|
|
173
|
+
`cxc state` prints a quick diagnostic report:
|
|
174
|
+
|
|
175
|
+
- distro name and ID, kernel version
|
|
176
|
+
- whether **ffmpeg** is installed
|
|
177
|
+
- whether the API key is configured
|
|
178
|
+
- Python binary and version
|
|
179
|
+
- whether you are inside a virtualenv
|
|
180
|
+
- config file permissions (warns if not `600`)
|
|
181
|
+
- config directory and music directory
|
|
182
|
+
|
|
183
|
+
```
|
|
184
|
+
===========================================
|
|
185
|
+
CXC STATE...
|
|
186
|
+
===========================================
|
|
187
|
+
Distro : ...
|
|
188
|
+
Kernel : ...
|
|
189
|
+
FFmpeg : Installed
|
|
190
|
+
APIKEY : Active
|
|
191
|
+
Python3 : ... (3-11-0)
|
|
192
|
+
Env : system
|
|
193
|
+
Config Mode : 0o600 (Secure)
|
|
194
|
+
Config DIR : /home/you/.config/cxc/config.toml
|
|
195
|
+
Music DIR : /home/you/Music
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**About**
|
|
199
|
+
|
|
200
|
+
`cxc about` shows the project name, author, license, PyPI/GitHub links, and a short description of cxc.
|
|
201
|
+
|
|
202
|
+
**Config format & migration**
|
|
203
|
+
|
|
204
|
+
The configuration format changed from a Python file (`config.py`) to **TOML** (`config.toml`). You don't need to do anything manually:
|
|
205
|
+
|
|
206
|
+
- If you upgrade from an old version, cxc migrates automatically the first time you run it:
|
|
207
|
+
1. reads your old `config.py`,
|
|
208
|
+
2. writes the new `config.toml`,
|
|
209
|
+
3. keeps a backup of the old file as `config.py.bak`,
|
|
210
|
+
4. removes the old `.lock` file.
|
|
211
|
+
- Your API key and all other settings are preserved.
|
|
212
|
+
- If you have no old config, a fresh `config.toml` is created for you.
|
|
213
|
+
- The file is stored with owner-only permissions (`600`) because it holds your API key.
|
|
214
|
+
- cxc now requires **Python 3.11+** (for the built-in `tomllib`).
|
|
215
|
+
|
|
216
|
+
**Update**
|
|
217
|
+
|
|
218
|
+
## What's New in v2.0.0
|
|
219
|
+
|
|
220
|
+
- **New `cxc chat`** — the AI chat was rebuilt as a Textual terminal UI: Markdown bubbles, animated typing indicator, help screen, themes, and a footer with key bindings.
|
|
221
|
+
- **Send files to the AI** — `/file <path> <prompt>` supports images (`.jpg`, `.jpeg`, `.png`, `.webp`, sent inline) and plain-text files.
|
|
222
|
+
- **Config manager** — `cxc config path|edit|reset|set|list-theme` to inspect and change settings without opening the file by hand, including a theme picker (`cxc config list-theme`).
|
|
223
|
+
- **`cxc state`** — a system report covering distro, kernel, ffmpeg, API key status, Python/venv, config permissions, and folders.
|
|
224
|
+
- **`cxc about`** — a short about screen with author, license, and project links.
|
|
225
|
+
- **New config keys** — `LOADING_STYLES` and `THEME`, plus the TOML file is now grouped into `[ai]`, `[appearance]`, and `[folders]`.
|
|
226
|
+
|
|
227
|
+
## What's New in v1.1.0
|
|
228
|
+
|
|
229
|
+
- **Smarter `cxc update`** — the updater now checks PyPI for the latest release and only offers to upgrade when a newer version exists, instead of always running `pipx upgrade`.
|
|
230
|
+
- **Download hands off to mpx** — after a download finishes, cxc prints the saved track name and points you to `cxc mpx` to play it, instead of spawning a separate mpv player.
|
|
231
|
+
- **Cleanup** — removed leftover mpv playback code and unused imports from `cxc.py`, `downloader.py`, and `chat.py`.
|
|
232
|
+
|
|
233
|
+
## What's New in v1.0.0 (First Stable Release)
|
|
234
|
+
|
|
235
|
+
- **Video Downloader (DV)** — download videos with yt-dlp and pick the resolution, e.g. `cxc DV -r "360" "<URL>"`.
|
|
236
|
+
- **Self Update** — update cxc straight from the terminal using `pipx upgrade`, e.g. `cxc update`.
|
|
237
|
+
- **Local Search** — find your downloaded music/videos on your device with partial-title and typo-tolerant matching, e.g. `cxc search --local "<music title>"`.
|
|
238
|
+
- **New config format** — configuration moved from `config.py` to `config.toml`, with automatic migration from the old file. See the [Configuration](#configuration) section.
|
|
239
|
+
- **VLC-based mpx** — the music player now uses `python-vlc` with full playback controls (pause, next/prev, volume), with an automatic `mpv` fallback.
|
|
240
|
+
- **pyproject.toml** — packaging moved from `setup.py` to the modern `pyproject.toml` standard.
|
|
241
|
+
|
|
242
|
+
**Notes**
|
|
243
|
+
|
|
244
|
+
- Before using the chat feature, please set your configuration first in `~/.config/cxc/config.toml` (see [Configuration](#configuration)).
|
|
245
|
+
- The current release is **v2.0.0**.
|
|
246
|
+
- The `1.26.x` versions were the **nightly** channel. **v1.0.0 is the first stable release** of CXC, so the versioning restarts from here.
|
|
247
|
+
|
|
248
|
+
I will update regularly but I can't guarantee it, so see you in the next update.
|
cxc-2.0.0/README.md
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
**CodeX Core CXC**
|
|
2
|
+
|
|
3
|
+
Hello everyone, my name is Rion. This is my boredom project, which might be useful for you. This tool has several features such as:
|
|
4
|
+
|
|
5
|
+
**Features**
|
|
6
|
+
|
|
7
|
+
- Download Music with yt-dlp
|
|
8
|
+
- Search Music with yt-dlp
|
|
9
|
+
- Video Downloader (DV)
|
|
10
|
+
- Local Search (typo-tolerant)
|
|
11
|
+
- mpx Music Player X (VLC / mpv)
|
|
12
|
+
- AI Chat — full terminal UI built with Textual
|
|
13
|
+
- Send images and text files to the AI from chat (`/file`)
|
|
14
|
+
- Theme picker with automatic saving
|
|
15
|
+
- Config manager (`path`, `edit`, `reset`, `set`, `list-theme`)
|
|
16
|
+
- System state report (`state`)
|
|
17
|
+
- About screen (`about`)
|
|
18
|
+
- Self Update (checks PyPI, upgrades via pipx)
|
|
19
|
+
|
|
20
|
+
**How to use**
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
cxc help
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Commands**
|
|
27
|
+
|
|
28
|
+
| Command | Alias | Description |
|
|
29
|
+
| ------------------------------ | ----- | ------------------------------------ |
|
|
30
|
+
| `cxc search "<title>"` | `-S` | Search music information |
|
|
31
|
+
| `cxc search --local "<title>"` | | Search your downloaded files locally |
|
|
32
|
+
| `cxc download "<title>"` | `-D` | Search and download music to MP3 |
|
|
33
|
+
| `cxc DV -r "<res>" "<URL>"` | | Download a video at a chosen quality |
|
|
34
|
+
| `cxc mpx` | | Open Music Player X |
|
|
35
|
+
| `cxc chat` | | Open the AI chat UI |
|
|
36
|
+
| `cxc state` | | Display current system state |
|
|
37
|
+
| `cxc about` | | Show information about cxc |
|
|
38
|
+
| `cxc config <subcommand>` | | Manage the cxc configuration |
|
|
39
|
+
| `cxc time` | `-t` | Show time, day, month, and year |
|
|
40
|
+
| `cxc update` | `-U` | Check PyPI and update via `pipx` |
|
|
41
|
+
| `cxc version` | `-v` | Show the current version |
|
|
42
|
+
| `cxc help` | `h` | Display the help menu |
|
|
43
|
+
|
|
44
|
+
**mpx (Music Player X)**
|
|
45
|
+
|
|
46
|
+
`cxc mpx` opens an interactive player. It uses **python-vlc** when available and automatically falls back to **mpv** otherwise.
|
|
47
|
+
|
|
48
|
+
| Command | Description |
|
|
49
|
+
| ----------------- | --------------------------------- |
|
|
50
|
+
| `play <n>` | Play track number `<n>` |
|
|
51
|
+
| `play all` | Play every track in the folder |
|
|
52
|
+
| `play <filename>` | Play a file by name |
|
|
53
|
+
| `pause` | Pause / resume |
|
|
54
|
+
| `resume` | Resume playback |
|
|
55
|
+
| `stop` | Stop playback |
|
|
56
|
+
| `next` / `prev` | Next / previous track |
|
|
57
|
+
| `volume <0-100>` | Set volume (no argument shows it) |
|
|
58
|
+
| `now` | Show the current track |
|
|
59
|
+
| `list` | List all tracks |
|
|
60
|
+
| `help` | Show the mpx help |
|
|
61
|
+
| `quit` | Exit mpx |
|
|
62
|
+
|
|
63
|
+
> Note: python-vlc needs the native **libvlc** library. On systems without it, `cxc mpx` falls back to **mpv** (with limited controls: no pause/next/prev/volume).
|
|
64
|
+
|
|
65
|
+
**AI Chat**
|
|
66
|
+
|
|
67
|
+
`cxc chat` opens a Textual-based chat UI with Markdown rendering and streamed "typing" feedback.
|
|
68
|
+
|
|
69
|
+
| Input / Key | Description |
|
|
70
|
+
| ---------------------------- | -------------------------------------------------------- |
|
|
71
|
+
| `<message>` | Send a message to the AI |
|
|
72
|
+
| `/file <path> <prompt>` | Send a file to the AI, with an optional prompt |
|
|
73
|
+
| `help` | Open the in-app help screen |
|
|
74
|
+
| `quit` | Leave the chat |
|
|
75
|
+
| `Ctrl+Q` | Quit the app |
|
|
76
|
+
| `Ctrl+H` | Open the help screen |
|
|
77
|
+
| `Ctrl+P` | Open the Textual command palette (theme picker, etc.) |
|
|
78
|
+
|
|
79
|
+
File support:
|
|
80
|
+
|
|
81
|
+
- **Images** — `.jpg`, `.jpeg`, `.png`, `.webp` are sent inline as base64 so the model can see them.
|
|
82
|
+
```
|
|
83
|
+
/file ~/photo.png Look at this.
|
|
84
|
+
```
|
|
85
|
+
- **Text files** — any other extension is read as UTF-8 and appended to your prompt.
|
|
86
|
+
```
|
|
87
|
+
/file ~/notes.txt Summarize this.
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The theme is saved to `~/.config/cxc/config.toml` automatically when you change it, so your choice sticks between sessions.
|
|
91
|
+
|
|
92
|
+
**Configuration**
|
|
93
|
+
|
|
94
|
+
cxc stores its settings in `~/.config/cxc/config.toml` (TOML format). The file is created automatically on first run — just edit it and restart cxc.
|
|
95
|
+
|
|
96
|
+
```toml
|
|
97
|
+
# CodeX Core (cxc) configuration
|
|
98
|
+
# Edit this file then restart cxc.
|
|
99
|
+
|
|
100
|
+
[ai]
|
|
101
|
+
API = "PASTE_YOUR_API_KEY"
|
|
102
|
+
MODEL = "gemini-2.5-flash"
|
|
103
|
+
# AI_PROMPT may reference other keys, e.g. {AI_NAME}
|
|
104
|
+
AI_PROMPT = "You Are {AI_NAME}"
|
|
105
|
+
|
|
106
|
+
[appearance]
|
|
107
|
+
LOADING_STYLES = "#"
|
|
108
|
+
AI_NAME = "Your_Ai_Name"
|
|
109
|
+
THEME = "catppuccin-mocha"
|
|
110
|
+
|
|
111
|
+
[folders]
|
|
112
|
+
MUSIC_DIR = "Music"
|
|
113
|
+
VIDEO_DIR = "Videos"
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
| Key | Description |
|
|
117
|
+
| ---------------- | -------------------------------------------------------------- |
|
|
118
|
+
| `API` | Your Gemini API key (required for `cxc chat`). |
|
|
119
|
+
| `MODEL` | The AI model to use, e.g. `gemini-2.5-flash`. |
|
|
120
|
+
| `AI_PROMPT` | The system prompt. May reference other keys, e.g. `{AI_NAME}`. |
|
|
121
|
+
| `LOADING_STYLES` | Character used for the animated "typing" indicator in chat. |
|
|
122
|
+
| `AI_NAME` | The name shown for the AI in chat. |
|
|
123
|
+
| `THEME` | Textual theme used by the chat UI (see `list-theme`). |
|
|
124
|
+
| `MUSIC_DIR` | Folder for downloaded music, relative to your home directory. |
|
|
125
|
+
| `VIDEO_DIR` | Folder for downloaded videos, relative to your home directory. |
|
|
126
|
+
|
|
127
|
+
**Managing the config**
|
|
128
|
+
|
|
129
|
+
| Command | Description |
|
|
130
|
+
| ------------------------------ | -------------------------------------------- |
|
|
131
|
+
| `cxc config` | Show the config help |
|
|
132
|
+
| `cxc config path` | Show the config directory |
|
|
133
|
+
| `cxc config edit` | Open `config.toml` in `$EDITOR`/nano/vim |
|
|
134
|
+
| `cxc config reset` | Reset the config to defaults |
|
|
135
|
+
| `cxc config set <KEY> <VALUE>` | Set a single value in `config.toml` |
|
|
136
|
+
| `cxc config list-theme` | List available Textual themes |
|
|
137
|
+
|
|
138
|
+
Examples:
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
cxc config path
|
|
142
|
+
cxc config set THEME catppuccin-mocha
|
|
143
|
+
cxc config set AI_NAME Nova
|
|
144
|
+
cxc config list-theme
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
> `cxc config reset` wipes **all** settings, including your API key. Back up first.
|
|
148
|
+
|
|
149
|
+
**State**
|
|
150
|
+
|
|
151
|
+
`cxc state` prints a quick diagnostic report:
|
|
152
|
+
|
|
153
|
+
- distro name and ID, kernel version
|
|
154
|
+
- whether **ffmpeg** is installed
|
|
155
|
+
- whether the API key is configured
|
|
156
|
+
- Python binary and version
|
|
157
|
+
- whether you are inside a virtualenv
|
|
158
|
+
- config file permissions (warns if not `600`)
|
|
159
|
+
- config directory and music directory
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
===========================================
|
|
163
|
+
CXC STATE...
|
|
164
|
+
===========================================
|
|
165
|
+
Distro : ...
|
|
166
|
+
Kernel : ...
|
|
167
|
+
FFmpeg : Installed
|
|
168
|
+
APIKEY : Active
|
|
169
|
+
Python3 : ... (3-11-0)
|
|
170
|
+
Env : system
|
|
171
|
+
Config Mode : 0o600 (Secure)
|
|
172
|
+
Config DIR : /home/you/.config/cxc/config.toml
|
|
173
|
+
Music DIR : /home/you/Music
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
**About**
|
|
177
|
+
|
|
178
|
+
`cxc about` shows the project name, author, license, PyPI/GitHub links, and a short description of cxc.
|
|
179
|
+
|
|
180
|
+
**Config format & migration**
|
|
181
|
+
|
|
182
|
+
The configuration format changed from a Python file (`config.py`) to **TOML** (`config.toml`). You don't need to do anything manually:
|
|
183
|
+
|
|
184
|
+
- If you upgrade from an old version, cxc migrates automatically the first time you run it:
|
|
185
|
+
1. reads your old `config.py`,
|
|
186
|
+
2. writes the new `config.toml`,
|
|
187
|
+
3. keeps a backup of the old file as `config.py.bak`,
|
|
188
|
+
4. removes the old `.lock` file.
|
|
189
|
+
- Your API key and all other settings are preserved.
|
|
190
|
+
- If you have no old config, a fresh `config.toml` is created for you.
|
|
191
|
+
- The file is stored with owner-only permissions (`600`) because it holds your API key.
|
|
192
|
+
- cxc now requires **Python 3.11+** (for the built-in `tomllib`).
|
|
193
|
+
|
|
194
|
+
**Update**
|
|
195
|
+
|
|
196
|
+
## What's New in v2.0.0
|
|
197
|
+
|
|
198
|
+
- **New `cxc chat`** — the AI chat was rebuilt as a Textual terminal UI: Markdown bubbles, animated typing indicator, help screen, themes, and a footer with key bindings.
|
|
199
|
+
- **Send files to the AI** — `/file <path> <prompt>` supports images (`.jpg`, `.jpeg`, `.png`, `.webp`, sent inline) and plain-text files.
|
|
200
|
+
- **Config manager** — `cxc config path|edit|reset|set|list-theme` to inspect and change settings without opening the file by hand, including a theme picker (`cxc config list-theme`).
|
|
201
|
+
- **`cxc state`** — a system report covering distro, kernel, ffmpeg, API key status, Python/venv, config permissions, and folders.
|
|
202
|
+
- **`cxc about`** — a short about screen with author, license, and project links.
|
|
203
|
+
- **New config keys** — `LOADING_STYLES` and `THEME`, plus the TOML file is now grouped into `[ai]`, `[appearance]`, and `[folders]`.
|
|
204
|
+
|
|
205
|
+
## What's New in v1.1.0
|
|
206
|
+
|
|
207
|
+
- **Smarter `cxc update`** — the updater now checks PyPI for the latest release and only offers to upgrade when a newer version exists, instead of always running `pipx upgrade`.
|
|
208
|
+
- **Download hands off to mpx** — after a download finishes, cxc prints the saved track name and points you to `cxc mpx` to play it, instead of spawning a separate mpv player.
|
|
209
|
+
- **Cleanup** — removed leftover mpv playback code and unused imports from `cxc.py`, `downloader.py`, and `chat.py`.
|
|
210
|
+
|
|
211
|
+
## What's New in v1.0.0 (First Stable Release)
|
|
212
|
+
|
|
213
|
+
- **Video Downloader (DV)** — download videos with yt-dlp and pick the resolution, e.g. `cxc DV -r "360" "<URL>"`.
|
|
214
|
+
- **Self Update** — update cxc straight from the terminal using `pipx upgrade`, e.g. `cxc update`.
|
|
215
|
+
- **Local Search** — find your downloaded music/videos on your device with partial-title and typo-tolerant matching, e.g. `cxc search --local "<music title>"`.
|
|
216
|
+
- **New config format** — configuration moved from `config.py` to `config.toml`, with automatic migration from the old file. See the [Configuration](#configuration) section.
|
|
217
|
+
- **VLC-based mpx** — the music player now uses `python-vlc` with full playback controls (pause, next/prev, volume), with an automatic `mpv` fallback.
|
|
218
|
+
- **pyproject.toml** — packaging moved from `setup.py` to the modern `pyproject.toml` standard.
|
|
219
|
+
|
|
220
|
+
**Notes**
|
|
221
|
+
|
|
222
|
+
- Before using the chat feature, please set your configuration first in `~/.config/cxc/config.toml` (see [Configuration](#configuration)).
|
|
223
|
+
- The current release is **v2.0.0**.
|
|
224
|
+
- The `1.26.x` versions were the **nightly** channel. **v1.0.0 is the first stable release** of CXC, so the versioning restarts from here.
|
|
225
|
+
|
|
226
|
+
I will update regularly but I can't guarantee it, so see you in the next update.
|
{cxc-1.26.4 → cxc-2.0.0}/chat.py
RENAMED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import os,
|
|
1
|
+
import requests, os, base64, sys
|
|
2
2
|
from textual.app import App, ComposeResult
|
|
3
3
|
from textual.containers import Horizontal, Vertical, ScrollableContainer, Center
|
|
4
|
-
from textual.widgets import Header, Footer, Input, Static, Markdown
|
|
4
|
+
from textual.widgets import Header, Footer, Input, Static, Markdown, LoadingIndicator
|
|
5
5
|
from textual.binding import Binding
|
|
6
6
|
from textual.screen import ModalScreen
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
from pathlib import Path
|
|
8
|
+
from config_loader import load_config, set_conf
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
config = importlib.util.module_from_spec(spec)
|
|
14
|
-
spec.loader.exec_module(config)
|
|
15
|
-
CVT = config.Config
|
|
16
|
-
|
|
10
|
+
CVT = load_config()
|
|
11
|
+
style = CVT.LOADING_STYLES
|
|
17
12
|
|
|
18
13
|
API_KEY = f"{CVT.API}"
|
|
19
14
|
MODEL_AI = f"{CVT.MODEL}"
|
|
@@ -31,6 +26,13 @@ class HelpScreen(ModalScreen):
|
|
|
31
26
|
"""[ HELP ]
|
|
32
27
|
|
|
33
28
|
quit : Go out
|
|
29
|
+
/file : Send Media To Ai
|
|
30
|
+
|
|
31
|
+
Example
|
|
32
|
+
|
|
33
|
+
- /file <path> <prompt>
|
|
34
|
+
|
|
35
|
+
- /file ~/photo.png Look at this.
|
|
34
36
|
|
|
35
37
|
Press ESC to close
|
|
36
38
|
""",
|
|
@@ -45,6 +47,7 @@ class ChatBubble(Markdown):
|
|
|
45
47
|
pass
|
|
46
48
|
|
|
47
49
|
class CodeX(App):
|
|
50
|
+
|
|
48
51
|
CSS = """
|
|
49
52
|
Screen {
|
|
50
53
|
background: #1a1a1a;
|
|
@@ -120,6 +123,8 @@ class CodeX(App):
|
|
|
120
123
|
Binding("ctrl+H", "help", "Help", priority=True),
|
|
121
124
|
]
|
|
122
125
|
|
|
126
|
+
def _handle_exception(self, error: Exception) -> None:
|
|
127
|
+
self.exit(message=f"Error ({type(error).__name__}): {error}")
|
|
123
128
|
|
|
124
129
|
def compose(self):
|
|
125
130
|
yield Header(name="CodeX Core", classes="header")
|
|
@@ -128,9 +133,35 @@ class CodeX(App):
|
|
|
128
133
|
yield Input(placeholder="Type a message ...", id="input-box")
|
|
129
134
|
yield Footer()
|
|
130
135
|
|
|
131
|
-
def on_mount(self):
|
|
136
|
+
def on_mount(self) -> None:
|
|
137
|
+
self.theme = getattr(CVT, "THEME", "catppuccin-mocha")
|
|
132
138
|
self.query_one("#input-box", Input).focus()
|
|
133
139
|
|
|
140
|
+
def watch_theme(self, new_theme: str) -> None:
|
|
141
|
+
set_conf("THEME", new_theme)
|
|
142
|
+
|
|
143
|
+
def show_typing(self):
|
|
144
|
+
chat = self.query_one("#chat-area", ScrollableContainer)
|
|
145
|
+
col = Vertical(id="typing-indicator")
|
|
146
|
+
col.styles.height = 2
|
|
147
|
+
col.styles.width = "100%"
|
|
148
|
+
lbl = Static(f"{CVT.AI_NAME} is typing...")
|
|
149
|
+
lbl.styles.color = "#777777"
|
|
150
|
+
loader = Static("•")
|
|
151
|
+
loader.styles.color = "#888888"
|
|
152
|
+
dots = [f"[{style}___]", f"[{style}{style}__]", f"[{style}{style}{style}_]", f"[{style}{style}{style}{style}]"]
|
|
153
|
+
loader.set_interval(0.3, lambda: loader.update(dots[int(__import__("time").time() * 3) % 4]))
|
|
154
|
+
chat.mount(col)
|
|
155
|
+
col.mount(lbl)
|
|
156
|
+
col.mount(loader)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def hide_typing(self):
|
|
160
|
+
try:
|
|
161
|
+
self.query_one("#typing-indicator").remove()
|
|
162
|
+
except Exception:
|
|
163
|
+
pass
|
|
164
|
+
|
|
134
165
|
def on_input_submitted(self, event: Input.Submitted):
|
|
135
166
|
msg = event.value.strip()
|
|
136
167
|
if not msg:
|
|
@@ -146,10 +177,54 @@ class CodeX(App):
|
|
|
146
177
|
event.input.focus()
|
|
147
178
|
return
|
|
148
179
|
|
|
180
|
+
elif msg.lower().startswith("/file "):
|
|
181
|
+
parts = msg.split(" ", 2)
|
|
182
|
+
file_path = os.path.expanduser(parts[1]) if len(parts) > 1 else ""
|
|
183
|
+
prompt = parts[2] if len(parts) > 2 else "Analyze this file."
|
|
184
|
+
|
|
185
|
+
if not os.path.isfile(file_path):
|
|
186
|
+
self.add_ai_msg(f"File not found: `{file_path}`")
|
|
187
|
+
self.query_one("#input-box", Input).value = ""
|
|
188
|
+
return
|
|
189
|
+
|
|
190
|
+
ext = os.path.splitext(file_path)[1].lower()
|
|
191
|
+
mime_types = {
|
|
192
|
+
".jpg": "image/jpeg",
|
|
193
|
+
".jpeg": "image/jpeg",
|
|
194
|
+
".png": "image/png",
|
|
195
|
+
".webp": "image/webp",
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if ext in mime_types:
|
|
199
|
+
with open(file_path, "rb") as f:
|
|
200
|
+
b64_data = base64.b64encode(f.read()).decode("utf-8")
|
|
201
|
+
ai_parts = [
|
|
202
|
+
{"text": prompt},
|
|
203
|
+
{
|
|
204
|
+
"inline_data": {
|
|
205
|
+
"mime_type": mime_types[ext],
|
|
206
|
+
"data": b64_data
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
]
|
|
210
|
+
self.add_user_msg(f"🖼️ **{file_path}**\n\n{prompt}")
|
|
211
|
+
else:
|
|
212
|
+
with open(file_path, "r", encoding="utf-8") as f:
|
|
213
|
+
file_content = f.read()
|
|
214
|
+
full_msg = f"{prompt}\n\n--- File: {file_path} ---\n{file_content}"
|
|
215
|
+
ai_parts = [{"text": full_msg}]
|
|
216
|
+
self.add_user_msg(f"📄 **{file_path}**\n\n{prompt}")
|
|
217
|
+
|
|
218
|
+
self.query_one("#input-box", Input).value = ""
|
|
219
|
+
self.run_worker(lambda: self.get_ai_response(ai_parts), name="ai_request", thread=True)
|
|
220
|
+
return
|
|
149
221
|
|
|
150
222
|
self.add_user_msg(msg)
|
|
151
223
|
self.query_one("#input-box", Input).value = ""
|
|
152
|
-
self.
|
|
224
|
+
self.show_typing()
|
|
225
|
+
self.run_worker(lambda: self.get_ai_response([{"text": msg}]), name="ai_request", thread=True)
|
|
226
|
+
|
|
227
|
+
|
|
153
228
|
|
|
154
229
|
def add_user_msg(self, text):
|
|
155
230
|
chat = self.query_one("#chat-area", ScrollableContainer)
|
|
@@ -164,6 +239,7 @@ class CodeX(App):
|
|
|
164
239
|
chat.scroll_end()
|
|
165
240
|
|
|
166
241
|
def add_ai_msg(self, text):
|
|
242
|
+
self.hide_typing()
|
|
167
243
|
chat = self.query_one("#chat-area", ScrollableContainer)
|
|
168
244
|
col = Vertical(classes="ai-row")
|
|
169
245
|
col.styles.width = "100%"
|
|
@@ -178,10 +254,10 @@ class CodeX(App):
|
|
|
178
254
|
col.mount(bubble)
|
|
179
255
|
chat.scroll_end()
|
|
180
256
|
|
|
181
|
-
def get_ai_response(self,
|
|
257
|
+
def get_ai_response(self, parts):
|
|
182
258
|
history.append({
|
|
183
259
|
"role": "user",
|
|
184
|
-
"parts":
|
|
260
|
+
"parts": parts
|
|
185
261
|
})
|
|
186
262
|
SYS_PROMPT = f"{CVT.AI_PROMPT}"
|
|
187
263
|
payload = {
|