Route ordinary CLI results through the bounded JSON writer after command registration, including managed member inspection. Remove JavaScript-specific output plumbing while preserving filters, envelopes, cancellation, and failure exits. Measure formatted UTF-16 expansion before Incur token counting and return resource_constraint above the runtime string limit, with recovery guidance. Validate output above the real V8 string limit by SHA-256 and exercise the compiled managed provider. Clean-worktree validation: npm run check; 76 focused tests passed, with 2 optional-provider skips; test discovery passed. Fixes #1371.
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import { analyzeJavaScriptApplication } from "../application/javascript/JavaScriptApplicationService.js";
|
|
import { createProgressReporter } from "../application/ProgressReporter.js";
|
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
import type { JsonValue } from "../domain/jsonValue.js";
|
|
|
|
/** Execute the shared one-shot CLI boundary for static JavaScript analysis. */
|
|
export const runCliJavaScriptApplicationAnalysis = async (
|
|
input: unknown,
|
|
signal?: AbortSignal,
|
|
): Promise<JsonValue> => {
|
|
const progress = createProgressReporter(
|
|
async (update) => {
|
|
process.stderr.write(`${JSON.stringify({ rea_progress: update })}\n`);
|
|
},
|
|
{ minimumIntervalMs: 0 },
|
|
);
|
|
const result = await analyzeJavaScriptApplication(input, {
|
|
progress,
|
|
...(signal === undefined ? {} : { signal }),
|
|
});
|
|
return result.ok ? result.value : cliError(result.error);
|
|
};
|
|
|
|
const cliError = (
|
|
error: Parameters<typeof projectAnalysisError>[0],
|
|
): JsonValue => ({
|
|
error: "JavaScript application analysis failed",
|
|
...projectAnalysisError(error),
|
|
});
|