UNPKG

autosnippet

Version:

Extract code patterns into a knowledge base for AI coding assistants

45 lines (44 loc) 1.6 kB
/** * createSupersedeProposal — 统一的 supersede 提案创建逻辑 * * 内部 Agent 路径 (lifecycle.ts / composite.ts) 和外部 MCP 路径 (consolidated.ts) * 共用此函数,确保知识替代的进化架构入口唯一。 * * 流程: * 1. 从 DI 容器获取 ProposalRepository * 2. 验证旧 Recipe 存在 * 3. 去重检查(ProposalRepository 内部) * 4. 创建 type='supersede' 提案,进入 72h 观察窗口 */ import type { ProposalSource } from '../../repository/evolution/ProposalRepository.js'; /** 最小 DI 容器接口 — 兼容 ServiceContainer / McpServiceContainer / ToolHandlerContext.container */ interface MinimalContainer { get(name: string): unknown; } export interface SupersedeInput { /** 被替代的旧 Recipe ID */ oldRecipeId: string; /** 新提交的 Recipe ID 列表 */ newRecipeIds: string[]; /** 来源标识:'ide-agent' | 'metabolism' | 'decay-scan' */ source?: ProposalSource; /** 置信度,默认 0.8 */ confidence?: number; } export interface SupersedeResult { proposalId: string; type: 'supersede'; targetRecipe: { id: string; }; status: string; expiresAt: number; message: string; } /** * 在 DI 容器中查找 ProposalRepository,验证旧 Recipe 存在后创建 supersede 提案。 * * @returns SupersedeResult(成功)| null(ProposalRepo 不可用 / 旧 Recipe 不存在 / 去重拒绝) */ export declare function createSupersedeProposal(container: MinimalContainer, input: SupersedeInput): Promise<SupersedeResult | null>; export {};