MCPcopy Create free account
hub / github.com/IAmUnbounded/devctx / readLastLines

Function readLastLines

devctx/src/core/parser.ts:471–488  ·  view source on GitHub ↗
(
    filePath: string,
    maxLines: number
)

Source from the content-addressed store, hash-verified

469// -------------------------------------------------------------------
470
471async function readLastLines(
472 filePath: string,
473 maxLines: number
474): Promise<string[]> {
475 const lines: string[] = [];
476 const fileStream = fs.createReadStream(filePath, { encoding: "utf-8" });
477 const rl = readline.createInterface({ input: fileStream, crlfDelay: Infinity });
478
479 const buffer: string[] = [];
480 for await (const line of rl) {
481 buffer.push(line);
482 if (buffer.length > maxLines * 2) {
483 buffer.splice(0, maxLines); // keep a sliding window
484 }
485 }
486
487 return buffer.slice(-maxLines);
488}
489
490function extractTaskFromMessages(messages: string[]): string {
491 // First user message is usually the task

Callers 1

parseClaudeSessionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected