feat(models+gate): 模型按项目可配置(默认 opus-4.8) + diff 声明外文件硬闸
① 模型可配置(项目维度,默认 opus-4.8)
- 新增 projects.models(JSON,按角色 executor/planner/reviewer/conflict
覆盖,值可为字符串=全复杂度统一 或 {easy,medium,hard} 分档)
- models.ts 重构 resolveModel:优先级 项目级 models > 旧 project.model
(仅 executor/planner) > env > 默认 DEFAULT_MODEL(opus-4.8)
- 取消内置 fable/sonnet 分档默认:所有角色默认 opus-4.8(彻底回避 fable-5
不可用问题,需要时项目级显式配置即可);回退链改 opus→sonnet→fable
- API PATCH /projects 透传 models;sanitizeModels 落库校验
② diff 声明外文件闸(task.scopeFiles)
- 新增 tasks.scope_files(JSON glob/路径数组)
- checks.ts: globToRegExp/matchesAnyGlob + scopeFileGate(改动文件越界=硬闸,
空声明跳过,git 出错不拦截);pipeline runApproveGates 接入
- planner 拆解新增每子任务 files 字段:prompt 要求 + parseDecompose 解析 +
ingest 落 scopeFiles,自动填充声明范围
- executor prompt 注入「声明文件范围约束」,让 agent 知边界(gate 才公平)
迁移:projects.models / tasks.scope_files 走 ensureColumn 幂等迁移(旧库补列)
测试:models 默认/配置/优先级、scope glob/gate、planner files 解析、
store 持久化往返、迁移补列 —— 237 通过
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,17 @@ export const HARD_MAX_DEPTH = 4;
|
||||
/** 自动执行边界(Easy 任务由后台执行器自动跑到什么程度) */
|
||||
export type Autonomy = 'manual' | 'auto-easy' | 'auto-approved';
|
||||
|
||||
/** 单角色模型配置:字符串=全复杂度统一;对象=按复杂度(easy/medium/hard)分档。缺项回落默认。 */
|
||||
export type ModelTierConfig = string | { easy?: string; medium?: string; hard?: string };
|
||||
|
||||
/** 项目级可配置模型(按场景/角色覆盖默认 opus-4.8;缺省角色走默认)。存 projects.models(JSON)。 */
|
||||
export interface ProjectModels {
|
||||
executor?: ModelTierConfig; // 执行改动
|
||||
planner?: ModelTierConfig; // 拆解 Hard / 写方案 Medium
|
||||
reviewer?: ModelTierConfig; // 执行后双复审(code + security)
|
||||
conflict?: ModelTierConfig; // 解合并冲突
|
||||
}
|
||||
|
||||
export interface Project {
|
||||
id: Id;
|
||||
name: string;
|
||||
@@ -39,6 +50,8 @@ export interface Project {
|
||||
budgetPeriod?: 'day' | 'month'; // 预算周期(默认 month)
|
||||
/** L2 项目级 agent 执行规范(注入 executor/planner/reviewer/conflict 的 prompt 头部)*/
|
||||
agentRules?: string | null;
|
||||
/** 项目级可配置模型(按角色/复杂度覆盖默认 opus-4.8;null=全用默认)*/
|
||||
models?: ProjectModels | null;
|
||||
}
|
||||
|
||||
export interface ApprovalRecord {
|
||||
@@ -81,6 +94,7 @@ export interface Task {
|
||||
status: TaskStatus;
|
||||
priority: number;
|
||||
deps: Id[]; // 兄弟依赖(同层)
|
||||
scopeFiles?: string[] | null; // 声明的改动文件范围(glob/路径);非空时 diff 触碰范围外文件 = 硬闸拦截
|
||||
// 三选一产出(按复杂度)
|
||||
plan: string | null; // Hard:分析 + 拆解说明
|
||||
spec: string | null; // Medium:改动内容 + 为什么
|
||||
|
||||
Reference in New Issue
Block a user