sapper-iq 1.1.16 → 1.1.18
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 +1 -1
- package/sapper.mjs +16 -5
package/package.json
CHANGED
package/sapper.mjs
CHANGED
|
@@ -27,10 +27,13 @@ process.on('SIGINT', () => {
|
|
|
27
27
|
console.log(chalk.red('\nForce quitting...'));
|
|
28
28
|
process.exit(1);
|
|
29
29
|
}
|
|
30
|
+
// Set flag to abort current stream
|
|
31
|
+
abortStream = true;
|
|
32
|
+
|
|
30
33
|
// Clear current line and move to new one - stops ghost output
|
|
31
34
|
process.stdout.clearLine(0);
|
|
32
35
|
process.stdout.cursorTo(0);
|
|
33
|
-
console.log(chalk.yellow('\
|
|
36
|
+
console.log(chalk.yellow('\n⏹️ Stopping response... (Ctrl+C again to force quit)'));
|
|
34
37
|
|
|
35
38
|
// Reset terminal immediately
|
|
36
39
|
resetTerminal();
|
|
@@ -104,6 +107,7 @@ function statusBadge(text, type = 'info') {
|
|
|
104
107
|
|
|
105
108
|
let stepMode = false;
|
|
106
109
|
let debugMode = false; // Toggle with /debug command
|
|
110
|
+
let abortStream = false; // Flag to interrupt AI response
|
|
107
111
|
let rl = readline.createInterface({
|
|
108
112
|
input: process.stdin,
|
|
109
113
|
output: process.stdout,
|
|
@@ -528,7 +532,7 @@ Do NOT just display content. Actually WRITE files using the tool.`
|
|
|
528
532
|
});
|
|
529
533
|
|
|
530
534
|
// 5. Save to context file so it persists
|
|
531
|
-
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
|
|
535
|
+
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages, null, 2));
|
|
532
536
|
|
|
533
537
|
console.log(chalk.green(`✅ Pruned context. Sapper reminded to stay in Agent Mode.`));
|
|
534
538
|
console.log(chalk.gray(`Context size: ${messages.length} messages\n`));
|
|
@@ -596,7 +600,7 @@ Do NOT just display content. Actually WRITE files using the tool.`
|
|
|
596
600
|
content: `I've scanned the entire codebase. Here are all the files:\n${formattedScan}\n\nYou now have the full codebase context. Use this information to help me.`
|
|
597
601
|
});
|
|
598
602
|
|
|
599
|
-
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
|
|
603
|
+
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages, null, 2));
|
|
600
604
|
console.log(chalk.gray('📝 Codebase added to context. AI now has full picture.\n'));
|
|
601
605
|
continue;
|
|
602
606
|
}
|
|
@@ -624,10 +628,17 @@ Do NOT just display content. Actually WRITE files using the tool.`
|
|
|
624
628
|
|
|
625
629
|
let msg = '';
|
|
626
630
|
const MAX_RESPONSE_LENGTH = 29000; // Guard against infinite loops (increased for multi-file reads)
|
|
631
|
+
abortStream = false; // Reset abort flag before streaming
|
|
627
632
|
|
|
628
633
|
console.log(chalk.magenta('┌─[') + chalk.white.bold('Sapper') + chalk.magenta(']'));
|
|
629
634
|
process.stdout.write(chalk.magenta('│ '));
|
|
630
635
|
for await (const chunk of response) {
|
|
636
|
+
// Check if user pressed Ctrl+C
|
|
637
|
+
if (abortStream) {
|
|
638
|
+
console.log(chalk.yellow('\n│ [Response interrupted]'));
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
|
|
631
642
|
const content = chunk.message.content;
|
|
632
643
|
process.stdout.write(content);
|
|
633
644
|
msg += content;
|
|
@@ -715,7 +726,7 @@ Do NOT just display content. Actually WRITE files using the tool.`
|
|
|
715
726
|
|
|
716
727
|
messages.push({ role: 'user', content: `RESULT (${path}): ${result}` });
|
|
717
728
|
}
|
|
718
|
-
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
|
|
729
|
+
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages, null, 2));
|
|
719
730
|
|
|
720
731
|
if (toolMatches.length > 30) {
|
|
721
732
|
console.log(chalk.yellow('\n⚠️ Reading 30+ files! This might take time.'));
|
|
@@ -730,7 +741,7 @@ Do NOT just display content. Actually WRITE files using the tool.`
|
|
|
730
741
|
});
|
|
731
742
|
} else {
|
|
732
743
|
// Normal response - save and wait for next input
|
|
733
|
-
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
|
|
744
|
+
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages, null, 2));
|
|
734
745
|
active = false;
|
|
735
746
|
spinner.stop(); // Ensure spinner is dead
|
|
736
747
|
resetTerminal(); // Force terminal back to normal state
|