MCPcopy Create free account
hub / github.com/cortexkit/magic-context / runSetup

Function runSetup

packages/cli/src/commands/setup.ts:19–54  ·  view source on GitHub ↗
(argv: string[])

Source from the content-addressed store, hash-verified

17import { runSetup as runPiSetup } from "./setup-pi";
18
19export async function runSetup(argv: string[]): Promise<number> {
20 const dryRun = argv.includes("--dry-run");
21 intro(dryRun ? "Magic Context setup (dry run)" : "Magic Context setup");
22
23 const adapters = await resolveAdaptersForCommand(argv, {
24 allowMulti: true,
25 verb: "setup",
26 });
27
28 if (adapters.length === 0) {
29 outro("No harness selected. Nothing to do.");
30 return 0;
31 }
32
33 let anyFailure = false;
34 for (const adapter of adapters) {
35 log.step(`Configuring ${adapter.displayName} (${adapter.pluginPackageName})…`);
36
37 if (!adapter.isInstalled()) {
38 log.warn(`${adapter.displayName} host not found on PATH. ${adapter.getInstallHint()}.`);
39 anyFailure = true;
40 continue;
41 }
42
43 const code = await dispatchSetup(adapter, dryRun);
44 if (code !== 0) anyFailure = true;
45 if (!dryRun) printNextSteps(adapter);
46 }
47
48 if (anyFailure) {
49 outro("Setup finished with warnings — see above.");
50 return 1;
51 }
52 outro(dryRun ? "Dry run done — no changes were made." : "Done.");
53 return 0;
54}
55
56async function dispatchSetup(adapter: HarnessAdapter, dryRun: boolean): Promise<number> {
57 switch (adapter.kind) {

Callers 1

mainFunction · 0.50

Calls 9

introFunction · 0.90
outroFunction · 0.90
dispatchSetupFunction · 0.85
printNextStepsFunction · 0.85
stepMethod · 0.80
isInstalledMethod · 0.65
warnMethod · 0.65
getInstallHintMethod · 0.65

Tested by

no test coverage detected