Skip to content

Commit f8fe9fe

Browse files
Prevent ENOENT by creating templates dir and redirecting generator output to tools.ts; ensure directory exists and fix inline generator comment; also make WebSearchParams.depth optional.
🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
1 parent 90f0246 commit f8fe9fe

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

common/src/templates/initial-agents-dir/types/tools.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export interface WebSearchParams {
173173
/** The search query to find relevant web content */
174174
query: string
175175
/** Search depth - 'standard' for quick results, 'deep' for more comprehensive search. Default is 'standard'. */
176-
depth: 'standard' | 'deep'
176+
depth?: 'standard' | 'deep'
177177
}
178178

179179
/**

scripts/generate-tool-definitions.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bun
22

3-
import { writeFileSync } from 'fs'
4-
import { join } from 'path'
3+
import { writeFileSync, mkdirSync } from 'fs'
4+
import { join, dirname } from 'path'
55
import { execSync } from 'child_process'
66

77
import { compileToolDefinitions } from '@codebuff/common/tools/compile-tool-definitions'
@@ -15,15 +15,22 @@ function main() {
1515

1616
try {
1717
const content = compileToolDefinitions()
18-
const outputPath = join(process.cwd(), 'common/src/util/types/tools.d.ts')
18+
// Write to the templates path (common/src/templates/initial-agents-dir/types)
19+
const outputPath = join(
20+
process.cwd(),
21+
'common/src/templates/initial-agents-dir/types/tools.ts',
22+
)
23+
24+
// Create the directory if it does not exist
25+
mkdirSync(dirname(outputPath), { recursive: true })
1926

2027
writeFileSync(outputPath, content, 'utf8')
2128

2229
// Format the generated file with prettier
2330
console.log('🎨 Formatting generated file...')
2431
execSync(`npx prettier --write "${outputPath}"`, { stdio: 'inherit' })
2532

26-
console.log('✅ Successfully generated tools.d.ts')
33+
console.log('✅ Successfully generated tools.ts')
2734
console.log(`📁 Output: ${outputPath}`)
2835
} catch (error) {
2936
console.error('❌ Failed to generate tool definitions:', error)

0 commit comments

Comments
 (0)