test(experiment): repair relationship discovery env loading
This commit is contained in:
@@ -25,10 +25,12 @@
|
||||
import fs from "fs/promises";
|
||||
import path from "path";
|
||||
import { fileURLToPath } from "url";
|
||||
import dotenv from "dotenv";
|
||||
|
||||
dotenv.config({ path: ".env.local" });
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const resultsDir = path.resolve(__dirname, "../../tests/experimental/results");
|
||||
const envLocalPath = path.resolve(__dirname, "../../.env.local");
|
||||
|
||||
// ─── Fragment paths ──────────────────────────────────────────────────────────
|
||||
|
||||
@@ -351,18 +353,9 @@ async function inspectApparatus() {
|
||||
// ─── Live execution (exactly one model call) ──────────────────────────────────
|
||||
|
||||
async function executeLive() {
|
||||
// Load .env.local for authoritative config
|
||||
let envContent = "";
|
||||
try {
|
||||
envContent = await fs.readFile(envLocalPath, "utf-8");
|
||||
} catch {
|
||||
console.error(".env.local not found. Cannot execute live mode.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const baseUrl = parseEnv(envContent, "OLLAMA_BASE_URL");
|
||||
const baseUrl = process.env.OLLAMA_BASE_URL;
|
||||
if (!baseUrl) {
|
||||
console.error("OLLAMA_BASE_URL not set in .env.local. Cannot execute live mode.");
|
||||
console.error("OLLAMA_BASE_URL not set in environment. Cannot execute live mode.");
|
||||
process.exit(1);
|
||||
}
|
||||
if (baseUrl === "http://localhost:11434" || baseUrl === "http://127.0.0.1:11434") {
|
||||
@@ -370,9 +363,9 @@ async function executeLive() {
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const modelName = parseEnv(envContent, "OLLAMA_MODEL");
|
||||
const modelName = process.env.OLLAMA_MODEL;
|
||||
if (!modelName) {
|
||||
console.error("OLLAMA_MODEL not set in .env.local. Cannot execute live mode.");
|
||||
console.error("OLLAMA_MODEL not set in environment. Cannot execute live mode.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -441,21 +434,6 @@ async function executeLive() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
// ─── Helper: parse .env.local ────────────────────────────────────────────────
|
||||
|
||||
function parseEnv(content, key) {
|
||||
const lines = content.split("\n");
|
||||
for (const line of lines) {
|
||||
const trimmed = line.trim();
|
||||
if (trimmed.startsWith("#")) continue;
|
||||
const [k, ...vParts] = trimmed.split("=");
|
||||
if (k.trim() === key) {
|
||||
return vParts.join("=").trim().replace(/^["']|["']$/g, "");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ─── CLI entry point ──────────────────────────────────────────────────────────
|
||||
|
||||
async function main() {
|
||||
|
||||
Reference in New Issue
Block a user