MCPcopy Index your code
hub / github.com/RedPlanetHQ/core / readFirstLine

Function readFirstLine

packages/cli/src/utils/coding-agents/codex.ts:32–49  ·  view source on GitHub ↗

* Read the first JSONL line from a file and parse it.

(filePath: string)

Source from the content-addressed store, hash-verified

30 * Read the first JSONL line from a file and parse it.
31 */
32async function readFirstLine(filePath: string): Promise<Record<string, unknown> | null> {
33 return new Promise((resolve) => {
34 const rl = createInterface({input: createReadStream(filePath), crlfDelay: Infinity});
35 let done = false;
36 rl.on('line', (line) => {
37 if (done || !line.trim()) return;
38 done = true;
39 rl.close();
40 try {
41 resolve(JSON.parse(line));
42 } catch {
43 resolve(null);
44 }
45 });
46 rl.on('close', () => { if (!done) resolve(null); });
47 rl.on('error', () => resolve(null));
48 });
49}
50
51/**
52 * Walk ~/.codex/sessions/YYYY/MM/DD/ and yield rollout JSONL files (newest first).

Callers 2

scanFunction · 0.85
scanSessionsMethod · 0.85

Calls 5

onMethod · 0.80
trimMethod · 0.80
closeMethod · 0.65
resolveFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected