sapper-iq 1.1.0 → 1.1.1

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 +38 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sapper-iq",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
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
@@ -148,6 +148,27 @@ const tools = {
148
148
  });
149
149
  return filtered.length > 0 ? filtered.join('\n') : '(empty or all files filtered)';
150
150
  } catch (e) { return `Error: ${e.message}`; }
151
+ },
152
+ search: (pattern) => {
153
+ return new Promise((resolve) => {
154
+ const excludeDirs = Array.from(IGNORE_DIRS).join(',');
155
+ // Use grep to search for pattern, excluding ignored directories
156
+ const cmd = `grep -rEin "${pattern.replace(/"/g, '\\"')}" . --exclude-dir={${excludeDirs}} --include="*.{js,ts,jsx,tsx,py,java,go,rs,rb,php,c,cpp,h,css,scss,html,json,md,txt,yml,yaml,toml,sh}" 2>/dev/null | head -50`;
157
+
158
+ const proc = spawn('sh', ['-c', cmd], { cwd: process.cwd() });
159
+ let output = '';
160
+
161
+ proc.stdout.on('data', (data) => { output += data.toString(); });
162
+ proc.stderr.on('data', (data) => { output += data.toString(); });
163
+
164
+ proc.on('close', () => {
165
+ if (output.trim()) {
166
+ resolve(`Found matches:\n${output.trim()}`);
167
+ } else {
168
+ resolve(`No matches found for: ${pattern}`);
169
+ }
170
+ });
171
+ });
151
172
  }
152
173
  };
153
174
 
@@ -221,16 +242,31 @@ READING GUIDELINES:
221
242
  TOOL FORMAT (CRITICAL - FOLLOW EXACTLY):
222
243
  ✅ CORRECT: [TOOL:LIST].[/TOOL]
223
244
  ✅ CORRECT: [TOOL:READ]./file.js[/TOOL]
245
+ ✅ CORRECT: [TOOL:SEARCH]functionName[/TOOL]
224
246
  ✅ CORRECT: [TOOL:WRITE]./file.js]full content here[/TOOL]
225
247
  ✅ CORRECT: [TOOL:PATCH]./file.js]old code|||new code[/TOOL]
226
248
  ❌ WRONG: [TOOL:LIST].[/] - missing TOOL at end!
227
249
 
250
+ AVAILABLE TOOLS:
251
+ - LIST: List directory contents
252
+ - READ: Read file contents
253
+ - SEARCH: Find text/code across all files (grep-like, returns file:line:match)
254
+ - WRITE: Create or overwrite entire file (requires confirmation)
255
+ - PATCH: Make small edits to existing file (requires confirmation)
256
+ - MKDIR: Create directory
257
+ - SHELL: Run terminal command (requires confirmation)
258
+
259
+ SMART WORKFLOW:
260
+ 1. For unknown codebases: [TOOL:SEARCH]main|index|app[/TOOL] to find entry points
261
+ 2. To find where something is defined: [TOOL:SEARCH]function myFunc[/TOOL]
262
+ 3. SEARCH returns file paths + line numbers - then READ specific files
263
+
228
264
  PATCH vs WRITE:
229
265
  - Use PATCH for small changes (1-10 lines): [TOOL:PATCH]path]old|||new[/TOOL]
230
266
  - Use WRITE only for new files or complete rewrites
231
267
 
232
268
  WORKFLOW:
233
- 1. LIST directory → 2. READ files (as many as needed) → 3. ANALYZE and RESPOND`
269
+ 1. LIST or SEARCH → 2. READ relevant files → 3. ANALYZE and RESPOND`
234
270
  }];
235
271
  }
236
272
 
@@ -360,6 +396,7 @@ WORKFLOW:
360
396
  result = 'Error: PATCH requires format [TOOL:PATCH]path]OLD_TEXT|||NEW_TEXT[/TOOL]';
361
397
  }
362
398
  }
399
+ else if (type.toLowerCase() === 'search') result = await tools.search(path);
363
400
  else if (type.toLowerCase() === 'shell') result = await tools.shell(path);
364
401
 
365
402
  messages.push({ role: 'user', content: `RESULT (${path}): ${result}` });