新增预设工作台:编辑、版本树、结构检查、用例试跑放在同一页。

改预设要能一边写一边看装出来的 messages,还要多模型对照,所以把编辑与试跑拆成两个视图塞进一个页面;版本存完整快照、可分叉,用例全局共用一份、运行记录按预设存。顺带让读预设文件先剥 BOM,静态资源改成不缓存,免得改了脚本还要强刷。
This commit is contained in:
2026-10-26 01:09:40 +08:00
parent 98e51f9c6c
commit f3303038fe
20 changed files with 6263 additions and 6 deletions
+7 -2
View File
@@ -19,6 +19,11 @@ function presetPath(id: string): string {
return path.join(getPresetsDir(), `${id}.json`);
}
/** Windows 编辑器可能给 JSON 加 BOM;JSON.parse 不认,先剥掉。 */
function parsePreset(raw: string): PresetPackage {
return JSON.parse(raw.replace(/^\uFEFF/, "")) as PresetPackage;
}
export function listPresets(): PresetPackage[] {
ensureUserDataDirs();
let files: string[];
@@ -33,7 +38,7 @@ export function listPresets(): PresetPackage[] {
try {
const filePath = path.join(getPresetsDir(), file);
const raw = readFileSync(filePath, "utf8");
presets.push(withoutReasoningEffort(JSON.parse(raw) as PresetPackage, filePath));
presets.push(withoutReasoningEffort(parsePreset(raw), filePath));
} catch {
/* skip corrupt files */
}
@@ -45,7 +50,7 @@ export function getPreset(id: string): PresetPackage | null {
try {
const filePath = presetPath(id);
const raw = readFileSync(filePath, "utf8");
return withoutReasoningEffort(JSON.parse(raw) as PresetPackage, filePath);
return withoutReasoningEffort(parsePreset(raw), filePath);
} catch {
return null;
}