autosnippet
Version:
Extract code patterns into a knowledge base for AI coding assistants
132 lines (131 loc) • 3.91 kB
TypeScript
/**
* ChatAgentTasks — Agent 预定义任务方法
*
* 每个任务接收 context 对象: { invokeAgent, aiProvider, container, logger }
* - invokeAgent(toolName, params) — 直接执行工具 handler(纯数据工具)
* - aiProvider — AI Provider 实例
* - container — ServiceContainer
* - logger — Logger 实例
*/
/** AI provider interface subset used by task functions */
interface TaskAiProvider {
chat(prompt: string, opts?: Record<string, unknown>): Promise<string>;
chatWithStructuredOutput(prompt: string, opts?: Record<string, unknown>): Promise<unknown>;
}
/** Task execution context provided by the ChatAgent framework */
interface TaskContext {
invokeAgent(toolName: string, params: Record<string, unknown>): Promise<Record<string, unknown>>;
aiProvider?: TaskAiProvider;
container: {
get(name: string): unknown;
};
logger?: unknown;
}
/** Candidate input shape for check-and-submit */
interface CandidateInput {
title?: string;
code?: string;
[key: string]: unknown;
}
/** Duplicate search result entry */
interface DuplicateEntry {
title?: string;
similarity: number;
[key: string]: unknown;
}
/** Guard violation entry */
interface GuardViolation {
severity?: string;
message?: string;
ruleName?: string;
line?: number;
matches?: Array<{
line?: number;
[key: string]: unknown;
}>;
[key: string]: unknown;
}
/**
* 任务: 提交前查重 + 质量预评
* 1. check_duplicate → 若发现相似 ≥ 0.7 则建议合并
* 2. 顺便返回质量评估建议
*/
export declare function taskCheckAndSubmit(context: TaskContext, { candidate, projectRoot }: {
candidate: CandidateInput;
projectRoot?: string;
}): Promise<{
duplicates: DuplicateEntry[];
highSimilarity: DuplicateEntry[];
aiVerdict: string | null;
recommendation: string;
}>;
/**
* 任务: 批量发现 Recipe 间的知识图谱关系
* 委托给 AgentFactory.discoverRelations (独立 Explore → Synthesize 管线)
*/
export declare function taskDiscoverAllRelations(context: TaskContext, { batchSize }?: {
batchSize?: number | undefined;
}): Promise<unknown>;
/** 任务: 批量 AI 补全候选语义字段 */
export declare function taskFullEnrich(context: TaskContext, { status, maxCount }?: {
status?: string | undefined;
maxCount?: number | undefined;
}): Promise<Record<string, unknown>>;
/**
* 任务: 批量质量审计全部 Recipe
* 对活跃 Recipe 逐个评分,返回低于阈值的列表
*/
export declare function taskQualityAudit(context: TaskContext, { threshold, maxCount }?: {
threshold?: number | undefined;
maxCount?: number | undefined;
}): Promise<{
total: number;
lowQuality: never[];
message: string;
threshold?: undefined;
gradeDistribution?: undefined;
lowQualityCount?: undefined;
} | {
total: number;
threshold: number;
gradeDistribution: {
A: number;
B: number;
C: number;
D: number;
F: number;
};
lowQualityCount: number;
lowQuality: {
id: string;
title: string | undefined;
score: number;
grade: string;
dimensions: unknown;
}[];
message?: undefined;
}>;
/**
* 任务: Guard 完整扫描
* 对代码运行全部 Guard 规则 + 生成修复建议
*/
export declare function taskGuardFullScan(context: TaskContext, { code, language, filePath }?: {
code?: string;
language?: string;
filePath?: string;
}): Promise<{
error: string;
filePath?: undefined;
language?: undefined;
violationCount?: undefined;
violations?: undefined;
suggestions?: undefined;
} | {
filePath: string;
language: string | undefined;
violationCount: number;
violations: GuardViolation[] | undefined;
suggestions: unknown;
error?: undefined;
}>;
export {};