MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / runCli

Function runCli

scripts/agent-config-smoke.ts:45–74  ·  view source on GitHub ↗
(
  ctx: CliContext,
  args: readonly string[],
  options: { readonly allowFailure?: boolean } = {},
)

Source from the content-addressed store, hash-verified

43};
44
45const runCli = async (
46 ctx: CliContext,
47 args: readonly string[],
48 options: { readonly allowFailure?: boolean } = {},
49): Promise<CliResult> => {
50 const proc = Bun.spawn([process.execPath, "run", cliEntrypoint, ...args], {
51 cwd: repoRoot,
52 env: {
53 ...process.env,
54 EXECUTOR_DEV: "1",
55 EXECUTOR_DATA_DIR: ctx.dataDir,
56 EXECUTOR_SCOPE_DIR: ctx.scopeDir,
57 },
58 stdout: "pipe",
59 stderr: "pipe",
60 });
61
62 const [stdout, stderr, exitCode] = await Promise.all([
63 new Response(proc.stdout).text(),
64 new Response(proc.stderr).text(),
65 proc.exited,
66 ]);
67 const result = { stdout, stderr, text: `${stdout}${stderr}`, exitCode };
68
69 if (exitCode !== 0 && !options.allowFailure) {
70 throw new Error(`CLI failed (${exitCode}) for ${args.join(" ")}\n${result.text}`);
71 }
72
73 return result;
74};
75
76const parseJsonOutput = <T>(result: CliResult): T => {
77 const start = result.stdout.indexOf("{");

Callers 3

callToolFunction · 0.85
approvePausedCallFunction · 0.85
runSmokeFunction · 0.85

Calls 1

textMethod · 0.65

Tested by

no test coverage detected