MCPcopy Create free account
hub / github.com/modem-dev/hunk / makeSnapshot

Function makeSnapshot

scripts/daemon-memory-check.ts:298–340  ·  view source on GitHub ↗
(sessionId: string, updateIndex = 0, options: CliOptions = defaultOptions)

Source from the content-addressed store, hash-verified

296}
297
298function makeSnapshot(sessionId: string, updateIndex = 0, options: CliOptions = defaultOptions) {
299 const fileIndex = updateIndex % Math.max(1, options.filesPerSession);
300 const hunkIndex = updateIndex % Math.max(1, options.hunksPerFile);
301 const filePath = `src/${sessionId}/file-${fileIndex}.ts`;
302 const liveComments = Array.from({ length: 3 }, (_, commentIndex) => ({
303 commentId: `${sessionId}-comment-${updateIndex}-${commentIndex}`,
304 filePath,
305 hunkIndex,
306 side: "new",
307 line: hunkIndex * (options.linesPerHunk + 3) + commentIndex + 1,
308 summary: `Memory harness comment ${updateIndex}.${commentIndex}`,
309 rationale: `Snapshot churn rationale ${sessionId} ${updateIndex} ${commentIndex}`,
310 author: "daemon-memory-check",
311 createdAt: new Date().toISOString(),
312 }));
313
314 return {
315 updatedAt: new Date().toISOString(),
316 state: {
317 selectedFileId: `${sessionId}-file-${fileIndex}`,
318 selectedFilePath: filePath,
319 selectedHunkIndex: hunkIndex,
320 selectedHunkOldRange: [hunkIndex * (options.linesPerHunk + 3) + 1, options.linesPerHunk],
321 selectedHunkNewRange: [hunkIndex * (options.linesPerHunk + 3) + 1, options.linesPerHunk],
322 showAgentNotes: updateIndex % 2 === 0,
323 liveCommentCount: liveComments.length,
324 liveComments,
325 reviewNoteCount: liveComments.length,
326 reviewNotes: liveComments.map((comment) => ({
327 noteId: `note-${comment.commentId}`,
328 source: "user",
329 filePath: comment.filePath,
330 hunkIndex: comment.hunkIndex,
331 newRange: [comment.line, 1],
332 body: comment.rationale,
333 title: comment.summary,
334 author: comment.author,
335 createdAt: comment.createdAt,
336 editable: true,
337 })),
338 },
339 };
340}
341
342async function openRegisteredSocket(
343 port: number,

Callers 2

openRegisteredSocketFunction · 0.85
sendSnapshotUpdatesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected