refactor: return complete tool results inline
This commit is contained in:
@@ -17,24 +17,11 @@ export const registerArtifactCommands = (
|
||||
|
||||
const registerInventoryCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
cli.command(CLI_COMMANDS.inventoryArtifact, {
|
||||
description: "Build a bounded deterministic artifact graph",
|
||||
description: "Build a complete deterministic artifact graph",
|
||||
args: z.object({
|
||||
path: z.string().describe("Application or package path"),
|
||||
}),
|
||||
options: z.object({
|
||||
offset: z
|
||||
.number()
|
||||
.int()
|
||||
.min(0)
|
||||
.default(0)
|
||||
.describe("Zero-based offset for graph nodes, occurrences, and edges"),
|
||||
limit: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(500)
|
||||
.default(100)
|
||||
.describe("Maximum nodes, occurrences, and edges per result section"),
|
||||
integrityPolicy: z
|
||||
.enum(["fail", "record-and-continue"])
|
||||
.default("fail")
|
||||
@@ -67,12 +54,6 @@ const registerInventoryCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
args.path,
|
||||
"inventory_artifact",
|
||||
{
|
||||
node_offset: options.offset,
|
||||
node_limit: options.limit,
|
||||
occurrence_offset: options.offset,
|
||||
occurrence_limit: options.limit,
|
||||
edge_offset: options.offset,
|
||||
edge_limit: options.limit,
|
||||
integrity_policy: options.integrityPolicy,
|
||||
integrity_continue_approved: options.integrityContinueApproved,
|
||||
max_integrity_mismatches: options.maxIntegrityMismatches,
|
||||
@@ -118,41 +99,14 @@ const registerExtractionCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
const registerInspectionCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
cli.command(CLI_COMMANDS.inspectArtifact, {
|
||||
description:
|
||||
"Inspect one artifact with bounded observations and explicit next probes",
|
||||
"Inspect one artifact and return all available observations and next probes",
|
||||
args: z.object({
|
||||
path: z.string().describe("Application or package path"),
|
||||
}),
|
||||
options: z.object({
|
||||
maxObservations: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(500)
|
||||
.default(100)
|
||||
.describe("Maximum retained observations"),
|
||||
maxRelationships: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(500)
|
||||
.default(100)
|
||||
.describe("Maximum retained derived relationships"),
|
||||
}),
|
||||
alias: {
|
||||
maxObservations: "max-observations",
|
||||
maxRelationships: "max-relationships",
|
||||
},
|
||||
run: ({ args, options }) =>
|
||||
options: z.object({}),
|
||||
run: ({ args }) =>
|
||||
logCliCommand(logger, "inspect-artifact", () =>
|
||||
runProviderAnalysis(
|
||||
args.path,
|
||||
"inspect_artifact",
|
||||
{
|
||||
max_observations: options.maxObservations,
|
||||
max_relationships: options.maxRelationships,
|
||||
},
|
||||
logger,
|
||||
),
|
||||
runProviderAnalysis(args.path, "inspect_artifact", {}, logger),
|
||||
),
|
||||
});
|
||||
};
|
||||
|
||||
+10
-101
@@ -25,17 +25,6 @@ export const registerCoreAnalysisCommands = (
|
||||
|
||||
const registerCoreCommands = (cli: CliInstance, logger: Logger): void => {
|
||||
const overviewOptions = z.object({
|
||||
detail: z
|
||||
.enum(["concise", "detailed"])
|
||||
.default("concise")
|
||||
.describe("Overview detail level"),
|
||||
limit: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(50)
|
||||
.default(10)
|
||||
.describe("Maximum overview items to return"),
|
||||
snapshot: z
|
||||
.string()
|
||||
.min(1)
|
||||
@@ -43,20 +32,12 @@ const registerCoreCommands = (cli: CliInstance, logger: Logger): void => {
|
||||
.describe("Load and update a local analysis snapshot"),
|
||||
provider: providerSelectionOption,
|
||||
});
|
||||
const analyzeOptions = overviewOptions.extend({
|
||||
approved: z
|
||||
.boolean()
|
||||
.default(false)
|
||||
.describe(
|
||||
"Approve static analysis when the path is a JavaScript directory or ASAR",
|
||||
),
|
||||
});
|
||||
cli.command(CLI_COMMANDS.analyze, {
|
||||
description: "Get an overview of an app",
|
||||
args: z.object({
|
||||
path: z.string().describe("App, program, or analysis database path"),
|
||||
}),
|
||||
options: analyzeOptions,
|
||||
options: overviewOptions,
|
||||
run: ({ args, options }) =>
|
||||
logCliCommand(logger, "analyze", () =>
|
||||
runRoutedOverview(args.path, options, logger),
|
||||
@@ -73,7 +54,7 @@ const registerCoreCommands = (cli: CliInstance, logger: Logger): void => {
|
||||
runDirectAnalysis(
|
||||
args.path,
|
||||
"binary_overview",
|
||||
{ detail: options.detail, limit: options.limit },
|
||||
{},
|
||||
directAnalysisOptions(logger, options.snapshot, options.provider),
|
||||
),
|
||||
),
|
||||
@@ -107,9 +88,6 @@ const registerCoreCommands = (cli: CliInstance, logger: Logger): void => {
|
||||
const runRoutedOverview = async (
|
||||
path: string,
|
||||
options: {
|
||||
readonly approved: boolean;
|
||||
readonly detail: "concise" | "detailed";
|
||||
readonly limit: number;
|
||||
readonly snapshot?: string | undefined;
|
||||
readonly provider?: string | undefined;
|
||||
},
|
||||
@@ -122,12 +100,11 @@ const runRoutedOverview = async (
|
||||
)
|
||||
return runCliJavaScriptApplicationAnalysis({
|
||||
input_path: resolve(path),
|
||||
approved: options.approved,
|
||||
});
|
||||
return runDirectAnalysis(
|
||||
path,
|
||||
"binary_overview",
|
||||
{ detail: options.detail, limit: options.limit },
|
||||
{},
|
||||
directAnalysisOptions(logger, options.snapshot, options.provider),
|
||||
);
|
||||
};
|
||||
@@ -172,7 +149,7 @@ const registerXrefsCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
|
||||
const registerTraceCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
cli.command(CLI_COMMANDS.trace, {
|
||||
description: "Trace a bounded literal feature through analyzed references",
|
||||
description: "Trace a literal feature through analyzed references",
|
||||
args: z.object({
|
||||
path: z.string().describe("App or program path"),
|
||||
query: z.string().min(1).describe("Literal feature query"),
|
||||
@@ -186,16 +163,8 @@ const registerTraceCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(100)
|
||||
.default(20)
|
||||
.describe("Maximum matching roots to examine"),
|
||||
maxOperations: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(100)
|
||||
.default(20)
|
||||
.describe("Maximum analysis operations in the trace"),
|
||||
.default(10_000)
|
||||
.describe("Maximum matching results to return"),
|
||||
snapshot: z
|
||||
.string()
|
||||
.min(1)
|
||||
@@ -205,7 +174,6 @@ const registerTraceCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
}),
|
||||
alias: {
|
||||
caseSensitive: "case-sensitive",
|
||||
maxOperations: "max-operations",
|
||||
},
|
||||
run: ({ args, options }) =>
|
||||
logCliCommand(logger, "trace", () =>
|
||||
@@ -216,7 +184,6 @@ const registerTraceCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
query: args.query,
|
||||
case_sensitive: options.caseSensitive,
|
||||
limit: options.limit,
|
||||
max_operations: options.maxOperations,
|
||||
},
|
||||
directAnalysisOptions(logger, options.snapshot, options.provider),
|
||||
),
|
||||
@@ -226,37 +193,12 @@ const registerTraceCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
|
||||
const registerFunctionCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
cli.command(CLI_COMMANDS.function, {
|
||||
description: "Analyze one bounded function with evidence",
|
||||
description: "Analyze one complete function with evidence",
|
||||
args: z.object({
|
||||
path: z.string().describe("App or program path"),
|
||||
address: z.string().describe("Procedure name or address"),
|
||||
}),
|
||||
options: z.object({
|
||||
includeAssembly: z
|
||||
.boolean()
|
||||
.default(false)
|
||||
.describe("Include bounded assembly instructions"),
|
||||
limit: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(500)
|
||||
.default(100)
|
||||
.describe("Maximum referenced items to return"),
|
||||
maxPseudocodeChars: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(100_000)
|
||||
.default(20_000)
|
||||
.describe("Maximum pseudocode characters to return"),
|
||||
maxInstructions: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(5_000)
|
||||
.default(500)
|
||||
.describe("Maximum assembly instructions to return"),
|
||||
snapshot: z
|
||||
.string()
|
||||
.min(1)
|
||||
@@ -264,23 +206,12 @@ const registerFunctionCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
.describe("Load and update a local analysis snapshot"),
|
||||
provider: providerSelectionOption,
|
||||
}),
|
||||
alias: {
|
||||
includeAssembly: "include-assembly",
|
||||
maxPseudocodeChars: "max-pseudocode-chars",
|
||||
maxInstructions: "max-instructions",
|
||||
},
|
||||
run: ({ args, options }) =>
|
||||
logCliCommand(logger, "function", () =>
|
||||
runDirectAnalysis(
|
||||
args.path,
|
||||
"analyze_function",
|
||||
{
|
||||
procedure: args.address,
|
||||
include_assembly: options.includeAssembly,
|
||||
limit: options.limit,
|
||||
max_pseudocode_chars: options.maxPseudocodeChars,
|
||||
max_instructions: options.maxInstructions,
|
||||
},
|
||||
{ procedure: args.address },
|
||||
directAnalysisOptions(logger, options.snapshot, options.provider),
|
||||
),
|
||||
),
|
||||
@@ -295,20 +226,6 @@ const registerNativeApiCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
address: z.string().describe("Procedure name or address"),
|
||||
}),
|
||||
options: z.object({
|
||||
maxPseudocodeChars: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(100_000)
|
||||
.default(20_000)
|
||||
.describe("Maximum pseudocode characters to inspect"),
|
||||
maxInstructions: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(5_000)
|
||||
.default(500)
|
||||
.describe("Maximum assembly instructions to inspect"),
|
||||
snapshot: z
|
||||
.string()
|
||||
.min(1)
|
||||
@@ -316,20 +233,12 @@ const registerNativeApiCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
.describe("Load and update a local analysis snapshot"),
|
||||
provider: providerSelectionOption,
|
||||
}),
|
||||
alias: {
|
||||
maxPseudocodeChars: "max-pseudocode-chars",
|
||||
maxInstructions: "max-instructions",
|
||||
},
|
||||
run: ({ args, options }) =>
|
||||
logCliCommand(logger, "inspect-native-api", () =>
|
||||
runDirectAnalysis(
|
||||
args.path,
|
||||
"inspect_native_api",
|
||||
{
|
||||
procedure: args.address,
|
||||
max_pseudocode_chars: options.maxPseudocodeChars,
|
||||
max_instructions: options.maxInstructions,
|
||||
},
|
||||
{ procedure: args.address },
|
||||
directAnalysisOptions(logger, options.snapshot, options.provider),
|
||||
),
|
||||
),
|
||||
@@ -386,7 +295,7 @@ const registerInstructionsCommand = (
|
||||
|
||||
const registerSearchCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
cli.command(CLI_COMMANDS.search, {
|
||||
description: "Search bounded analyzed strings or procedure names",
|
||||
description: "Search analyzed strings or procedure names",
|
||||
args: z.object({
|
||||
path: z.string().describe("App or program path"),
|
||||
pattern: z.string().min(1).describe("Literal text or regex pattern"),
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { analyzeJavaScriptApplication } from "../application/JavaScriptApplicationService.js";
|
||||
import { loadConfiguredPermissionAuthority } from "../application/PermissionConfiguration.js";
|
||||
import { parseConfig } from "../config.js";
|
||||
import { projectAnalysisError } from "../domain/errors.js";
|
||||
import type { JsonValue } from "../domain/jsonValue.js";
|
||||
|
||||
@@ -8,11 +6,7 @@ import type { JsonValue } from "../domain/jsonValue.js";
|
||||
export const runCliJavaScriptApplicationAnalysis = async (
|
||||
input: unknown,
|
||||
): Promise<JsonValue> => {
|
||||
const config = parseConfig(process.env);
|
||||
if (!config.ok) return cliError(config.error);
|
||||
const authority = await loadConfiguredPermissionAuthority(config.value);
|
||||
if (!authority.ok) return cliError(authority.error);
|
||||
const result = await analyzeJavaScriptApplication(authority.value, input);
|
||||
const result = await analyzeJavaScriptApplication(input);
|
||||
return result.ok ? result.value : cliError(result.error);
|
||||
};
|
||||
|
||||
|
||||
+8
-309
@@ -1,9 +1,6 @@
|
||||
import { z } from "incur";
|
||||
|
||||
import {
|
||||
compareManagedMemberPaths,
|
||||
type ManagedMemberPathInspectionLimits,
|
||||
} from "../application/ManagedMemberComparisonService.js";
|
||||
import { compareManagedMemberPaths } from "../application/ManagedMemberComparisonService.js";
|
||||
import { verifyManagedNativeBoundariesEvidence } from "../application/ManagedNativeVerificationService.js";
|
||||
import { importManagedReconstructionEvidence } from "../application/ManagedReconstructionService.js";
|
||||
import { planManagedRuntimeCorrelationEvidence } from "../application/ManagedRuntimeCorrelationService.js";
|
||||
@@ -18,49 +15,6 @@ import type { Logger } from "../logger.js";
|
||||
import type { CliInstance } from "./types.js";
|
||||
import { registerProjectManagedApplicationGraph } from "./managedProjectGraphCommand.js";
|
||||
|
||||
const managedOffset = (subject: string) =>
|
||||
z.number().int().min(0).default(0).describe(`Zero-based ${subject} offset`);
|
||||
|
||||
const managedLimit = (subject: string, maximum: number, fallback: number) =>
|
||||
z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(maximum)
|
||||
.default(fallback)
|
||||
.describe(`Maximum ${subject} to return`);
|
||||
|
||||
const managedInspectionLimits = {
|
||||
maxFileBytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(4_096)
|
||||
.max(1_073_741_824)
|
||||
.default(268_435_456)
|
||||
.describe("Maximum managed artifact file size accepted for inspection"),
|
||||
maxMetadataBytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(256)
|
||||
.max(268_435_456)
|
||||
.default(67_108_864)
|
||||
.describe("Maximum CLI metadata region size accepted for inspection"),
|
||||
maxTableRows: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(1_000_000)
|
||||
.default(100_000)
|
||||
.describe("Maximum rows accepted in any CLI metadata table"),
|
||||
maxHeapItemBytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(16_777_216)
|
||||
.default(1_048_576)
|
||||
.describe("Maximum bytes accepted for one CLI metadata heap item"),
|
||||
};
|
||||
|
||||
export const registerManagedCommands = (
|
||||
cli: CliInstance,
|
||||
logger: Logger,
|
||||
@@ -84,46 +38,9 @@ const registerInspectManagedArtifact = (
|
||||
args: z.object({
|
||||
path: z.string().describe("Managed PE executable or assembly path"),
|
||||
}),
|
||||
options: z.object({
|
||||
referenceOffset: managedOffset("assembly-reference"),
|
||||
referenceLimit: managedLimit("assembly references", 500, 100),
|
||||
resourceOffset: managedOffset("manifest-resource"),
|
||||
resourceLimit: managedLimit("manifest resources", 500, 100),
|
||||
attributeOffset: managedOffset("assembly-attribute"),
|
||||
attributeLimit: managedLimit("assembly attributes", 500, 100),
|
||||
...managedInspectionLimits,
|
||||
}),
|
||||
alias: {
|
||||
referenceOffset: "reference-offset",
|
||||
referenceLimit: "reference-limit",
|
||||
resourceOffset: "resource-offset",
|
||||
resourceLimit: "resource-limit",
|
||||
attributeOffset: "attribute-offset",
|
||||
attributeLimit: "attribute-limit",
|
||||
maxFileBytes: "max-file-bytes",
|
||||
maxMetadataBytes: "max-metadata-bytes",
|
||||
maxTableRows: "max-table-rows",
|
||||
maxHeapItemBytes: "max-heap-item-bytes",
|
||||
},
|
||||
run: ({ args, options }) =>
|
||||
run: ({ args }) =>
|
||||
logCliCommand(logger, "inspect-managed-artifact", () =>
|
||||
runProviderAnalysis(
|
||||
args.path,
|
||||
"inspect_managed_artifact",
|
||||
{
|
||||
reference_offset: options.referenceOffset,
|
||||
reference_limit: options.referenceLimit,
|
||||
resource_offset: options.resourceOffset,
|
||||
resource_limit: options.resourceLimit,
|
||||
attribute_offset: options.attributeOffset,
|
||||
attribute_limit: options.attributeLimit,
|
||||
max_file_bytes: options.maxFileBytes,
|
||||
max_metadata_bytes: options.maxMetadataBytes,
|
||||
max_table_rows: options.maxTableRows,
|
||||
max_heap_item_bytes: options.maxHeapItemBytes,
|
||||
},
|
||||
logger,
|
||||
),
|
||||
runProviderAnalysis(args.path, "inspect_managed_artifact", {}, logger),
|
||||
),
|
||||
});
|
||||
};
|
||||
@@ -138,85 +55,9 @@ const registerInspectManagedMembers = (
|
||||
args: z.object({
|
||||
path: z.string().describe("Managed PE executable or assembly path"),
|
||||
}),
|
||||
options: z.object({
|
||||
typeOffset: managedOffset("type definition"),
|
||||
typeLimit: managedLimit("type definitions", 500, 100),
|
||||
methodOffset: managedOffset("method definition"),
|
||||
methodLimit: managedLimit("method definitions", 500, 100),
|
||||
fieldOffset: managedOffset("field definition"),
|
||||
fieldLimit: managedLimit("field definitions", 500, 100),
|
||||
memberRefOffset: managedOffset("member reference"),
|
||||
memberRefLimit: managedLimit("member references", 500, 100),
|
||||
edgeOffset: managedOffset("member edge"),
|
||||
edgeLimit: managedLimit("member edges", 1_000, 250),
|
||||
instructionAnchorLimit: z
|
||||
.number()
|
||||
.int()
|
||||
.min(0)
|
||||
.max(500)
|
||||
.default(100)
|
||||
.describe("Maximum CIL instruction anchors per method"),
|
||||
...managedInspectionLimits,
|
||||
maxMethodBodyBytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(16_777_216)
|
||||
.default(1_048_576)
|
||||
.describe("Maximum CIL method body size accepted for inspection"),
|
||||
maxMethodInstructions: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(100_000)
|
||||
.default(10_000)
|
||||
.describe("Maximum decoded CIL instructions per method"),
|
||||
}),
|
||||
alias: {
|
||||
typeOffset: "type-offset",
|
||||
typeLimit: "type-limit",
|
||||
methodOffset: "method-offset",
|
||||
methodLimit: "method-limit",
|
||||
fieldOffset: "field-offset",
|
||||
fieldLimit: "field-limit",
|
||||
memberRefOffset: "member-ref-offset",
|
||||
memberRefLimit: "member-ref-limit",
|
||||
edgeOffset: "edge-offset",
|
||||
edgeLimit: "edge-limit",
|
||||
instructionAnchorLimit: "instruction-anchor-limit",
|
||||
maxFileBytes: "max-file-bytes",
|
||||
maxMetadataBytes: "max-metadata-bytes",
|
||||
maxTableRows: "max-table-rows",
|
||||
maxHeapItemBytes: "max-heap-item-bytes",
|
||||
maxMethodBodyBytes: "max-method-body-bytes",
|
||||
maxMethodInstructions: "max-method-instructions",
|
||||
},
|
||||
run: ({ args, options }) =>
|
||||
run: ({ args }) =>
|
||||
logCliCommand(logger, "inspect-managed-members", () =>
|
||||
runProviderAnalysis(
|
||||
args.path,
|
||||
"inspect_managed_members",
|
||||
{
|
||||
type_offset: options.typeOffset,
|
||||
type_limit: options.typeLimit,
|
||||
method_offset: options.methodOffset,
|
||||
method_limit: options.methodLimit,
|
||||
field_offset: options.fieldOffset,
|
||||
field_limit: options.fieldLimit,
|
||||
member_ref_offset: options.memberRefOffset,
|
||||
member_ref_limit: options.memberRefLimit,
|
||||
edge_offset: options.edgeOffset,
|
||||
edge_limit: options.edgeLimit,
|
||||
instruction_anchor_limit: options.instructionAnchorLimit,
|
||||
max_file_bytes: options.maxFileBytes,
|
||||
max_metadata_bytes: options.maxMetadataBytes,
|
||||
max_table_rows: options.maxTableRows,
|
||||
max_heap_item_bytes: options.maxHeapItemBytes,
|
||||
max_method_body_bytes: options.maxMethodBodyBytes,
|
||||
max_method_instructions: options.maxMethodInstructions,
|
||||
},
|
||||
logger,
|
||||
),
|
||||
runProviderAnalysis(args.path, "inspect_managed_members", {}, logger),
|
||||
),
|
||||
});
|
||||
};
|
||||
@@ -231,44 +72,12 @@ const registerInspectManagedNativeBoundaries = (
|
||||
args: z.object({
|
||||
path: z.string().describe("Managed PE executable or assembly path"),
|
||||
}),
|
||||
options: z.object({
|
||||
moduleRefOffset: managedOffset("module reference"),
|
||||
moduleRefLimit: managedLimit("module references", 500, 100),
|
||||
importOffset: managedOffset("platform import"),
|
||||
importLimit: managedLimit("platform imports", 500, 100),
|
||||
implementationOffset: managedOffset("native implementation"),
|
||||
implementationLimit: managedLimit("native implementations", 500, 100),
|
||||
...managedInspectionLimits,
|
||||
}),
|
||||
alias: {
|
||||
moduleRefOffset: "module-ref-offset",
|
||||
moduleRefLimit: "module-ref-limit",
|
||||
importOffset: "import-offset",
|
||||
importLimit: "import-limit",
|
||||
implementationOffset: "implementation-offset",
|
||||
implementationLimit: "implementation-limit",
|
||||
maxFileBytes: "max-file-bytes",
|
||||
maxMetadataBytes: "max-metadata-bytes",
|
||||
maxTableRows: "max-table-rows",
|
||||
maxHeapItemBytes: "max-heap-item-bytes",
|
||||
},
|
||||
run: ({ args, options }) =>
|
||||
run: ({ args }) =>
|
||||
logCliCommand(logger, "inspect-managed-native-boundaries", () =>
|
||||
runProviderAnalysis(
|
||||
args.path,
|
||||
"inspect_managed_native_boundaries",
|
||||
{
|
||||
module_ref_offset: options.moduleRefOffset,
|
||||
module_ref_limit: options.moduleRefLimit,
|
||||
import_offset: options.importOffset,
|
||||
import_limit: options.importLimit,
|
||||
implementation_offset: options.implementationOffset,
|
||||
implementation_limit: options.implementationLimit,
|
||||
max_file_bytes: options.maxFileBytes,
|
||||
max_metadata_bytes: options.maxMetadataBytes,
|
||||
max_table_rows: options.maxTableRows,
|
||||
max_heap_item_bytes: options.maxHeapItemBytes,
|
||||
},
|
||||
{},
|
||||
logger,
|
||||
),
|
||||
),
|
||||
@@ -288,84 +97,11 @@ const registerCompareManagedMembers = (
|
||||
description:
|
||||
"Compare two managed PE/CLI member inventories without name-based matching",
|
||||
args: compareManagedMemberArgs,
|
||||
options: z.object({
|
||||
maxMethodMatches: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(50_000)
|
||||
.default(10_000)
|
||||
.describe("Maximum exact method matches to return"),
|
||||
maxFieldMatches: z
|
||||
.number()
|
||||
.int()
|
||||
.min(0)
|
||||
.max(50_000)
|
||||
.default(5_000)
|
||||
.describe("Maximum exact field matches to return"),
|
||||
maxCandidates: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(500)
|
||||
.default(50)
|
||||
.describe("Maximum ambiguous candidates per unmatched member"),
|
||||
typeLimit: managedLimit("type definitions per artifact", 500, 500),
|
||||
methodLimit: managedLimit("method definitions per artifact", 500, 500),
|
||||
fieldLimit: managedLimit("field definitions per artifact", 500, 500),
|
||||
memberRefLimit: managedLimit("member references per artifact", 500, 500),
|
||||
edgeLimit: managedLimit("member edges per artifact", 1_000, 1_000),
|
||||
instructionAnchorLimit: z
|
||||
.number()
|
||||
.int()
|
||||
.min(0)
|
||||
.max(500)
|
||||
.default(500)
|
||||
.describe("Maximum CIL instruction anchors per compared method"),
|
||||
...managedInspectionLimits,
|
||||
maxMethodBodyBytes: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(16_777_216)
|
||||
.default(1_048_576)
|
||||
.describe("Maximum CIL method body size accepted for comparison"),
|
||||
maxMethodInstructions: z
|
||||
.number()
|
||||
.int()
|
||||
.min(1)
|
||||
.max(100_000)
|
||||
.default(100_000)
|
||||
.describe("Maximum decoded CIL instructions per compared method"),
|
||||
}),
|
||||
alias: {
|
||||
maxMethodMatches: "max-method-matches",
|
||||
maxFieldMatches: "max-field-matches",
|
||||
maxCandidates: "max-candidates",
|
||||
typeLimit: "type-limit",
|
||||
methodLimit: "method-limit",
|
||||
fieldLimit: "field-limit",
|
||||
memberRefLimit: "member-ref-limit",
|
||||
edgeLimit: "edge-limit",
|
||||
instructionAnchorLimit: "instruction-anchor-limit",
|
||||
maxFileBytes: "max-file-bytes",
|
||||
maxMetadataBytes: "max-metadata-bytes",
|
||||
maxTableRows: "max-table-rows",
|
||||
maxHeapItemBytes: "max-heap-item-bytes",
|
||||
maxMethodBodyBytes: "max-method-body-bytes",
|
||||
maxMethodInstructions: "max-method-instructions",
|
||||
},
|
||||
run: ({ args, options }) =>
|
||||
run: ({ args }) =>
|
||||
logCliCommand(logger, "compare-managed-members", async () => {
|
||||
const result = await compareManagedMemberPaths({
|
||||
leftPath: args.leftPath,
|
||||
rightPath: args.rightPath,
|
||||
comparisonLimits: {
|
||||
max_method_matches: options.maxMethodMatches,
|
||||
max_field_matches: options.maxFieldMatches,
|
||||
max_candidates: options.maxCandidates,
|
||||
},
|
||||
memberLimits: buildMemberLimits(options),
|
||||
});
|
||||
return result.ok
|
||||
? result.value
|
||||
@@ -377,43 +113,6 @@ const registerCompareManagedMembers = (
|
||||
});
|
||||
};
|
||||
|
||||
interface ManagedMemberLimitOptions {
|
||||
readonly maxFileBytes: number;
|
||||
readonly typeLimit: number;
|
||||
readonly methodLimit: number;
|
||||
readonly fieldLimit: number;
|
||||
readonly memberRefLimit: number;
|
||||
readonly edgeLimit: number;
|
||||
readonly instructionAnchorLimit: number;
|
||||
readonly maxMetadataBytes: number;
|
||||
readonly maxTableRows: number;
|
||||
readonly maxHeapItemBytes: number;
|
||||
readonly maxMethodBodyBytes: number;
|
||||
readonly maxMethodInstructions: number;
|
||||
}
|
||||
|
||||
const buildMemberLimits = (
|
||||
options: ManagedMemberLimitOptions,
|
||||
): ManagedMemberPathInspectionLimits => ({
|
||||
maxFileBytes: options.maxFileBytes,
|
||||
typeOffset: 0,
|
||||
typeLimit: options.typeLimit,
|
||||
methodOffset: 0,
|
||||
methodLimit: options.methodLimit,
|
||||
fieldOffset: 0,
|
||||
fieldLimit: options.fieldLimit,
|
||||
memberRefOffset: 0,
|
||||
memberRefLimit: options.memberRefLimit,
|
||||
edgeOffset: 0,
|
||||
edgeLimit: options.edgeLimit,
|
||||
instructionAnchorLimit: options.instructionAnchorLimit,
|
||||
maxMetadataBytes: options.maxMetadataBytes,
|
||||
maxTableRows: options.maxTableRows,
|
||||
maxHeapItemBytes: options.maxHeapItemBytes,
|
||||
maxMethodBodyBytes: options.maxMethodBodyBytes,
|
||||
maxMethodInstructions: options.maxMethodInstructions,
|
||||
});
|
||||
|
||||
const registerImportManagedReconstruction = (
|
||||
cli: CliInstance,
|
||||
logger: Logger,
|
||||
|
||||
@@ -13,7 +13,6 @@ import {
|
||||
import { runUninstall } from "../application/Uninstall.js";
|
||||
import { runUpgrade, systemUpgradeHost } from "../application/Upgrade.js";
|
||||
import {
|
||||
conciseSetupResult,
|
||||
confirmInteractiveSetup,
|
||||
renderInteractiveSetupResult,
|
||||
renderSetupProgress,
|
||||
@@ -25,7 +24,6 @@ import { CLI_COMMANDS } from "../cliCommandNames.js";
|
||||
import type { Logger } from "../logger.js";
|
||||
import type { CliInstance } from "./types.js";
|
||||
import { SUPPORTED_CLIENT_DEFINITIONS } from "../application/SupportedClients.js";
|
||||
import { projectDoctorReport } from "../application/DoctorProjection.js";
|
||||
|
||||
const supportedClientIds = SUPPORTED_CLIENT_DEFINITIONS.map(({ name }) => name);
|
||||
const supportedClientSchema = z
|
||||
@@ -80,10 +78,6 @@ const registerSetupCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
.boolean()
|
||||
.default(false)
|
||||
.describe("Use sequential accessible setup prompts"),
|
||||
detail: z
|
||||
.enum(["summary", "full"])
|
||||
.default("summary")
|
||||
.describe("Summary or complete setup and doctor diagnostics"),
|
||||
}),
|
||||
alias: { yes: "y" },
|
||||
run: ({ options, formatExplicit }) =>
|
||||
@@ -110,10 +104,6 @@ const registerDoctorCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe("Require the installed REA skill identity to be aligned"),
|
||||
detail: z
|
||||
.enum(["summary", "full"])
|
||||
.default("summary")
|
||||
.describe("Summary or complete doctor diagnostics"),
|
||||
}),
|
||||
run: ({ options }) =>
|
||||
logCliCommand(logger, "doctor", () =>
|
||||
@@ -121,7 +111,7 @@ const registerDoctorCommand = (cli: CliInstance, logger: Logger): void => {
|
||||
options.target,
|
||||
createSystemDoctorHost(),
|
||||
doctorScope(options),
|
||||
).then((report) => projectDoctorReport(report, options.detail)),
|
||||
),
|
||||
),
|
||||
});
|
||||
};
|
||||
@@ -163,7 +153,6 @@ interface SetupCommandOptions {
|
||||
readonly skill?: boolean | undefined;
|
||||
readonly dryRun: boolean;
|
||||
readonly accessible: boolean;
|
||||
readonly detail: "summary" | "full";
|
||||
}
|
||||
|
||||
const runSetupCommand = async (input: {
|
||||
@@ -185,7 +174,7 @@ const runSetupCommand = async (input: {
|
||||
: undefined,
|
||||
);
|
||||
if (interactive) renderInteractiveSetupResult(result);
|
||||
return options.detail === "full" ? result : conciseSetupResult(result);
|
||||
return result;
|
||||
};
|
||||
|
||||
const setupRunOptions = (
|
||||
|
||||
@@ -39,17 +39,11 @@ const registerCapabilityCommands = (cli: CliInstance, logger: Logger): void => {
|
||||
command === "capabilities"
|
||||
? "List provider capabilities and side effects"
|
||||
: "List configured analysis providers",
|
||||
options: z.object({
|
||||
detail: z
|
||||
.enum(["summary", "full"])
|
||||
.default("summary")
|
||||
.describe("Summary or complete provider descriptors"),
|
||||
}),
|
||||
run: ({ options }) =>
|
||||
run: () =>
|
||||
logCliCommand(logger, command, () =>
|
||||
command === CLI_COMMANDS.providers
|
||||
? runProviderStatus(logger, options.detail)
|
||||
: runCapabilityStatus(logger, options.detail),
|
||||
? runProviderStatus(logger)
|
||||
: runCapabilityStatus(logger),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user