mirror of
https://github.com/morluto/rea.git
synced 2026-11-17 04:04:25 +00:00
refactor(cli): read global arguments once with one REA owner (#11687)
parseCliGlobalArguments replaces normalizeCliArguments, splitIncurBuiltinArguments and splitCliTimingArguments: it normalizes spaced output forms, routes the root --update alias, splits builtin switches and output values, and reads the timing global in one pass. The output-argument reader, the launcher's doctor path, lazy registration, the Amp scope guard, completions, mcp add, strict positionals and sensitive-value redaction read that record instead of scanning argv again. Only the incur hand-off adapter remains until dispatch moves to REA. Output is unchanged; the CLI parity goldens pass as recorded.
This commit is contained in:
1 parent
ec1cf3a9bd
commit
5257a3d912
21 files changed
+484
-481
No files matched your search
+18
-15
@@ -6,7 +6,7 @@ import type { FridaInstrumentationPort } from "../ports/frida/FridaInstrumentati
|
||||
import { currentClientRegistrationCommand } from "../application/ClientRegistrationIdentity.js";
|
||||
import {
|
||||
adaptCliOutputArgumentsForIncur,
|
||||
normalizeCliArguments,
|
||||
parseCliGlobalArguments,
|
||||
} from "../cliBuiltinArguments.js";
|
||||
import type { DirectAnalysis } from "../composition/directAnalysis.js";
|
||||
import { parseLogLevel } from "../config/processStart.js";
|
||||
@@ -153,28 +153,31 @@ export const createCliShell = (options: CliShellOptions): CliInstance => {
|
||||
const serveDeclared = excludeDeclaredSensitiveArguments(cli);
|
||||
encodeCliArgumentErrors(cli);
|
||||
const serve = cli.serve.bind(cli);
|
||||
const complete = createCliCompletions(cli, environment);
|
||||
const completions = createCliCompletions(cli, environment);
|
||||
cli.serve = (arguments_ = process.argv.slice(2), serveOptions) => {
|
||||
if (complete(arguments_, serveOptions ?? {})) return Promise.resolve();
|
||||
const normalized = normalizeCliArguments(arguments_);
|
||||
if (completions.complete(arguments_, serveOptions ?? {}))
|
||||
return Promise.resolve();
|
||||
const global = parseCliGlobalArguments(arguments_);
|
||||
if (completions.writeScript(global, serveOptions ?? {}))
|
||||
return Promise.resolve();
|
||||
const registration = serveMcpRegistration(
|
||||
normalized,
|
||||
global,
|
||||
environment,
|
||||
defaultRegistration,
|
||||
serveOptions ?? {},
|
||||
);
|
||||
if (registration !== undefined) return registration;
|
||||
const result = serveStrict(
|
||||
normalized,
|
||||
serveOptions ?? {},
|
||||
(tokens, selected) =>
|
||||
serveDeclared(tokens, selected, (declared, declaredOptions) =>
|
||||
reportUnknownMcpSubcommand(cli.name, declared, declaredOptions)
|
||||
? Promise.resolve()
|
||||
: serve(adaptCliOutputArgumentsForIncur(declared), declaredOptions),
|
||||
),
|
||||
const result = serveStrict(global, serveOptions ?? {}, (selected) =>
|
||||
serveDeclared(global, selected, (declaredOptions) =>
|
||||
reportUnknownMcpSubcommand(cli.name, global, declaredOptions)
|
||||
? Promise.resolve()
|
||||
: serve(
|
||||
adaptCliOutputArgumentsForIncur(global.arguments),
|
||||
declaredOptions,
|
||||
),
|
||||
),
|
||||
);
|
||||
const note = completionHelpNote(normalized);
|
||||
const note = completionHelpNote(global);
|
||||
if (note === undefined) return result;
|
||||
return result.then(() => {
|
||||
const write =
|
||||
|
||||
Reference in new issue
Block a user