fix: replace hardcoded Mac paths with relative paths in learning engine (routing-optimizer, prompt-optimizer, few-shot-curator)

This commit is contained in:
Rene Fichtmueller 2026-04-02 23:58:53 +02:00
parent c3248da6c0
commit 52697bc6fc
3 changed files with 19 additions and 8 deletions

View File

@ -9,16 +9,19 @@
*/
import { readFileSync, writeFileSync, readdirSync } from 'fs';
import { join } from 'path';
import { fileURLToPath } from 'url';
import { join, resolve } from 'path';
import yaml from 'js-yaml';
import { query, withTransaction } from '../db/client.js';
import { logger } from '../observability/logger.js';
// ─── Constants ──────────────────────────────────────────────────────────────
const _dir = fileURLToPath(new URL('.', import.meta.url));
const _defaultTemplatesDir = resolve(join(_dir, '..', '..', '..', 'gateway', 'prompts', 'templates'));
const TEMPLATES_DIR =
process.env['TEMPLATES_DIR'] ??
'/Users/renefichtmueller/Desktop/Claude Code/llm-gateway/packages/gateway/prompts/templates';
process.env['TEMPLATES_DIR'] ?? _defaultTemplatesDir;
const MIN_CONFIDENCE = 9.0;
const SIMILARITY_THRESHOLD = 0.7;

View File

@ -13,7 +13,8 @@
*/
import { readFileSync, writeFileSync } from 'fs';
import { join } from 'path';
import { fileURLToPath } from 'url';
import { join, resolve } from 'path';
import yaml from 'js-yaml';
import { query, withTransaction } from '../db/client.js';
import { callGateway } from '../gateway-client.js';
@ -22,9 +23,11 @@ import { bumpMinorVersion } from '../few-shot-curator/index.js';
// ─── Constants ──────────────────────────────────────────────────────────────
const _dir = fileURLToPath(new URL('.', import.meta.url));
const _defaultTemplatesDir = resolve(join(_dir, '..', '..', '..', 'gateway', 'prompts', 'templates'));
const TEMPLATES_DIR =
process.env['TEMPLATES_DIR'] ??
'/Users/renefichtmueller/Desktop/Claude Code/llm-gateway/packages/gateway/prompts/templates';
process.env['TEMPLATES_DIR'] ?? _defaultTemplatesDir;
// Task types that MUST have human review before prompt updates go live
const SENSITIVE_TASK_TYPES = new Set([

View File

@ -10,6 +10,8 @@
*/
import { readFileSync, writeFileSync } from 'fs';
import { fileURLToPath } from 'url';
import { join, resolve } from 'path';
import yaml from 'js-yaml';
import { query, withTransaction } from '../db/client.js';
import { postInternal } from '../gateway-client.js';
@ -17,9 +19,12 @@ import { logger } from '../observability/logger.js';
// ─── Constants ──────────────────────────────────────────────────────────────
// Resolve path relative to this file: packages/learning/src/routing-optimizer/ → packages/gateway/src/config/
const _dir = fileURLToPath(new URL('.', import.meta.url));
const _defaultRoutingRulesPath = resolve(join(_dir, '..', '..', '..', 'gateway', 'src', 'config', 'routing-rules.yaml'));
const ROUTING_RULES_PATH =
process.env['ROUTING_RULES_PATH'] ??
'/Users/renefichtmueller/Desktop/Claude Code/llm-gateway/packages/gateway/src/config/routing-rules.yaml';
process.env['ROUTING_RULES_PATH'] ?? _defaultRoutingRulesPath;
const MIN_CONFIDENCE_DELTA = 1.0;
const MIN_LATENCY_IMPROVEMENT_PCT = 30;