Reverse engineer anything with agents, from app behavior down to native binaries.
TypeScript agent-skillsai-agentsbinary-analysisclaude-codeclicodexcordisdecompilerdeveloper-toolsdshdsh-pluginghidrahopperllmmcpmodel-context-protocolreareverse-engineeringstatic-analysistouhou
refactor(cli): share analysis snapshot option contract
morlutod77bc0e8a050
diff --git a/src/cli/coreBinaryCommands.ts b/src/cli/coreBinaryCommands.tsindex 3ea172746..21ca05f24 100644--- a/src/cli/coreBinaryCommands.ts+++ b/src/cli/coreBinaryCommands.ts@@ -9,6 +9,7 @@ import type { Logger } from "pino";import {directAnalysisOptionsFromCli,nativeOpenOptionFields,+ snapshotSelectionOption,} from "./options.js";import type { CliInstance } from "./types.js";import { runCliJavaScriptApplicationAnalysis } from "./javascriptApplicationAnalysis.js";@@ -38,11 +39,7 @@ const registerOverviewCommands = (runDirectAnalysis: DirectAnalysis["runDirectAnalysis"],): void => {const overviewOptions = z.object({- snapshot: z- .string()- .min(1)- .optional()- .describe("Load and update a local analysis snapshot"),+ snapshot: snapshotSelectionOption,...nativeOpenOptionFields,});// `analyze` declares the JavaScript integrity policy for its JavaScript@@ -179,11 +176,7 @@ const registerDecompileCommand = (.describe("Ghidra source-file byte offset; mapped internally to an analysis address",),- snapshot: z- .string()- .min(1)- .optional()- .describe("Load and update a local analysis snapshot"),+ snapshot: snapshotSelectionOption,...nativeOpenOptionFields,}),run: ({ args, options }) =>@@ -266,11 +259,7 @@ const registerXrefsCommand = (.describe("Address or symbol name; use --address=<value> for leading dashes",),- snapshot: z- .string()- .min(1)- .optional()- .describe("Load and update a local analysis snapshot"),+ snapshot: snapshotSelectionOption,...nativeOpenOptionFields,}),run: ({ args, options }) =>@@ -315,11 +304,7 @@ const registerTraceCommand = (.boolean().default(false).describe("Match the query with exact letter case"),- snapshot: z- .string()- .min(1)- .optional()- .describe("Load and update a local analysis snapshot"),+ snapshot: snapshotSelectionOption,...nativeOpenOptionFields,}),run: ({ args, options }) =>@@ -365,11 +350,7 @@ const registerFunctionCommand = (.describe("Procedure name or address; use --procedure=<value> for leading dashes",),- snapshot: z- .string()- .min(1)- .optional()- .describe("Load and update a local analysis snapshot"),+ snapshot: snapshotSelectionOption,...nativeOpenOptionFields,}),run: ({ args, options }) =>@@ -414,11 +395,7 @@ const registerInstructionsCommand = (.describe("Procedure name or address; use --procedure=<value> for leading dashes",),- snapshot: z- .string()- .min(1)- .optional()- .describe("Load and update a local analysis snapshot"),+ snapshot: snapshotSelectionOption,...nativeOpenOptionFields,}),run: ({ args, options }) =>@@ -475,11 +452,7 @@ const registerSearchCommand = (.boolean().default(false).describe("Match the pattern with exact letter case"),- snapshot: z- .string()- .min(1)- .optional()- .describe("Load and update a local analysis snapshot"),+ snapshot: snapshotSelectionOption,...nativeOpenOptionFields,}),run: ({ args, options }) =>diff --git a/src/cli/coreNativeCommands.ts b/src/cli/coreNativeCommands.tsindex 80d07187f..1c60d2fee 100644--- a/src/cli/coreNativeCommands.ts+++ b/src/cli/coreNativeCommands.ts@@ -7,6 +7,7 @@ import type { Logger } from "pino";import {directAnalysisOptionsFromCli,nativeOpenOptionFields,+ snapshotSelectionOption,} from "./options.js";import type { CliInstance } from "./types.js";@@ -271,11 +272,9 @@ const registerNativeDispatchMetadataCommand = (.max(20_000).default(5_000).describe("Maximum symbol records to inspect"),- snapshot: z- .string()- .min(1)- .optional()- .describe("Load or update the local analysis snapshot"),+ snapshot: snapshotSelectionOption.describe(+ "Load or update the local analysis snapshot",+ ),...nativeOpenOptionFields,}),run: async ({ args, options }) =>@@ -360,11 +359,7 @@ const registerNativeApiCommand = (address: z.string().describe("Procedure name or address"),}),options: z.object({- snapshot: z- .string()- .min(1)- .optional()- .describe("Load and update a local analysis snapshot"),+ snapshot: snapshotSelectionOption,...nativeOpenOptionFields,}),run: ({ args, options }) =>diff --git a/src/cli/options.ts b/src/cli/options.tsindex fdee7cb2d..9749cb590 100644--- a/src/cli/options.ts+++ b/src/cli/options.ts@@ -26,6 +26,13 @@ export const providerSelectionOption = analysisProviderSelectorSchema"Bind deep analysis to a provider ID or use deterministic auto selection",);+/** Optional path to the local analysis snapshot loaded or updated by a command. */+export const snapshotSelectionOption = z+ .string()+ .min(1)+ .optional()+ .describe("Load and update a local analysis snapshot");+/** Explicit interpretation for headerless native executable formats. */export const formatSelectionOption = executableFormatHintSchema.optional()