The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
CLI tests refuse to run without an isolated home and data folder (#1146)
Dee366200ad95db
diff --git a/cli/src/config/env.ts b/cli/src/config/env.tsindex 7b595ca00..b085cb5c5 100644--- a/cli/src/config/env.ts+++ b/cli/src/config/env.ts@@ -1,3 +1,4 @@+import './testIsolation.js'import './loadEnv.js'import { existsSync, mkdirSync, readdirSync, renameSync, rmSync } from 'fs'import { homedir } from 'os'diff --git a/cli/src/config/envIsolation.spec.ts b/cli/src/config/envIsolation.spec.tsindex f77aa87b8..19aefcc96 100644--- a/cli/src/config/envIsolation.spec.ts+++ b/cli/src/config/envIsolation.spec.ts@@ -13,6 +13,7 @@ import { join, sep } from 'node:path'import { describe, expect, it } from 'vitest'import { env } from './env.js'import { AUTH_DIR } from '../lib/authSession.js'+import { assertTestIsolation, TEST_ISOLATED } from './testIsolation.js'const productRoot = join(homedir(), '.harness')@@ -39,6 +40,14 @@ describe('test environment isolation', () => {it('keeps the hook routes off the developer\'s ~/.harness, so no spec records a daemon beside theirs or routes by one', () => {expect(env.HARNESS_HOOK_ROUTES_DIR.startsWith(productRoot)).toBe(false)})+ // From the repository root Vitest finds no config and skips vitest.setup.ts, and every spec used the real+ // ~/.harness: 19 stopped-harness fixtures turned up in one Mac's live store (2026-10-10).+ it('refuses a Vitest run that vitest.setup.ts did not isolate, and nothing else', () => {+ expect(process.env[TEST_ISOLATED]).toBe('1')+ expect(() => assertTestIsolation({ VITEST: 'true' })).toThrow('no isolated home or data folder')+ expect(() => assertTestIsolation({ VITEST: 'true', [TEST_ISOLATED]: '1' })).not.toThrow()+ expect(() => assertTestIsolation({})).not.toThrow()+ })it('keeps account reads and refreshes in the test-owned auth directory', () => {expect(AUTH_DIR).toBe(join(env.ADAPTER_DATA_DIR, 'auth'))expect(AUTH_DIR.startsWith(productRoot)).toBe(false)diff --git a/cli/src/config/testIsolation.ts b/cli/src/config/testIsolation.tsnew file mode 100644index 000000000..a432190aa--- /dev/null+++ b/cli/src/config/testIsolation.ts@@ -0,0 +1,20 @@+/**+ * Refuses a test run that has no throwaway home and data folder.+ *+ * `vitest.setup.ts` gives every spec its own home, data, runtime and auth folders, but only when Vitest+ * runs from `cli/`, where its config is. Run from the repository root it finds no config, skips the setup,+ * and every spec reads and writes the developer's real `~/.harness`, `~/.claude` and `~/.codex`. The+ * 2026-10-10 audit found 19 of `stopAgentService.spec.ts`'s fixtures (pid 77, session `saved`, folder+ * `/tmp`) in one Mac's live `stopped-agents/`, listed in its Cmd-P as stopped harnesses.+ *+ * `env.ts` imports this first, before anything resolves or moves a folder under the home.+ */+export const TEST_ISOLATED = 'HARNESS_TEST_ISOLATED'++export function assertTestIsolation(env: NodeJS.ProcessEnv = process.env): void {+ if (!env.VITEST || env[TEST_ISOLATED] === '1') return+ throw new Error('This test run has no isolated home or data folder, so it would use the real ~/.harness. '+ + 'Run the CLI tests from cli/ (npm test, or npx vitest there).')+}++assertTestIsolation()diff --git a/cli/vitest.setup.ts b/cli/vitest.setup.tsindex 56d00a96e..ce07740b9 100644--- a/cli/vitest.setup.ts+++ b/cli/vitest.setup.ts@@ -58,3 +58,5 @@ process.env.HARNESS_HOOK_ROUTES_DIR = join(process.env.ADAPTER_DATA_DIR, 'hook-r// holds today (a published catalog turned a fixture registry of two into the live shelf of 23).// Loopback port 9 refuses at once, so the live catalog falls back to the registry each test stubs.process.env.HARNESS_STORE_CATALOG_URL ??= 'http://127.0.0.1:9/catalog.json'+// Last: everything above is in place, so `config/testIsolation.ts` may let `env.ts` load.+process.env.HARNESS_TEST_ISOLATED = '1'