(tool: AnthropicTool)
| 436 | |
| 437 | // 为工具生成示例参数 |
| 438 | const makeExampleParams = (tool: AnthropicTool): Record<string, unknown> => { |
| 439 | if (/^(Read|read_file|ReadFile)$/i.test(tool.name)) return { file_path: 'src/index.ts' }; |
| 440 | if (/^(Bash|execute_command|RunCommand|run_command)$/i.test(tool.name)) return { command: 'ls -la' }; |
| 441 | if (/^(Write|write_to_file|WriteFile|write_file)$/i.test(tool.name)) return { file_path: 'output.txt', content: '...' }; |
| 442 | if (/^(ListDir|list_dir|list_directory|ListDirectory|list_files)$/i.test(tool.name)) return { path: '.' }; |
| 443 | if (/^(Search|search_files|SearchFiles|grep_search|codebase_search)$/i.test(tool.name)) return { query: 'TODO' }; |
| 444 | if (/^(Edit|edit_file|EditFile|replace_in_file)$/i.test(tool.name)) return { file_path: 'src/main.ts', old_text: 'old', new_text: 'new' }; |
| 445 | // 第三方工具:从 schema 中提取前 2 个参数名 |
| 446 | if (tool.input_schema?.properties) { |
| 447 | return Object.fromEntries( |
| 448 | Object.entries(tool.input_schema.properties as Record<string, { type?: string }>) |
| 449 | .slice(0, 2) |
| 450 | .map(([k, v]) => [k, v.type === 'boolean' ? true : v.type === 'number' ? 1 : 'value']) |
| 451 | ); |
| 452 | } |
| 453 | return { input: 'value' }; |
| 454 | }; |
| 455 | |
| 456 | // 选取 few-shot 工具集:按工具来源/命名空间分组,每个组选一个代表 |
| 457 | // 确保 MCP 工具、Skills、Plugins 等不同类别各有代表 (#67) |
no outgoing calls
no test coverage detected