/** @jsxImportSource smithers-orchestrator */
import { createSmithers, Sequence, Task, AnthropicAgent } from "smithers-orchestrator";
import { z } from "zod";
const AnalysisSchema = z.object({
summary: z.string(),
issues: z.array(z.object({
file: z.string(),
line: z.number(),
severity: z.enum(["low", "medium", "high"]),
description: z.string(),
})),
});
const { Workflow, smithers, outputs } = createSmithers({
analysis: AnalysisSchema,
fix: z.object({
patch: z.string(),
filesChanged: z.array(z.string()),
}),
});
const analyst = new AnthropicAgent({
model: "claude-sonnet-4-20250514",
instructions: "You are a senior code reviewer. Return structured JSON.",
});
const fixer = new AnthropicAgent({
model: "claude-sonnet-4-20250514",
instructions: "Write minimal, correct fixes as a unified diff.",
});
export default smithers((ctx) => {
const analysis = ctx.outputMaybe(outputs.analysis, { nodeId: "analyze" });
return (
<Workflow name="review">
<Sequence>
<Task id="analyze" output={outputs.analysis} agent={analyst}>
{`Review ${ctx.input.repo}`}
</Task>
{analysis ? (
<Task id="fix" output={outputs.fix} agent={fixer}>
{`Fix these issues:\n${analysis.issues.map(i =>
`- [${i.severity}] ${i.file}:${i.line} - ${i.description}`
).join("\n")}`}
</Task>
) : null}
</Sequence>
</Workflow>
);
});