sapper-iq 1.0.11 ā 1.0.13
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 +50 -9
package/package.json
CHANGED
package/sapper.mjs
CHANGED
|
@@ -87,11 +87,31 @@ const tools = {
|
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
+
async function checkForUpdates() {
|
|
91
|
+
try {
|
|
92
|
+
const response = await fetch('https://registry.npmjs.org/sapper-iq/latest');
|
|
93
|
+
const data = await response.json();
|
|
94
|
+
const latestVersion = data.version;
|
|
95
|
+
|
|
96
|
+
if (latestVersion && latestVersion !== CURRENT_VERSION) {
|
|
97
|
+
console.log(chalk.yellow('š UPDATE AVAILABLE!'));
|
|
98
|
+
console.log(chalk.gray(` Current: v${CURRENT_VERSION}`));
|
|
99
|
+
console.log(chalk.green(` Latest: v${latestVersion}`));
|
|
100
|
+
console.log(chalk.cyan(' Run: npm update -g sapper-iq\n'));
|
|
101
|
+
}
|
|
102
|
+
} catch (error) {
|
|
103
|
+
// Silently fail if update check fails
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
90
107
|
async function runSapper() {
|
|
91
108
|
console.clear();
|
|
92
109
|
console.log(chalk.cyan.bold(` SAPPER v${CURRENT_VERSION} | Autonomous "OpenCode" Mode`));
|
|
93
110
|
console.log(chalk.gray(`š Working Directory: ${process.cwd()}\n`));
|
|
94
111
|
|
|
112
|
+
// Check for updates
|
|
113
|
+
await checkForUpdates();
|
|
114
|
+
|
|
95
115
|
let messages = [];
|
|
96
116
|
if (fs.existsSync(CONTEXT_FILE)) {
|
|
97
117
|
const resume = await safeQuestion(chalk.green('Resume previous session? (y/n): '));
|
|
@@ -115,14 +135,20 @@ CRITICAL: You are working in the CURRENT DIRECTORY. Always use relative paths!
|
|
|
115
135
|
|
|
116
136
|
STRATEGY:
|
|
117
137
|
1. When asked to analyze, use [TOOL:LIST].[/TOOL] first (NOTE: dot, not slash!)
|
|
118
|
-
2.
|
|
119
|
-
3.
|
|
120
|
-
4.
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
ā
CORRECT: [TOOL:
|
|
125
|
-
|
|
138
|
+
2. Read ONLY 2-3 KEY files in the SAME turn (README, package.json, main entry)
|
|
139
|
+
3. DON'T read ALL files at once - read strategically!
|
|
140
|
+
4. After reading files, PROVIDE ANALYSIS - don't just list more!
|
|
141
|
+
5. Use format: [TOOL:TYPE]path]content[/TOOL]
|
|
142
|
+
|
|
143
|
+
TOOL FORMAT (CRITICAL - FOLLOW EXACTLY):
|
|
144
|
+
ā
CORRECT: [TOOL:LIST].[/TOOL]
|
|
145
|
+
ā
CORRECT: [TOOL:READ]./file.js[/TOOL]
|
|
146
|
+
ā WRONG: [TOOL:LIST].[/] - missing TOOL at end!
|
|
147
|
+
ā WRONG: [TOOL:LIST]/[/TOOL] - wrong directory!
|
|
148
|
+
|
|
149
|
+
WORKFLOW:
|
|
150
|
+
1. LIST directory ā 2. READ 2-3 key files ā 3. ANALYZE and RESPOND
|
|
151
|
+
Don't keep executing tools endlessly - provide insights after reading!`
|
|
126
152
|
}];
|
|
127
153
|
}
|
|
128
154
|
|
|
@@ -165,8 +191,23 @@ EXAMPLES:
|
|
|
165
191
|
messages.push({ role: 'user', content: `RESULT (${path}): ${result}` });
|
|
166
192
|
}
|
|
167
193
|
fs.writeFileSync(CONTEXT_FILE, JSON.stringify(messages));
|
|
194
|
+
|
|
195
|
+
// Limit tool executions - if too many, warn and exit
|
|
196
|
+
if (toolMatches.length > 10) {
|
|
197
|
+
console.log(chalk.yellow('\nā ļø Too many tool calls in one response! AI should analyze, not just read endlessly.'));
|
|
198
|
+
active = false;
|
|
199
|
+
}
|
|
168
200
|
} else {
|
|
169
|
-
|
|
201
|
+
// No tools found - check if malformed command
|
|
202
|
+
if (msg.includes('[TOOL:') && msg.includes('[/]')) {
|
|
203
|
+
console.log(chalk.red('\nā Malformed tool command detected! Expected format: [TOOL:TYPE]path[/TOOL]'));
|
|
204
|
+
messages.push({
|
|
205
|
+
role: 'user',
|
|
206
|
+
content: 'ERROR: Your tool command is malformed. Use [TOOL:TYPE]path]content[/TOOL] or [TOOL:TYPE]path[/TOOL]'
|
|
207
|
+
});
|
|
208
|
+
} else {
|
|
209
|
+
active = false;
|
|
210
|
+
}
|
|
170
211
|
}
|
|
171
212
|
}
|
|
172
213
|
ask();
|