sapper-iq 1.0.16 → 1.0.18

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/sapper.mjs +28 -17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sapper-iq",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "AI-powered development assistant that executes commands and builds projects",
5
5
  "main": "sapper.mjs",
6
6
  "bin": {
package/sapper.mjs CHANGED
@@ -132,29 +132,38 @@ async function runSapper() {
132
132
  if (messages.length === 0) {
133
133
  messages = [{
134
134
  role: 'system',
135
- content: `You are Sapper, a senior engineer working in: ${process.cwd()}
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. 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]
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 OR read all if analyzing entire project
156
+ - If > 50 files: Read key files first, then ask user for focus area
148
157
 
149
158
  TOOL FORMAT (CRITICAL - FOLLOW EXACTLY):
150
159
  ✅ CORRECT: [TOOL:LIST].[/TOOL]
151
160
  ✅ CORRECT: [TOOL:READ]./file.js[/TOOL]
161
+ ✅ CORRECT: [TOOL:LIST]./src[/TOOL] then read all files found
152
162
  ❌ WRONG: [TOOL:LIST].[/] - missing TOOL at end!
153
163
  ❌ WRONG: [TOOL:LIST]/[/TOOL] - wrong directory!
154
164
 
155
165
  WORKFLOW:
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!`
166
+ 1. LIST directory → 2. READ files (as many as needed) → 3. ANALYZE and RESPOND`
158
167
  }];
159
168
  }
160
169
 
@@ -212,27 +221,29 @@ Don't keep executing tools endlessly - provide insights after reading!`
212
221
  }
213
222
  fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
214
223
 
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;
224
+ // Warn if reading too many files at once
225
+ if (toolMatches.length > 30) {
226
+ console.log(chalk.yellow('\n⚠️ Reading 30+ files! This might take time. Consider being more selective.'));
219
227
  }
220
228
  } else {
221
- // No tools found - check if malformed command
229
+ // No tools - check for malformed commands
222
230
  if (msg.includes('[TOOL:') && msg.includes('[/]')) {
223
- console.log(chalk.red('\n❌ Malformed tool command detected! Expected format: [TOOL:TYPE]path[/TOOL]'));
231
+ console.log(chalk.red('\n❌ Malformed tool: Use [TOOL:TYPE]path[/TOOL]'));
224
232
  messages.push({
225
233
  role: 'user',
226
- content: 'ERROR: Your tool command is malformed. Use [TOOL:TYPE]path]content[/TOOL] or [TOOL:TYPE]path[/TOOL]'
234
+ content: 'ERROR: Tool format wrong! Use [TOOL:TYPE]path[/TOOL]'
227
235
  });
228
236
  } else {
229
- // Normal response without tools - save context and wait for next input
237
+ // Normal response - save and continue
230
238
  fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
231
239
  active = false;
232
240
  }
233
241
  }
234
242
  }
235
243
  ask();
244
+ }).catch((error) => {
245
+ console.error(chalk.red('\n❌ Error in conversation loop:'), error);
246
+ ask(); // Continue despite error
236
247
  });
237
248
  };
238
249
  ask();