sapper-iq 1.1.2 → 1.1.3

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/sapper.mjs +19 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sapper-iq",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "AI-powered development assistant that executes commands and builds projects",
5
5
  "main": "sapper.mjs",
6
6
  "bin": {
package/sapper.mjs CHANGED
@@ -31,6 +31,19 @@ process.on('SIGINT', () => {
31
31
  setTimeout(() => { ctrlCCount = 0; }, 2000); // Reset after 2 seconds
32
32
  });
33
33
 
34
+ // Reset terminal state - fixes "ghost input" after shell commands or AI streaming
35
+ function resetTerminal() {
36
+ if (process.stdin.isTTY) {
37
+ try {
38
+ process.stdin.setRawMode(false); // Disable raw mode
39
+ process.stdin.pause(); // Pause the stream
40
+ process.stdin.resume(); // Resume to clear buffers
41
+ } catch (e) {
42
+ // Ignore errors if terminal is in weird state
43
+ }
44
+ }
45
+ }
46
+
34
47
  // Initialize versioning
35
48
  let CURRENT_VERSION = "1.1.0";
36
49
  try {
@@ -62,7 +75,7 @@ function recreateReadline() {
62
75
  }
63
76
 
64
77
  async function safeQuestion(query) {
65
- // Ensure we are ready to receive input
78
+ resetTerminal(); // Clear terminal state before asking
66
79
  if (rl.closed) recreateReadline();
67
80
 
68
81
  return new Promise((resolve) => {
@@ -136,11 +149,15 @@ const tools = {
136
149
  stdio: 'inherit', shell: useShell
137
150
  });
138
151
  proc.on('close', (code) => {
152
+ // Crucial: give control back to Node
153
+ if (process.stdin.isTTY) {
154
+ try { process.stdin.setRawMode(false); } catch (e) {}
155
+ }
139
156
  // Delay slightly to let terminal settle
140
157
  setTimeout(() => {
141
158
  recreateReadline();
142
159
  resolve(`Command completed with code ${code}`);
143
- }, 100);
160
+ }, 200);
144
161
  });
145
162
  });
146
163
  }