fix: harden CLI parsing, MCP startup and release integrity
This commit is contained in:
1 parent
f0902f5f20
commit
103ead0fe5
53 files changed
+3713
-1945
No files matched your search
+17
-4
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bun
|
||||
import { parseArgs, stringOption, booleanOption } from "./cli/parser.js";
|
||||
import { printJson, redactSensitiveText } from "./cli/printer.js";
|
||||
import { parseArgs, stringOption, booleanOption, isJsonRequested } from "./cli/parser.js";
|
||||
import { cliErrorResult } from "./cli/runner.js";
|
||||
import { printHelp, printJson, redactSensitiveText } from "./cli/printer.js";
|
||||
import { getSessionClientForRuntime, initCorpRuntime, requireSelectedCorp } from "./cli/helpers.js";
|
||||
import {
|
||||
ApprovalService,
|
||||
@@ -27,10 +28,22 @@ import type { AiProExecutionContext } from "./cli/commands/aipro/types.js";
|
||||
export async function runAiProCli(
|
||||
rawArgs: string[]
|
||||
): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||
const parsed = parseArgs(rawArgs);
|
||||
try {
|
||||
return await runAiProCliOnce(rawArgs);
|
||||
} catch (error) {
|
||||
return cliErrorResult(error, isJsonRequested(rawArgs));
|
||||
}
|
||||
}
|
||||
|
||||
async function runAiProCliOnce(rawArgs: string[]): Promise<{ stdout: string; stderr: string; exitCode: number }> {
|
||||
const parsed = parseArgs(rawArgs, "aipro");
|
||||
const jsonMode = booleanOption(parsed.options, ["json", "j"]);
|
||||
if (booleanOption(parsed.options, ["help", "h", "?"])) {
|
||||
const help = printHelp(["aipro", ...(parsed.area && parsed.area !== "help" ? [parsed.area] : [])]);
|
||||
return { stdout: jsonMode ? printJson({ help }) : `${help}\n`, stderr: "", exitCode: 0 };
|
||||
}
|
||||
const runtime = initCorpRuntime({
|
||||
corpId: stringOption(parsed.options, ["corp", "c"]),
|
||||
corpId: stringOption(parsed.options, ["corp"]),
|
||||
jsonMode,
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user