mirror of
https://github.com/morluto/rea.git
synced 2026-12-03 13:41:17 -05:00
48220827c4
* 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.
82 lines
3.1 KiB
TypeScript
82 lines
3.1 KiB
TypeScript
import { projectCliAnalysisResult } from "./projectCliAnalysisResult.js";
|
|
import { z } from "incur";
|
|
import { createWebModuleTraceService } from "../composition/webModules.js";
|
|
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
import { logCliCommand } from "../cliLogging.js";
|
|
import { webModuleTraceInputSchema } from "../domain/webModuleTrace.js";
|
|
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";
|
|
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
|
|
|
|
const importMapInputSchema =
|
|
webModuleTraceInputSchema.shape.import_map.unwrap();
|
|
|
|
/** Expose the same selected-context module trace through the CLI. */
|
|
export const registerWebModuleCommands = (
|
|
cli: CliInstance,
|
|
logger: Logger,
|
|
environment: Readonly<Record<string, string | undefined>>,
|
|
): void => {
|
|
const service = createWebModuleTraceService(environment);
|
|
cli.command(CLI_COMMANDS.traceWebModuleImports, {
|
|
description:
|
|
"Trace one captured script's native imports to URLs and captured source candidates",
|
|
args: z.object({
|
|
manifestPath: localPathStringSchema.describe(
|
|
"export_web_scripts manifest path; a relative path resolves against the current directory",
|
|
),
|
|
scriptIndex: cliDecimalField(
|
|
webModuleTraceInputSchema.shape.script_index.describe(
|
|
"Zero-based manifest script index",
|
|
),
|
|
),
|
|
}),
|
|
options: z.object({
|
|
importerUrl: webModuleTraceInputSchema.shape.importer_url,
|
|
importMapPath: importMapInputSchema.shape.path
|
|
.optional()
|
|
.describe(
|
|
"Absolute local import-map JSON path; requires --import-map-base-url",
|
|
),
|
|
importMapBaseUrl: importMapInputSchema.shape.base_url
|
|
.optional()
|
|
.describe("HTTP(S) import-map base URL; requires --import-map-path"),
|
|
}),
|
|
run: ({ args, options }) =>
|
|
withCommandCancellation((signal) =>
|
|
logCliCommand(logger, CLI_COMMANDS.traceWebModuleImports, () =>
|
|
finishAnalysisCommand(
|
|
() =>
|
|
service.trace(
|
|
{
|
|
manifest_path: absoluteCallerPath(args.manifestPath),
|
|
script_index: args.scriptIndex,
|
|
...(options.importerUrl === undefined
|
|
? {}
|
|
: { importer_url: options.importerUrl }),
|
|
...(options.importMapPath === undefined &&
|
|
options.importMapBaseUrl === undefined
|
|
? {}
|
|
: {
|
|
import_map: {
|
|
path: options.importMapPath,
|
|
base_url: options.importMapBaseUrl,
|
|
},
|
|
}),
|
|
},
|
|
{ signal },
|
|
),
|
|
service,
|
|
"web-module-trace",
|
|
"trace_web_module_imports",
|
|
signal,
|
|
).then(projectCliAnalysisResult),
|
|
),
|
|
),
|
|
});
|
|
};
|