Skip to content

Commit ea0c2d2

Browse files
authored
Merge pull request #194 from ProverCoderAI/issue-192
chore: trim session backup outputs
2 parents fd6fb9c + 9d46902 commit ea0c2d2

File tree

1 file changed

+17
-25
lines changed

1 file changed

+17
-25
lines changed

scripts/session-backup-gist.js

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -423,21 +423,12 @@ const buildSnapshotReadme = ({ backupRepo, source, manifestUrl, summary, session
423423
"",
424424
].join("\n");
425425

426-
const buildCommentBody = ({ backupRepo, source, manifestUrl, readmeUrl, summary }) => {
426+
const buildCommentBody = ({ source, manifestUrl, readmeUrl, summary }) => {
427427
const lines = [
428428
"## AI Session Backup",
429-
"",
430-
"A snapshot of the AI session context used during development has been saved.",
431-
"",
432-
`Backup Repo: ${backupRepo.fullName}`,
433-
`Source Commit: ${source.commitSha}`,
434-
`Created At: ${source.createdAt}`,
429+
`Commit: ${source.commitSha}`,
435430
`Files: ${summary.fileCount} (${formatBytes(summary.totalBytes)})`,
436-
"",
437-
`README: ${readmeUrl}`,
438-
`Manifest: ${manifestUrl}`,
439-
"",
440-
"This snapshot metadata was used during development.",
431+
`Links: [README](${readmeUrl}) | [Manifest](${manifestUrl})`,
441432
];
442433

443434
lines.push(`<!-- docker-git-session-backup:${source.commitSha}:${source.createdAt} -->`);
@@ -504,7 +495,7 @@ const main = () => {
504495
if (prIsOpen(sourceRepo, args.prNumber, ghEnv)) {
505496
prContext = { repo: sourceRepo, prNumber: args.prNumber };
506497
} else {
507-
console.log(`[session-backup] Skipping PR comment: PR #${args.prNumber} is not open`);
498+
log(verbose, `Skipping PR comment: PR #${args.prNumber} is not open`);
508499
}
509500
} else if (args.postComment) {
510501
prContext = findPrContext(repoCandidates, branch, verbose, ghEnv);
@@ -595,13 +586,15 @@ const main = () => {
595586
},
596587
];
597588
if (args.dryRun) {
598-
console.log(`[dry-run] Would upload snapshot to ${backupRepo.fullName}:${snapshotRef}`);
599-
console.log(`[dry-run] Would write ${uploadEntries.length + 1} file(s) including README and manifest.`);
600-
console.log(`[dry-run] README URL: ${readmeUrl}`);
601-
console.log(`[dry-run] Manifest URL: ${manifestUrl}`);
589+
console.log(
590+
`[session-backup] dry-run: ${source.commitSha.slice(0, 12)} (${summary.fileCount} files, ${formatBytes(summary.totalBytes)})`
591+
);
592+
log(verbose, `[dry-run] Upload target: ${backupRepo.fullName}:${snapshotRef}`);
593+
log(verbose, `[dry-run] README URL: ${readmeUrl}`);
594+
log(verbose, `[dry-run] Manifest URL: ${manifestUrl}`);
602595
if (args.postComment && prContext !== null) {
603-
console.log(`[dry-run] Would post comment to PR #${prContext.prNumber} in ${prContext.repo}:`);
604-
console.log(buildCommentBody({ backupRepo, source, manifestUrl, readmeUrl, summary }));
596+
log(verbose, `Would post comment to PR #${prContext.prNumber} in ${prContext.repo}:`);
597+
log(verbose, buildCommentBody({ source, manifestUrl, readmeUrl, summary }));
605598
}
606599
return;
607600
}
@@ -615,22 +608,21 @@ const main = () => {
615608
ghEnv
616609
);
617610

618-
console.log(`[session-backup] Uploaded snapshot to ${backupRepo.fullName}`);
619-
console.log(`[session-backup] README: ${readmeUrl}`);
620-
console.log(`[session-backup] Manifest: ${uploadResult.manifestUrl}`);
611+
console.log(
612+
`[session-backup] ok: ${source.commitSha.slice(0, 12)} (${summary.fileCount} files, ${formatBytes(summary.totalBytes)})`
613+
);
614+
log(verbose, `[session-backup] Uploaded snapshot to ${backupRepo.fullName}:${snapshotRef}`);
615+
log(verbose, `[session-backup] Manifest: ${uploadResult.manifestUrl}`);
621616

622617
if (args.postComment && prContext !== null) {
623618
const comment = buildCommentBody({
624-
backupRepo,
625619
source,
626620
manifestUrl: uploadResult.manifestUrl,
627621
readmeUrl,
628622
summary,
629623
});
630624
postPrComment(prContext.repo, prContext.prNumber, comment, verbose, ghEnv);
631625
}
632-
633-
console.log("[session-backup] Session backup complete");
634626
} finally {
635627
fs.rmSync(tmpDir, { recursive: true, force: true });
636628
}

0 commit comments

Comments
 (0)