spaider
Version:
Deterministic-first AI code assistant that crawls your codebase to implement changes using open source LLMs
30 lines • 1.19 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.readFiles = void 0;
const utils_1 = require("../lib/utils");
const logger_1 = require("../services/logger");
const readFiles = async (ctx) => {
const results = await Promise.allSettled(ctx.files.map(async (file) => {
if (file.content)
return file;
// Resolve file path relative to project root
const resolvedPath = (0, utils_1.resolveFilePath)(file.path, ctx.projectRoot);
// Check if file exists first
if (!(await (0, utils_1.fileExists)(resolvedPath))) {
logger_1.Logger.warn(`File not found, skipping: ${file.path}`);
return null;
}
return {
...file,
path: resolvedPath, // Update path to resolved path
content: await (0, utils_1.readFile)(resolvedPath),
language: (0, utils_1.detectLanguage)(resolvedPath),
};
}));
ctx.files = results
.map((result) => (result.status === "fulfilled" ? result.value : null))
.filter((file) => file !== null);
return ctx;
};
exports.readFiles = readFiles;
//# sourceMappingURL=read.js.map