fix(contracts): align CLI/MCP boundary contracts (#946)

* fix(cli): validate native scenario and preserve JSON paths

* fix(process): reject invalid UTF-8 JSON inputs

* fix(cli): retain missing JSON path diagnostics

* test(cli): cover relative brace and bracket JSON paths

* test(cli): reject missing native scenario steps

* fix(mcp): advertise reserved process environment key

* fix(process): reject NUL in process scenario values

* fix(process): advertise NUL input constraints to MCP

* fix(cli): report scenario input schema issues

* fix(contracts): align CLI and MCP input validation

* fix(mcp): document semantic output constraints

* fix(mcp): describe process journal compatibility

* docs: regenerate catalog after schema grouping

* docs: regenerate catalog after main merge

* fix(cli): preserve JSON and native UI input diagnostics

* test(mcp): reuse advertised tool schemas in managed flow
This commit is contained in:
morluto
2026-10-08 00:03:36 +08:00
committed by GitHub
parent fc4a9a0592
commit 4a6073810a
26 changed files with 897 additions and 58 deletions
+15 -2
View File
@@ -15,8 +15,6 @@ export const parseCliJsonInput = async (
> => {
const inline = parseJson(value);
if (inline !== undefined) return { ok: true, value: inline };
if (["{", "["].includes(value.trimStart()[0] ?? ""))
return { ok: false, error: inputError(operation) };
try {
// Read raw bytes so invalid UTF-8 is rejected by parseJson instead of
// being silently replaced by lossy "utf8" decoding.
@@ -25,10 +23,25 @@ export const parseCliJsonInput = async (
? jsonFileError(value, operation, "invalid-json")
: { ok: true, value: parsed };
} catch (cause: unknown) {
if (
["{", "["].includes(value.trimStart()[0] ?? "") &&
cannotBeAnExistingFile(cause) &&
!hasExplicitJsonFileExtension(value)
)
return { ok: false, error: inputError(operation) };
return jsonFileError(value, operation, "read-failed", cause);
}
};
const cannotBeAnExistingFile = (cause: unknown): boolean =>
typeof cause === "object" &&
cause !== null &&
"code" in cause &&
(cause.code === "ENOENT" || cause.code === "ENAMETOOLONG");
const hasExplicitJsonFileExtension = (value: string): boolean =>
value.toLowerCase().endsWith(".json");
const parseJson = (value: string | Uint8Array): unknown => {
let text: string;
if (typeof value === "string") {