sapper-iq 1.0.18 → 1.0.19
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 +17 -28
package/package.json
CHANGED
package/sapper.mjs
CHANGED
|
@@ -132,38 +132,29 @@ async function runSapper() {
|
|
|
132
132
|
if (messages.length === 0) {
|
|
133
133
|
messages = [{
|
|
134
134
|
role: 'system',
|
|
135
|
-
content: `You are Sapper, a senior engineer.
|
|
135
|
+
content: `You are Sapper, a senior engineer working in: ${process.cwd()}
|
|
136
136
|
|
|
137
137
|
CRITICAL: You are working in the CURRENT DIRECTORY. Always use relative paths!
|
|
138
138
|
- Use . or ./ for current directory
|
|
139
139
|
- NEVER use / (that's the root directory)
|
|
140
140
|
- Use relative paths like ./file.js or subfolder/file.js
|
|
141
141
|
|
|
142
|
-
STRATEGY
|
|
143
|
-
1.
|
|
144
|
-
2.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
3. Use format: [TOOL:TYPE]path]content[/TOOL]
|
|
149
|
-
4. After reading, PROVIDE ANALYSIS - don't just list more!
|
|
150
|
-
|
|
151
|
-
READING GUIDELINES:
|
|
152
|
-
- If user says "analyze src folder" → Read ALL files in src/
|
|
153
|
-
- If user says "read everything" → List directory, then read all files
|
|
154
|
-
- If < 20 files total: Read them all
|
|
155
|
-
- If > 20 files: Ask user which area to focus on OR read all if analyzing entire project
|
|
156
|
-
- If > 50 files: Read key files first, then ask user for focus area
|
|
142
|
+
STRATEGY:
|
|
143
|
+
1. When asked to analyze, use [TOOL:LIST].[/TOOL] first (NOTE: dot, not slash!)
|
|
144
|
+
2. Read ONLY 2-3 KEY files in the SAME turn (README, package.json, main entry)
|
|
145
|
+
3. DON'T read ALL files at once - read strategically!
|
|
146
|
+
4. After reading files, PROVIDE ANALYSIS - don't just list more!
|
|
147
|
+
5. Use format: [TOOL:TYPE]path]content[/TOOL]
|
|
157
148
|
|
|
158
149
|
TOOL FORMAT (CRITICAL - FOLLOW EXACTLY):
|
|
159
150
|
✅ CORRECT: [TOOL:LIST].[/TOOL]
|
|
160
151
|
✅ CORRECT: [TOOL:READ]./file.js[/TOOL]
|
|
161
|
-
✅ CORRECT: [TOOL:LIST]./src[/TOOL] then read all files found
|
|
162
152
|
❌ WRONG: [TOOL:LIST].[/] - missing TOOL at end!
|
|
163
153
|
❌ WRONG: [TOOL:LIST]/[/TOOL] - wrong directory!
|
|
164
154
|
|
|
165
155
|
WORKFLOW:
|
|
166
|
-
1. LIST directory → 2. READ
|
|
156
|
+
1. LIST directory → 2. READ 2-3 key files → 3. ANALYZE and RESPOND
|
|
157
|
+
Don't keep executing tools endlessly - provide insights after reading!`
|
|
167
158
|
}];
|
|
168
159
|
}
|
|
169
160
|
|
|
@@ -221,29 +212,27 @@ WORKFLOW:
|
|
|
221
212
|
}
|
|
222
213
|
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
|
|
223
214
|
|
|
224
|
-
//
|
|
225
|
-
if (toolMatches.length >
|
|
226
|
-
console.log(chalk.yellow('\n⚠️
|
|
215
|
+
// Limit tool executions - if too many, warn and exit
|
|
216
|
+
if (toolMatches.length > 10) {
|
|
217
|
+
console.log(chalk.yellow('\n⚠️ Too many tool calls in one response! AI should analyze, not just read endlessly.'));
|
|
218
|
+
active = false;
|
|
227
219
|
}
|
|
228
220
|
} else {
|
|
229
|
-
// No tools - check
|
|
221
|
+
// No tools found - check if malformed command
|
|
230
222
|
if (msg.includes('[TOOL:') && msg.includes('[/]')) {
|
|
231
|
-
console.log(chalk.red('\n❌ Malformed tool:
|
|
223
|
+
console.log(chalk.red('\n❌ Malformed tool command detected! Expected format: [TOOL:TYPE]path[/TOOL]'));
|
|
232
224
|
messages.push({
|
|
233
225
|
role: 'user',
|
|
234
|
-
content: 'ERROR:
|
|
226
|
+
content: 'ERROR: Your tool command is malformed. Use [TOOL:TYPE]path]content[/TOOL] or [TOOL:TYPE]path[/TOOL]'
|
|
235
227
|
});
|
|
236
228
|
} else {
|
|
237
|
-
// Normal response - save and
|
|
229
|
+
// Normal response without tools - save context and wait for next input
|
|
238
230
|
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
|
|
239
231
|
active = false;
|
|
240
232
|
}
|
|
241
233
|
}
|
|
242
234
|
}
|
|
243
235
|
ask();
|
|
244
|
-
}).catch((error) => {
|
|
245
|
-
console.error(chalk.red('\n❌ Error in conversation loop:'), error);
|
|
246
|
-
ask(); // Continue despite error
|
|
247
236
|
});
|
|
248
237
|
};
|
|
249
238
|
ask();
|