/** * AI 调用抽象层 * * @deprecated 仅 SDD Engine 模式(默认模式)使用。 * Host-Driven 模式下,子代理派发逻辑已迁移到 SKILL.md 文件中: * - `execution-sdd-orchestrator/SKILL.md` — 编排层派发指令 * - `execution-subagent-dispatch/SKILL.md` — 子代理 prompt 模板 * * 统一的子代理分发接口,遵循 Superpowers 的核心原则: * 1. 每个子代理使用全新上下文(不继承主会话历史) * 2. 产物通过文件传递(不占用上下文窗口) * 3. 支持多种 AI 后端:Claude Code、Cursor、自定义 CLI * * 子代理通信协议: * Controller → writes brief file → AI reads brief → AI writes report → Controller reads report * * 模型选择策略(5级层次): * cheap → standard → capable * 修复轮次 4-5 自动升级到更强模型 */ import type { TaskBrief, TaskReport, ReviewResult, Finding } from './types.js'; /** * AI 后端适配器接口 * 不同 AI 工具实现此接口来适配具体的调用方式 */ export interface AIBackend { /** 后端名称 */ readonly name: string; /** 调用 AI 执行任务,将输出写入 outputPath */ execute(promptFile: string, model?: string, outputPath?: string, cwd?: string): Promise; /** 检查后端是否可用 */ isAvailable(): boolean; } /** * 子代理分发选项 */ export interface DispatchOptions { /** 任务简报 */ brief: TaskBrief; /** 任务限定 */ taskConstraint: string; /** 使用的模型(可选,不指定则自动选择) */ model?: string; /** 超时时间(毫秒) */ timeout?: number; } export declare class AICaller { private backends; private workspaceDir; constructor(workspaceDir: string, preferredBackend?: string, options?: { timeout?: number; }); /** * 获取可用后端 */ private getAvailableBackend; /** * 写入分发 prompt 到文件 */ private writePromptFile; /** * 构建实现者 prompt * * 遵循 Superpowers 的子代理分发设计: * - 只告诉代理去哪里读简报(不粘贴任务描述) * - 传递全局约束和接口约定 * - 要求将报告写入指定文件 */ buildImplementerPrompt(brief: TaskBrief, projectContext: string, specConstraints: string): string; /** * 构建审查者 prompt * * 两阶段审查门(来自 Superpowers): * 1. 规格合规:实现是否覆盖所有需求 * 2. 代码质量:实现质量评估 */ buildReviewerPrompt(brief: TaskBrief, reviewPackagePath: string): string; /** * 构建重新审查 prompt * * 范围限定的重新审查——只审查修复 diff */ buildReReviewerPrompt(brief: TaskBrief, reviewPackagePath: string, openFindings: Finding[]): string; /** * 分发实现者子代理 * * 1. 写入实现者 prompt 到文件 * 2. 调用 AI 后端执行 * 3. 读取报告文件 * 4. 解析返回 TaskReport */ dispatchImplementer(brief: TaskBrief, projectContext: string, specConstraints: string, model?: string): Promise; /** * 分发审查者子代理 */ dispatchReviewer(brief: TaskBrief, _projectContext: string, _specConstraints: string, baseCommit?: string, headCommit?: string): Promise; /** * 分发重新审查者子代理(范围限定) */ dispatchReReviewer(brief: TaskBrief, openFindings: Finding[], baseCommit?: string, headCommit?: string): Promise; /** * 格式化简报文件内容 */ private formatBriefFile; /** * 解析任务报告 */ private parseTaskReport; /** * 解析审查结果 */ private parseReviewResult; /** * 状态映射 */ private mapStatus; /** * 从文本中提取 commit SHA * 使用 word boundary 避免误匹配非 SHA 的十六进制字符串 */ private extractCommits; } //# sourceMappingURL=ai-caller.d.ts.map