UNPKG

scai

Version:

> **A local-first AI CLI for understanding, querying, and iterating on large codebases.** > **100% local • No token costs • No cloud • No prompt injection • Private by design**

25 lines (24 loc) 872 B
// src/pipeline/modules/chunkManagerModule.ts import fs from 'fs'; import { normalizePath } from '../../utils/contentUtils.js'; import { splitCodeIntoChunks } from '../../utils/splitCodeIntoChunk.js'; export const chunkManagerModule = { name: "chunkManager", description: "Splits large files into manageable chunks for processing.", async run(input) { const filepath = normalizePath(input.filepath ?? ""); const fileContent = fs.readFileSync(filepath, "utf-8"); const maxTokens = 1500; const baseChunks = splitCodeIntoChunks(fileContent, maxTokens); return { content: fileContent, data: { baseChunks, workingChunks: [...baseChunks], chunkCount: baseChunks.length, filepath, }, filepath, }; }, };