feat: metadata.tracked 类型、validateConfig 校验与 mergeConfig 深合并
This commit is contained in:
@@ -37,6 +37,13 @@ export function validateConfig(config: RuneConfig): void {
|
||||
const plan = config.stages.plan;
|
||||
if (!plan) return;
|
||||
|
||||
if (config.metadata?.tracked && plan) {
|
||||
const hasTaskDoc = plan.documents.some((d) => d.name === "task");
|
||||
if (!hasTaskDoc) {
|
||||
throw new ConfigError('tracked 开启时 plan.documents 必须包含 name 为 "task" 的文档');
|
||||
}
|
||||
}
|
||||
|
||||
const docNames = new Set(plan.documents.map((d) => d.name));
|
||||
|
||||
for (const doc of plan.documents) {
|
||||
@@ -94,9 +101,10 @@ function mergeConfig(userConfig: Partial<RuneConfig>): RuneConfig {
|
||||
}
|
||||
}
|
||||
|
||||
if (userConfig.metadata) {
|
||||
result.metadata = userConfig.metadata;
|
||||
}
|
||||
result.metadata = {
|
||||
...defaultConfig.metadata,
|
||||
...userConfig.metadata,
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import type { RuneConfig } from "../types.ts";
|
||||
|
||||
export const defaultConfig: RuneConfig = {
|
||||
metadata: {
|
||||
tracked: true,
|
||||
},
|
||||
stages: {
|
||||
discuss: {
|
||||
prompt: `进入探索模式。深度思考,自由发散。跟随对话走向。
|
||||
|
||||
@@ -38,6 +38,7 @@ export interface RuneConfig {
|
||||
stages: StagesConfig;
|
||||
metadata?: {
|
||||
command?: string;
|
||||
tracked?: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user