diff --git a/docs/bridge.md b/docs/bridge.md index c4caa3e..a09b94d 100644 --- a/docs/bridge.md +++ b/docs/bridge.md @@ -56,6 +56,18 @@ The command: Use `--dry-run` to print the planned action without writing or posting. +### GitHub PR Comment + +```powershell +node .\tools\bifrost-bridge.mjs github-pr-comment ` + --repo-root E:\Projects\AetheriaLore ` + --identity nibu ` + --pr 12 ` + --content "This proposal needs a sharper leash before it becomes canon-shaped." +``` + +The command leaves a signed PR comment through `gh` and prints a JSON receipt. Repo Faces should use this when the argument belongs on the review artifact instead of dissolving into Discord scrollback. + ### Discord Post ```powershell diff --git a/tools/bifrost-bridge.mjs b/tools/bifrost-bridge.mjs index f4c82e2..0aa258f 100644 --- a/tools/bifrost-bridge.mjs +++ b/tools/bifrost-bridge.mjs @@ -21,6 +21,9 @@ async function main() { case "github-draft-pr": await createGitHubDraftPr(options); return; + case "github-pr-comment": + await commentGitHubPr(options); + return; case "discord-post": await postDiscordMessage(options); return; @@ -115,6 +118,36 @@ async function createGitHubDraftPr(options) { }); } +async function commentGitHubPr(options) { + const repoRoot = resolve(requireOption(options, "repo-root")); + const identity = slugify(requireOption(options, "identity")); + const pr = requireOption(options, "pr"); + const content = await readOptionText(options, "content", "content-file"); + const dryRun = options["dry-run"] === "true"; + const body = `${identity} says:\n\n${content.trim()}`; + + if (dryRun) { + printJson({ + dryRun: true, + action: "github-pr-comment", + repoRoot, + identity, + pr, + body, + }); + return; + } + + run("gh", ["pr", "comment", pr, "--body", body], repoRoot); + printJson({ + action: "github-pr-comment", + ok: true, + repoRoot, + identity, + pr, + }); +} + async function postDiscordMessage(options) { const token = process.env.BIFROST_DISCORD_BOT_TOKEN ?? process.env.DISCORD_BOT_TOKEN; const channelId = requireOption(options, "channel-id"); @@ -536,10 +569,12 @@ function printHelp() { Commands: github-draft-pr Write one file in a target repo and open a draft PR through gh + github-pr-comment Comment on a pull request through gh discord-post Post a message to Discord through the bot token or persona webhook pipe Examples: node tools/bifrost-bridge.mjs github-draft-pr --repo-root E:/Projects/AetheriaLore --identity nibu --title "Nibu: Glitchcraft" --path Aetheria/Articles/Nibu/glitchcraft.md --content-file article.md + node tools/bifrost-bridge.mjs github-pr-comment --repo-root E:/Projects/AetheriaLore --identity nibu --pr 12 --content "This needs a sharper leash." node tools/bifrost-bridge.mjs discord-post --channel-id 1501196543150264332 --persona-name Nibu --content "Draft PR opened: https://github.com/..." `); }