sapper-iq 1.0.19 → 1.0.21
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 +26 -14
package/package.json
CHANGED
package/sapper.mjs
CHANGED
|
@@ -132,29 +132,37 @@ 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.
|
|
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
|
-
|
|
142
|
+
STRATEGY FOR FILE READING:
|
|
143
|
+
1. Start with [TOOL:LIST].[/TOOL] to see what exists
|
|
144
|
+
2. READ FILES BASED ON TASK:
|
|
145
|
+
- Quick overview: Read 2-3 key files (README, package.json, main entry)
|
|
146
|
+
- Deep analysis: Read ALL relevant files (entire src/ folder, all components)
|
|
147
|
+
- User asks "read all": Read ALL files they mention
|
|
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
|
|
148
156
|
|
|
149
157
|
TOOL FORMAT (CRITICAL - FOLLOW EXACTLY):
|
|
150
158
|
✅ CORRECT: [TOOL:LIST].[/TOOL]
|
|
151
159
|
✅ CORRECT: [TOOL:READ]./file.js[/TOOL]
|
|
160
|
+
✅ CORRECT: [TOOL:LIST]./src[/TOOL] then read all files found
|
|
152
161
|
❌ WRONG: [TOOL:LIST].[/] - missing TOOL at end!
|
|
153
162
|
❌ WRONG: [TOOL:LIST]/[/TOOL] - wrong directory!
|
|
154
163
|
|
|
155
164
|
WORKFLOW:
|
|
156
|
-
1. LIST directory → 2. READ
|
|
157
|
-
Don't keep executing tools endlessly - provide insights after reading!`
|
|
165
|
+
1. LIST directory → 2. READ files (as many as needed) → 3. ANALYZE and RESPOND`
|
|
158
166
|
}];
|
|
159
167
|
}
|
|
160
168
|
|
|
@@ -194,7 +202,9 @@ Don't keep executing tools endlessly - provide insights after reading!`
|
|
|
194
202
|
console.log();
|
|
195
203
|
messages.push({ role: 'assistant', content: msg });
|
|
196
204
|
|
|
197
|
-
|
|
205
|
+
// Fixed regex: .+? (non-greedy) stops correctly before [/TOOL]
|
|
206
|
+
// Old regex [^\]\n]+ was broken - it stopped at ] which is at END of [/TOOL]
|
|
207
|
+
const toolMatches = [...msg.matchAll(/\[TOOL:(\w+)\](.+?)(?:\]([\s\S]*?))?\[\/TOOL\]/g)];
|
|
198
208
|
|
|
199
209
|
if (toolMatches.length > 0) {
|
|
200
210
|
for (const match of toolMatches) {
|
|
@@ -212,10 +222,9 @@ Don't keep executing tools endlessly - provide insights after reading!`
|
|
|
212
222
|
}
|
|
213
223
|
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
|
|
214
224
|
|
|
215
|
-
//
|
|
216
|
-
if (toolMatches.length >
|
|
217
|
-
console.log(chalk.yellow('\n⚠️
|
|
218
|
-
active = false;
|
|
225
|
+
// Warn if reading many files at once
|
|
226
|
+
if (toolMatches.length > 30) {
|
|
227
|
+
console.log(chalk.yellow('\n⚠️ Reading 30+ files! This might take time.'));
|
|
219
228
|
}
|
|
220
229
|
} else {
|
|
221
230
|
// No tools found - check if malformed command
|
|
@@ -233,6 +242,9 @@ Don't keep executing tools endlessly - provide insights after reading!`
|
|
|
233
242
|
}
|
|
234
243
|
}
|
|
235
244
|
ask();
|
|
245
|
+
}).catch((error) => {
|
|
246
|
+
console.error(chalk.red('\n❌ Error:'), error.message);
|
|
247
|
+
ask(); // Continue despite error
|
|
236
248
|
});
|
|
237
249
|
};
|
|
238
250
|
ask();
|