将变量替换和 expect 简写展开统一放入 Normalized 阶段, 运行时 AJV 使用 Normalized schema,导出 schema 面向 Authoring Config。 主要变更: - 新增 normalizer.ts 实现 normalizeAuthoringConfig() - 拆分 Authoring/Normalized 双 schema,checker 接口支持 authoring/normalized 片段 - config-loader 流程:normalize → Normalized AJV → semantic → resolve - validator 兼容层自动分派 raw/normalized expect 形态 - 删除 rawExpect,store.expect 列写入 null - Authoring schema 对 integer/boolean/enum 字段接受变量引用 - 修复 DB/HTTP validate 入口守卫和 LLM options integer 变量引用 - 优化 compact() 避免 undefined 覆盖隐患 - 移除 content.ts 恒为 true 的前置条件 - 同步 5 个主规范并归档 change
55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
import { Type } from "@sinclair/typebox";
|
|
|
|
import type { CheckerSchemas } from "../types";
|
|
|
|
import {
|
|
createAuthoringContentExpectationsSchema,
|
|
createAuthoringValueExpectationSchema,
|
|
createNormalizedContentExpectationsSchema,
|
|
createNormalizedValueExpectationSchema,
|
|
sizeSchema,
|
|
stringMapSchema,
|
|
} from "../../schema/fragments";
|
|
|
|
export const commandCheckerSchemas: CheckerSchemas = {
|
|
authoring: {
|
|
config: createCommandConfigSchema(),
|
|
expect: createCommandExpectSchema("authoring"),
|
|
},
|
|
normalized: {
|
|
config: createCommandConfigSchema(),
|
|
expect: createCommandExpectSchema("normalized"),
|
|
},
|
|
};
|
|
|
|
function createCommandConfigSchema() {
|
|
return Type.Object(
|
|
{
|
|
args: Type.Optional(Type.Array(Type.String())),
|
|
cwd: Type.Optional(Type.String()),
|
|
env: Type.Optional(stringMapSchema),
|
|
exec: Type.String({ minLength: 1 }),
|
|
maxOutputBytes: Type.Optional(sizeSchema),
|
|
},
|
|
{ additionalProperties: false },
|
|
);
|
|
}
|
|
|
|
function createCommandExpectSchema(kind: "authoring" | "normalized") {
|
|
return Type.Object(
|
|
{
|
|
durationMs: Type.Optional(
|
|
kind === "authoring" ? createAuthoringValueExpectationSchema() : createNormalizedValueExpectationSchema(),
|
|
),
|
|
exitCode: Type.Optional(Type.Array(Type.Integer())),
|
|
stderr: Type.Optional(
|
|
kind === "authoring" ? createAuthoringContentExpectationsSchema() : createNormalizedContentExpectationsSchema(),
|
|
),
|
|
stdout: Type.Optional(
|
|
kind === "authoring" ? createAuthoringContentExpectationsSchema() : createNormalizedContentExpectationsSchema(),
|
|
),
|
|
},
|
|
{ additionalProperties: false },
|
|
);
|
|
}
|