Skip to content

Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.

10.7 KB
Raw Blame
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([["8713"],{2361(e,n,t){t.r(n),t.d(n,{metadata:()=>i,default:()=>h,frontMatter:()=>o,contentTitle:()=>a,toc:()=>l,assets:()=>c});var i=JSON.parse('{"id":"integrations/github-companion","title":"GitHub Companion","description":"Mercury can act as your GitHub companion \u2014 creating pull requests, reviewing PRs, managing issues, and making co-authored commits \u2014 all through natural conversation. When configured, five GitHub tools are registered alongside Mercury\'s built-in toolset, letting you manage repositories without leaving the terminal or Telegram.","source":"@site/docs/integrations/github-companion.mdx","sourceDirName":"integrations","slug":"/integrations/github-companion","permalink":"/docs/integrations/github-companion","draft":false,"unlisted":false,"editUrl":"https://github.com/cosmicstack-labs/mercury-agent/tree/main/website/docs/integrations/github-companion.mdx","tags":[],"version":"current","frontMatter":{"id":"github-companion","title":"GitHub Companion"},"sidebar":"docsSidebar","previous":{"title":"Kanban Boards","permalink":"/docs/integrations/kanban-boards"},"next":{"title":"Telegram","permalink":"/docs/integrations/telegram"}}'),s=t(74848),r=t(28453);let o={id:"github-companion",title:"GitHub Companion"},a,c={},l=[{value:"Why set up GitHub?",id:"why-set-up-github",level:2},{value:"Setup",id:"setup",level:2},{value:"1. GitHub username",id:"1-github-username",level:3},{value:"2. Co-authored-by (automatic)",id:"2-co-authored-by-automatic",level:3},{value:"3. GitHub PAT (Personal Access Token)",id:"3-github-pat-personal-access-token",level:3},{value:"4. Default repo (optional)",id:"4-default-repo-optional",level:3},{value:"GitHub Tools",id:"github-tools",level:2},{value:"Co-Authored Commits",id:"co-authored-commits",level:2},{value:"Security",id:"security",level:2}];function d(e){let n={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",li:"li",ol:"ol",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",ul:"ul",...(0,r.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(n.p,{children:"Mercury can act as your GitHub companion \u2014 creating pull requests, reviewing PRs, managing issues, and making co-authored commits \u2014 all through natural conversation. When configured, five GitHub tools are registered alongside Mercury's built-in toolset, letting you manage repositories without leaving the terminal or Telegram."}),"\n",(0,s.jsx)(n.admonition,{title:"Conditional availability",type:"info",children:(0,s.jsxs)(n.p,{children:["GitHub tools ",(0,s.jsxs)(n.strong,{children:["only appear when ",(0,s.jsx)(n.code,{children:"GITHUB_TOKEN"})," is configured"]})," via ",(0,s.jsx)(n.code,{children:"mercury doctor"}),". Without a token, these tools are not registered and won't be available in conversation."]})}),"\n",(0,s.jsx)(n.h2,{id:"why-set-up-github",children:"Why set up GitHub?"}),"\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Co-authored commits"})," \u2014 Mercury's avatar appears alongside yours on every commit it helps with"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Pull requests"}),' \u2014 "Create a PR for this change" and Mercury stages, commits, pushes, and opens the PR']}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Issue management"}),' \u2014 "Check open issues" or "File a bug for the login crash"']}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Code review"}),' \u2014 "Review PR #5" and Mercury reads the diff and posts a summary']}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Full API access"})," \u2014 The ",(0,s.jsx)(n.code,{children:"github_api"})," tool lets Mercury hit any GitHub endpoint"]}),"\n"]}),"\n",(0,s.jsx)(n.h2,{id:"setup",children:"Setup"}),"\n",(0,s.jsxs)(n.p,{children:["Run ",(0,s.jsx)(n.code,{children:"mercury doctor"})," and fill in the four GitHub fields:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{className:"language-bash",children:"mercury doctor\n"})}),"\n",(0,s.jsx)(n.h3,{id:"1-github-username",children:"1. GitHub username"}),"\n",(0,s.jsx)(n.p,{children:"Your GitHub username. This is used for commit attribution and identifying you in API calls."}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"Example: hotheadhacker\n"})}),"\n",(0,s.jsx)(n.h3,{id:"2-co-authored-by-automatic",children:"2. Co-authored-by (automatic)"}),"\n",(0,s.jsxs)(n.p,{children:["Every Mercury-assisted commit automatically includes a ",(0,s.jsx)(n.code,{children:"Co-authored-by: Mercury <[email protected]>"})," trailer. No configuration needed \u2014 this is the default. Mercury's avatar will appear alongside yours on GitHub."]}),"\n",(0,s.jsxs)(n.p,{children:["You can customize the email in ",(0,s.jsx)(n.code,{children:"~/.mercury/.env"})," by setting ",(0,s.jsx)(n.code,{children:"GITHUB_EMAIL"})," if you prefer a different co-author address."]}),"\n",(0,s.jsx)(n.h3,{id:"3-github-pat-personal-access-token",children:"3. GitHub PAT (Personal Access Token)"}),"\n",(0,s.jsxs)(n.p,{children:["You need a token so Mercury can authenticate with the GitHub API. ",(0,s.jsx)(n.strong,{children:"Never share this token."})," It's stored locally in ",(0,s.jsx)(n.code,{children:"~/.mercury/.env"})," and never sent anywhere except GitHub's API."]}),"\n",(0,s.jsxs)(n.admonition,{title:"Where to create your token",type:"warning",children:[(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Fine-grained PAT (recommended):"})}),(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["Go to ",(0,s.jsx)(n.a,{href:"https://github.com/settings/personal-access-tokens/new",children:"github.com/settings/personal-access-tokens/new"})]}),"\n",(0,s.jsxs)(n.li,{children:["Give it a name (e.g. ",(0,s.jsx)(n.code,{children:"mercury-agent"}),") and set an expiration"]}),"\n",(0,s.jsxs)(n.li,{children:["Under ",(0,s.jsx)(n.strong,{children:"Repository access"}),", select ",(0,s.jsx)(n.strong,{children:"All repositories"})," or choose specific repos"]}),"\n",(0,s.jsxs)(n.li,{children:["Under ",(0,s.jsx)(n.strong,{children:"Permissions \u2192 Repository permissions"}),", grant:","\n",(0,s.jsxs)(n.ul,{children:["\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Contents"})," \u2014 Read and write"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Pull requests"})," \u2014 Read and write"]}),"\n",(0,s.jsxs)(n.li,{children:[(0,s.jsx)(n.strong,{children:"Issues"})," \u2014 Read and write"]}),"\n"]}),"\n"]}),"\n",(0,s.jsxs)(n.li,{children:["Click ",(0,s.jsx)(n.strong,{children:"Generate token"})," and copy it immediately"]}),"\n"]}),(0,s.jsx)(n.p,{children:(0,s.jsx)(n.strong,{children:"Classic PAT:"})}),(0,s.jsxs)(n.ol,{children:["\n",(0,s.jsxs)(n.li,{children:["Go to ",(0,s.jsx)(n.a,{href:"https://github.com/settings/tokens/new",children:"github.com/settings/tokens/new"})]}),"\n",(0,s.jsxs)(n.li,{children:["Give it a name (e.g. ",(0,s.jsx)(n.code,{children:"mercury-agent"}),") and set an expiration"]}),"\n",(0,s.jsxs)(n.li,{children:["Select the ",(0,s.jsx)(n.strong,{children:"repo"})," scope (full control of private repositories)"]}),"\n",(0,s.jsxs)(n.li,{children:["Click ",(0,s.jsx)(n.strong,{children:"Generate token"})," and copy it immediately"]}),"\n"]})]}),"\n",(0,s.jsx)(n.h3,{id:"4-default-repo-optional",children:"4. Default repo (optional)"}),"\n",(0,s.jsxs)(n.p,{children:["Set a default repository so you can say ",(0,s.jsx)(n.code,{children:'"create an issue"'})," without specifying the repo every time. You can enter it in any of these formats:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"hotheadhacker/mercury-agent\nhttps://github.com/hotheadhacker/mercury-agent\n"})}),"\n",(0,s.jsx)(n.p,{children:"Mercury will parse the owner and repo name automatically from either format."}),"\n",(0,s.jsxs)(n.p,{children:["Press ",(0,s.jsx)(n.strong,{children:"Enter"})," on any field to keep its current value. When the PAT is set, you'll see:"]}),"\n",(0,s.jsx)(n.pre,{children:(0,s.jsx)(n.code,{children:"\u2713 GitHub tools registered (5)\n"})}),"\n",(0,s.jsx)(n.h2,{id:"github-tools",children:"GitHub Tools"}),"\n",(0,s.jsxs)(n.table,{children:[(0,s.jsx)(n.thead,{children:(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.th,{children:"Tool"}),(0,s.jsx)(n.th,{children:"What it does"})]})}),(0,s.jsxs)(n.tbody,{children:[(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"create_pr"})}),(0,s.jsx)(n.td,{children:"Create a pull request with title, body, head branch, and base branch"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"review_pr"})}),(0,s.jsx)(n.td,{children:"Fetch a PR diff, review the changes, and post review comments"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"list_issues"})}),(0,s.jsx)(n.td,{children:"List and filter issues in a repository (open, closed, by label, by assignee)"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"create_issue"})}),(0,s.jsx)(n.td,{children:"Create a new issue with title, body, labels, and assignees"})]}),(0,s.jsxs)(n.tr,{children:[(0,s.jsx)(n.td,{children:(0,s.jsx)(n.code,{children:"github_api"})}),(0,s.jsx)(n.td,{children:"Raw GitHub API access \u2014 an escape hatch for any endpoint not covered above"})]})]})]}),"\n",(0,s.jsx)(n.h2,{id:"co-authored-commits",children:"Co-Authored Commits"}),"\n",(0,s.jsxs)(n.p,{children:["When Mercury commits code using ",(0,s.jsx)(n.code,{children:"git_commit"}),", it automatically appends a ",(0,s.jsx)(n.code,{children:"Co-authored-by: Mercury <[email protected]>"})," trailer. This means Mercury's avatar appears alongside yours in GitHub's commit history \u2014 giving credit where it's due."]}),"\n",(0,s.jsx)(n.h2,{id:"security",children:"Security"}),"\n",(0,s.jsx)(n.admonition,{title:"PAT storage",type:"warning",children:(0,s.jsxs)(n.p,{children:["Your GitHub PAT is stored in ",(0,s.jsx)(n.code,{children:"~/.mercury/mercury.yaml"})," alongside your other configuration. It is never sent to any external service \u2014 only to the GitHub API directly from your machine. Treat this file like any other credential: don't commit it, don't share it, and rotate the token if you suspect it's compromised."]})})]})}function h(e={}){let{wrapper:n}={...(0,r.R)(),...e.components};return n?(0,s.jsx)(n,{...e,children:(0,s.jsx)(d,{...e})}):d(e)}},28453(e,n,t){t.d(n,{R:()=>o,x:()=>a});var i=t(96540);let s={},r=i.createContext(s);function o(e){let n=i.useContext(r);return i.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function a(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(s):e.components||s:o(e.components),i.createElement(r.Provider,{value:n},e.children)}}}]);