test(cli): report CLI fields that admit values their contract refuses (#10575)

* test(cli): report CLI fields that admit values their contract refuses

For every CLI command that reaches an MCP contract, compare each
name-matched CLI field with its contract field on empty, NUL,
caller-relative host path and numeric argv spellings. The 16 mismatches on
main are recorded in a baseline with a counted ceiling that can only go
down: a new mismatch fails, and so does a listed one that no longer occurs.

* test: cover constrained CLI contract fields

* fix(cli): admit relative web trace paths

* test(cli): probe numeric contract fields by type, including bounds

Numeric probes no longer require the contract to admit 0 or 1, so ranged fields such as inspect-byte-entropy --block-size (256..65536) are compared, with probes just past each declared bound.

* fix(cli): describe caller-relative web trace paths and expect native Windows spellings

The relative-path CLI arguments lost their contract descriptions; they now describe the caller-relative resolution. absoluteCallerPath renders native separators on Windows, so the web trace acceptance tests use native manifest paths for CLI and MCP parity.

* test(cli): keep forward-slash Windows manifest coverage through MCP

The CLI renders caller paths with native separators through absoluteCallerPath; MCP keeps the caller's spelling. The web trace parity tests now also call MCP with the forward-slash manifest spelling and expect the same trace with that path echoed, restoring the #1078 coverage.
This commit is contained in:
morluto authored and GitHub committed 2026-11-15 17:07:09 +08:00
1 parent d0fee4e58e
commit 48220827c4
10 files changed
+450 -45

No files matched your search

+10 -4
View File
@@ -18,6 +18,8 @@ import type { Logger } from "pino";
import type { CliInstance } from "./types.js";
import { cliDecimalField } from "./options.js";
import { withCommandCancellation } from "./commandCancellation.js";
import { localPathStringSchema } from "../domain/localPath.js";
import { absoluteCallerPath } from "../filesystem/callerPath.js";
const sourceMapSelection = webSourceLocationInputSchema.shape.source_map;
const generatedPosition = webSourceLocationInputSchema.shape.generated_position;
@@ -33,13 +35,17 @@ export const registerWebSourceLocationCommands = (
description:
"Trace one retained script position through an explicitly selected local source map",
args: z.object({
manifestPath: webSourceLocationInputSchema.shape.manifest_path,
manifestPath: localPathStringSchema.describe(
"export_web_scripts manifest path; a relative path resolves against the current directory",
),
scriptIndex: cliDecimalField(
webSourceLocationInputSchema.shape.script_index.describe(
"Zero-based manifest script index",
),
),
sourceMapPath: sourceMapSelection.shape.path,
sourceMapPath: localPathStringSchema.describe(
"Local source-map path, not fetched; a relative path resolves against the current directory",
),
sourceMapUrl: sourceMapSelection.shape.url,
line: cliDecimalField(
generatedPosition.shape.line.describe("One-based generated line"),
@@ -76,10 +82,10 @@ export const registerWebSourceLocationCommands = (
run: () =>
service.trace(
{
manifest_path: args.manifestPath,
manifest_path: absoluteCallerPath(args.manifestPath),
script_index: args.scriptIndex,
source_map: {
path: args.sourceMapPath,
path: absoluteCallerPath(args.sourceMapPath),
url: args.sourceMapUrl,
},
generated_position: { line: args.line, column: args.column },