feat: metadata.tracked 类型、validateConfig 校验与 mergeConfig 深合并

This commit is contained in:
2026-06-10 08:52:18 +08:00
parent af58f786af
commit 7d5af32ce5
5 changed files with 108 additions and 7 deletions

View File

@@ -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;
}

View File

@@ -1,6 +1,9 @@
import type { RuneConfig } from "../types.ts";
export const defaultConfig: RuneConfig = {
metadata: {
tracked: true,
},
stages: {
discuss: {
prompt: `进入探索模式。深度思考,自由发散。跟随对话走向。

View File

@@ -38,6 +38,7 @@ export interface RuneConfig {
stages: StagesConfig;
metadata?: {
command?: string;
tracked?: boolean;
};
}