From e2718064d684bc50b7a64cf54bdb1d6c4b36576b Mon Sep 17 00:00:00 2001 From: Adam <13062491+adambkovacs@users.noreply.github.com> Date: Wed, 10 Dec 2025 13:11:52 -0800 Subject: [PATCH] fix(agentdb): add ESM __dirname polyfill to agentdb-cli.ts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The agentdb-cli.ts uses __dirname on line 62 but runs as an ES module where __dirname is not available. This causes all MCP tools that rely on the CLI to fail with "__dirname is not defined". Added the standard ESM polyfill using fileURLToPath and dirname from Node.js built-in modules. Fixes #77 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- agentic-flow/src/agentdb/cli/agentdb-cli.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/agentic-flow/src/agentdb/cli/agentdb-cli.ts b/agentic-flow/src/agentdb/cli/agentdb-cli.ts index 77a0e77d0..7d362f106 100644 --- a/agentic-flow/src/agentdb/cli/agentdb-cli.ts +++ b/agentic-flow/src/agentdb/cli/agentdb-cli.ts @@ -19,6 +19,12 @@ import { SkillLibrary, Skill, SkillQuery } from '../controllers/SkillLibrary.js' import { EmbeddingService } from '../controllers/EmbeddingService.js'; import * as fs from 'fs'; import * as path from 'path'; +import { fileURLToPath } from 'url'; +import { dirname } from 'path'; + +// ESM __dirname polyfill (required since ES modules don't have __dirname) +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); // Color codes for terminal output const colors = {