Files
reverse-engineering-anything/src/cli/webScriptCommands.ts
T
morlutoandCursor Agent 562779bd71 fix(mcp): advertise absolute paths for tools that reject relative inputs (#9179)
* fix(mcp): advertise absolute paths for tools that reject relative inputs

The domain schemas accepted relative paths, then handlers rejected them
with isAbsolute. Those inputs now use absoluteLocalPathStringSchema, and
the duplicate handler checks are gone.

* fix(javascript): own recovery path admission in the schema

Relative recovery paths now fail in absoluteLocalPathStringSchema, including
the additional_paths index. Drop the duplicate handler check, and make the
CLI, MCP, and tools/list tests assert that schema fact.

* test: assert absolute-path facts instead of error prose

Recovery and web-script tests keep the field, format code, and regex
expectation. They no longer freeze the schema's explanatory sentence.

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
2026-11-07 15:49:50 +08:00

52 lines
1.9 KiB
TypeScript

import { Cli, z } from "incur";
import { exportWebScripts } from "../application/WebScriptExportService.js";
import { exportWebScriptsInputSchema } from "../domain/webScriptExport.js";
import { ArtifactResourceScope } from "../artifacts/ArtifactResourceScope.js";
import { CLI_COMMANDS } from "../cliCommandNames.js";
import { logCliCommand } from "../cliLogging.js";
import type { Logger } from "pino";
import { withCommandCancellation } from "./commandCancellation.js";
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
import { WEB_SCRIPT_EXPORT_PROVIDER } from "../domain/investigationProviders.js";
/** Register the local captured-script export CLI workflow. */
export const registerWebScriptCommands = (
cli: ReturnType<typeof Cli.create>,
logger: Logger,
): void => {
cli.command(CLI_COMMANDS.exportWebScripts, {
description:
"Export retained website scripts into an absent directory for static JavaScript analysis",
args: z.object({
capturePath: exportWebScriptsInputSchema.shape.capture_path,
outputDirectory: exportWebScriptsInputSchema.shape.output_directory,
}),
run: ({ args }) =>
withCommandCancellation((signal) =>
logCliCommand(logger, CLI_COMMANDS.exportWebScripts, async () => {
const resources = new ArtifactResourceScope();
const result = await finishAnalysisCommand(
() =>
exportWebScripts(
{
capture_path: args.capturePath,
output_directory: args.outputDirectory,
},
resources,
{ signal },
),
resources,
WEB_SCRIPT_EXPORT_PROVIDER.id,
"export_web_scripts",
signal,
"Web script export resources",
);
return result.ok
? result.value
: { error: "Script export failed", ...result.error };
}),
),
});
};