ineedcodes 1.6.0 → 1.6.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ineedcodes",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Your terminal, now autonomous. Just say what you want, ineed does the rest.",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/src/session.js CHANGED
@@ -505,6 +505,7 @@ export async function startSession(cfg, { fresh = false, resume = null } = {}) {
505
505
  if (s?.history?.length) {
506
506
  history = s.history;
507
507
  sessionId = s.id;
508
+ renderHistory(s.history);
508
509
  say(green(`Resumed ${s.id} (${Math.floor(s.history.length / 2)} turns). Continue where we left off.`));
509
510
  } else say(red(`No session with code ${codeArg}. Check /resume for the list of codes.`));
510
511
  busy = false;
@@ -519,6 +520,7 @@ export async function startSession(cfg, { fresh = false, resume = null } = {}) {
519
520
  if (s?.history?.length) {
520
521
  history = s.history;
521
522
  sessionId = s.id;
523
+ renderHistory(s.history);
522
524
  say(green(`Resumed ${s.id} (${Math.floor(s.history.length / 2)} turns). Continue where we left off.`));
523
525
  if (TUI) redrawChat();
524
526
  } else say(red(`No session with code ${pick}. Check the list above.`));
@@ -645,14 +647,14 @@ export async function startSession(cfg, { fresh = false, resume = null } = {}) {
645
647
  }
646
648
 
647
649
  function redrawChat() {
648
- for (let i = chatTop; i <= chatBot; i++) {
649
- screen.at(i, 1);
650
- screen.clearLine();
651
- }
652
- screen.at(chatTop, 1);
650
+ // build the whole frame in one buffer, then paint once: no flicker
653
651
  const vis = chatBot - chatTop + 1;
654
652
  const show = chatLines.slice(-vis);
655
- process.stdout.write(show.join('\r\n'));
653
+ let buf = '';
654
+ for (let i = 0; i < vis; i++) {
655
+ buf += `\x1b[${chatTop + i};1H\x1b[2K` + (show[i] ?? '');
656
+ }
657
+ process.stdout.write(buf);
656
658
  scrollRegion();
657
659
  }
658
660
 
@@ -661,10 +663,29 @@ export async function startSession(cfg, { fresh = false, resume = null } = {}) {
661
663
  redrawChat();
662
664
  }
663
665
 
664
- const tuiUserLine = input => {
666
+ function renderHistory(h) {
667
+ if (!TUI) {
668
+ for (const m of h) {
669
+ const c = String(m.content ?? '').replaceAll('\n', ' ').slice(0, 90);
670
+ if (c) console.log(' ' + gray((m.role === 'user' ? 'you: ' : 'ineed: ') + c));
671
+ }
672
+ return;
673
+ }
674
+ if (!tuiReady) return;
675
+ setTimeout(() => {
676
+ for (const m of h) {
677
+ if (m.role === 'user') tuiUserLine(String(m.content ?? ''));
678
+ else if (m.content) tuiPrint(box([dim(' (earlier) ') + trunc(String(m.content).replaceAll('\n', ' '), 90)]));
679
+ }
680
+ drawStatus();
681
+ scrollRegion();
682
+ }, 0);
683
+ }
684
+
685
+ function tuiUserLine(input) {
665
686
  for (const l of wrapLines(userBubble(input), Math.max(10, (process.stdout.columns || 80) - 4))) chatLines.push(l);
666
687
  redrawChat();
667
- };
688
+ }
668
689
 
669
690
  const layout = () => {
670
691
  const rows = process.stdout.rows || 24;
@@ -682,6 +703,18 @@ export async function startSession(cfg, { fresh = false, resume = null } = {}) {
682
703
 
683
704
  rl.on('resize', layout);
684
705
 
706
+ // typed-ahead input while busy: echo it above the status bar so the user sees what they type
707
+ let typedAhead = '';
708
+ rl.on('keypress', (ch, key) => {
709
+ if (!busy || !key) return;
710
+ if (key.name === 'backspace') typedAhead = typedAhead.slice(0, -1);
711
+ else if (key.name === 'return') typedAhead = '';
712
+ else if (key.ctrl || !ch || ch < ' ') return;
713
+ else typedAhead += ch;
714
+ process.stdout.write(`\x1b[${statusRow - 1};1H\x1b[2K` + dim(' you: ') + typedAhead);
715
+ scrollRegion();
716
+ });
717
+
685
718
  // keep Ctrl+Z from suspending us in raw mode: swallow the key, tell the user
686
719
  const origWrite = rl.write.bind(rl);
687
720
  rl.write = (d, key) => {
package/src/ui.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // ui.js: terminal helpers. No dependencies, respects NO_COLOR and non-TTY.
2
2
 
3
- export const VERSION = '1.6.0';
3
+ export const VERSION = '1.6.1';
4
4
 
5
5
  const USE_COLOR = process.stdout.isTTY && !process.env.NO_COLOR;
6
6
  const wrap = (code, t) => USE_COLOR ? `\x1b[${code}m${t}\x1b[0m` : String(t);