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
HTML agent-harnessagent-orchestrationagentsai-agentsautonomous-agentsclaude-codecodexcoding-agentsdesktop-appdeveloper-toolselectrongemini-cliharnessharness-engineeringlocal-firstmemorymulti-agentopencodeorchestrationtypescript
Merge branch 'feature/ci-watcher' into integration/roadmap
Chaitanya Giri0f13c3e4dfb9
diff --cc src/main/index.tsindex c5068d96,03c22bb0..11143811--- a/src/main/index.ts+++ b/src/main/index.ts@@@ -16,7 -15,7 +16,8 @@@ import { HiveManager, type AgentMeta, timport { HookServer } from './hooks';import { MemoryManager } from './memory';import { enrichMessage } from './assistant';+import { readAgentUsage } from './transcript';+ import { listIssues, listCIRuns } from './github';const isDev = !!process.env.ELECTRON_RENDERER_URL;const ptyManager = new PtyManager();@@@ -381,52 -303,16 +382,62 @@@ ipcMain.handle('app:resetAll', () =>app.exit(0);});+// ─── IPC: token telemetry (real usage + est. cost from CC transcripts) ───────+ipcMain.handle('hive:agentUsage', (_evt, cwd: unknown) =>+ typeof cwd === 'string' ? readAgentUsage(cwd) : null);++// ─── IPC: scheduled missions (recurring auto-dispatch) ──────────────────────+ipcMain.handle('missions:list', () => readConfig().missions ?? []);+ipcMain.handle('missions:save', (_evt, missions) => {+ writeConfig({ missions: missions as ScheduledMission[] });+ syncMissions();+ return { ok: true };+});++// ─── IPC: full-text search across hive files (board, tasks, memory) ──────────+ipcMain.handle('hive:textSearch', (_evt, query: unknown) => {+ if (typeof query !== 'string' || !query.trim()) return { ok: false, results: [] };+ const root = hive.root();+ if (!root) return { ok: false, results: [] };+ const q = query.toLowerCase();+ const results: Array<{ source: string; excerpt: string }> = [];+ // Each target file is (path, readable label). agents/<id>/memory.md is expanded below.+ const targets: Array<{ path: string; source: string }> = [+ { path: join(root, 'board.md'), source: 'board.md' },+ { path: join(root, 'tasks.json'), source: 'tasks.json' }+ ];+ const agentsDir = join(root, 'agents');+ if (existsSync(agentsDir)) {+ for (const id of readdirSync(agentsDir)) {+ targets.push({ path: join(agentsDir, id, 'memory.md'), source: `${id}/memory.md` });+ }+ }+ for (const { path, source } of targets) {+ if (!existsSync(path)) continue;+ let hits = 0;+ for (const line of readFileSync(path, 'utf8').split('\n')) {+ if (hits >= 3) break;+ const idx = line.toLowerCase().indexOf(q);+ if (idx === -1) continue;+ // ~40 chars of context on either side of the match.+ const excerpt = line.slice(Math.max(0, idx - 40), idx + q.length + 40).trim();+ results.push({ source, excerpt });+ hits++;+ }+ }+ return { ok: true, results };+});++ // ─── IPC: GitHub issue ingestion (gh CLI) ────────────────────────────────────+ ipcMain.handle('github:issues', (_evt, cwd: unknown) =>+ typeof cwd === 'string' ? listIssues(cwd) : { ok: false, error: 'no cwd' }+ );++ // ─── IPC: GitHub CI status watcher (gh CLI) ──────────────────────────────────+ ipcMain.handle('github:ciRuns', (_evt, cwd: unknown) =>+ typeof cwd === 'string' ? listCIRuns(cwd) : { ok: false, error: 'no cwd' }+ );+app.whenReady().then(() => {// Bootstrap the hive (if harnessHome is configured) and start the message router.if (hive.enabled()) {diff --cc src/preload/index.tsindex f74e8545,7a31cfdf..a762db7b--- a/src/preload/index.ts+++ b/src/preload/index.ts@@@ -122,16 -96,24 +122,34 @@@ export interface GitCommitexport interface GitStatusEntry { path: string; index: string; worktree: string }export interface GitStatus { staged: GitStatusEntry[]; unstaged: GitStatusEntry[]; untracked: string[] }+/** Real token usage + estimated USD cost summed from an agent's Claude Code+ * transcripts under ~/.claude/projects (Sonnet pricing). */+export interface AgentUsage {+ inputTokens: number;+ outputTokens: number;+ cacheReadTokens: number;+ cacheWriteTokens: number;+ estimatedCostUsd: number;+}++ /** 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[];+ }++ /** A CI (GitHub Actions) workflow run, normalized for the renderer. */+ export interface CIRun {+ name: string;+ status: string;+ conclusion: string | null;+ url: string;+ }+const api = {version: '0.1.0',@@@ -257,25 -239,18 +275,38 @@@* into onboarding. The process exits, so this promise never resolves. */resetAll: (): Promise<void> => ipcRenderer.invoke('app:resetAll'),+ // ─── Token telemetry (real usage + est. cost from CC transcripts) ──────────+ /** Sum input/output/cache tokens + estimated USD cost for an agent from its+ * Claude Code transcripts. Returns null for an invalid cwd. */+ agentUsage: (cwd: string): Promise<AgentUsage | null> =>+ ipcRenderer.invoke('hive:agentUsage', cwd),++ // ─── Task kanban (hive/tasks.json) ───────────────────────────────────────+ /** Overwrite the hive task ledger with the full task list and commit it. */+ hiveWriteTasks: (tasks: HiveTask[]): Promise<{ ok: boolean; error?: string }> =>+ ipcRenderer.invoke('hive:writeTasks', tasks),++ // ─── Scheduled missions (recurring auto-dispatch) ──────────────────────────+ listMissions: (): Promise<ScheduledMission[]> => ipcRenderer.invoke('missions:list'),+ saveMissions: (missions: ScheduledMission[]): Promise<{ ok: boolean }> =>+ ipcRenderer.invoke('missions:save', missions),++ // ─── Full-text search across hive files (board, tasks, memory) ─────────────+ textSearch: (q: string): Promise<{ ok: boolean; results: Array<{ source: string; excerpt: string }> }> =>- ipcRenderer.invoke('hive:textSearch', q)++ ipcRenderer.invoke('hive:textSearch', q),+++ // ─── GitHub issue ingestion (gh CLI) ───────────────────────────────────────+ /** List up to 30 open issues in the repo at `cwd` via the `gh` CLI. Returns+ * `{ ok: false, error }` if `gh` is missing/unauthenticated or `cwd` isn't a repo. */+ githubIssues: (cwd: string): Promise<{ ok: boolean; issues?: GHIssue[]; error?: string }> =>+ ipcRenderer.invoke('github:issues', cwd),++ // ─── GitHub CI status watcher (gh CLI) ─────────────────────────────────────+ /** List up to 5 recent CI (GitHub Actions) runs in the repo at `cwd` via the+ * `gh` CLI. Returns `{ ok: false, error }` if `gh` is missing/unauthenticated,+ * `cwd` isn't a repo, or the repo has no Actions. */+ githubCIRuns: (cwd: string): Promise<{ ok: boolean; runs?: CIRun[]; error?: string }> =>+ ipcRenderer.invoke('github:ciRuns', cwd)};contextBridge.exposeInMainWorld('cth', api);diff --cc src/renderer/src/components/CommandCenterPanel.tsxindex 6c34687e,4560f8db..a89e7cf6--- a/src/renderer/src/components/CommandCenterPanel.tsx+++ b/src/renderer/src/components/CommandCenterPanel.tsx@@@ -18,27 -16,26 +18,45 @@@ import { buildSpawnCommand, AGENT_MODEL* per-agent model + dispatch + assistant access), a memory view, and a live* activity feed / board / usage meter. */-type CCTab = 'terminal' | 'floor' | 'memory' | 'activity' | 'handbook';+type CCTab = 'terminal' | 'floor' | 'tasks' | 'memory' | 'graph' | 'activity' | 'handbook';++/** A recurring auto-dispatched mission (mirrors the main-process config type). */+interface ScheduledMission {+ id: string;+ label: string;+ intervalMs: number;+ to: string;+ body: string;+ enabled: boolean;+ lastFiredAt?: number;+}++/** Interval presets offered in the SCHEDULES form / shown as badges. */+const INTERVAL_OPTS: { ms: number; label: string }[] = [+ { ms: 3600000, label: '1h' },+ { ms: 21600000, label: '6h' },+ { ms: 86400000, label: '24h' },+ { ms: 604800000, label: 'weekly' }+];+ /** A GitHub issue as returned by `window.cth.githubIssues` (labels/assignees flattened). */+ interface GHIssue {+ number: number;+ title: string;+ body: string;+ url: string;+ labels: string[];+ assignees: string[];+ }++ /** A CI run as returned by `window.cth.githubCIRuns` (GitHub Actions workflow runs). */+ interface CIRun {+ name: string;+ status: string;+ conclusion: string | null;+ url: string;+ }+const TABS: { key: CCTab; label: string; icon: Parameters<typeof Icon>[0]['name'] }[] = [{ key: 'terminal', label: 'terminal', icon: 'terminal' },{ key: 'floor', label: 'floor', icon: 'mcp' },@@@ -181,48 -154,16 +199,53 @@@ function FloorTab({ seed }: { seed: { tconst [dispatchTo, setDispatchTo] = useState<string>('broadcast');const [dispatchText, setDispatchText] = useState('');const [dispatchMsg, setDispatchMsg] = useState<string | null>(null);+ // ── ISSUES section state ──+ const [issueRepo, setIssueRepo] = useState<string>('');+ const [issues, setIssues] = useState<GHIssue[]>([]);+ const [issuesLoading, setIssuesLoading] = useState(false);+ const [issuesError, setIssuesError] = useState<string | null>(null);+ // ── Scheduled missions (recurring auto-dispatch) ──+ const [missions, setMissions] = useState<ScheduledMission[]>([]);+ const [mLabel, setMLabel] = useState('');+ const [mInterval, setMInterval] = useState<string>(String(INTERVAL_OPTS[0].ms));+ const [mTo, setMTo] = useState<string>('god');+ const [mBody, setMBody] = useState('');+useEffect(() => {window.cth.getConfig().then((c) => setRepos(c.registeredRepos ?? [])).catch(() => { /* noop */ });+ window.cth.listMissions().then(setMissions).catch(() => { /* noop */ });}, []);+ // Seed the dispatch box from a task-card "assign" (keyed on seq so repeat+ // assigns re-prefill). seq === 0 is the untouched initial state — skip it.+ useEffect(() => {+ if (seed.seq > 0) setDispatchText(seed.text);+ }, [seed.seq, seed.text]);++ const persistMissions = async (next: ScheduledMission[]) => {+ setMissions(next);+ await window.cth.saveMissions(next).catch(() => { /* noop */ });+ };+ const toggleMission = (id: string) =>+ persistMissions(missions.map((m) => (m.id === id ? { ...m, enabled: !m.enabled } : m)));+ const addMission = () => {+ if (!mLabel.trim() || !mBody.trim()) return;+ const next: ScheduledMission = {+ id: `m_${Date.now().toString(36)}`,+ label: mLabel.trim(),+ intervalMs: Number(mInterval),+ to: mTo,+ body: mBody.trim(),+ enabled: true+ };+ persistMissions([...missions, next]);+ setMLabel(''); setMBody('');+ };+ const targetName = (to: string) =>+ to === 'broadcast' ? 'everyone' : to === 'god' ? 'Michael' : agents.find((a) => a.id === to)?.name ?? to;+ const intervalLabel = (ms: number) => INTERVAL_OPTS.find((o) => o.ms === ms)?.label ?? `${Math.round(ms / 3600000)}h`;+const restartWithModel = async (a: Agent, model: string | undefined) => {if (!a.ptyId) return;setRestarting(a.id);@@@ -555,11 -468,17 +658,13 @@@ function ActivityTab()return (<Scroll>+ <CIStatusSection />+<Section title="USAGE (this session)">{agents.map((a) => (- <div key={a.id} style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 2 }}>- <span style={{ fontSize: 12, color: 'var(--cth-ink-700)', width: 90 }}>{a.name}</span>- <Bar value={toolCounts[a.id] ?? 0} max={Math.max(1, ...agents.map((x) => toolCounts[x.id] ?? 0))} />- <span style={{ fontSize: 11, color: 'var(--cth-ink-500)' }}>{toolCounts[a.id] ?? 0}</span>- </div>+ <UsageRow key={a.id} name={a.name} cwd={a.cwd} maxCost={maxCost} onCost={reportCost(a.id)} />))}- <Muted>tool calls this session (not billed $ — interactive sessions don't expose cost)</Muted>+ <Muted>tokens from ~/.claude/projects/ transcripts</Muted></Section><Section title="ACTIVITY">@@@ -579,45 -498,125 +684,164 @@@);}+/** One agent's real token usage, polled from its Claude Code transcripts on+ * mount and every 10s. Renders: name | input Kt | output Kt | est $X.XX, with+ * a bar normalized to the most-expensive agent (via the lifted-up cost). */+function UsageRow({ name, cwd, maxCost, onCost }: {+ name: string; cwd: string; maxCost: number; onCost: (cost: number) => void;+}) {+ const [usage, setUsage] = useState<{ inputTokens: number; outputTokens: number; estimatedCostUsd: number } | null>(null);++ useEffect(() => {+ let alive = true;+ const refresh = async () => {+ try {+ const u = await window.cth.agentUsage(cwd);+ if (!alive || !u) return;+ setUsage(u);+ onCost(u.estimatedCostUsd);+ } catch { /* noop */ }+ };+ refresh();+ const id = setInterval(refresh, 10000);+ return () => { alive = false; clearInterval(id); };+ // onCost is recreated each render but stable in behavior; cwd is the real key.+ // eslint-disable-next-line react-hooks/exhaustive-deps+ }, [cwd]);++ const inK = usage ? (usage.inputTokens / 1000).toFixed(1) : '0.0';+ const outK = usage ? (usage.outputTokens / 1000).toFixed(1) : '0.0';+ const cost = usage?.estimatedCostUsd ?? 0;++ return (+ <div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 2 }}>+ <span style={{ fontSize: 12, color: 'var(--cth-ink-700)', width: 90 }}>{name}</span>+ <Bar value={cost} max={maxCost} />+ <span style={{ fontSize: 11, color: 'var(--cth-ink-500)', width: 56, textAlign: 'right' }}>{inK}/{outK}Kt</span>+ <span style={{ fontSize: 11, color: 'var(--cth-ink-700)', width: 52, textAlign: 'right' }}>${cost.toFixed(2)}</span>+ </div>+ );+}++ // ─── CI status — per-repo latest workflow run, polled every 30s ──────────────++ /** Per-repo CI poll result: the latest run plus any error surfaced by the IPC. */+ interface RepoCIState {+ run: CIRun | null;+ error: string | null;+ }++ /** A run failed if it completed with a non-success conclusion. */+ function ciFailed(run: CIRun): boolean {+ return run.status === 'completed' && run.conclusion !== null && run.conclusion !== 'success';+ }++ /** Status chip: green=success, red=failure, yellow=in_progress/queued. */+ function CIChip({ run }: { run: CIRun }) {+ let bg = 'var(--cth-lemon)';+ let label = run.status || 'queued';+ if (run.status === 'completed') {+ if (run.conclusion === 'success') { bg = 'var(--cth-mint)'; label = 'success'; }+ else { bg = 'var(--cth-coral)'; label = run.conclusion || 'failed'; }+ }+ return (+ <span style={{+ fontSize: 10, lineHeight: '14px', padding: '0 6px', flexShrink: 0,+ background: bg, boxShadow: 'inset 0 0 0 1px var(--cth-ink-900)', color: 'var(--cth-ink-900)'+ }}>{label}</span>+ );+ }++ /** Polls `githubCIRuns` for every registered repo every 30s. gh being missing+ * or unauthenticated surfaces as a muted per-repo error — never a crash. */+ function CIStatusSection() {+ const [repos, setRepos] = useState<string[]>([]);+ const [states, setStates] = useState<Record<string, RepoCIState>>({});+ const [copied, setCopied] = useState<string | null>(null);+ const timer = useRef<ReturnType<typeof setInterval> | null>(null);++ useEffect(() => {+ window.cth.getConfig().then((c) => setRepos(c.registeredRepos ?? [])).catch(() => { /* noop */ });+ }, []);++ useEffect(() => {+ if (repos.length === 0) return;+ let cancelled = false;+ const refresh = async () => {+ const next: Record<string, RepoCIState> = {};+ for (const repo of repos) {+ try {+ const res = await window.cth.githubCIRuns(repo);+ next[repo] = res.ok+ ? { run: (res.runs ?? [])[0] ?? null, error: null }+ : { run: null, error: res.error ?? 'Failed to fetch CI runs.' };+ } catch (e) {+ next[repo] = { run: null, error: e instanceof Error ? e.message : String(e) };+ }+ }+ if (!cancelled) setStates(next);+ };+ refresh();+ timer.current = setInterval(refresh, 30000);+ return () => { cancelled = true; if (timer.current) clearInterval(timer.current); };+ }, [repos]);++ const copyUrl = async (url: string) => {+ try {+ await window.cth.copyToClipboard(url);+ setCopied(url);+ setTimeout(() => setCopied((c) => (c === url ? null : c)), 1300);+ } catch { /* noop */ }+ };++ if (repos.length === 0) return null;++ return (+ <Section title="CI STATUS">+ {repos.map((repo) => {+ const st = states[repo];+ const short = repo.split('/').filter(Boolean).pop() || repo;+ const run = st?.run ?? null;+ return (+ <div key={repo} style={{+ display: 'flex', flexDirection: 'column', gap: 4,+ padding: 6, marginBottom: 6,+ background: 'var(--cth-paper-100)', boxShadow: 'inset 0 0 0 1px var(--cth-ink-300)'+ }}>+ <div style={{ display: 'flex', alignItems: 'center', gap: 6 }}>+ <span style={{ flex: 1, fontSize: 12, color: 'var(--cth-ink-900)', wordBreak: 'break-word' }}>{short}</span>+ {run && <CIChip run={run} />}+ </div>+ {run && (+ <div style={{ fontSize: 11, color: 'var(--cth-ink-500)', wordBreak: 'break-word' }}>+ {run.name || 'workflow'}+ </div>+ )}+ {!st && <Muted>checking…</Muted>}+ {st && !run && !st.error && <Muted>No runs yet.</Muted>}+ {st?.error && (+ <div style={{ fontSize: 11, color: 'var(--cth-ink-500)', wordBreak: 'break-word' }}>{st.error}</div>+ )}+ {run && ciFailed(run) && run.url && (+ <button+ onClick={() => copyUrl(run.url)}+ title="Copy the failing run's URL"+ style={{+ alignSelf: 'flex-start', display: 'inline-flex', alignItems: 'center', gap: 4,+ padding: '2px 7px 1px', border: 'none', cursor: 'pointer',+ background: copied === run.url ? 'var(--cth-mint)' : 'var(--cth-cream-200)',+ boxShadow: 'inset 0 0 0 1px var(--cth-ink-700)',+ fontFamily: 'var(--cth-font-ui)', fontSize: 11, color: 'var(--cth-ink-900)'+ }}+ ><Icon name={copied === run.url ? 'check' : 'code'} /> {copied === run.url ? 'copied' : 'copy run URL'}</button>+ )}+ </div>+ );+ })}+ </Section>+ );+ }+// ─── Handbook tab — copyable Claude command reference ────────────────────────interface Cmd { cmd: string; kind: 'slash' | 'cli'; desc: string; usage?: string }