/**
 * Built-in workflow: `audit_repo`
 *
 * Fan-out repo audit. Phase 1 inventories the repo; phase 2 spawns N reviewers
 * in parallel, one per dimension (bugs / perf / security / tests / style);
 * phase 3 synthesises into a structured report. The script is kept readable so
 * users can copy it into `~/.xopc/workflows/` as a starting point.
 *
 * Args:
 *   - scope: subdirectory to focus on (default '.')
 *   - dimensions: subset of dimension keys, e.g. ['security', 'bugs']
 */
export declare const AUDIT_REPO_SCRIPT = "export const meta = {\n  name: 'audit_repo',\n  description: 'Fan-out repository audit across multiple dimensions, then synthesize a structured report.',\n  whenToUse: 'User asks for a thorough / multi-dimension code review of the whole repo or a major subsystem.',\n  examplePrompts: [\n    { field: 'goal', text: 'Run a thorough audit of this repository' },\n    { field: 'goal', text: 'Review code quality across the whole codebase' },\n  ],\n  i18n: {\n    zh: {\n      description: '\u591A\u7EF4\u5EA6\u5E76\u884C\u5BA1\u67E5\u6574\u4E2A\u4ED3\u5E93\uFF0C\u5E76\u6C47\u603B\u4E3A\u7ED3\u6784\u5316\u62A5\u544A\u3002',\n      whenToUse: '\u7528\u6237\u9700\u8981\u5BF9\u6574\u5E93\u6216\u4E3B\u8981\u5B50\u7CFB\u7EDF\u505A\u5168\u9762\u3001\u591A\u7EF4\u5EA6\u7684\u4EE3\u7801\u5BA1\u67E5\u65F6\u3002',\n      examplePrompts: [\n        { field: 'goal', text: '\u5BF9\u6574\u4E2A\u4ED3\u5E93\u505A\u4E00\u6B21\u5168\u9762\u5BA1\u67E5' },\n        { field: 'goal', text: '\u4ECE\u4EE3\u7801\u8D28\u91CF\u7EF4\u5EA6\u5BA1\u67E5\u6574\u4E2A\u4EE3\u7801\u5E93' },\n      ],\n    },\n  },\n  tags: ['code-review', 'audit'],\n  estimatedAgents: { min: 7, max: 7 },\n  phases: [\n    { title: 'Inventory' },\n    { title: 'Review' },\n    { title: 'Synthesize' },\n  ],\n}\n\nconst READ_ONLY_TOOLS = ['read_file', 'grep', 'find', 'list_dir']\n\nconst scope = args && typeof args === 'object' && args.scope\n  ? String(args.scope)\n  : '.'\n\nconst ALL_DIMENSIONS = [\n  { key: 'bugs', focus: 'Correctness bugs, null-safety, error handling, race conditions, off-by-one, dead code.' },\n  { key: 'perf', focus: 'Performance issues, hot paths, N+1 patterns, accidental quadratic loops, sync I/O, missing caching.' },\n  { key: 'security', focus: 'Auth/authz, input validation, secret handling, injection sinks, unsafe deserialization, SSRF.' },\n  { key: 'tests', focus: 'Test coverage gaps, brittle tests, integration vs unit gaps, missing regression cases.' },\n  { key: 'style', focus: 'Inconsistent conventions, naming, unused exports, duplication, layering violations.' },\n]\n\nlet dimensions = ALL_DIMENSIONS\nif (args && typeof args === 'object' && Array.isArray(args.dimensions) && args.dimensions.length) {\n  const keys = new Set(args.dimensions.map((d) => String(d)))\n  dimensions = ALL_DIMENSIONS.filter((d) => keys.has(d.key))\n  if (!dimensions.length) dimensions = ALL_DIMENSIONS\n}\n\nphase('Inventory')\nconst inventory = await agent(\n  'Produce a compact map of this repository scope: ' + scope + '. ' +\n    'Cover layout, main modules, the 5\u201310 most important files, and obvious entry points. Be terse and structured.',\n  { label: 'repo inventory', toolset: READ_ONLY_TOOLS },\n)\n\nphase('Review')\nconst findings = await parallel(\n  dimensions.map((d) => () =>\n    agent(\n      'Review scope \"' + scope + '\" through the ' + d.key + ' lens.\\n' +\n        'Focus: ' + d.focus + '\\n\\n' +\n        'Inventory for orientation:\\n' + inventory + '\\n\\n' +\n        'Return findings: file paths, line numbers when known, severity (low/med/high), a one-sentence why, a one-sentence fix.',\n      {\n        label: d.key + ' review',\n        toolset: READ_ONLY_TOOLS,\n        schema: {\n          type: 'object',\n          properties: {\n            findings: {\n              type: 'array',\n              items: {\n                type: 'object',\n                properties: {\n                  file: { type: 'string' },\n                  line: { type: ['number', 'string'] },\n                  severity: { type: 'string', enum: ['low', 'med', 'high'] },\n                  title: { type: 'string' },\n                  fix: { type: 'string' },\n                },\n                required: ['file', 'severity', 'title', 'fix'],\n              },\n            },\n          },\n          required: ['findings'],\n        },\n      },\n    ),\n  ),\n)\n\nphase('Synthesize')\nconst live = findings.filter(Boolean)\nif (!live.length) {\n  return { ok: true, scope, summary: 'No findings.', byDimension: {}, priorityActions: [] }\n}\nconst byDimension = {}\nfor (let i = 0; i < dimensions.length; i++) {\n  byDimension[dimensions[i].key] = live[i]?.findings ?? []\n}\n\nconst summary = await agent(\n  'Synthesize a compact report from these per-dimension findings. Deduplicate near-identical items. ' +\n    'Order by severity (high \u2192 low). Cap topFindings at 20. ' +\n    'Also return priorityActions: the top 5 fixes ranked by impact, each with effort (S|M|L).\\n\\n' +\n    JSON.stringify(byDimension, null, 2),\n  {\n    label: 'report synthesis',\n    schema: {\n      type: 'object',\n      properties: {\n        topFindings: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              dimension: { type: 'string' },\n              file: { type: 'string' },\n              severity: { type: 'string' },\n              title: { type: 'string' },\n              fix: { type: 'string' },\n            },\n            required: ['dimension', 'file', 'severity', 'title'],\n          },\n        },\n        priorityActions: {\n          type: 'array',\n          items: {\n            type: 'object',\n            properties: {\n              file: { type: 'string' },\n              severity: { type: 'string' },\n              title: { type: 'string' },\n              effort: { type: 'string', enum: ['S', 'M', 'L'] },\n            },\n            required: ['file', 'severity', 'title', 'effort'],\n          },\n        },\n        summary: { type: 'string' },\n      },\n      required: ['topFindings', 'priorityActions', 'summary'],\n    },\n  },\n)\n\nreturn {\n  ok: true,\n  scope,\n  dimensions: dimensions.map((d) => d.key),\n  ...(summary ?? { topFindings: [], priorityActions: [], summary: 'synthesis failed' }),\n  byDimension,\n}\n";
