mirror of
https://github.com/morluto/rea.git
synced 2026-10-26 17:35:11 +00:00
Share ordered schema positions between Gemini literal checks, DeepSeek regex checks, and catalog array-shape checks. Reuse the canonical keyword and local reference owners; keep unreferenced instance literals opaque and unresolved external or dynamic targets unknown. Gemini and catalog checks now catch constraints in schemas reached through references into examples. Preserve source paths, resource scopes, cycles and regex occurrence counts. Align fixture first-error selection with the native Gemini check and use consistent bracketed array locations in diagnostics. Validation: 55 focused tests passed, including full/compact MCP catalogs; typecheck, lint, discovery, and Node source-loader checks passed. The old Gemini scanner reproduced the local-reference false negative. Installed Gemini and DeepSeek clients were not run.
28 lines
1.0 KiB
TypeScript
28 lines
1.0 KiB
TypeScript
import { clientSchemaPositions } from "./client-schema-positions.mjs";
|
|
|
|
export interface GeminiUnsupportedLiteral {
|
|
readonly path: string;
|
|
readonly keyword: "const" | "enum";
|
|
readonly reason: "boolean" | "empty-string";
|
|
}
|
|
|
|
/** Gemini's declaration policy, including schemas selected by resolved local references. */
|
|
export const geminiUnsupportedLiteral = (
|
|
schema: unknown,
|
|
): GeminiUnsupportedLiteral | undefined => {
|
|
for (const position of clientSchemaPositions(schema)) {
|
|
if (position.kind !== "keyword") continue;
|
|
const { keyword, value, path } = position;
|
|
if (keyword === "const") {
|
|
if (typeof value === "boolean")
|
|
return { path, keyword, reason: "boolean" };
|
|
if (value === "") return { path, keyword, reason: "empty-string" };
|
|
} else if (keyword === "enum" && Array.isArray(value)) {
|
|
if (value.some((item) => typeof item === "boolean"))
|
|
return { path, keyword, reason: "boolean" };
|
|
if (value.includes("")) return { path, keyword, reason: "empty-string" };
|
|
}
|
|
}
|
|
return undefined;
|
|
};
|