{"version":3,"file":"deep-review.d.ts","sourceRoot":"","sources":["../../../src/pack/templates/deep-review.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,mBAAmB,EAAqB,MAAM,iBAAiB,CAAC;AAE9E,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AACrD,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAElD;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,upFA0ErC,CAAC;AAEF,0EAA0E;AAC1E,wBAAgB,2BAA2B,IAAI,OAAO,CAAC,MAAM,CAAC,CAE7D;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAQnF","sourcesContent":["import { composeWorkflowEntrypoint } from \"../../components/workflow-sdk/index.ts\";\nimport { type WrittenWorkflowPack, writeWorkflowPack } from \"./write-pack.ts\";\n\nexport const DEEP_REVIEW_WORKFLOW_ID = \"deep-review\";\nexport const DEEP_REVIEW_TRIGGER = \"/deep-review\";\n\n/**\n * The /deep-review workflow body: discover changed files, review each one,\n * adversarially verify every finding, and return only the confirmed ones.\n * Fixed orchestration — the script holds the control flow; child agents do\n * the reading and judging.\n */\nexport const DEEP_REVIEW_WORKFLOW_BODY = `\nconst FILES_SCHEMA = {\n\ttype: \"object\",\n\trequired: [\"files\"],\n\tproperties: { files: { type: \"array\", items: { type: \"string\" } } },\n};\nconst FINDINGS_SCHEMA = {\n\ttype: \"object\",\n\trequired: [\"findings\"],\n\tproperties: {\n\t\tfindings: {\n\t\t\ttype: \"array\",\n\t\t\titems: {\n\t\t\t\ttype: \"object\",\n\t\t\t\trequired: [\"summary\", \"severity\"],\n\t\t\t\tproperties: {\n\t\t\t\t\tsummary: { type: \"string\" },\n\t\t\t\t\tseverity: { enum: [\"low\", \"medium\", \"high\"] },\n\t\t\t\t\tline: { type: \"integer\" },\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t},\n};\nconst VERDICT_SCHEMA = {\n\ttype: \"object\",\n\trequired: [\"confirmed\"],\n\tproperties: { confirmed: { type: \"boolean\" }, reason: { type: \"string\" } },\n};\n\nrunWorkflow(async ({ args }) => {\n\tconst scope = typeof args.text === \"string\" && args.text.trim() ? args.text.trim() : \"the current working tree\";\n\tconst discovered = await agent(\n\t\t\"List the source files with pending changes in \" +\n\t\t\tscope +\n\t\t\t\". Run 'git diff --name-only HEAD' (fall back to 'git status --porcelain') in the workspace and report the changed source files. Exclude lockfiles and generated output.\",\n\t\t{ schema: FILES_SCHEMA },\n\t);\n\tconst reviews = await pipeline(\n\t\tdiscovered.files,\n\t\t(file) =>\n\t\t\tagent(\n\t\t\t\t\"Review the file \" +\n\t\t\t\t\tfile +\n\t\t\t\t\t\" strictly for correctness bugs in its pending changes: logic errors, broken edge cases, wrong conditions, unsafe assumptions. Read the file before judging. Report only defects you are confident about; do not report style issues.\",\n\t\t\t\t{ schema: FINDINGS_SCHEMA },\n\t\t\t),\n\t\tasync (review, file) => {\n\t\t\tconst verified = await parallel(\n\t\t\t\treview.findings.map((finding) => async () => {\n\t\t\t\t\tconst verdict = await agent(\n\t\t\t\t\t\t\"Adversarially verify this code-review finding for \" +\n\t\t\t\t\t\t\tfile +\n\t\t\t\t\t\t\t': \"' +\n\t\t\t\t\t\t\tfinding.summary +\n\t\t\t\t\t\t\t'\". Read the file and try to REFUTE the finding. Confirm it only if you can point to the concrete failure; default to refuted when uncertain.',\n\t\t\t\t\t\t{ schema: VERDICT_SCHEMA },\n\t\t\t\t\t);\n\t\t\t\t\treturn verdict.confirmed ? { ...finding, file, reason: verdict.reason ?? \"\" } : null;\n\t\t\t\t}),\n\t\t\t);\n\t\t\treturn verified.filter(Boolean);\n\t\t},\n\t);\n\tconst findings = reviews\n\t\t.filter(Boolean)\n\t\t.flat()\n\t\t.sort((left, right) => {\n\t\t\tconst rank = { high: 0, medium: 1, low: 2 };\n\t\t\treturn (rank[left.severity] ?? 3) - (rank[right.severity] ?? 3);\n\t\t});\n\tlog(\"deep-review: \" + findings.length + \" confirmed finding(s)\");\n\treturn { scope, findings };\n});\n`;\n\n/** The composed single-file component entrypoint (SDK prelude + body). */\nexport function composeDeepReviewEntrypoint(): Promise<string> {\n\treturn composeWorkflowEntrypoint(DEEP_REVIEW_WORKFLOW_BODY);\n}\n\n/** Write a complete, importable /deep-review optimization pack into `directory`. */\nexport function writeDeepReviewPack(directory: string): Promise<WrittenWorkflowPack> {\n\treturn writeWorkflowPack(directory, {\n\t\tid: DEEP_REVIEW_WORKFLOW_ID,\n\t\ttrigger: DEEP_REVIEW_TRIGGER,\n\t\tversion: \"1.0.0\",\n\t\tdescription: \"Voting-style code review workflow: per-file reviewers plus adversarial verification.\",\n\t\tbody: DEEP_REVIEW_WORKFLOW_BODY,\n\t});\n}\n"]}