From c762bbe31edf17152ac501aa41ec05856f2e9845 Mon Sep 17 00:00:00 2001 From: theflysurfer Date: Sat, 7 Mar 2026 16:58:17 +0100 Subject: [PATCH] fix(annotate): resolve file paths correctly on Windows (#233) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(annotate): resolve file paths correctly on Windows - Use PLANNOTATOR_CWD env var to get original working directory - Strip @ prefix from file paths (Claude Code reference syntax) - Add debug logging (PLANNOTATOR_DEBUG=1) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude * fix: add missing path import for annotate subcommand The dynamic `import("path")` was removed but `path.isAbsolute()` and `path.join()` are still used, causing a ReferenceError at runtime. Co-Authored-By: Claude Opus 4.6 --------- Co-authored-by: Julien Fernandez Co-authored-by: Claude Co-authored-by: Michael Ramos --- apps/hook/server/index.ts | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/apps/hook/server/index.ts b/apps/hook/server/index.ts index a046f924..3893e693 100644 --- a/apps/hook/server/index.ts +++ b/apps/hook/server/index.ts @@ -37,6 +37,7 @@ import { } from "@plannotator/server/annotate"; import { getGitContext, runGitDiff } from "@plannotator/server/git"; import { writeRemoteShareLink } from "@plannotator/server/share-url"; +import path from "path"; // Embed the built HTML at compile time // @ts-ignore - Bun import attribute for text @@ -111,15 +112,33 @@ if (args[0] === "review") { // ANNOTATE MODE // ============================================ - const filePath = args[1]; + let filePath = args[1]; if (!filePath) { console.error("Usage: plannotator annotate "); process.exit(1); } - // Resolve to absolute path - const path = await import("path"); - const absolutePath = path.resolve(filePath); + // Strip @ prefix if present (Claude Code file reference syntax) + if (filePath.startsWith("@")) { + filePath = filePath.slice(1); + } + + // Resolve path - use PLANNOTATOR_CWD if set (original working directory before script cd'd) + const originalCwd = process.env.PLANNOTATOR_CWD || process.cwd(); + + // Debug: log path resolution (visible in stderr, won't interfere with stdout JSON) + if (process.env.PLANNOTATOR_DEBUG) { + console.error(`[DEBUG] Original CWD: ${originalCwd}`); + console.error(`[DEBUG] File path arg: ${filePath}`); + } + + const absolutePath = path.isAbsolute(filePath) + ? filePath + : path.join(originalCwd, filePath); + + if (process.env.PLANNOTATOR_DEBUG) { + console.error(`[DEBUG] Resolved path: ${absolutePath}`); + } // Read the markdown file const file = Bun.file(absolutePath);