codeep 1.0.21 → 1.0.22

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.
@@ -196,9 +196,6 @@ export declare function getOpenAITools(): OpenAITool[];
196
196
  * Get tools in Anthropic Tool Use format
197
197
  */
198
198
  export declare function getAnthropicTools(): AnthropicTool[];
199
- /**
200
- * Parse tool calls from OpenAI response
201
- */
202
199
  export declare function parseOpenAIToolCalls(toolCalls: any[]): ToolCall[];
203
200
  /**
204
201
  * Parse tool calls from Anthropic response
@@ -174,6 +174,33 @@ export function getAnthropicTools() {
174
174
  /**
175
175
  * Parse tool calls from OpenAI response
176
176
  */
177
+ /**
178
+ * Normalize tool name to lowercase with underscores
179
+ */
180
+ function normalizeToolName(name) {
181
+ const toolNameMap = {
182
+ 'executecommand': 'execute_command',
183
+ 'execute_command': 'execute_command',
184
+ 'readfile': 'read_file',
185
+ 'read_file': 'read_file',
186
+ 'writefile': 'write_file',
187
+ 'write_file': 'write_file',
188
+ 'editfile': 'edit_file',
189
+ 'edit_file': 'edit_file',
190
+ 'deletefile': 'delete_file',
191
+ 'delete_file': 'delete_file',
192
+ 'listfiles': 'list_files',
193
+ 'list_files': 'list_files',
194
+ 'searchcode': 'search_code',
195
+ 'search_code': 'search_code',
196
+ 'createdirectory': 'create_directory',
197
+ 'create_directory': 'create_directory',
198
+ 'fetchurl': 'fetch_url',
199
+ 'fetch_url': 'fetch_url',
200
+ };
201
+ const lower = name.toLowerCase().replace(/-/g, '_');
202
+ return toolNameMap[lower] || lower;
203
+ }
177
204
  export function parseOpenAIToolCalls(toolCalls) {
178
205
  if (!toolCalls || !Array.isArray(toolCalls))
179
206
  return [];
@@ -186,7 +213,7 @@ export function parseOpenAIToolCalls(toolCalls) {
186
213
  parameters = {};
187
214
  }
188
215
  return {
189
- tool: tc.function?.name || '',
216
+ tool: normalizeToolName(tc.function?.name || ''),
190
217
  parameters,
191
218
  id: tc.id,
192
219
  };
@@ -201,7 +228,7 @@ export function parseAnthropicToolCalls(content) {
201
228
  return content
202
229
  .filter(block => block.type === 'tool_use')
203
230
  .map(block => ({
204
- tool: block.name || '',
231
+ tool: normalizeToolName(block.name || ''),
205
232
  parameters: block.input || {},
206
233
  id: block.id,
207
234
  }))
@@ -386,7 +413,7 @@ function tryParseToolCall(str) {
386
413
  const parsed = JSON.parse(cleaned);
387
414
  if (parsed.tool && typeof parsed.tool === 'string') {
388
415
  return {
389
- tool: parsed.tool,
416
+ tool: normalizeToolName(parsed.tool),
390
417
  parameters: parsed.parameters || {},
391
418
  id: parsed.id,
392
419
  };
@@ -394,9 +421,9 @@ function tryParseToolCall(str) {
394
421
  }
395
422
  catch {
396
423
  // Try to extract tool name and parameters manually for malformed JSON
397
- const toolMatch = str.match(/"tool"\s*:\s*"([^"]+)"/);
424
+ const toolMatch = str.match(/"tool"\s*:\s*"([^"]+)"/i);
398
425
  if (toolMatch) {
399
- const tool = toolMatch[1];
426
+ const tool = normalizeToolName(toolMatch[1]);
400
427
  const params = {};
401
428
  // Extract simple string parameters
402
429
  const paramMatches = str.matchAll(/"(\w+)"\s*:\s*"([^"]*)"/g);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeep",
3
- "version": "1.0.21",
3
+ "version": "1.0.22",
4
4
  "description": "AI-powered coding assistant built for the terminal. Multiple LLM providers, project-aware context, and a seamless development workflow.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",