Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
582 changes: 536 additions & 46 deletions src/advance/classic/cognitive-engine.ts

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/advance/classic/fix/cognitive-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,14 @@ export interface CognitiveDecision extends MaintainerDecision {
reasoning: string;
/** 决策置信度 */
confidence: 'high' | 'medium' | 'low';
/** 认知阶段推断出的可能受影响文件,供修复执行阶段做受控审计 */
affectedFiles?: string[];
/** 修复完成后必须检查的语义验证目标 */
verificationPlan?: string[];
/** 方案评审阶段识别出的剩余风险或控制措施 */
risks?: string[];
/** 对候选方案进行红队挑战后保留的关键意见 */
adversarialConcerns?: string[];
/** 最终决策对红队意见的逐项回应 */
adversarialResponses?: string[];
}
5 changes: 2 additions & 3 deletions src/advance/classic/fix/fix-tool-loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,11 @@ export class FixToolLoop {
this.maxTruncationRetries = options.maxTruncationRetries ?? 3;
this.maxNoToolCallRetries = options.maxNoToolCallRetries ?? 2;
this.maxUnchangedFinishRetries = options.maxUnchangedFinishRetries ?? 2;
this.maxStepsWithoutProgress = options.maxStepsWithoutProgress ?? 5;
this.maxStepsWithoutProgress = options.maxStepsWithoutProgress ?? Number.POSITIVE_INFINITY;
this.staleReminderStep =
options.staleReminderStep ?? Math.max(1, this.maxStepsWithoutProgress - 2);
this.extraSystemPrompt = options.extraSystemPrompt ?? '';
this.maxReadOnlySteps =
options.maxReadOnlySteps ?? Math.max(8, this.maxStepsWithoutProgress + 3);
this.maxReadOnlySteps = options.maxReadOnlySteps ?? Number.POSITIVE_INFINITY;
this.readOnlyReminderStep =
options.readOnlyReminderStep ?? Math.max(1, this.maxReadOnlySteps - 2);
this.finalActingSteps = Math.max(1, options.finalActingSteps ?? 3);
Expand Down
22 changes: 22 additions & 0 deletions src/advance/classic/fix/issue-scope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import type { LlmClient } from '../../llm/client.js';
import type { ReviewFinding } from '../provider/types.js';
import type { FocusedContext } from './focused-context-builder.js';
import type { MaintainerLocalJudge } from './maintainer-local-judge.js';
import { extractJsonText } from '../utils/json-extraction.js';
import { defaultPromptLoader, type PromptLoader } from '../../llm/prompts/loader.js';

Expand All @@ -23,6 +24,8 @@ export interface ScopeClassifierOptions {
llmClient?: LlmClient;
/** 是否启用 LLM 二次确认;默认 false,避免每个 finding 都调用 LLM */
enableLlmConfirm?: boolean;
/** 可选的轻量判别辅助,用于启发式规则未命中时的 scope 初筛 */
localJudge?: MaintainerLocalJudge;
/** 可选的 prompt 加载器,默认使用全局 loader */
promptLoader?: PromptLoader;
}
Expand All @@ -42,6 +45,25 @@ export class IssueScopeClassifier {
return heuristic;
}

if (
this.options.localJudge &&
typeof this.options.localJudge.preFilterScope === 'function'
) {
const verdict = await this.options.localJudge.preFilterScope(
finding.message,
finding.file,
finding.line,
);
if ('kind' in verdict && verdict.kind === 'reliable') {
if (verdict.scope !== 'local') {
return {
scope: verdict.scope,
reason: verdict.reason,
};
}
}
}

if (this.options.enableLlmConfirm && this.options.llmClient) {
return await this.confirmWithLlm(finding, context);
}
Expand Down
Loading
Loading