From 7eae9764afab668a9ba3e7e0ce4fe8e81bb8d1bf Mon Sep 17 00:00:00 2001 From: Gab Date: Wed, 15 Apr 2026 15:09:16 +1000 Subject: [PATCH] Bump to 1.0.39: fix tf_sync module not found after npm install getPythonSyncPath() only searched __dirname-relative paths which don't resolve correctly from the compiled binary. Added process.execPath- relative candidates so it finds /python from /bin/tfcode. Co-Authored-By: Claude Opus 4.6 (1M context) --- packages/tfcode/package.json | 2 +- packages/tfcode/src/cli/cmd/tools.ts | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/tfcode/package.json b/packages/tfcode/package.json index 10094cf6a..b7849e233 100644 --- a/packages/tfcode/package.json +++ b/packages/tfcode/package.json @@ -1,6 +1,6 @@ { "$schema": "https://json.schemastore.org/package.json", - "version": "1.0.38", + "version": "1.0.39", "name": "@toothfairyai/tfcode", "type": "module", "license": "MIT", diff --git a/packages/tfcode/src/cli/cmd/tools.ts b/packages/tfcode/src/cli/cmd/tools.ts index e44c3572a..54d83a3f4 100644 --- a/packages/tfcode/src/cli/cmd/tools.ts +++ b/packages/tfcode/src/cli/cmd/tools.ts @@ -64,20 +64,19 @@ const TFCODE_CONFIG_DIR = ".tfcode" const TFCODE_TOOLS_FILE = "tools.json" function getPythonSyncPath(): string { - // Check embedded python path first (for npm distribution) - const embedded = [ - path.join(__dirname, "..", "..", "..", "..", "python"), // packages/tfcode/python - path.join(__dirname, "..", "..", "..", "python"), // dist/python - ] - for (const p of embedded) { - if (existsSync(p)) return p - } - // Fallback to development paths - const dev = [ + const binDir = path.dirname(process.execPath) + const candidates = [ + // npm install: binary is at /bin/tfcode, python at /python + path.join(binDir, "..", "python"), + path.join(binDir, "python"), + // Embedded paths relative to compiled source + path.join(__dirname, "..", "..", "..", "..", "python"), + path.join(__dirname, "..", "..", "..", "python"), + // Development paths path.join(__dirname, "..", "..", "..", "..", "tf-sync", "src", "tf_sync"), path.join(process.cwd(), "packages", "tf-sync", "src", "tf_sync"), ] - for (const p of dev) { + for (const p of candidates) { if (existsSync(p)) return p } return "tf_sync"