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(harness): pre-accept bypass warning + hourly ops standup w/ terminal compaction

Chaitanya Giri84c795ab701a
diff --git a/src/main/config.ts b/src/main/config.ts
index 3e5e83e8..a83ce5bf 100644
--- a/src/main/config.ts
+++ b/src/main/config.ts
@@ -1,6 +1,7 @@
import { app } from 'electron';
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
+import { homedir } from 'node:os';
/** A recurring auto-dispatched mission fired on an interval by the scheduler. */
export interface ScheduledMission {
@@ -10,9 +11,30 @@ export interface ScheduledMission {
to: string;
body: string;
enabled: boolean;
+ /** When true, the scheduler also sends `/compact` to every live terminal when
+ * this mission fires — keeping each agent's context lean on a cadence. */
+ autoCompact?: boolean;
lastFiredAt?: number;
}
+/** The built-in hourly ops standup: god reviews who's doing what + whether tasks
+ * are on track and agents are running, and every terminal's context is compacted.
+ * Shipped enabled by default; users can toggle it off in the Command Center. */
+export const OPS_STANDUP_MISSION: ScheduledMission = {
+ id: 'ops-standup',
+ label: 'Hourly ops standup',
+ intervalMs: 3_600_000,
+ to: 'god',
+ body:
+ 'Hourly ops standup. Review every agent: who is doing what, and confirm each ' +
+ 'is still running (not stalled or idle-stale). Check the task board — are ' +
+ 'in-flight tasks on track, and is anything blocked or unowned? Flag stale ' +
+ 'agents and at-risk tasks, and keep the board accurate. (Terminal contexts ' +
+ 'are auto-compacted as part of this standup.)',
+ enabled: true,
+ autoCompact: true
+};
+
export interface HarnessConfig {
/** Has the user completed the first-run onboarding? */
onboardingComplete: boolean;
@@ -32,6 +54,9 @@ export interface HarnessConfig {
embeddingModel: 'minilm' | 'embeddinggemma';
/** Recurring auto-dispatch missions handled by the scheduler. */
missions?: ScheduledMission[];
+ /** One-time guard: has the built-in hourly ops standup been seeded into an
+ * existing install's missions? Prevents re-adding it after a user deletes it. */
+ opsStandupSeeded?: boolean;
/** Fire native desktop notifications on agent lifecycle events (idle finish / waiting for input). */
notifications?: boolean;
/** Master toggle for the Slack → Michael's-queue integration. */
@@ -54,7 +79,7 @@ const DEFAULTS: HarnessConfig = {
defaultCommand: 'claude',
semanticMemory: true,
embeddingModel: 'minilm',
- missions: [],
+ missions: [OPS_STANDUP_MISSION],
notifications: false,
slackEnabled: false,
slackSigningSecret: undefined,
@@ -114,3 +139,50 @@ export function ensureHarnessHome(path: string): { ok: boolean; error?: string }
return { ok: false, error: e instanceof Error ? e.message : String(e) };
}
}
+
+/** Idempotently pre-accept Claude Code's first-run prompts so agents spawned with
+ * `--permission-mode bypassPermissions` start cleanly. Without this, a fresh
+ * install shows an interactive "WARNING: Bypass Permissions mode … 1. No, exit /
+ * 2. Yes, I accept" prompt that the PTY can't answer in time, so the agent exits
+ * code 1 on its own (reported by multiple users).
+ *
+ * Two separate gates, written only when they aren't already satisfied (so we
+ * rarely touch files a running `claude` also writes):
+ * 1. `~/.claude/settings.json` → `skipDangerousModePermissionPrompt` +
+ * `skipAutoPermissionPrompt` — these gate the bypass-mode warning (global).
+ * 2. `~/.claude.json` → `projects[cwd].hasTrustDialogAccepted` — the per-folder
+ * "do you trust the files in this folder?" dialog. */
+export function ensureClaudePermissionsAccepted(cwd?: string): void {
+ const home = homedir();
+ if (!home) return;
+ // 1) Global bypass-mode warning gate.
+ try {
+ const dir = join(home, '.claude');
+ const p = join(dir, 'settings.json');
+ let s: Record<string, unknown> = {};
+ if (existsSync(p)) {
+ try { s = JSON.parse(readFileSync(p, 'utf8')) as Record<string, unknown>; } catch { s = {}; }
+ }
+ if (s.skipDangerousModePermissionPrompt !== true || s.skipAutoPermissionPrompt !== true) {
+ s.skipDangerousModePermissionPrompt = true;
+ s.skipAutoPermissionPrompt = true;
+ mkdirSync(dir, { recursive: true });
+ writeFileSync(p, JSON.stringify(s, null, 2), 'utf8');
+ }
+ } catch { /* best-effort; never block a spawn */ }
+ // 2) Per-folder trust dialog gate (only when this cwd isn't already trusted).
+ if (cwd) {
+ try {
+ const p = join(home, '.claude.json');
+ let c: { projects?: Record<string, { hasTrustDialogAccepted?: boolean }> } = {};
+ if (existsSync(p)) {
+ try { c = JSON.parse(readFileSync(p, 'utf8')); } catch { c = {}; }
+ }
+ if (c.projects?.[cwd]?.hasTrustDialogAccepted !== true) {
+ c.projects = c.projects ?? {};
+ c.projects[cwd] = { ...(c.projects[cwd] ?? {}), hasTrustDialogAccepted: true };
+ writeFileSync(p, JSON.stringify(c, null, 2), 'utf8');
+ }
+ } catch { /* best-effort */ }
+ }
+}
diff --git a/src/main/index.ts b/src/main/index.ts
index c92c4aac..c96a5e50 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -4,8 +4,8 @@ import { rmSync, existsSync, readFileSync, readdirSync } from 'node:fs';
import { join, resolve, sep } from 'node:path';
import { PtyManager, type SpawnOptions } from './pty';
import {
- readConfig, writeConfig, resetConfig, ensureHarnessHome,
- type HarnessConfig, type ScheduledMission
+ readConfig, writeConfig, resetConfig, ensureHarnessHome, ensureClaudePermissionsAccepted,
+ OPS_STANDUP_MISSION, type HarnessConfig, type ScheduledMission
} from './config';
import { listDir, readFileText, writeFileText } from './fs';
import {
@@ -122,6 +122,17 @@ function syncMissions(): void {
if (hive.enabled()) {
hive.send({ to: m.to, act: 'request', subject: m.label, body: m.body }, 'scheduler');
}
+ // Compact every live terminal's context on this tick. Send the slash
+ // command, then a return a beat later (the input box needs the text to
+ // register before submit — mirrors the renderer's submitToPty cadence).
+ if (m.autoCompact) {
+ for (const t of ptyManager.list()) {
+ try {
+ ptyManager.write(t.id, '/compact');
+ setTimeout(() => { try { ptyManager.write(t.id, '\r'); } catch { /* pty gone */ } }, 200);
+ } catch { /* pty gone */ }
+ }
+ }
const current = readConfig().missions ?? [];
const next = current.map((x) =>
x.id === m.id ? { ...x, lastFiredAt: Date.now() } : x
@@ -144,6 +155,22 @@ function syncMissions(): void {
}
}
+/** One-time migration: ensure the built-in hourly ops standup exists for installs
+ * that predate it. Guarded by `opsStandupSeeded` so a user who later deletes the
+ * mission doesn't get it re-added on every boot. Stamps lastFiredAt = now so the
+ * first standup waits a full interval instead of firing (and compacting every
+ * terminal) immediately on launch. */
+function ensureDefaultMissions(): void {
+ const cfg = readConfig();
+ if (cfg.opsStandupSeeded) return;
+ const missions = cfg.missions ?? [];
+ const has = missions.some((m) => m.id === OPS_STANDUP_MISSION.id);
+ writeConfig({
+ missions: has ? missions : [...missions, { ...OPS_STANDUP_MISSION, lastFiredAt: Date.now() }],
+ opsStandupSeeded: true
+ });
+}
+
/** The live renderer webContents, or null if the window is gone/destroyed.
* Anything that emits to the renderer from a timer/socket/child callback must
* route through here — during quit the window can be destroyed while those
@@ -297,6 +324,10 @@ ipcMain.handle('pty:spawn', async (_evt, opts: SpawnOptions & { hive?: AgentMeta
// Remember which agent owns this PTY so closing the tab can archive it. A
// live terminal means active — ensureAgent above already cleared `archived`.
if (opts.hive?.id) ptyToAgent.set(opts.id, opts.hive.id);
+ // Pre-accept Claude Code's bypass-mode warning + folder-trust dialog so the
+ // agent (spawned with --permission-mode bypassPermissions) doesn't stall on an
+ // interactive prompt it can't answer and exit code 1. Best-effort, never blocks.
+ try { ensureClaudePermissionsAccepted(opts.cwd); } catch { /* never block spawn */ }
return ptyManager.spawn(opts);
});
ipcMain.handle('pty:write', (_evt, id: string, data: string) => {
@@ -602,6 +633,7 @@ app.whenReady().then(() => {
if (hive.enabled()) {
hive.ensureHive();
hive.startRouter();
+ ensureDefaultMissions(); // one-time: seed the built-in hourly ops standup
syncMissions(); // arm recurring auto-dispatch missions now the router is live
hookServer.start();
memory.start(); // init shared palace + mine loop (no-op without mempalace)
diff --git a/src/preload/index.ts b/src/preload/index.ts
index fd78f405..0323c403 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -81,6 +81,7 @@ export interface ScheduledMission {
to: string;
body: string;
enabled: boolean;
+ autoCompact?: boolean;
lastFiredAt?: number;
}
diff --git a/src/renderer/src/components/CommandCenterPanel.tsx b/src/renderer/src/components/CommandCenterPanel.tsx
index 4927c307..b73d115f 100644
--- a/src/renderer/src/components/CommandCenterPanel.tsx
+++ b/src/renderer/src/components/CommandCenterPanel.tsx
@@ -28,6 +28,7 @@ interface ScheduledMission {
to: string;
body: string;
enabled: boolean;
+ autoCompact?: boolean;
lastFiredAt?: number;
}