ccx-relay 1.6.1 → 1.7.0
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.
- package/.env.example +12 -0
- package/README.md +23 -19
- package/package.json +3 -2
- package/src/gemini.js +3 -5
package/.env.example
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Google Gemini API key (required).
|
|
2
|
+
# Get one at https://aistudio.google.com/apikey
|
|
3
|
+
GEMINI_API_KEY=
|
|
4
|
+
|
|
5
|
+
# Gemini model to use for prompt rewriting (optional).
|
|
6
|
+
# Default: gemini-3.5-flash
|
|
7
|
+
GEMINI_MODEL=gemini-3.5-flash
|
|
8
|
+
|
|
9
|
+
# Trailing marker that triggers "enhance current line" when you press Enter
|
|
10
|
+
# (optional). Type your prompt, append this marker, then press Enter once to
|
|
11
|
+
# enhance (not submit) - press Enter again to actually submit. Default: ;;
|
|
12
|
+
CCX_MARKER=;;
|
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ npm install -g ccx-relay
|
|
|
38
38
|
Run the one-time setup wizard:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
ccx
|
|
41
|
+
ccx init
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
This will prompt for your Gemini API key (get one at https://aistudio.google.com/apikey), validate it, let you pick a model, and save config to your user directory (`%APPDATA%\ccx\config.json` on Windows, `~/.config/ccx/config.json` on macOS/Linux). Config survives npm upgrades.
|
|
@@ -46,13 +46,13 @@ This will prompt for your Gemini API key (get one at https://aistudio.google.com
|
|
|
46
46
|
Other init commands:
|
|
47
47
|
|
|
48
48
|
```bash
|
|
49
|
-
ccx
|
|
50
|
-
ccx
|
|
49
|
+
ccx init --show # print current config (key masked)
|
|
50
|
+
ccx init --reset # wipe config and start over
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
### Environment variable override
|
|
54
54
|
|
|
55
|
-
You can skip `ccx
|
|
55
|
+
You can skip `ccx init` and set env vars directly (useful for CI):
|
|
56
56
|
|
|
57
57
|
```bash
|
|
58
58
|
export GEMINI_API_KEY=AIza...
|
|
@@ -81,14 +81,14 @@ While the wrapped process is running:
|
|
|
81
81
|
|
|
82
82
|
### Changing the marker
|
|
83
83
|
|
|
84
|
-
Change `CCX_MARKER` via `ccx
|
|
84
|
+
Change `CCX_MARKER` via `ccx init` or env var (default `;;`). No source changes needed.
|
|
85
85
|
|
|
86
86
|
## Testing it locally
|
|
87
87
|
|
|
88
88
|
1. `npm install`
|
|
89
|
-
2. `npm test` — runs
|
|
89
|
+
2. `npm run test` — runs `node --check` against the CLI entry point to catch syntax errors.
|
|
90
90
|
3. `npm link`
|
|
91
|
-
4.
|
|
91
|
+
4. Set up `.env` with a real `GEMINI_API_KEY`.
|
|
92
92
|
5. Sanity-check the relay mechanics with a safe command first, before pointing it at `claude`:
|
|
93
93
|
|
|
94
94
|
```bash
|
|
@@ -97,9 +97,9 @@ Change `CCX_MARKER` via `ccx-init` or env var (default `;;`). No source changes
|
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
You should see a completely normal shell. Type a sentence with a typo, e.g. `pls fix teh bug in server.js;;`,
|
|
100
|
-
then press **Enter**. You should see
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
then press **Enter**. You should see `[ccx] enhancing...` flash briefly, then the line rewritten in place
|
|
101
|
+
(e.g. `Please fix the bug in server.js`) with nothing submitted yet. Press Enter again to run it as a normal
|
|
102
|
+
shell command.
|
|
103
103
|
|
|
104
104
|
6. Once the mechanics check out, run it against the real target:
|
|
105
105
|
|
|
@@ -109,18 +109,22 @@ Change `CCX_MARKER` via `ccx-init` or env var (default `;;`). No source changes
|
|
|
109
109
|
|
|
110
110
|
## Known limitations
|
|
111
111
|
|
|
112
|
-
- **
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
- **Works best for single-line prompts typed straight through.** The line buffer is a plain JS string built up as
|
|
113
|
+
you type; it does not model cursor position.
|
|
114
|
+
- **Heavy mid-line editing via arrow keys is not fully tracked.** Escape sequences (arrow keys, Home/End, etc.) are
|
|
115
|
+
detected and forwarded to the child untouched so navigation still *works* visually, but `ccx`'s internal buffer
|
|
116
|
+
does not move its own "cursor" — it only appends on printable input and pops on backspace. If you arrow back into
|
|
117
|
+
the middle of a line and start editing there, the buffer sent to Gemini (and the backspace count used to erase the
|
|
118
|
+
line) can drift out of sync with what's actually on screen. Worth testing carefully before relying on it for
|
|
119
|
+
heavily-edited multi-line pastes.
|
|
115
120
|
- **Byte-wise, not codepoint-wise.** Input is processed one byte at a time; multi-byte UTF-8 characters (accents,
|
|
116
121
|
emoji, non-Latin scripts) may not round-trip through the buffer correctly, though they are still forwarded to the
|
|
117
|
-
child untouched when you're not
|
|
118
|
-
- **Status
|
|
119
|
-
|
|
120
|
-
terminal) but isn't guaranteed on every terminal emulator
|
|
121
|
-
stray line if the row count changes between draws.
|
|
122
|
+
child untouched when you're not invoking the hotkey.
|
|
123
|
+
- **Status line display is best-effort.** `ccx` uses ANSI save/restore-cursor sequences to show and clear the
|
|
124
|
+
`[ccx] enhancing...` message on its own line. This works in standard ANSI/VT terminals (including the VS Code
|
|
125
|
+
integrated terminal) but isn't guaranteed on every terminal emulator.
|
|
122
126
|
- **The marker itself is reserved.** If you genuinely need a prompt to end with `;;` literally, either add a
|
|
123
|
-
trailing space after it or change
|
|
127
|
+
trailing space after it or change `CCX_MARKER` to something you don't otherwise type.
|
|
124
128
|
|
|
125
129
|
## Windows-specific notes
|
|
126
130
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "ccx-relay",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.7.0",
|
|
5
5
|
"description": "Transparent PTY wrapper for Claude Code (or any CLI) that lets you refine your prompt with Gemini AI before submitting it, without leaving your terminal session.",
|
|
6
6
|
"main": "bin/ccx.js",
|
|
7
7
|
"bin": {
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"bin",
|
|
13
13
|
"src",
|
|
14
|
-
"README.md"
|
|
14
|
+
"README.md",
|
|
15
|
+
".env.example"
|
|
15
16
|
],
|
|
16
17
|
"scripts": {
|
|
17
18
|
"test": "node --test test/**/*.test.js",
|
package/src/gemini.js
CHANGED
|
@@ -14,11 +14,9 @@ const SYSTEM_PROMPT =
|
|
|
14
14
|
'Output must contain nothing but the rewritten line itself.';
|
|
15
15
|
|
|
16
16
|
function buildAuthHeaders(apiKey) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
// 401 Unauthorized when sent that way (confirmed against the live API).
|
|
21
|
-
return { 'x-goog-api-key': apiKey };
|
|
17
|
+
return apiKey.startsWith('AQ.')
|
|
18
|
+
? { 'Authorization': `Bearer ${apiKey}` }
|
|
19
|
+
: { 'x-goog-api-key': apiKey };
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
export async function listModels(apiKey) {
|