/** * Agent Contract — 统一的 JSON 输出格式 * * 移植自 OpenSpec 的 agent-contract 模式,为 AI 代理提供结构化输出 * * 所有命令支持 --json 选项时,输出格式为: * { * status: 'success' | 'error' | 'blocked', * data?: any, * diagnostics?: Array<{ severity, code, message, fix? }>, * nextSteps?: string[] * } */ export type AgentStatus = 'success' | 'error' | 'blocked' | 'warning'; export type DiagnosticSeverity = 'info' | 'warning' | 'error' | 'critical'; export interface Diagnostic { /** 严重程度 */ severity: DiagnosticSeverity; /** 诊断代码(如 CONFIG_MISSING, SCHEMA_INVALID) */ code: string; /** 人类可读的消息 */ message: string; /** 修复建议 */ fix?: string; } export interface AgentResponse { /** 操作状态 */ status: AgentStatus; /** 响应数据(命令特定) */ data?: T; /** 诊断信息(警告、错误、建议) */ diagnostics?: Diagnostic[]; /** 建议的下一步操作 */ nextSteps?: string[]; } /** * status 命令的 data 结构 */ export interface StatusData { change: string; artifacts: Array<{ name: string; status: 'complete' | 'incomplete' | 'missing'; path: string; }>; tasks: { total: number; complete: number; blocked: number; pending: number; }; specs: { added: number; modified: number; removed: number; }; } /** * apply 命令的 data 结构 */ export interface ApplyData { change: string; execution: { mode: 'serial' | 'parallel' | 'host-driven'; completedTasks: number; totalTasks: number; blockedTasks: number; parkedFindings: number; }; conflicts?: string[]; mergeFailures?: string[]; } /** * propose 命令的 data 结构 */ export interface ProposeData { change: string; artifacts: Array<{ name: string; path: string; created: boolean; }>; schema: string; } /** * archive 命令的 data 结构 */ export interface ArchiveData { change: string; archivedAs: string; path: string; specsUpdated: number; totals: { added: number; modified: number; removed: number; total: number; }; warnings: string[]; } /** * schemas 命令的 data 结构 */ export interface SchemasData { schemas: Array<{ id: string; name: string; artifactCount: number; valid: boolean; source: 'project' | 'user' | 'builtin'; }>; } /** * instructions 命令的 data 结构 */ export interface InstructionsData { artifactId: string; change: string; context: string; rules: string[]; template: string; instruction: string; resolvedOutputPath: string; } /** * 创建成功的响应 */ export declare function successResponse(data: T, diagnostics?: Diagnostic[]): AgentResponse; /** * 创建错误的响应 */ export declare function errorResponse(message: string, code: string, fix?: string): AgentResponse; /** * 创建阻塞的响应 */ export declare function blockedResponse(message: string, nextSteps: string[]): AgentResponse; /** * 创建警告的响应 */ export declare function warningResponse(data: T, warnings: Diagnostic[]): AgentResponse; /** * 输出 JSON 响应(用于 --json 模式) */ export declare function outputJson(response: AgentResponse): void; //# sourceMappingURL=agent-contract.d.ts.map