Skip to content

an open-source alternative to the dots, bots and muses of the world, run an office of claude code/codex like agents on your laptop, sandboxes or anywhere, uses your existing subscriptions

feat(main): add GitHub issue ingestion via gh CLI

Chaitanya Girid0c11036fc62
diff --git a/src/main/github.ts b/src/main/github.ts
new file mode 100644
index 00000000..2c89077f
--- /dev/null
+++ b/src/main/github.ts
@@ -0,0 +1,64 @@
+import { spawn } from 'node:child_process';
+
+/** A GitHub issue, normalized for the renderer (labels/assignees flattened to names). */
+export interface GHIssue {
+ number: number;
+ title: string;
+ body: string;
+ url: string;
+ labels: string[];
+ assignees: string[];
+}
+
+/** Shape `gh issue list --json` emits for each issue (the fields we ask for). */
+interface RawGHIssue {
+ number?: number;
+ title?: string;
+ body?: string;
+ url?: string;
+ state?: string;
+ labels?: Array<{ name?: string }>;
+ assignees?: Array<{ login?: string }>;
+}
+
+/**
+ * List up to 30 issues in the repo at `cwd` via the `gh` CLI.
+ *
+ * Returns `{ ok: false, error }` on any failure — spawn error (e.g. `gh` not
+ * installed), non-zero exit (e.g. unauthenticated / not a repo), or a JSON
+ * parse failure — so callers never have to try/catch.
+ */
+export function listIssues(cwd: string): Promise<{ ok: boolean; issues?: GHIssue[]; error?: string }> {
+ return new Promise((resolve) => {
+ const proc = spawn(
+ 'gh',
+ ['issue', 'list', '--json', 'number,title,body,assignees,labels,url,state', '--limit', '30'],
+ { cwd }
+ );
+ let stdout = '';
+ let stderr = '';
+ proc.stdout.on('data', (d) => { stdout += d.toString(); });
+ proc.stderr.on('data', (d) => { stderr += d.toString(); });
+ proc.on('error', (e) => resolve({ ok: false, error: e.message }));
+ proc.on('close', (code) => {
+ if (code !== 0) {
+ resolve({ ok: false, error: stderr.trim() || `gh exited ${code}` });
+ return;
+ }
+ try {
+ const raw = JSON.parse(stdout) as RawGHIssue[];
+ const issues: GHIssue[] = (Array.isArray(raw) ? raw : []).map((i) => ({
+ number: i.number ?? 0,
+ title: i.title ?? '',
+ body: i.body ?? '',
+ url: i.url ?? '',
+ labels: (i.labels ?? []).map((l) => l.name ?? '').filter(Boolean),
+ assignees: (i.assignees ?? []).map((a) => a.login ?? '').filter(Boolean)
+ }));
+ resolve({ ok: true, issues });
+ } catch (e) {
+ resolve({ ok: false, error: e instanceof Error ? e.message : String(e) });
+ }
+ });
+ });
+}
diff --git a/src/main/index.ts b/src/main/index.ts
index b8771c77..71bb9a27 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -15,6 +15,7 @@ import { HiveManager, type AgentMeta, type HiveMessage } from './hive';
import { HookServer } from './hooks';
import { MemoryManager } from './memory';
import { enrichMessage } from './assistant';
+import { listIssues } from './github';
const isDev = !!process.env.ELECTRON_RENDERER_URL;
const ptyManager = new PtyManager();
@@ -302,6 +303,11 @@ ipcMain.handle('app:resetAll', () => {
app.exit(0);
});
+// ─── IPC: GitHub issue ingestion (gh CLI) ────────────────────────────────────
+ipcMain.handle('github:issues', (_evt, cwd: unknown) =>
+ typeof cwd === 'string' ? listIssues(cwd) : { ok: false, error: 'no cwd' }
+);
+
app.whenReady().then(() => {
// Bootstrap the hive (if harnessHome is configured) and start the message router.
if (hive.enabled()) {