ccx-relay 2.5.0 → 2.6.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/bin/ccx.js +21 -14
- package/package.json +1 -1
package/bin/ccx.js
CHANGED
|
@@ -92,16 +92,18 @@ const contextLines = [];
|
|
|
92
92
|
|
|
93
93
|
function stripAnsi(s) {
|
|
94
94
|
return s
|
|
95
|
-
.replace(/\x1b\[[
|
|
96
|
-
.replace(/\x1b\][^\x07]*\x07/g, '')
|
|
95
|
+
.replace(/\x1b\[[\d;?]*[A-Za-z]/g, '') // CSI (including ?-prefixed private modes)
|
|
96
|
+
.replace(/\x1b\][^\x07]*\x07/g, '') // OSC
|
|
97
|
+
.replace(/\x1b[()#;?][A-Za-z]/g, '') // other 2-byte ESC sequences
|
|
97
98
|
.replace(/\r/g, '');
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
ptyProcess.onData(data => {
|
|
101
102
|
process.stdout.write(data);
|
|
102
103
|
for (const ln of stripAnsi(data).split('\n')) {
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
const t = ln.trim();
|
|
105
|
+
if (t.length > 12) { // skip echoed single chars and short noise
|
|
106
|
+
contextLines.push(t);
|
|
105
107
|
if (contextLines.length > CONTEXT_MAX) contextLines.shift();
|
|
106
108
|
}
|
|
107
109
|
}
|
|
@@ -111,15 +113,20 @@ process.stdout.on('resize', () => {
|
|
|
111
113
|
ptyProcess.resize(process.stdout.columns, process.stdout.rows);
|
|
112
114
|
});
|
|
113
115
|
|
|
114
|
-
// ── Erase current input
|
|
115
|
-
//
|
|
116
|
-
//
|
|
117
|
-
// For multi-line
|
|
118
|
-
function eraseInput(line) {
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
ptyProcess.write('\
|
|
116
|
+
// ── Erase current input ───────────────────────────────────────────────────────
|
|
117
|
+
// Pure backspace approach — avoids Ctrl+U (\x15) which toggles Claude Code's
|
|
118
|
+
// manual mode, and Ctrl+D (\x04) which sends EOF on empty lines.
|
|
119
|
+
// For multi-line (Shift+Enter blocks): ANSI line-clear sequence per line.
|
|
120
|
+
function eraseInput(line, cursor) {
|
|
121
|
+
const parts = line.split('\n');
|
|
122
|
+
if (parts.length > 1) {
|
|
123
|
+
ptyProcess.write('\x1b[2K');
|
|
124
|
+
for (let i = 1; i < parts.length; i++) ptyProcess.write('\x1b[1A\x1b[2K');
|
|
125
|
+
ptyProcess.write('\x1b[G');
|
|
126
|
+
} else {
|
|
127
|
+
const after = line.length - cursor;
|
|
128
|
+
if (after > 0) ptyProcess.write(`\x1b[${after}C`);
|
|
129
|
+
ptyProcess.write(Buffer.alloc(line.length, 0x7f));
|
|
123
130
|
}
|
|
124
131
|
}
|
|
125
132
|
|
|
@@ -150,7 +157,7 @@ const handler = createInputHandler({
|
|
|
150
157
|
else if (err instanceof TimeoutError) msg = `Timed out after ${config.timeoutSeconds}s — original restored`;
|
|
151
158
|
else if (err instanceof NetworkError) msg = 'No connection — original restored';
|
|
152
159
|
await spinnerStop('error', msg);
|
|
153
|
-
eraseInput(line);
|
|
160
|
+
eraseInput(line, cursor);
|
|
154
161
|
ptyProcess.write(toSend);
|
|
155
162
|
handler.setBusy(false);
|
|
156
163
|
handler.setLine(toSend);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "ccx-relay",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.6.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": {
|