UNPKG

spaider

Version:

Deterministic-first AI code assistant that crawls your codebase to implement changes using open source LLMs

30 lines 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.discoverFiles = void 0; const discovery_1 = require("../services/discovery"); const logger_1 = require("../services/logger"); const discoverFiles = async (ctx) => { if (!ctx.intent) { throw new Error("Intent analysis must be completed before discovering files"); } let discoveredPaths = []; // Discover from explicit paths if (ctx.intent.filePaths.length > 0) { logger_1.Logger.debug(`Discovering files based on paths \n${ctx.intent.filePaths.join("\n")}`); const paths = await discovery_1.Discovery.discoverFromPaths(ctx.intent.filePaths, ctx.files.map((f) => f.path), ctx.projectRoot); discoveredPaths.push(...paths); } const searchTerms = [...ctx.intent.searchTerms, ctx.intent.description]; if (searchTerms.length > 0) { logger_1.Logger.debug(`Discovering files based on hints \n${searchTerms.join("\n")}`); const paths = await discovery_1.Discovery.discoverFromSearchTerms(searchTerms, ctx.files.map((f) => f.path), ctx.projectRoot); discoveredPaths.push(...paths); } // Remove duplicates and paths that already exist in ctx.files discoveredPaths = [...new Set(discoveredPaths)].filter((path) => !ctx.files.some((file) => file.path === path)); ctx.files = [...ctx.files, ...discoveredPaths.map((path) => ({ path }))]; console.log(`✓ Discovered new files \n${discoveredPaths.join("\n")}`); return ctx; }; exports.discoverFiles = discoverFiles; //# sourceMappingURL=discovery.js.map