fix(cli): advertise parsed JSON documents in --schema

`--schema` for JSON-input CLI commands showed only an opaque
`inputJson` string, so callers could not see the document the command
actually parses. The argument now carries the decoded document as its
contentSchema, built from the same contract each command or its service
parses with (the Evidence input frame, or the ledger and coverage
request schemas). `$schema` is stripped, and a schema JSON Schema cannot
represent is refused rather than advertised as {}.

Fixes #9195
Supersedes #9283

Squashed from #9283 (with morluto's validation test) and rebased onto
main; the coverage test now expects boundary_id's stable-identifier
pattern from #9919. #9214 by 1052326311 took the same approach.

Co-Authored-By: morluto <76467478+morluto@users.noreply.github.com>
Co-Authored-By: 1052326311 <65798732+1052326311@users.noreply.github.com>
Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
This commit is contained in:
authored and Ysopwnable committed 2026-11-14 14:16:39 +01:00
1 parent 3e95d22dd4
commit d734e6424d
15 files changed
+625 -66

No files matched your search

+18 -10
View File
@@ -18,6 +18,13 @@ import type { CliInstance } from "./types.js";
import { localPathStringSchema } from "../domain/localPath.js";
import { withCommandCancellation } from "./commandCancellation.js";
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
import { jsonInputArgument } from "./jsonInputArgument.js";
import { inspectAnalysisViewInputSchema } from "../domain/analysisView/analysisViewRequest.js";
const inspectEvidenceBundleCliInputSchema =
getEvidenceBundleInputSchema.safeExtend({
path: importEvidenceBundleInputSchema.shape.path,
});
/** Project selected views of completed analysis Evidence through the CLI. */
export const registerAnalysisViewCommands = (
@@ -28,11 +35,10 @@ export const registerAnalysisViewCommands = (
description:
"Inspect a local Evidence bundle completely, as discovery metadata, as a page of selected complete records, or as direct-link and retained-closure membership.",
args: z.object({
inputJson: z
.string()
.describe(
"JSON or JSON file with absolute path, detail, optional record filters, records or links offset/limit, and links traversal/link_status",
),
inputJson: jsonInputArgument(
"JSON or JSON file with absolute path, detail, optional record filters, records or links offset/limit, and links traversal/link_status",
inspectEvidenceBundleCliInputSchema,
),
}),
run: ({ args }) =>
withCommandCancellation((signal) =>
@@ -43,10 +49,9 @@ export const registerAnalysisViewCommands = (
signal,
);
if (!input.ok) return input.error;
const schema = getEvidenceBundleInputSchema.safeExtend({
path: importEvidenceBundleInputSchema.shape.path,
});
const parsed = schema.safeParse(input.value);
const parsed = inspectEvidenceBundleCliInputSchema.safeParse(
input.value,
);
if (!parsed.success)
return {
error: "Evidence bundle inspection failed",
@@ -75,7 +80,10 @@ export const registerAnalysisViewCommands = (
description:
"Project a selected view of completed Evidence JSON for a supported analysis operation. For inventory rows, use --format csv or --format tsv with --filter-output normalized_result.items and --columns logical_path,artifact_id (if those fields are included in the view).",
args: z.object({
inputJson: z.string().describe("Inline workflow JSON or JSON file path"),
inputJson: jsonInputArgument(
"Inline workflow JSON or JSON file path",
inspectAnalysisViewInputSchema,
),
}),
options: z.object({
evidenceBundle: localPathStringSchema