MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / main

Function main

sdk/e2e/examples/sdk-lint.example.ts:28–62  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

26`.trim()
27
28async function main() {
29 const apiKey = process.env.CODEBUFF_API_KEY
30 if (!apiKey) {
31 console.error('CODEBUFF_API_KEY environment variable is required')
32 process.exit(1)
33 }
34
35 const client = new CodebuffClient({ apiKey })
36
37 console.log('🔎 Linting code...\n')
38 console.log('Code:')
39 console.log('```')
40 console.log(CODE_TO_LINT)
41 console.log('```\n')
42 console.log('Lint results:\n')
43
44 const result = await client.run({
45 agent: 'codebuff/base2@latest',
46 prompt: `Act as a linter. Find issues in this code and provide specific feedback:\n\n${CODE_TO_LINT}`,
47 handleStreamChunk: (chunk) => {
48 if (typeof chunk === 'string') {
49 process.stdout.write(chunk)
50 }
51 },
52 })
53
54 console.log('\n')
55
56 if (result.output.type === 'error') {
57 console.error('Error:', result.output.message)
58 process.exit(1)
59 }
60
61 console.log('✅ Linting complete!')
62}
63
64main().catch(console.error)

Callers 1

Calls 1

runMethod · 0.95

Tested by

no test coverage detected