mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
fix(annotate): resolve file paths correctly on Windows (#233)
* 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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> --------- Co-authored-by: Julien Fernandez <theflysurfer@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Michael Ramos <mdramos8@gmail.com>
This commit is contained in:
@@ -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 <file.md>");
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user