sapper-iq 1.1.8 ā 1.1.9
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 +45 -0
package/package.json
CHANGED
package/sapper.mjs
CHANGED
|
@@ -61,6 +61,7 @@ const spinner = ora();
|
|
|
61
61
|
const CONTEXT_FILE = '.sapper_context.json';
|
|
62
62
|
|
|
63
63
|
let stepMode = false;
|
|
64
|
+
let debugMode = false; // Toggle with /debug command
|
|
64
65
|
let rl = readline.createInterface({
|
|
65
66
|
input: process.stdin,
|
|
66
67
|
output: process.stdout,
|
|
@@ -380,6 +381,7 @@ Do NOT just display content. Actually WRITE files using the tool.`
|
|
|
380
381
|
console.log(chalk.white(' /reset, /clear') + chalk.gray(' - Clear all context and start fresh'));
|
|
381
382
|
console.log(chalk.white(' /prune') + chalk.gray(' - Remove old messages, keep last 4'));
|
|
382
383
|
console.log(chalk.white(' /context') + chalk.gray(' - Show current context size'));
|
|
384
|
+
console.log(chalk.white(' /debug') + chalk.gray(' - Toggle debug mode (shows regex analysis)'));
|
|
383
385
|
console.log(chalk.white(' /help') + chalk.gray(' - Show this help message'));
|
|
384
386
|
console.log(chalk.white(' exit') + chalk.gray(' - Exit Sapper\n'));
|
|
385
387
|
continue;
|
|
@@ -395,6 +397,16 @@ Do NOT just display content. Actually WRITE files using the tool.`
|
|
|
395
397
|
continue;
|
|
396
398
|
}
|
|
397
399
|
|
|
400
|
+
// Handle debug mode toggle
|
|
401
|
+
if (input.toLowerCase() === '/debug') {
|
|
402
|
+
debugMode = !debugMode;
|
|
403
|
+
console.log(chalk.magenta(`š§ Debug mode: ${debugMode ? 'ON' : 'OFF'}`));
|
|
404
|
+
if (debugMode) {
|
|
405
|
+
console.log(chalk.gray(' Will show regex matching details after each AI response.'));
|
|
406
|
+
}
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
|
|
398
410
|
messages.push({ role: 'user', content: input });
|
|
399
411
|
|
|
400
412
|
let toolRounds = 0; // Prevent infinite loops
|
|
@@ -436,6 +448,39 @@ Do NOT just display content. Actually WRITE files using the tool.`
|
|
|
436
448
|
// Fixed regex: .+? (non-greedy) stops correctly before [/TOOL]
|
|
437
449
|
const toolMatches = [...msg.matchAll(/\[TOOL:(\w+)\](.+?)(?:\]([\s\S]*?))?\[\/TOOL\]/g)];
|
|
438
450
|
|
|
451
|
+
// Debug mode: show what regex sees
|
|
452
|
+
if (debugMode) {
|
|
453
|
+
console.log(chalk.magenta('\nāāā DEBUG: REGEX ANALYSIS āāā'));
|
|
454
|
+
console.log(chalk.gray(`Response length: ${msg.length} chars`));
|
|
455
|
+
|
|
456
|
+
// Check for tool-like patterns
|
|
457
|
+
const hasToolStart = msg.includes('[TOOL:');
|
|
458
|
+
const hasToolEnd = msg.includes('[/TOOL]');
|
|
459
|
+
const hasBrokenEnd = msg.includes('[/]') || msg.includes('[/WRITE]') || msg.includes('[/READ]');
|
|
460
|
+
|
|
461
|
+
console.log(chalk.gray(`Contains [TOOL:: ${hasToolStart ? chalk.green('YES') : chalk.red('NO')}`));
|
|
462
|
+
console.log(chalk.gray(`Contains [/TOOL]: ${hasToolEnd ? chalk.green('YES') : chalk.red('NO')}`));
|
|
463
|
+
if (hasBrokenEnd) {
|
|
464
|
+
console.log(chalk.red(`ā ļø Found broken closing tag: [/] or [/WRITE] etc.`));
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
console.log(chalk.gray(`Matches found: ${toolMatches.length}`));
|
|
468
|
+
|
|
469
|
+
if (toolMatches.length > 0) {
|
|
470
|
+
toolMatches.forEach((m, i) => {
|
|
471
|
+
console.log(chalk.cyan(` Match ${i+1}: type=${m[1]}, path=${m[2]?.substring(0,50)}...`));
|
|
472
|
+
});
|
|
473
|
+
} else if (hasToolStart) {
|
|
474
|
+
// Show the raw tool attempt for debugging
|
|
475
|
+
const toolAttempt = msg.match(/\[TOOL:[^\]]*\][^\[]{0,100}/s);
|
|
476
|
+
if (toolAttempt) {
|
|
477
|
+
console.log(chalk.yellow(` Raw tool attempt (first 150 chars):`);
|
|
478
|
+
console.log(chalk.gray(` "${toolAttempt[0].substring(0, 150)}..."`));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
console.log(chalk.magenta('āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā\n'));
|
|
482
|
+
}
|
|
483
|
+
|
|
439
484
|
if (toolMatches.length > 0) {
|
|
440
485
|
toolRounds++;
|
|
441
486
|
|