mirror of
https://github.com/morluto/rea
synced 2026-10-28 06:46:47 -04:00
166dcd21d0
* feat(javascript): recover readable modules with Wakaru Integrate pinned upstream source behind a typed optional recovery port, preserve source identity and producer provenance, and publish verified artifacts for existing JavaScript analysis through CLI and MCP. Add focused real-tool CI with genuine bundler fixtures and bounded resource, cancellation, cleanup, schema and packaged-artifact checks. Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) * fix(javascript): align recovery catalog and browser verification Share canonical Wakaru provider identity, describe CLI mode options, and format the new workflow test. Disconnect the real page transport after its observation readiness progress instead of a fixed delay. Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing) * refactor(javascript): consume the investigation evidence writer Verify that the SDK recovery handler records complete Evidence through the newly shared investigation owner. Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) * chore(test): account for isolated recovery fixture compilers * fix(javascript): validate recovery paths before acquiring the engine Return field-specific invalid_format diagnostics for relative paths and verify compiled CLI/MCP parity even when the optional engine is unavailable. Assisted-by: Yukari (gensokyo-skills:yukari-boundary-analysis) Assisted-by: Kogasa (gensokyo-skills:kogasa-surprise-testing)
70 lines
2.5 KiB
TypeScript
70 lines
2.5 KiB
TypeScript
import { z } from "incur";
|
|
import { JavaScriptRecoveryService } from "../application/JavaScriptRecoveryService.js";
|
|
import { createJavaScriptRecoveryProvider } from "../composition/javascriptRecovery.js";
|
|
import { CLI_COMMANDS } from "../cliCommandNames.js";
|
|
import { logCliCommand } from "../cliLogging.js";
|
|
import { projectAnalysisError } from "../domain/analysisErrorProjection.js";
|
|
import type { Logger } from "../logger.js";
|
|
import type { CliInstance } from "./types.js";
|
|
import { withCommandCancellation } from "./commandCancellation.js";
|
|
|
|
/** Share source recovery with MCP while keeping CLI spelling at this boundary. */
|
|
export const registerJavaScriptRecoveryCommands = (
|
|
cli: CliInstance,
|
|
logger: Logger,
|
|
environment: Readonly<Record<string, string | undefined>>,
|
|
): void => {
|
|
const service = new JavaScriptRecoveryService(
|
|
createJavaScriptRecoveryProvider(environment),
|
|
);
|
|
cli.command(CLI_COMMANDS.recoverJavaScriptSources, {
|
|
description:
|
|
"Recover readable JavaScript modules with source provenance and verified files",
|
|
args: z.object({
|
|
path: z
|
|
.string()
|
|
.describe("Absolute UTF-8 JavaScript input; never executed"),
|
|
outputDirectory: z.string().describe("Absolute absent output directory"),
|
|
}),
|
|
options: z.object({
|
|
extractionMode: z
|
|
.enum(["structural", "heuristic", "inspection"])
|
|
.optional()
|
|
.describe(
|
|
"Structural boundaries, heuristic fallback, or inspection-only regions",
|
|
),
|
|
rewriteLevel: z
|
|
.enum(["minimal", "standard", "aggressive"])
|
|
.optional()
|
|
.describe(
|
|
"Upstream syntax recovery level; runtime equivalence remains unknown",
|
|
),
|
|
}),
|
|
run: ({ args, options }) =>
|
|
withCommandCancellation((signal) =>
|
|
logCliCommand(
|
|
logger,
|
|
CLI_COMMANDS.recoverJavaScriptSources,
|
|
async () => {
|
|
const result = await service.recover(
|
|
{
|
|
path: args.path,
|
|
output_directory: args.outputDirectory,
|
|
...(options.extractionMode === undefined
|
|
? {}
|
|
: { extraction_mode: options.extractionMode }),
|
|
...(options.rewriteLevel === undefined
|
|
? {}
|
|
: { rewrite_level: options.rewriteLevel }),
|
|
},
|
|
{ signal },
|
|
);
|
|
return result.ok
|
|
? result.value
|
|
: projectAnalysisError(result.error);
|
|
},
|
|
),
|
|
),
|
|
});
|
|
};
|