MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / execute

Method execute

src/tools/cloud/cloud-tools.ts:62–93  ·  view source on GitHub ↗
(a: z.infer<typeof CiArgs>, ctx: ToolContext)

Source from the content-addressed store, hash-verified

60 isReadOnly = true; isDestructive = false; argsSchema = CiArgs;
61
62 async execute(a: z.infer<typeof CiArgs>, ctx: ToolContext): Promise<ToolResult> {
63 const cwd = a.cwd ?? ctx.cwd ?? process.cwd();
64 const action = a.action ?? 'list';
65
66 if (action === 'view') {
67 if (!a.run_id) return { content: 'view requires run_id (get one from ci_status action:list).', isError: true };
68 const r = await runProcess('gh', ['run', 'view', a.run_id], { cwd, timeoutMs: 30_000 });
69 if (r.notFound) return { content: notInstalledMessage('gh', 'Install GitHub CLI from https://cli.github.com/ and run `gh auth login`.'), isError: true };
70 return { content: (r.stdout || r.stderr).trim() || '(no output)', isError: !r.ok };
71 }
72
73 // list — request JSON for a clean condensed table.
74 const args = ['run', 'list', '--limit', String(a.limit ?? 10), '--json', 'databaseId,workflowName,status,conclusion,headBranch,createdAt,displayTitle'];
75 if (a.branch) args.push('--branch', a.branch);
76 const r = await runProcess('gh', args, { cwd, timeoutMs: 30_000 });
77 if (r.notFound) return { content: notInstalledMessage('gh', 'Install GitHub CLI from https://cli.github.com/ and run `gh auth login`.'), isError: true };
78 if (!r.ok) return { content: (r.stderr || r.stdout).trim() || 'gh run list failed', isError: true };
79 try {
80 const runs = JSON.parse(r.stdout);
81 if (!runs.length) return { content: 'No workflow runs found.' };
82 const lines = ['# Recent CI runs', ''];
83 for (const run of runs) {
84 const mark = run.conclusion === 'success' ? '✓' : run.conclusion === 'failure' ? '✗' : run.status === 'in_progress' ? '⟳' : '·';
85 lines.push(` ${mark} [${run.databaseId}] ${String(run.workflowName).padEnd(20)} ${run.headBranch} ${run.conclusion ?? run.status} — ${run.displayTitle}`);
86 }
87 lines.push('');
88 lines.push('View one with ci_status action:view, run_id:<id>.');
89 return { content: lines.join('\n') };
90 } catch {
91 return { content: r.stdout.slice(0, 4000) };
92 }
93 }
94}

Callers

nothing calls this directly

Calls 3

runProcessFunction · 0.85
notInstalledMessageFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected