From b99e2335a7ea89ee602c078fb558572396b8af76 Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Mon, 6 Jul 2026 09:11:23 +0530 Subject: [PATCH] refactor: switch to process.env for all packages, fix typos --- cli/package.json | 3 +++ cli/src/index.ts | 5 +++++ packages/core/src/attribute.ts | 4 ++-- packages/core/src/index.ts | 4 ---- packages/llm/src/config.ts | 8 -------- pnpm-lock.yaml | 6 +++++- vitest.config.evals.ts | 4 ++++ 7 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cli/package.json b/cli/package.json index 006fa2d..740a239 100644 --- a/cli/package.json +++ b/cli/package.json @@ -5,5 +5,8 @@ "type": "module", "exports": { ".": "./dist/index.js" + }, + "dependencies": { + "dotenv": "^17.4.2" } } diff --git a/cli/src/index.ts b/cli/src/index.ts index cb0ff5c..baa94fa 100644 --- a/cli/src/index.ts +++ b/cli/src/index.ts @@ -1 +1,6 @@ +import dotenv from "dotenv"; + +// Load environment variables once at CLI application entry point +dotenv.config(); + export {}; diff --git a/packages/core/src/attribute.ts b/packages/core/src/attribute.ts index feafd78..8776f32 100644 --- a/packages/core/src/attribute.ts +++ b/packages/core/src/attribute.ts @@ -73,7 +73,7 @@ export interface IAttribute { value: string, visibility: AttributeVisibility, ): void; - getVisibileAttributesFor(viewerId: string): Attribute[]; + getVisibleAttributesFor(viewerId: string): Attribute[]; } export abstract class AttributableObject implements IAttribute { @@ -107,7 +107,7 @@ export abstract class AttributableObject implements IAttribute { this.attributes.delete(name); } - getVisibileAttributesFor(viewerId: string): Attribute[] { + getVisibleAttributesFor(viewerId: string): Attribute[] { return Array.from(this.attributes.values()).filter((attr) => attr.hasAccess(viewerId), ); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 9ed8ffc..0d17a84 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,7 +1,3 @@ -import { config } from "dotenv"; -import path from "node:path"; -config({ path: path.resolve(__dirname, "../.env") }); - export * from "./attribute.js"; export * from "./entity.js"; export * from "./world.js"; diff --git a/packages/llm/src/config.ts b/packages/llm/src/config.ts index 3afef3c..4a5c7c0 100644 --- a/packages/llm/src/config.ts +++ b/packages/llm/src/config.ts @@ -1,12 +1,4 @@ import { z } from "zod"; -import dotenv from "dotenv"; -import path from "path"; - -// Load environment variables from .env file -dotenv.config(); -// In a monorepo, the cwd might be a package subdirectory, so check parent directories as well -dotenv.config({ path: path.resolve(process.cwd(), "../.env") }); -dotenv.config({ path: path.resolve(process.cwd(), "../../.env") }); const LLMConfigSchema = z.object({ GOOGLE_API_KEY: z.string().min(1, "GOOGLE_API_KEY is required"), diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3d584a3..e7e6c3f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -251,7 +251,11 @@ importers: specifier: ^4.4.3 version: 4.4.3 - cli: {} + cli: + dependencies: + dotenv: + specifier: ^17.4.2 + version: 17.4.2 content/scenario-builder: dependencies: diff --git a/vitest.config.evals.ts b/vitest.config.evals.ts index c59900b..075169f 100644 --- a/vitest.config.evals.ts +++ b/vitest.config.evals.ts @@ -1,4 +1,8 @@ import { defineConfig } from "vitest/config"; +import dotenv from "dotenv"; + +// Load environment variables for evals at test process startup +dotenv.config(); export default defineConfig({ test: {