fix(cli): validate integer tokens before coercion

Validate decimal tokens at the CLI owner before safe-number parsing. Apply the same rule to positional indexes/generations and repeated record selectors, retaining leading-zero decimals and canonical MCP inputs.

Refs #4182

Co-authored-by: Arjun Prabhulal <[email protected]>
This commit is contained in:
morlutoandArjun Prabhulal committed 2026-10-16 03:13:06 +08:00
1 parent 08a897b2cd
commit 8d8257928b
7 files changed
+123 -23

No files matched your search

+8 -11
View File
@@ -5,6 +5,7 @@ import { logCliCommand } from "../cliLogging.js";
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
import type { Logger } from "pino";
import type { CliInstance } from "./types.js";
import { cliIntegerArgument } from "./options.js";
import { withCommandCancellation } from "./commandCancellation.js";
/** Expose the same explicit selected map/point contract through the CLI. */
@@ -21,21 +22,17 @@ export const registerWebSourceLocationCommands = (
manifestPath: z
.string()
.describe("Absolute export_web_scripts manifest path"),
scriptIndex: z.coerce
.number()
.int()
.min(0)
.describe("Zero-based manifest script index"),
scriptIndex: cliIntegerArgument(0).describe(
"Zero-based manifest script index",
),
sourceMapPath: z.string().describe("Absolute local source-map path"),
sourceMapUrl: z
.string()
.describe("Absolute source-map URL context; no fetch"),
line: z.coerce.number().int().min(1).describe("One-based generated line"),
column: z.coerce
.number()
.int()
.min(0)
.describe("Zero-based UTF-16 generated column"),
line: cliIntegerArgument(1).describe("One-based generated line"),
column: cliIntegerArgument(0).describe(
"Zero-based UTF-16 generated column",
),
}),
run: ({ args }) =>
withCommandCancellation(async (signal) => {