sapper-iq 1.0.4 → 1.0.6
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 copy.mjs +9 -28
- package/sapper.mjs +60 -60
package/package.json
CHANGED
package/sapper copy.mjs
CHANGED
|
@@ -234,24 +234,16 @@ async function runSapper() {
|
|
|
234
234
|
|
|
235
235
|
**CRITICAL - Tool Format Rules:**
|
|
236
236
|
- NEVER use JSON format
|
|
237
|
-
- ONLY use this EXACT format for tools: [TOOL:TYPE:path
|
|
238
|
-
- For single-line content: [TOOL:TYPE:path:content] (legacy format still supported)
|
|
237
|
+
- ONLY use this EXACT format for tools: [TOOL:TYPE:path:content]
|
|
239
238
|
- Types: SHELL, READ, WRITE, MKDIR, LIST, SEARCH
|
|
240
239
|
|
|
241
240
|
**Examples:**
|
|
242
|
-
[TOOL:SHELL:npm install]
|
|
243
|
-
[TOOL:READ:./package.json]
|
|
244
|
-
[TOOL:WRITE:./app.js
|
|
245
|
-
[TOOL:MKDIR:./src/components]
|
|
246
|
-
[TOOL:LIST:./src]
|
|
247
|
-
[TOOL:SEARCH:function myFunction]
|
|
248
|
-
|
|
249
|
-
**For multi-line content (like markdown files):**
|
|
250
|
-
[TOOL:WRITE:./file.md]
|
|
251
|
-
Multi-line
|
|
252
|
-
content here
|
|
253
|
-
with - [ ] checkboxes
|
|
254
|
-
[/TOOL]
|
|
241
|
+
[TOOL:SHELL:npm install]
|
|
242
|
+
[TOOL:READ:./package.json]
|
|
243
|
+
[TOOL:WRITE:./app.js:console.log('hello')]
|
|
244
|
+
[TOOL:MKDIR:./src/components]
|
|
245
|
+
[TOOL:LIST:./src]
|
|
246
|
+
[TOOL:SEARCH:function myFunction]
|
|
255
247
|
|
|
256
248
|
**Shell Command Rules:**
|
|
257
249
|
- For operations in a specific directory, chain with cd: cd /path/to/project && npm install
|
|
@@ -416,18 +408,7 @@ with - [ ] checkboxes
|
|
|
416
408
|
messages.push({ role: 'assistant', content: msg });
|
|
417
409
|
|
|
418
410
|
const summaryMatch = msg.match(/\[SUMMARY:(.*?)\]/s);
|
|
419
|
-
|
|
420
|
-
// Support both formats:
|
|
421
|
-
// New: [TOOL:TYPE:path]content[/TOOL] (handles multi-line content with brackets)
|
|
422
|
-
// Old: [TOOL:TYPE:path:content] (for backward compatibility)
|
|
423
|
-
const newFormatMatches = [...msg.matchAll(/\[TOOL:(\w+):([^\]]+)\]([\s\S]*?)\[\/TOOL\]/g)];
|
|
424
|
-
const oldFormatMatches = [...msg.matchAll(/\[TOOL:(\w+):([^:\]]+):([^\]]+)\]/g)];
|
|
425
|
-
|
|
426
|
-
// Normalize to unified format: [fullMatch, type, path, content]
|
|
427
|
-
const toolMatches = [
|
|
428
|
-
...newFormatMatches.map(m => [m[0], m[1], m[2], m[3]]),
|
|
429
|
-
...oldFormatMatches.map(m => [m[0], m[1], m[2], m[3]])
|
|
430
|
-
];
|
|
411
|
+
const toolMatches = [...msg.matchAll(/\[TOOL:(\w+):([^:\]]+):?([\s\S]*?)\]/g)];
|
|
431
412
|
|
|
432
413
|
if (summaryMatch) {
|
|
433
414
|
console.log(chalk.green.bold("\n✅ MISSION COMPLETE:"));
|
|
@@ -469,7 +450,7 @@ with - [ ] checkboxes
|
|
|
469
450
|
break;
|
|
470
451
|
}
|
|
471
452
|
} else {
|
|
472
|
-
const planMatch = msg.match(/\[PLAN:(
|
|
453
|
+
const planMatch = msg.match(/\[PLAN:(.*?)\]/);
|
|
473
454
|
if (planMatch) {
|
|
474
455
|
const feedback = await safeQuestion(chalk.yellow('\nModify plan or type "go": '));
|
|
475
456
|
if (feedback.toLowerCase() === '/stop') { active = false; break; }
|
package/sapper.mjs
CHANGED
|
@@ -230,57 +230,66 @@ async function runSapper() {
|
|
|
230
230
|
if (messages.length === 0) {
|
|
231
231
|
messages = [{
|
|
232
232
|
role: 'system',
|
|
233
|
-
content: `You are Sapper, a senior software engineer AI assistant.
|
|
234
|
-
|
|
235
|
-
**CRITICAL
|
|
236
|
-
-
|
|
237
|
-
-
|
|
238
|
-
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
233
|
+
content: `You are Sapper, a senior software engineer AI assistant. Your PRIMARY function is to EXECUTE ACTIONS, not explain them.
|
|
234
|
+
|
|
235
|
+
**CRITICAL INSTRUCTION: EXECUTE TOOLS IMMEDIATELY**
|
|
236
|
+
When the user asks you to do something, DO IT using tools - don't explain how to do it.
|
|
237
|
+
- ❌ WRONG: "To analyze the files, you would use [TOOL:LIST]..."
|
|
238
|
+
- ✅ CORRECT: Immediately execute [TOOL:LIST]./[/TOOL] and analyze results
|
|
239
|
+
|
|
240
|
+
**TOOL FORMAT (Version 1.0.5+):**
|
|
241
|
+
[TOOL:TYPE]path]content[/TOOL]
|
|
242
|
+
|
|
243
|
+
**Available Tools:**
|
|
244
|
+
- SHELL: Execute commands
|
|
245
|
+
- READ: Read file contents
|
|
246
|
+
- WRITE: Create/update files
|
|
247
|
+
- MKDIR: Create directories
|
|
248
|
+
- LIST: List directory contents
|
|
249
|
+
- SEARCH: Search for patterns
|
|
250
|
+
|
|
251
|
+
**FORMAT EXAMPLES:**
|
|
252
|
+
[TOOL:SHELL]npm install[/TOOL]
|
|
253
|
+
[TOOL:READ]./package.json[/TOOL]
|
|
254
|
+
[TOOL:WRITE]./app.js]console.log('hello')[/TOOL]
|
|
255
|
+
[TOOL:MKDIR]./src/components[/TOOL]
|
|
256
|
+
[TOOL:LIST]./src[/TOOL]
|
|
257
|
+
[TOOL:SEARCH]function myFunction[/TOOL]
|
|
258
|
+
|
|
259
|
+
**Multi-line content:**
|
|
260
|
+
[TOOL:WRITE]./README.md]
|
|
261
|
+
# Title
|
|
262
|
+
- [ ] checkbox
|
|
263
|
+
- [x] done
|
|
264
|
+
Arrays: [1, 2, 3]
|
|
254
265
|
[/TOOL]
|
|
255
266
|
|
|
256
|
-
**
|
|
257
|
-
-
|
|
258
|
-
-
|
|
259
|
-
-
|
|
260
|
-
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
-
|
|
266
|
-
|
|
267
|
-
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
- Work flexibly with ANY directory the user specifies
|
|
283
|
-
- Always chain cd with your command when working in a specific directory`
|
|
267
|
+
**CRITICAL: Notice the bracket placement!**
|
|
268
|
+
- Path comes AFTER the colon
|
|
269
|
+
- Close bracket ] after path
|
|
270
|
+
- Then content
|
|
271
|
+
- Then [/TOOL]
|
|
272
|
+
|
|
273
|
+
**Shell Commands:**
|
|
274
|
+
- Change directory with cd: [TOOL:SHELL]cd /path/to/project && npm install[/TOOL]
|
|
275
|
+
- Chain commands: cd /path && npm install && npm run dev
|
|
276
|
+
- Use non-interactive flags: npx create-next-app --typescript --no-git
|
|
277
|
+
|
|
278
|
+
**ACTION-FIRST WORKFLOW:**
|
|
279
|
+
1. User asks → You EXECUTE tools immediately
|
|
280
|
+
2. For complex tasks: [PLAN:description] then execute each step
|
|
281
|
+
3. Multiple tools allowed per response
|
|
282
|
+
4. End with [SUMMARY:what was completed]
|
|
283
|
+
|
|
284
|
+
**DO NOT:**
|
|
285
|
+
- Explain tool syntax to the user
|
|
286
|
+
- Show examples of what "could" be done
|
|
287
|
+
- Use JSON format or markdown code blocks for tools
|
|
288
|
+
- Wait for permission - execute the tools
|
|
289
|
+
|
|
290
|
+
**REMEMBER:** You are an executor, not an advisor. When asked to "analyze files", immediately use [TOOL:LIST] and [TOOL:READ]. When asked to "create project", immediately use [TOOL:SHELL] with the commands. Execute first, explain after if needed.
|
|
291
|
+
|
|
292
|
+
Working directory: ${process.cwd()}`
|
|
284
293
|
}];
|
|
285
294
|
}
|
|
286
295
|
|
|
@@ -417,17 +426,8 @@ with - [ ] checkboxes
|
|
|
417
426
|
|
|
418
427
|
const summaryMatch = msg.match(/\[SUMMARY:(.*?)\]/s);
|
|
419
428
|
|
|
420
|
-
//
|
|
421
|
-
|
|
422
|
-
// Old: [TOOL:TYPE:path:content] (for backward compatibility)
|
|
423
|
-
const newFormatMatches = [...msg.matchAll(/\[TOOL:(\w+):([^\]]+)\]([\s\S]*?)\[\/TOOL\]/g)];
|
|
424
|
-
const oldFormatMatches = [...msg.matchAll(/\[TOOL:(\w+):([^:\]]+):([^\]]+)\]/g)];
|
|
425
|
-
|
|
426
|
-
// Normalize to unified format: [fullMatch, type, path, content]
|
|
427
|
-
const toolMatches = [
|
|
428
|
-
...newFormatMatches.map(m => [m[0], m[1], m[2], m[3]]),
|
|
429
|
-
...oldFormatMatches.map(m => [m[0], m[1], m[2], m[3]])
|
|
430
|
-
];
|
|
429
|
+
// Primary format: [TOOL:TYPE:path]content[/TOOL]
|
|
430
|
+
const toolMatches = [...msg.matchAll(/\[TOOL:(\w+)\]([^\[]+?)\]([\s\S]*?)\[\/TOOL\]/g)];
|
|
431
431
|
|
|
432
432
|
if (summaryMatch) {
|
|
433
433
|
console.log(chalk.green.bold("\n✅ MISSION COMPLETE:"));
|