scai
Version:
> **AI-powered CLI for local code analysis, commit message suggestions, and natural-language queries.** 100% local, private, GDPR-friendly, made in Denmark/EU with ❤️.
25 lines (24 loc) • 872 B
JavaScript
// 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,
};
},
};