coder-agent 2.7.1 → 2.7.2

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.
Files changed (2) hide show
  1. package/dist/index.js +44 -19
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -183,10 +183,52 @@ async function main() {
183
183
  if (!apiKey) {
184
184
  apiKey = await promptApiKey();
185
185
  }
186
+ let currentAbortController = null;
187
+ let originalListeners = [];
188
+ let isHijacked = false;
189
+ let tempSigintHandler = null;
190
+ const startHijack = () => {
191
+ if (isHijacked)
192
+ return;
193
+ originalListeners = process.stdin.listeners("data");
194
+ for (const listener of originalListeners) {
195
+ process.stdin.removeListener("data", listener);
196
+ }
197
+ tempSigintHandler = (data) => {
198
+ if (data.includes(3)) { // Ctrl+C byte
199
+ if (currentAbortController) {
200
+ currentAbortController.abort();
201
+ }
202
+ }
203
+ };
204
+ process.stdin.on("data", tempSigintHandler);
205
+ process.stdin.resume();
206
+ isHijacked = true;
207
+ };
208
+ const stopHijack = () => {
209
+ if (!isHijacked)
210
+ return;
211
+ process.stdin.removeListener("data", tempSigintHandler);
212
+ for (const listener of originalListeners) {
213
+ process.stdin.on("data", listener);
214
+ }
215
+ originalListeners = [];
216
+ tempSigintHandler = null;
217
+ isHijacked = false;
218
+ };
186
219
  const confirmHandler = async (question) => {
187
220
  if (rl) {
221
+ const wasHijacked = isHijacked;
222
+ if (wasHijacked) {
223
+ stopHijack();
224
+ rl.resume();
225
+ }
188
226
  return new Promise((resolve) => {
189
227
  rl.question(question, (answer) => {
228
+ if (wasHijacked) {
229
+ rl.pause();
230
+ startHijack();
231
+ }
190
232
  resolve(answer.trim().toLowerCase().startsWith("y"));
191
233
  });
192
234
  });
@@ -236,7 +278,6 @@ async function main() {
236
278
  let inputBuffer = "";
237
279
  let pasteTimeout = null;
238
280
  let lineCountInBurst = 0;
239
- let currentAbortController = null;
240
281
  async function executeAgentChat(trimmed) {
241
282
  // Pause standard input processing during agent thinking & updates
242
283
  rl.pause();
@@ -294,20 +335,7 @@ async function main() {
294
335
  return;
295
336
  }
296
337
  currentAbortController = new AbortController();
297
- // Hijack stdin data listeners during agent execution to allow Ctrl+C to abort the agent immediately
298
- const originalListeners = process.stdin.listeners("data");
299
- for (const listener of originalListeners) {
300
- process.stdin.removeListener("data", listener);
301
- }
302
- const tempSigintHandler = (data) => {
303
- if (data.includes(3)) { // Ctrl+C byte
304
- if (currentAbortController) {
305
- currentAbortController.abort();
306
- }
307
- }
308
- };
309
- process.stdin.on("data", tempSigintHandler);
310
- process.stdin.resume();
338
+ startHijack();
311
339
  try {
312
340
  await agent.chat(trimmed, currentAbortController.signal);
313
341
  }
@@ -329,10 +357,7 @@ async function main() {
329
357
  }
330
358
  }
331
359
  finally {
332
- process.stdin.removeListener("data", tempSigintHandler);
333
- for (const listener of originalListeners) {
334
- process.stdin.on("data", listener);
335
- }
360
+ stopHijack();
336
361
  currentAbortController = null;
337
362
  }
338
363
  rl.resume();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coder-agent",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "CLI coding agent powered by Google Gemini",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",