@qodo/sdk 0.4.0 → 0.6.0

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 (57) hide show
  1. package/.claude/skills/qodo-agent/SKILL.md +656 -0
  2. package/.claude/skills/qodo-agent/assets/programmatic-agent.ts +317 -0
  3. package/.claude/skills/qodo-agent/references/builtin-tools.md +342 -0
  4. package/.claude/skills/qodo-agent/references/common-issues.md +457 -0
  5. package/dist/api/agent.d.ts +0 -1
  6. package/dist/api/agent.d.ts.map +1 -1
  7. package/dist/api/agent.js +5 -127
  8. package/dist/api/agent.js.map +1 -1
  9. package/dist/bin/install-skill.d.ts +14 -0
  10. package/dist/bin/install-skill.d.ts.map +1 -0
  11. package/dist/bin/install-skill.js +125 -0
  12. package/dist/bin/install-skill.js.map +1 -0
  13. package/dist/index.d.ts +1 -0
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +3 -0
  16. package/dist/index.js.map +1 -1
  17. package/dist/mcp/MCPManager.d.ts +0 -16
  18. package/dist/mcp/MCPManager.d.ts.map +1 -1
  19. package/dist/mcp/MCPManager.js +1 -42
  20. package/dist/mcp/MCPManager.js.map +1 -1
  21. package/dist/mcp/builtinServers.d.ts.map +1 -1
  22. package/dist/mcp/builtinServers.js +0 -12
  23. package/dist/mcp/builtinServers.js.map +1 -1
  24. package/dist/mcp/index.d.ts +0 -1
  25. package/dist/mcp/index.d.ts.map +1 -1
  26. package/dist/mcp/index.js +0 -1
  27. package/dist/mcp/index.js.map +1 -1
  28. package/dist/mcp/servers/filesystem.d.ts +0 -31
  29. package/dist/mcp/servers/filesystem.d.ts.map +1 -1
  30. package/dist/mcp/servers/filesystem.js +0 -222
  31. package/dist/mcp/servers/filesystem.js.map +1 -1
  32. package/dist/mcp/servers/shell.d.ts.map +1 -1
  33. package/dist/mcp/servers/shell.js +21 -105
  34. package/dist/mcp/servers/shell.js.map +1 -1
  35. package/dist/mcp/serversRegistry.d.ts +1 -1
  36. package/dist/mcp/serversRegistry.d.ts.map +1 -1
  37. package/dist/mcp/serversRegistry.js +3 -3
  38. package/dist/mcp/serversRegistry.js.map +1 -1
  39. package/dist/mcp/toolProcessor.d.ts.map +1 -1
  40. package/dist/mcp/toolProcessor.js +0 -43
  41. package/dist/mcp/toolProcessor.js.map +1 -1
  42. package/dist/sdk/QodoSDK.d.ts.map +1 -1
  43. package/dist/sdk/QodoSDK.js +0 -9
  44. package/dist/sdk/QodoSDK.js.map +1 -1
  45. package/dist/sdk/builders.d.ts +1 -1
  46. package/dist/sdk/builders.d.ts.map +1 -1
  47. package/dist/sdk/builders.js +1 -1
  48. package/dist/sdk/builders.js.map +1 -1
  49. package/dist/sdk/schemas.d.ts +1 -1
  50. package/dist/sdk/schemas.d.ts.map +1 -1
  51. package/dist/sdk/schemas.js +1 -1
  52. package/dist/sdk/schemas.js.map +1 -1
  53. package/package.json +9 -5
  54. package/dist/mcp/servers/gerrit.d.ts +0 -19
  55. package/dist/mcp/servers/gerrit.d.ts.map +0 -1
  56. package/dist/mcp/servers/gerrit.js +0 -515
  57. package/dist/mcp/servers/gerrit.js.map +0 -1
