import assert from "node:assert/strict";
import test from "node:test";
import { __testables } from "../src/core.mjs";
const { _parseAnswer } = __testables;
test("parseAnswer keeps in-project files on Windows paths", () => {
if (process.platform !== "win32") {
return;
}
const projectRoot = "D:\\MCP\\fast-context-mcp";
const xml =
'<ANSWER><file path="/codebase/src/server.mjs"><range>1-10</range></file></ANSWER>';
const result = _parseAnswer(xml, projectRoot);
assert.equal(result.files.length, 1);
assert.equal(result.files[0].path, "src/server.mjs");
});
test("parseAnswer rejects traversal paths", () => {
const projectRoot = process.cwd();
const xml =
'<ANSWER><file path="/codebase/../outside.js"><range>1-2</range></file></ANSWER>';
const result = _parseAnswer(xml, projectRoot);
assert.equal(result.files.length, 0);
});