junecoder 1.0.12 → 1.0.13

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/package.json +1 -1
  2. package/tui.mjs +27 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "junecoder",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "Zero Npm Dependencies Agent Framework",
5
5
  "main": "agent.mjs",
6
6
  "type": "module",
package/tui.mjs CHANGED
@@ -272,19 +272,32 @@ export async function startTUI(agent, opts = {}) {
272
272
 
273
273
  keyStream.on("keypress", (str, key) => {
274
274
  if (state.permission) {
275
- const ch = (str || key.name || "").toLowerCase();
276
- if (ch === "y" || key.name === "y") state.permission.resolve({ allowed: true });
277
- else if (ch === "a" || key.name === "a") { agent.autoApprove = true; state.permission.resolve({ allowed: true }); pushLine(" [auto] Auto-approve ON.", C.warn); }
278
- else if (ch === "n" || key.name === "n") {
279
- // Enter reason mode
280
- state.permission.reasonMode = true;
281
- state.input = []; state.cursor = 0;
282
- state.status = "Denied — why? (Enter to send, Esc to skip)";
283
- render();
284
- return;
275
+ if (state.permission.reasonMode) {
276
+ // In reason mode: Escape cancels, everything else passes through for typing
277
+ if (key.name === "escape") {
278
+ state.input = []; state.cursor = 0;
279
+ const resolve = state.permission.resolve;
280
+ state.permission = null; state.permissionPreview = [];
281
+ state.status = state.processing ? "Processing..." : "Ready";
282
+ resolve({ allowed: false });
283
+ render(); return;
284
+ }
285
+ // Fall through to normal key handling (typing, Enter→submit, Ctrl+C, etc.)
286
+ } else {
287
+ const ch = (str || key.name || "").toLowerCase();
288
+ if (ch === "y" || key.name === "y") state.permission.resolve({ allowed: true });
289
+ else if (ch === "a" || key.name === "a") { agent.autoApprove = true; state.permission.resolve({ allowed: true }); pushLine(" [auto] Auto-approve ON.", C.warn); }
290
+ else if (ch === "n" || key.name === "n") {
291
+ // Enter reason mode
292
+ state.permission.reasonMode = true;
293
+ state.input = []; state.cursor = 0;
294
+ state.status = "Denied — why? (Enter to send, Esc to skip)";
295
+ render();
296
+ return;
297
+ }
298
+ else return;
299
+ state.permission = null; state.permissionPreview = []; state.status = state.processing ? "Processing..." : "Ready"; render(); return;
285
300
  }
286
- else return;
287
- state.permission = null; state.permissionPreview = []; state.status = state.processing ? "Processing..." : "Ready"; render(); return;
288
301
  }
289
302
  if (state.question) {
290
303
  if (key.name === "return" || key.name === "enter") {
@@ -301,14 +314,6 @@ export async function startTUI(agent, opts = {}) {
301
314
  if (state.question.options.length === 0) { editInput(str, key); render(); return; }
302
315
  return;
303
316
  }
304
- if (state.permission?.reasonMode && key.name === "escape") {
305
- state.input = []; state.cursor = 0;
306
- const resolve = state.permission.resolve;
307
- state.permission = null; state.permissionPreview = [];
308
- state.status = state.processing ? "Processing..." : "Ready";
309
- resolve({ allowed: false });
310
- render(); return;
311
- }
312
317
  if (key.name === "c" && key.ctrl) {
313
318
  if (state.processing && state.controller) { state.controller.abort(); state.status = "Aborting..."; render(); }
314
319
  else { cleanup(); process.exit(0); }
@@ -360,7 +365,8 @@ export async function startTUI(agent, opts = {}) {
360
365
 
361
366
  async function submit() {
362
367
  const text = state.input.join("").trim();
363
- if (!text || (state.processing && !state.permission?.reasonMode)) return;
368
+ if (!text && !state.permission?.reasonMode) return;
369
+ if (state.processing && !state.permission?.reasonMode) return;
364
370
 
365
371
  // ─── Permission reason mode ────────────────────────────────────────────
366
372
  if (state.permission?.reasonMode) {