fix(cli): reject non-decimal guidance search limits (#9165)

This commit is contained in:
RRFZ authored and GitHub committed 2026-11-07 01:28:12 +08:00
1 parent 128f7c330f
commit 9cdcdf3dff
2 files changed
+12 -3

No files matched your search

+5 -3
View File
@@ -14,6 +14,7 @@ import { logCliCommand } from "../cliLogging.js";
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
import type { Logger } from "pino";
import type { CliInstance } from "./types.js";
import { cliDecimalField } from "./options.js";
/** Guidance descriptors owned by one CLI host. */
export class CliGuidanceResources {
@@ -64,9 +65,10 @@ export const registerGuidanceCommands = (
locator: readGuidanceSectionInputSchema.shape.locator
.optional()
.describe("Required with --action read; locator returned by search"),
limit: searchGuidanceLimitSchema
.optional()
.describe("Maximum search matches; search only, defaults to 8"),
// Decimal tokens only: numeric coercion would read "0x2" as 2.
limit: cliDecimalField(searchGuidanceLimitSchema.optional()).describe(
"Maximum search matches; search only, defaults to 8",
),
cursor: searchGuidanceInputSchema.shape.cursor
.optional()
.describe("Continue a search page; search only"),
+7
View File
@@ -75,6 +75,13 @@ it("reports no matches and rejects invalid CLI inputs", async () => {
});
const empty = await run(["guidance", "--query", " "]);
expect(empty.exitCode).not.toBe(0);
// Numeric coercion would read "0x2" as a two-match page.
const hexLimit = await run(["guidance", "--query", "module", "--limit=0x2"]);
expect(hexLimit.exitCode).not.toBe(0);
expect(JSON.parse(hexLimit.stdout)).toMatchObject({
code: "VALIDATION_ERROR",
fieldErrors: [expect.objectContaining({ path: "limit" })],
});
const malformed = await run([
"guidance",
"--action",