forked from CodebuffAI/codebuff
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-tool-definitions.ts
More file actions
executable file
·43 lines (34 loc) · 1.28 KB
/
Copy pathgenerate-tool-definitions.ts
File metadata and controls
executable file
·43 lines (34 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bun
import { execSync } from 'child_process'
import { writeFileSync, mkdirSync } from 'fs'
import { join, dirname } from 'path'
import { compileToolDefinitions } from '@codebuff/common/tools/compile-tool-definitions'
/**
* Regenerates the tool-definitions.d.ts file from the current tool schemas.
* This ensures the type definitions stay in sync with the actual tool parameters.
*/
function main() {
console.log('🔧 Generating tool definitions...')
try {
const content = compileToolDefinitions()
// Write to the templates path (common/src/templates/initial-agents-dir/types)
const outputPath = join(
process.cwd(),
'common/src/templates/initial-agents-dir/types/tools.ts',
)
// Create the directory if it does not exist
mkdirSync(dirname(outputPath), { recursive: true })
writeFileSync(outputPath, content, 'utf8')
// Format the generated file with prettier
console.log('🎨 Formatting generated file...')
execSync(`npx prettier --write "${outputPath}"`, { stdio: 'inherit' })
console.log('✅ Successfully generated tools.ts')
console.log(`📁 Output: ${outputPath}`)
} catch (error) {
console.error('❌ Failed to generate tool definitions:', error)
process.exit(1)
}
}
if (import.meta.main) {
main()
}