sapper-iq 1.0.15 → 1.0.17
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 -8
package/package.json
CHANGED
package/sapper.mjs
CHANGED
|
@@ -115,7 +115,13 @@ async function runSapper() {
|
|
|
115
115
|
let messages = [];
|
|
116
116
|
if (fs.existsSync(CONTEXT_FILE)) {
|
|
117
117
|
const resume = await safeQuestion(chalk.green('Resume previous session? (y/n): '));
|
|
118
|
-
if (resume.toLowerCase() === 'y')
|
|
118
|
+
if (resume.toLowerCase() === 'y') {
|
|
119
|
+
messages = JSON.parse(fs.readFileSync(CONTEXT_FILE, 'utf8'));
|
|
120
|
+
} else {
|
|
121
|
+
// User said no - delete the old context file
|
|
122
|
+
fs.unlinkSync(CONTEXT_FILE);
|
|
123
|
+
console.log(chalk.gray('Starting fresh session...\n'));
|
|
124
|
+
}
|
|
119
125
|
}
|
|
120
126
|
|
|
121
127
|
const localModels = await ollama.list();
|
|
@@ -206,27 +212,29 @@ Don't keep executing tools endlessly - provide insights after reading!`
|
|
|
206
212
|
}
|
|
207
213
|
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
|
|
208
214
|
|
|
209
|
-
//
|
|
215
|
+
// Warn if too many tools
|
|
210
216
|
if (toolMatches.length > 10) {
|
|
211
|
-
console.log(chalk.yellow('\n⚠️ Too many tool calls
|
|
212
|
-
active = false;
|
|
217
|
+
console.log(chalk.yellow('\n⚠️ Too many tool calls! Read 2-3 files, then analyze.'));
|
|
213
218
|
}
|
|
214
219
|
} else {
|
|
215
|
-
// No tools
|
|
220
|
+
// No tools - check for malformed commands
|
|
216
221
|
if (msg.includes('[TOOL:') && msg.includes('[/]')) {
|
|
217
|
-
console.log(chalk.red('\n❌ Malformed tool
|
|
222
|
+
console.log(chalk.red('\n❌ Malformed tool: Use [TOOL:TYPE]path[/TOOL]'));
|
|
218
223
|
messages.push({
|
|
219
224
|
role: 'user',
|
|
220
|
-
content: 'ERROR:
|
|
225
|
+
content: 'ERROR: Tool format wrong! Use [TOOL:TYPE]path[/TOOL]'
|
|
221
226
|
});
|
|
222
227
|
} else {
|
|
223
|
-
// Normal response
|
|
228
|
+
// Normal response - save and continue
|
|
224
229
|
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
|
|
225
230
|
active = false;
|
|
226
231
|
}
|
|
227
232
|
}
|
|
228
233
|
}
|
|
229
234
|
ask();
|
|
235
|
+
}).catch((error) => {
|
|
236
|
+
console.error(chalk.red('\n❌ Error in conversation loop:'), error);
|
|
237
|
+
ask(); // Continue despite error
|
|
230
238
|
});
|
|
231
239
|
};
|
|
232
240
|
ask();
|