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 pull request #369 from drona23/fix/provider-hook-spaced-paths-364
chaitanyagiric212970e0b06
diff --cc test/hive-hook-node.test.cjsindex aa819d19,ca3ae33a..db8f6515--- a/test/hive-hook-node.test.cjs+++ b/test/hive-hook-node.test.cjs@@@ -171,53 -169,64 +171,111 @@@ test('every hook installer routes throu}});+test('Codex hook commands survive a hive path containing spaces', { skip: !POSIX, timeout: 10_000 }, async (t) => {+ // Keep this root short enough for macOS's Unix-domain socket path limit while+ // putting the literal space after a unique component. The shell's first token+ // is then guaranteed absent, which makes the exit-127 negative control stable.+ const isolated = isolatedHomes(t, undefined, '/tmp');+ const home = isolated.home;+ const harness = `${isolated.harness} space`;+ const hive = new HiveManager(() => harness);+ hive.ensureHive();+ const agentDir = path.join(harness, 'hive', 'agents', 'a1');+ const codexHome = hive.installCodexHooks(agentDir, 'a1');+ const config = fs.readFileSync(path.join(codexHome, 'config.toml'), 'utf8');+ const commands = [...config.matchAll(/^command\s*=\s*(.+)$/gm)].map((m) => {+ const literal = m[1].trim();+ return literal.startsWith('"') ? JSON.parse(literal) : literal.slice(1, -1);+ });++ assert.equal(commands.length, 8, 'every Codex lifecycle hook must be generated');+ const launcher = launcherIn(harness);+ const shim = path.join(harness, 'hive', 'bin', 'cth-hook.cjs');+ const sock = path.join(harness, 'hive', 'hooks.sock');+ const env = { PATH: STRIPPED_PATH, HIVE_SOCK: sock, AGENT_ID: 'a1', HOME: home };++ const before = await run(`${launcher} ${shim}`, env);+ assert.equal(before.code, 127, 'negative control: the current unquoted command must fail at the first space');++ try { fs.unlinkSync(sock); } catch { /* not there */ }+ const received = [];+ const server = net.createServer((conn) => {+ let buf = '';+ conn.on('error', () => { /* the shim may hang up first */ });+ conn.on('data', (d) => { buf += d; });+ conn.on('close', () => { if (buf) received.push(buf); });+ conn.write(JSON.stringify({ ok: true }) + '\n', () => conn.end());+ });+ await new Promise((resolve, reject) => {+ server.once('error', reject);+ server.listen(sock, resolve);+ });+ t.after(() => server.close());++ const after = await run(commands[0], env);+ assert.equal(after.code, 0, `Codex hook failed from a space-containing hive path: ${after.stderr}`);+ await new Promise((resolve) => setTimeout(resolve, 300));+ assert.ok(received.length > 0, 'the quoted hook command never reached HIVE_SOCK');+});++ test('POSIX Gemini and Antigravity hooks survive a hive path containing spaces', { skip: !POSIX }, async (t) => {+ // Keep the socket short enough for macOS sun_path while retaining a literal+ // space in the user-selected harness root.+ const base = fs.mkdtempSync('/tmp/md-provider-space-');+ const home = path.join(base, 'user');+ const harness = path.join(base, 'harness space');+ t.after(() => fs.rmSync(base, { recursive: true, force: true }));++ const realHome = process.env.HOME;+ const realProfile = process.env.USERPROFILE;+ process.env.HOME = home;+ process.env.USERPROFILE = home;+ t.after(() => {+ if (realHome === undefined) delete process.env.HOME; else process.env.HOME = realHome;+ if (realProfile === undefined) delete process.env.USERPROFILE; else process.env.USERPROFILE = realProfile;+ });+ assert.equal(os.homedir(), home, 'home redirect failed — aborting before touching the real home');++ const hive = new HiveManager(() => harness);+ hive.ensureHive();+ hive.installAgyHooks();+ hive.installGeminiHooks(path.join(harness, 'hive/agents/a1'));++ const commands = hookCommandsUnder(home);+ const providerCommands = [+ ['antigravity', commands.find((candidate) => candidate.includes('agy-hook.cjs'))],+ ['gemini', hookCommandsUnder(harness).find((candidate) => candidate.includes('gemini-hook.cjs'))]+ ];++ const sock = path.join(harness, 'hive', 'hooks.sock');+ const received = [];+ const server = net.createServer((conn) => {+ let buf = '';+ conn.on('error', () => { /* shim may hang up first */ });+ conn.on('data', (d) => { buf += d; });+ conn.on('close', () => { if (buf) received.push(buf); });+ conn.write(JSON.stringify({ ok: true }) + '\n', () => conn.end());+ });+ await new Promise((resolve, reject) => {+ server.once('error', reject);+ server.listen(sock, resolve);+ });+ t.after(() => server.close());++ for (const [provider, command] of providerCommands) {+ assert.ok(command, `${provider} installer produced no command`);+ const result = await run(command, {+ PATH: STRIPPED_PATH,+ HOME: home,+ AGENT_ID: 'a1',+ HIVE_SOCK: sock+ });+ assert.equal(result.code, 0, `${provider} command failed: ${command}\n${result.stderr}`);+ }+ await new Promise((resolve) => setTimeout(resolve, 300));+ assert.equal(received.length, 2, 'both provider hook shims must reach HIVE_SOCK');+ });+test('Codex rollouts remain isolated and are visible under the standard scan roots', (t) => {const { home, harness } = isolatedHomes(t);const hive = new HiveManager(() => harness);