@@ -0,0 +1,317 @@
1
+ /**
2
+ * Complete @qodo/sdk Programmatic Agent Template
3
+ *
4
+ * This template demonstrates all key SDK features:
5
+ * - sdkAgent() and sdkCommand() builders
6
+ * - Zod schemas with proper descriptions
7
+ * - Event streaming with matchSdkEvent()
8
+ * - Error handling
9
+ * - Proper cleanup with dispose()
10
+ *
11
+ * Usage:
12
+ * npx tsx programmatic-agent.ts
13
+ */
14
+
15
+ import {
16
+ QodoSDK,
17
+ sdkAgent,
18
+ sdkCommand,
19
+ sdkArgs,
20
+ SdkEventType,
21
+ matchSdkEvent,
22
+ zJsonValue,
23
+ zJsonAny,
24
+ QodoSchemaError,
25
+ QodoAuthError,
26
+ } from '@qodo/sdk';
27
+ import { z } from 'zod';
28
+
29
+ // =============================================================================
30
+ // STEP 1: Define Output Schemas
31
+ // =============================================================================
32
+ // IMPORTANT: Every property MUST have .describe() or you'll get QodoSchemaError
33
+
34
+ const analyzeOutputSchema = z.object({
35
+ summary: z.string().describe('Brief overall assessment of the code quality'),
36
+ metrics: z
37
+ .object({
38
+ files_analyzed: z.number().describe('Number of files analyzed'),
39
+ total_lines: z.number().describe('Total lines of code'),
40
+ issues_found: z.number().describe('Total issues found'),
41
+ })
42
+ .describe('Quantitative metrics from the analysis'),
43
+ issues: z
44
+ .array(
45
+ z.object({
46
+ file: z.string().describe('Relative path to the file'),
47
+ line: z.number().describe('Line number where issue occurs'),
48
+ severity: z.enum(['info', 'warning', 'error']).describe('Issue severity level'),
49
+ category: z
50
+ .enum(['style', 'bug', 'security', 'performance', 'maintainability'])
51
+ .describe('Issue category'),
52
+ message: z.string().describe('Human-readable description of the issue'),
53
+ suggestion: z.string().optional().describe('Suggested fix if available'),
54
+ })
55
+ )
56
+ .describe('List of issues found during analysis'),
57
+ recommendations: z
58
+ .array(z.string().describe('A specific recommendation'))
59
+ .describe('High-level recommendations for improvement'),
60
+ score: z.number().min(0).max(100).describe('Overall quality score from 0-100'),
61
+ });
62
+
63
+ const refactorOutputSchema = z.object({
64
+ changes_made: z
65
+ .array(
66
+ z.object({
67
+ file: z.string().describe('File that was modified'),
68
+ description: z.string().describe('What was changed'),
69
+ before_snippet: z.string().optional().describe('Code before the change'),
70
+ after_snippet: z.string().optional().describe('Code after the change'),
71
+ })
72
+ )
73
+ .describe('List of changes made during refactoring'),
74
+ files_modified: z.array(z.string().describe('File path')).describe('All files that were modified'),
75
+ summary: z.string().describe('Summary of refactoring performed'),
76
+ });
77
+
78
+ // =============================================================================
79
+ // STEP 2: Define Args Schemas
80
+ // =============================================================================
81
+ // Args schemas are optional but recommended for type-safe input validation
82
+
83
+ const analyzeArgsSchema = sdkArgs({
84
+ path: z.string().describe('Path to the directory or file to analyze'),
85
+ include_patterns: z
86
+ .array(z.string())
87
+ .optional()
88
+ .default(['**/*.ts', '**/*.js'])
89
+ .describe('Glob patterns for files to include'),
90
+ exclude_patterns: z
91
+ .array(z.string())
92
+ .optional()
93
+ .default(['**/node_modules/**', '**/dist/**'])
94
+ .describe('Glob patterns for files to exclude'),
95
+ severity_threshold: z
96
+ .enum(['info', 'warning', 'error'])
97
+ .optional()
98
+ .default('info')
99
+ .describe('Minimum severity to report'),
100
+ });
101
+
102
+ const refactorArgsSchema = sdkArgs({
103
+ path: z.string().describe('Path to refactor'),
104
+ pattern: z.string().describe('What to look for (e.g., "Convert callbacks to async/await")'),
105
+ dry_run: z.boolean().optional().default(false).describe('If true, show changes without applying'),
106
+ });
107
+
108
+ // =============================================================================
109
+ // STEP 3: Build the Agent Configuration
110
+ // =============================================================================
111
+
112
+ const codeAssistantAgent = sdkAgent({
113
+ instructions: `You are an expert code analysis and refactoring assistant.
114
+
115
+ Your capabilities:
116
+ - Analyze code for quality issues, bugs, and improvements
117
+ - Refactor code following best practices
118
+ - Provide actionable recommendations
119
+
120
+ Guidelines:
121
+ - Be thorough but prioritize high-impact issues
122
+ - Always explain the "why" behind recommendations
123
+ - Consider performance, maintainability, and security
124
+ - Respect existing code style when making changes`,
125
+
126
+ // Optional: specify model
127
+ // model: 'gpt-4',
128
+
129
+ // Optional: agent-level tool configuration
130
+ available_tools: ['filesystem', 'ripgrep', 'git'],
131
+
132
+ commands: {
133
+ analyze: sdkCommand({
134
+ name: 'analyze',
135
+ description: 'Analyze code quality and identify issues',
136
+ instructions: `Perform a comprehensive code analysis:
137
+
138
+ 1. Scan all matching files in the specified path
139
+ 2. Identify issues across these categories:
140
+ - Style: formatting, naming conventions, code organization
141
+ - Bugs: potential runtime errors, logic issues
142
+ - Security: vulnerabilities, unsafe patterns
143
+ - Performance: inefficiencies, optimization opportunities
144
+ - Maintainability: complexity, duplication, unclear code
145
+
146
+ 3. For each issue, provide:
147
+ - Exact file and line location
148
+ - Clear description of the problem
149
+ - Suggested fix when possible
150
+
151
+ 4. Calculate an overall quality score (0-100) based on:
152
+ - Issue density and severity
153
+ - Code organization
154
+ - Best practices adherence`,
155
+ available_tools: ['filesystem', 'ripgrep'],
156
+ args: analyzeArgsSchema,
157
+ output: analyzeOutputSchema,
158
+ }),
159
+
160
+ refactor: sdkCommand({
161
+ name: 'refactor',
162
+ description: 'Refactor code based on a specified pattern',
163
+ instructions: `Perform the requested refactoring:
164
+
165
+ 1. Search for code matching the specified pattern
166
+ 2. Apply the refactoring transformation
167
+ 3. Ensure changes don't break functionality
168
+ 4. If dry_run is true, describe changes without applying them
169
+ 5. Report all changes made with before/after snippets`,
170
+ available_tools: ['filesystem', 'ripgrep'],
171
+ args: refactorArgsSchema,
172
+ output: refactorOutputSchema,
173
+ permissions: 'rwx', // Read, write, execute
174
+ }),
175
+ },
176
+ });
177
+
178
+ // =============================================================================
179
+ // STEP 4: Create and Use the SDK
180
+ // =============================================================================
181
+
182
+ async function main() {
183
+ // Create SDK from the agent configuration
184
+ const sdk = QodoSDK.fromAgent(codeAssistantAgent, {
185
+ // Optional: override project path (defaults to cwd)
186
+ // projectPath: '/path/to/project',
187
+
188
+ // Optional: enable debug logging
189
+ // debug: true,
190
+
191
+ // Optional: custom tool approval (default: auto-approve)
192
+ // autoApproveTools: false,
193
+ // toolApproval: async ({ tool_name, tool_args }) => {
194
+ // console.log(`Tool requested: ${tool_name}`);
195
+ // return true; // or prompt user
196
+ // },
197
+ });
198
+
199
+ try {
200
+ // -------------------------------------------------------------------------
201
+ // Example 1: Run with streaming events
202
+ // -------------------------------------------------------------------------
203
+ console.log('Starting code analysis with streaming...\n');
204
+
205
+ for await (const event of sdk.stream('analyze', {
206
+ args: {
207
+ path: './src',
208
+ severity_threshold: 'warning',
209
+ },
210
+ })) {
211
+ matchSdkEvent(event, {
212
+ [SdkEventType.Init]: (e) => {
213
+ console.log(`SDK v${e.data.sdk_version} initialized`);
214
+ },
215
+
216
+ [SdkEventType.RunStarted]: (e) => {
217
+ console.log(`Run started - Session: ${e.data.session_id}`);
218
+ console.log(`Command: ${e.data.command || '(prompt mode)'}`);
219
+ },
220
+
221
+ [SdkEventType.MessageDelta]: (e) => {
222
+ // Stream assistant's text output
223
+ process.stdout.write(e.data.delta);
224
+ },
225
+
226
+ [SdkEventType.Progress]: (e) => {
227
+ if (e.data.title) {
228
+ console.log(`\n[Progress] ${e.data.title}`);
229
+ }
230
+ },
231
+
232
+ [SdkEventType.ToolRequested]: (e) => {
233
+ console.log(`\n[Tool] ${e.data.server_name}.${e.data.tool_name}`);
234
+ if (e.data.pending_approval) {
235
+ console.log(' (awaiting approval)');
236
+ }
237
+ },
238
+
239
+ [SdkEventType.ToolExecuted]: (e) => {
240
+ const status = e.data.result.isError ? 'ERROR' : 'OK';
241
+ console.log(`[Tool Result] ${status}`);
242
+ },
243
+
244
+ [SdkEventType.Error]: (e) => {
245
+ console.error(`\n[Error] ${e.data.message}`);
246
+ },
247
+
248
+ [SdkEventType.Final]: (e) => {
249
+ console.log('\n\n--- Analysis Complete ---');
250
+ console.log(`Success: ${e.data.success}`);
251
+
252
+ if (e.data.result.structured_output) {
253
+ const output = e.data.result.structured_output;
254
+ console.log(`\nScore: ${output.score}/100`);
255
+ console.log(`Issues found: ${output.issues?.length || 0}`);
256
+ console.log(`\nSummary: ${output.summary}`);
257
+ }
258
+ },
259
+
260
+ // Catch-all for events we don't handle
261
+ default: () => {},
262
+ });
263
+ }
264
+
265
+ // -------------------------------------------------------------------------
266
+ // Example 2: Simple run (no streaming)
267
+ // -------------------------------------------------------------------------
268
+ console.log('\n\n--- Running refactor command ---\n');
269
+
270
+ const refactorResult = await sdk.run('refactor', {
271
+ args: {
272
+ path: './src/utils',
273
+ pattern: 'Convert var declarations to const/let',
274
+ dry_run: true,
275
+ },
276
+ });
277
+
278
+ if (refactorResult.success) {
279
+ console.log('Refactor analysis complete!');
280
+ console.log('Changes that would be made:');
281
+ refactorResult.structured_output?.changes_made?.forEach((change: any) => {
282
+ console.log(` - ${change.file}: ${change.description}`);
283
+ });
284
+ } else {
285
+ console.error('Refactor failed:', refactorResult.error);
286
+ }
287
+
288
+ // -------------------------------------------------------------------------
289
+ // Example 3: Prompt mode (no predefined command)
290
+ // -------------------------------------------------------------------------
291
+ console.log('\n\n--- Prompt mode example ---\n');
292
+
293
+ const promptResult = await sdk.prompt(
294
+ 'What are the most common patterns you see in this codebase?'
295
+ );
296
+
297
+ console.log('Response:', promptResult.final_output);
298
+ } catch (error) {
299
+ // Handle specific error types
300
+ if (error instanceof QodoSchemaError) {
301
+ console.error('Schema validation error:', error.message);
302
+ console.error('Check that all output properties have .describe()');
303
+ } else if (error instanceof QodoAuthError) {
304
+ console.error('Authentication error:', error.message);
305
+ console.error('Check your QODO_API_KEY environment variable');
306
+ } else {
307
+ throw error;
308
+ }
309
+ } finally {
310
+ // IMPORTANT: Always dispose to cleanup MCP servers and connections
311
+ await sdk.dispose();
312
+ console.log('\nSDK disposed, cleanup complete.');
313
+ }
314
+ }
315
+
316
+ // Run the example
317
+ main().catch(console.error);
@@ -0,0 +1,342 @@
1
+ # Built-in Tools Reference
2
+
3
+ This guide covers the built-in MCP tools available in `@qodo/sdk` and when to use each one.
4
+
5
+ ## Overview
6
+
7
+ | Tool | Purpose | Use Cases |
8
+ |------|---------|-----------|
9
+ | `filesystem` | File operations | Read/write/edit files, navigate directories |
10
+ | `git` | Version control | Check status, diff, commit, branch operations |
11
+ | `ripgrep` | Code search | Find patterns in files, search across codebase |
12
+ | `shell` | Command execution | Run system commands, scripts, build tools |
13
+
14
+ ---
15
+
16
+ ## filesystem
17
+
18
+ File system operations with sandboxed access to allowed directories.
19
+
20
+ ### When to Use
21
+
22
+ - Reading file contents (single or multiple files)
23
+ - Writing or creating new files
24
+ - Making targeted edits to existing files
25
+ - Navigating and exploring directory structures
26
+ - Moving, renaming, or deleting files
27
+
28
+ ### Available Operations
29
+
30
+ | Operation | Description | Auto-Approved |
31
+ |-----------|-------------|---------------|
32
+ | `read_files` | Read one or more files with optional line ranges | No |
33
+ | `write_file` | Create or overwrite a file | No |
34
+ | `edit_file` | Make precise text replacements | No |
35
+ | `create_directory` | Create directories (recursive) | No |
36
+ | `list_files_in_directories` | List immediate children of directories | Yes |
37
+ | `directory_tree` | Get recursive directory structure (folders only) | Yes |
38
+ | `move_file` | Move or rename files/directories | No |
39
+ | `get_file_info` | Get file metadata (size, dates, permissions) | Yes |
40
+ | `list_allowed_directories` | Show accessible directories | Yes |
41
+ | `delete_files` | Delete files or directories | No |
42
+
43
+ ### Example Usage
44
+
45
+ ```typescript
46
+ // Agent that analyzes and refactors code needs filesystem access
47
+ const agent = sdkAgent({
48
+ commands: {
49
+ analyze: sdkCommand({
50
+ name: 'analyze',
51
+ description: 'Analyze code quality',
52
+ available_tools: ['filesystem'], // Read files, navigate directories
53
+ // ...
54
+ }),
55
+ refactor: sdkCommand({
56
+ name: 'refactor',
57
+ description: 'Refactor code',
58
+ available_tools: ['filesystem'], // Read AND write files
59
+ // ...
60
+ }),
61
+ },
62
+ });
63
+ ```
64
+
65
+ ### Key Features
66
+
67
+ - **Line ranges**: Read specific portions of files with `startLine`/`endLine`, `head`, or `tail`
68
+ - **Batch operations**: Read multiple files in one call
69
+ - **Git-style diffs**: `edit_file` returns a diff showing changes made
70
+ - **Safe by default**: Operations are sandboxed to allowed directories
71
+
72
+ ---
73
+
74
+ ## git
75
+
76
+ Git version control operations.
77
+
78
+ ### When to Use
79
+
80
+ - Checking repository status and changes
81
+ - Viewing diffs (staged, unstaged, between branches)
82
+ - Staging and committing changes
83
+ - Creating and switching branches
84
+ - Viewing commit history
85
+
86
+ ### Available Operations
87
+
88
+ | Operation | Description | Auto-Approved |
89
+ |-----------|-------------|---------------|
90
+ | `git_status` | Show working tree status | Yes |
91
+ | `git_diff_unstaged` | Show unstaged changes | Yes |
92
+ | `git_diff_staged` | Show staged changes | Yes |
93
+ | `git_diff` | Diff between branches/commits | Yes |
94
+ | `git_diff_files` | Get file contents before/after changes | Yes |
95
+ | `git_log` | Show commit history | Yes |
96
+ | `git_show` | Show commit contents | Yes |
97
+ | `git_add` | Stage files | No |
98
+ | `git_reset` | Unstage all changes | No |
99
+ | `git_commit` | Create a commit | No |
100
+ | `git_init` | Initialize a repository | No |
101
+ | `git_create_branch` | Create a new branch | No |
102
+ | `git_checkout` | Switch branches | No |
103
+
104
+ ### Example Usage
105
+
106
+ ```typescript
107
+ // Code review agent that examines changes
108
+ const agent = sdkAgent({
109
+ commands: {
110
+ review: sdkCommand({
111
+ name: 'review',
112
+ description: 'Review code changes',
113
+ available_tools: ['git', 'filesystem'], // Read diffs AND file contents
114
+ // ...
115
+ }),
116
+ },
117
+ });
118
+ ```
119
+
120
+ ### Key Features
121
+
122
+ - **Comprehensive diffs**: View changes at file, staged, or branch level
123
+ - **File content access**: `git_diff_files` returns full before/after content for changed files
124
+ - **Safe reads**: All read operations are auto-approved
125
+ - **Branch operations**: Create, checkout, and manage branches
126
+
127
+ ---
128
+
129
+ ## ripgrep
130
+
131
+ Fast code search using ripgrep (rg).
132
+
133
+ ### When to Use
134
+
135
+ - Searching for patterns across a codebase
136
+ - Finding function/class definitions
137
+ - Locating usages of variables or imports
138
+ - Searching with regex patterns
139
+ - Filtering by file type
140
+
141
+ ### Available Operations
142
+
143
+ | Operation | Description | Auto-Approved |
144
+ |-----------|-------------|---------------|
145
+ | `ripgrep_search` | Search for patterns in files | Yes |
146
+ | `ripgrep_file_types` | List supported file types | Yes |
147
+
148
+ ### Example Usage
149
+
150
+ ```typescript
151
+ // Agent that needs to find and understand code
152
+ const agent = sdkAgent({
153
+ commands: {
154
+ findUsages: sdkCommand({
155
+ name: 'findUsages',
156
+ description: 'Find all usages of a function or variable',
157
+ available_tools: ['ripgrep', 'filesystem'], // Search + read
158
+ // ...
159
+ }),
160
+ },
161
+ });
162
+ ```
163
+
164
+ ### Search Options
165
+
166
+ | Option | Description | Default |
167
+ |--------|-------------|---------|
168
+ | `pattern` | Search pattern (regex supported) | Required |
169
+ | `fileTypes` | File extensions to search (e.g., `['ts', 'js']`) | Required |
170
+ | `path` | Directory or file to search | `.` |
171
+ | `caseSensitive` | Case-sensitive matching | `false` |
172
+ | `wholeWord` | Match whole words only | `false` |
173
+ | `fixedStrings` | Treat pattern as literal (not regex) | `false` |
174
+ | `excludePatterns` | Patterns to exclude | `[]` |
175
+ | `maxResults` | Maximum results to return | `100` |
176
+ | `contextLines` | Lines of context around matches | `0` |
177
+ | `includeHidden` | Include hidden files | `false` |
178
+
179
+ ### Key Features
180
+
181
+ - **Fast**: Uses ripgrep for blazing-fast searches
182
+ - **Regex support**: Full regex pattern matching
183
+ - **File type filtering**: Required to focus searches and improve performance
184
+ - **Context**: Optionally show surrounding lines
185
+
186
+ ### Tips
187
+
188
+ 1. **Always specify fileTypes** - This is required and improves search performance
189
+ 2. **Use `fixedStrings: true`** for literal searches with special characters
190
+ 3. **Combine with filesystem** - Search finds locations, then read for full context
191
+
192
+ ---
193
+
194
+ ## shell
195
+
196
+ Execute shell commands with optional sandboxing.
197
+
198
+ ### When to Use
199
+
200
+ - Running build tools (npm, cargo, make)
201
+ - Executing scripts
202
+ - System commands (with appropriate permissions)
203
+ - Any command not covered by other tools
204
+
205
+ ### Available Operations
206
+
207
+ | Operation | Description | Auto-Approved |
208
+ |-----------|-------------|---------------|
209
+ | `shell_execute` | Execute a command | Depends on command |
210
+
211
+ ### Auto-Approved Commands
212
+
213
+ These read-only commands run without user confirmation:
214
+
215
+ **Unix/Linux/macOS:**
216
+ - `ls`, `pwd`, `whoami`, `date`, `echo`
217
+ - `cat`, `head`, `tail`, `grep`, `find`
218
+ - `wc`, `env`, `printenv`, `which`
219
+ - `ps`, `df`, `du`, `hostname`, `uname`, `id`, `groups`
220
+
221
+ **Windows:**
222
+ - `dir`, `echo`, `ver`, `where`, `whoami`, `hostname`
223
+
224
+ ### Example Usage
225
+
226
+ ```typescript
227
+ // Build agent that runs npm commands
228
+ const agent = sdkAgent({
229
+ commands: {
230
+ build: sdkCommand({
231
+ name: 'build',
232
+ description: 'Build the project',
233
+ available_tools: ['shell', 'filesystem'],
234
+ // ...
235
+ }),
236
+ test: sdkCommand({
237
+ name: 'test',
238
+ description: 'Run tests',
239
+ available_tools: ['shell'],
240
+ // ...
241
+ }),
242
+ },
243
+ });
244
+ ```
245
+
246
+ ### Execute Options
247
+
248
+ | Option | Description | Default |
249
+ |--------|-------------|---------|
250
+ | `command` | Command to execute | Required |
251
+ | `args` | Command arguments array | `[]` |
252
+ | `cwd` | Working directory | Current directory |
253
+ | `timeout` | Timeout in milliseconds | `30000` |
254
+ | `use_shell` | Execute through shell (enables pipes, redirects) | `false` |
255
+
256
+ ### Key Features
257
+
258
+ - **Shell mode**: Set `use_shell: true` for piping, redirection, etc.
259
+ - **Timeout protection**: Commands are killed after timeout
260
+ - **Cross-platform**: Works on macOS, Linux, and Windows
261
+ - **Optional sandboxing**: macOS supports sandbox-exec profiles
262
+
263
+ ### Tips
264
+
265
+ 1. **Prefer direct execution** (`use_shell: false`) for better security
266
+ 2. **Use `use_shell: true`** only when you need shell features (pipes, redirects)
267
+ 3. **Set appropriate timeouts** for long-running commands
268
+
269
+ ---
270
+
271
+ ## Tool Combinations
272
+
273
+ Common tool combinations for different tasks:
274
+
275
+ ### Code Analysis
276
+
277
+ ```typescript
278
+ available_tools: ['filesystem', 'ripgrep']
279
+ ```
280
+ Search for patterns, then read full file contents for context.
281
+
282
+ ### Code Modification
283
+
284
+ ```typescript
285
+ available_tools: ['filesystem', 'git']
286
+ ```
287
+ Read/edit files, then check status and create commits.
288
+
289
+ ### Full Development Workflow
290
+
291
+ ```typescript
292
+ available_tools: ['filesystem', 'git', 'ripgrep', 'shell']
293
+ ```
294
+ Complete access for complex development tasks.
295
+
296
+ ### Code Review
297
+
298
+ ```typescript
299
+ available_tools: ['git', 'filesystem']
300
+ ```
301
+ View diffs and read changed files for review.
302
+
303
+ ### Build & Test
304
+
305
+ ```typescript
306
+ available_tools: ['shell', 'filesystem']
307
+ ```
308
+ Run build commands and check output files.
309
+
310
+ ---
311
+
312
+ ## Security Considerations
313
+
314
+ 1. **Sandboxed Access**: filesystem operations are limited to allowed directories
315
+ 2. **Auto-Approval**: Read-only operations are generally auto-approved; write operations require approval
316
+ 3. **Shell Safety**: Direct execution is preferred over shell mode for security
317
+ 4. **Timeout Protection**: All shell commands have enforced timeouts
318
+
319
+ ---
320
+
321
+ ## Troubleshooting
322
+
323
+ ### Tool Not Available
324
+
325
+ If a tool isn't working, check:
326
+
327
+ 1. **Tool in `available_tools`**: Ensure the tool is listed in your command config
328
+ 2. **Not in `ignore_tools`**: Make sure it's not accidentally ignored
329
+ 3. **Dependencies installed**: ripgrep requires `rg` to be installed (or `@vscode/ripgrep` package)
330
+
331
+ ### Permission Denied
332
+
333
+ For filesystem operations:
334
+ - Check that the path is within allowed directories
335
+ - Use `list_allowed_directories` to see accessible paths
336
+
337
+ ### Shell Commands Failing
338
+
339
+ - Check the command exists on the system
340
+ - Verify the working directory exists
341
+ - Use `use_shell: true` if you need shell features
342
+ - Increase timeout for long-running commands