Files
reverse-engineering-anything/src/cli/pythonPycCommands.ts
T
morluto 9d7779d365 fix(cli): validate selected local paths before resolution
Reuse the nonempty NUL-free local path contract before normalization in artifact commands, auxiliary inputs, and output destinations. Empty selections now fail at parsing instead of selecting the working directory; explicit relative paths preserve their target.

Public CLI checks cover primary and auxiliary empty paths, exact relative-file digest, explicit current-directory selection, symlink parent semantics, and environment export inputs. Correct the desktop fixture to assert the existing CLI validation envelope.
2026-10-24 07:28:09 +08:00

58 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { z } from "incur";
import { localPathStringSchema } from "../domain/localPath.js";
import { absoluteCallerPath } from "../filesystem/callerPath.js";
import { createPythonPycService } from "../composition/pythonPyc.js";
import { CLI_COMMANDS } from "../cliCommandNames.js";
import { logCliCommand } from "../cliLogging.js";
import type { Logger } from "pino";
import type { CliInstance } from "./types.js";
import { withCommandCancellation } from "./commandCancellation.js";
import { inspectPythonPycInputSchema } from "../domain/python/pythonPyc.js";
import { finishAnalysisCommand } from "./finishAnalysisCommand.js";
/** Inspect operator-selected pyc files through the same shared workflow as MCP. */
export const registerPythonPycCommands = (
cli: CliInstance,
logger: Logger,
): void => {
cli.command(CLI_COMMANDS.inspectPythonPyc, {
description:
"Inspect a supported CPython 3.7–3.13 pyc header and marshal code objects without executing bytecode",
args: z.object({
path: localPathStringSchema.describe("Local CPython .pyc file"),
}),
options: z.object({
maxFileBytes: inspectPythonPycInputSchema.shape.max_file_bytes,
maxObjects: inspectPythonPycInputSchema.shape.max_objects,
maxDepth: inspectPythonPycInputSchema.shape.max_depth,
maxStringBytes: inspectPythonPycInputSchema.shape.max_string_bytes,
}),
run: ({ args, options }) =>
withCommandCancellation(async (signal) => {
const service = createPythonPycService();
return await logCliCommand(
logger,
CLI_COMMANDS.inspectPythonPyc,
async () =>
finishAnalysisCommand(
() =>
service.inspect(
{
path: absoluteCallerPath(args.path),
max_file_bytes: options.maxFileBytes,
max_objects: options.maxObjects,
max_depth: options.maxDepth,
max_string_bytes: options.maxStringBytes,
},
{ signal },
),
service,
"rea-python-pyc",
"inspect_python_pyc",
signal,
),
);
}),
});
};