Normalize plan file ids across platforms

This commit is contained in:
Mohamed Boudra
2026-05-28 22:36:12 +07:00
parent bcd1f28f9a
commit 71ce3b434e

View File

@@ -3,18 +3,15 @@ import fs from "node:fs/promises";
import type { AgentTimelineItem, ToolCallTimelineItem } from "./agent-sdk-types.js";
const PLAN_FILE_EXTENSIONS = new Set([".md", ".markdown"]);
const PLAN_DIRECTORIES = new Set([
`${path.sep}.paseo${path.sep}plans${path.sep}`,
`${path.sep}.opencode${path.sep}plans${path.sep}`,
]);
const PLAN_DIRECTORIES = new Set(["/.paseo/plans/", "/.opencode/plans/"]);
export function isPlanFilePath(filePath: string): boolean {
const normalized = path.normalize(filePath);
const ext = path.extname(normalized).toLowerCase();
const normalized = normalizePlanPath(filePath);
const ext = path.posix.extname(normalized).toLowerCase();
if (!PLAN_FILE_EXTENSIONS.has(ext)) {
return false;
}
const searchable = normalized.startsWith(path.sep) ? normalized : `${path.sep}${normalized}`;
const searchable = normalized.startsWith("/") ? normalized : `/${normalized}`;
return Array.from(PLAN_DIRECTORIES).some((dir) => searchable.includes(dir));
}
@@ -43,11 +40,15 @@ export async function planItemFromToolCall(params: {
return {
type: "plan",
planId: `plan-file:${path.normalize(detail.filePath)}`,
planId: `plan-file:${normalizePlanPath(detail.filePath)}`,
text: text.trim(),
};
}
function normalizePlanPath(filePath: string): string {
return path.posix.normalize(filePath.replace(/\\/g, "/"));
}
async function readPlanFile(
filePath: string,
cwd: string,