perf(cli): defer binary provider composition

This commit is contained in:
morluto
2026-10-11 11:07:15 +08:00
parent 76296c5a38
commit 21dbcf7a14
5 changed files with 77 additions and 18 deletions
+12 -5
View File
@@ -7,7 +7,6 @@ import {
} from "../application/DirectAnalysis.js";
import { runSessionStatus as executeSessionStatus } from "../application/DirectAnalysisStatus.js";
import type { DirectAnalysisDependencies } from "../application/DirectAnalysisDependencies.js";
import { createBinarySession, createManagedBinarySession } from "./binary.js";
/** Bind one-shot analysis and status commands to one caller-selected environment. */
export const createDirectAnalysis = (
@@ -16,9 +15,14 @@ export const createDirectAnalysis = (
const environment = snapshotEnvironment(selectedEnvironment);
const dependencies: DirectAnalysisDependencies = {
readConfiguration: () => parseConfig(environment),
createBinarySession: (config, logger) =>
createBinarySession(config, logger, environment),
createManagedBinarySession,
createBinarySession: async (config, logger) => {
const { createBinarySession } = await import("./binary.js");
return createBinarySession(config, logger, environment);
},
createManagedBinarySession: async () => {
const { createManagedBinarySession } = await import("./binary.js");
return createManagedBinarySession();
},
};
return {
runDirectAnalysis: executeDirectAnalysis.bind(undefined, dependencies),
@@ -34,6 +38,9 @@ export type DirectAnalysis = ReturnType<typeof createDirectAnalysis>;
export const runManagedProviderExecution = executeManagedProvider.bind(
undefined,
{
createManagedBinarySession,
createManagedBinarySession: async () => {
const { createManagedBinarySession } = await import("./binary.js");
return createManagedBinarySession();
},
},
);