返回 CodeWhale
review-main.ts
根目录 / crates / tui / extension-host / src / dsh / review-main.ts
1 /** Detached trusted offline reviewer. No HostRoot, plugin import or expression evaluation. */
2 import { reviewComposition, type ReviewedComposition } from './composition.ts'
3 import {reviewAgentPresets, type PresetReviewInput} from './agent-presets.ts'
4
5 try {
6 let bytes = 0
7 const chunks: Buffer[] = []
8 for await (const chunk of process.stdin) {
9 const part = Buffer.from(chunk)
10 bytes += part.length
11 if (bytes > 8 * 1024 * 1024) throw new Error('review request exceeds 8 MiB')
12 chunks.push(part)
13 }
14 const input = JSON.parse(Buffer.concat(chunks).toString('utf8')) as ReviewedComposition
15 const output = JSON.stringify((input as any).kind === 'agent-presets' ? await reviewAgentPresets(input as unknown as PresetReviewInput) : reviewComposition(input))
16 if (Buffer.byteLength(output) > 8 * 1024 * 1024) throw new Error('review response exceeds 8 MiB')
17 process.stdout.write(output)
18 } catch {
19 // Parser diagnostics can contain source literals. Emit a source-free error.
20 process.stderr.write('DSH composition review refused invalid or oversized data.\n')
21 process.exitCode = 1
22 }
23
23 lines TYPESCRIPT