MCPcopy Index your code
hub / github.com/garrytan/gstack / buildTranscriptPage

Function buildTranscriptPage

bin/gstack-memory-ingest.ts:703–754  ·  view source on GitHub ↗
(path: string, session: ParsedSession)

Source from the content-addressed store, hash-verified

701}
702
703function buildTranscriptPage(path: string, session: ParsedSession): PageRecord {
704 const remote = resolveGitRemote(session.cwd);
705 const slug_repo = repoSlug(remote);
706 const date = dateOnly(session.start_time);
707 const sessionPrefix = session.session_id.slice(0, 12);
708 const slug = `transcripts/${session.agent}/${slug_repo}/${date}-${sessionPrefix}`;
709 const title = `${session.agent} session — ${slug_repo} — ${date}`;
710 const tags = [
711 "transcript",
712 `agent:${session.agent}`,
713 `repo:${slug_repo}`,
714 `date:${date}`,
715 ];
716 if (session.partial) tags.push("partial:true");
717
718 const stats = statSync(path);
719 const sha = fileSha256(path);
720
721 const frontmatter = [
722 "---",
723 `agent: ${session.agent}`,
724 `session_id: ${session.session_id}`,
725 `cwd: ${session.cwd || ""}`,
726 `git_remote: ${remote || "_unattributed"}`,
727 `start_time: ${session.start_time || ""}`,
728 `end_time: ${session.end_time || ""}`,
729 `message_count: ${session.message_count}`,
730 `tool_calls: ${session.tool_calls}`,
731 `source_path: ${path}`,
732 session.partial ? "partial: true" : "",
733 "---",
734 "",
735 ].filter((l) => l !== "").join("\n");
736
737 return {
738 slug,
739 title,
740 type: "transcript",
741 agent: session.agent,
742 body: frontmatter + session.body,
743 tags,
744 source_path: path,
745 session_id: session.session_id,
746 cwd: session.cwd,
747 git_remote: remote,
748 start_time: session.start_time,
749 end_time: session.end_time,
750 partial: session.partial,
751 size_bytes: stats.size,
752 content_sha256: sha,
753 };
754}
755
756function buildArtifactPage(path: string, type: MemoryType): PageRecord {
757 const stats = statSync(path);

Callers 1

preparePagesFunction · 0.85

Calls 5

resolveGitRemoteFunction · 0.85
repoSlugFunction · 0.85
dateOnlyFunction · 0.85
fileSha256Function · 0.85
pushMethod · 0.45

Tested by

no test coverage detected