diff --git a/cli/src/commands/hatch.ts b/cli/src/commands/hatch.ts index 7caaa5f571e..3c201f357c0 100644 --- a/cli/src/commands/hatch.ts +++ b/cli/src/commands/hatch.ts @@ -538,6 +538,16 @@ async function hatchLocal(species: Species, name: string | null, daemonOnly: boo } } + const baseDataDir = join(process.env.BASE_DATA_DIR?.trim() || (process.env.HOME ?? userInfo().homedir), ".vellum"); + + if (existsSync(baseDataDir)) { + throw new Error( + `Base data directory already exists: ${baseDataDir}\n` + + " Another assistant may already be using this directory.\n" + + " To use a different directory, set the BASE_DATA_DIR environment variable.", + ); + } + console.log(`🥚 Hatching local assistant: ${instanceName}`); console.log(` Species: ${species}`); console.log(""); @@ -555,8 +565,6 @@ async function hatchLocal(species: Species, name: string | null, daemonOnly: boo throw error; } - const baseDataDir = join(process.env.BASE_DATA_DIR?.trim() || (process.env.HOME ?? userInfo().homedir), ".vellum"); - // Read the bearer token written by the daemon so the client can authenticate // with the gateway (which requires auth by default). let bearerToken: string | undefined;