MCPcopy Create free account
hub / github.com/Railly/agentfiles / parseFileSync

Function parseFileSync

src/conversations/parser.ts:149–183  ·  view source on GitHub ↗
(meta: ConversationMeta)

Source from the content-addressed store, hash-verified

147}
148
149function parseFileSync(meta: ConversationMeta): ConversationItem | null {
150 try {
151 const raw = readFileSync(meta.filePath, "utf-8");
152 const allLines = raw.split("\n").filter((l) => l.trim());
153 if (allLines.length === 0) return null;
154
155 const lines = allLines.length > MAX_LINES_PER_FILE
156 ? allLines.slice(0, MAX_LINES_PER_FILE)
157 : allLines;
158
159 const { messages, firstTimestamp, lastTimestamp } = extractMessages(lines);
160 if (messages.length === 0) return null;
161
162 const firstHuman = messages.find((m) => m.role === "human");
163 const title = firstHuman
164 ? firstHuman.text.slice(0, 120).replace(/\n/g, " ")
165 : "(empty conversation)";
166
167 return {
168 id: meta.uuid,
169 uuid: meta.uuid,
170 project: meta.project,
171 projectPath: meta.projectPath,
172 title,
173 messages,
174 messageCount: messages.length,
175 firstTimestamp,
176 lastTimestamp,
177 tags: [],
178 customTags: [],
179 isFavorite: false,
180 filePath: meta.filePath,
181 };
182 } catch { return null; }
183}
184
185async function parseFileAsync(meta: ConversationMeta): Promise<ConversationItem | null> {
186 return new Promise((resolve) => {

Callers 2

Calls 3

extractMessagesFunction · 0.85
sliceMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected