| 6073 | Need help? Common issues: |
| 6074 | `+`· Permission denied → Run: gh auth refresh -h github.com -s repo,workflow |
| 6075 | `+`· Not authorized → Ensure you have admin access to the repository |
| 6076 | `+"· For manual setup → Visit: https://github.com/anthropics/claude-code-action";throw Error(`Failed to create workflow file ${_}: ${M.stderr}${X}`)}}async function ONK(q,K,_,z,Y=!1,$,A,O){try{d("tengu_setup_github_actions_started",{skip_workflow:Y,has_api_key:!!K,using_default_secret_name:_==="ANTHROPIC_API_KEY",selected_claude_workflow:$.includes("claude"),selected_claude_review_workflow:$.includes("claude-review"),...O});let w=await a8("gh",["api",`repos/${q}`,"--jq",".id"]);if(w.code!==0)throw d("tengu_setup_github_actions_failed",{reason:"repo_not_found",exit_code:w.code,...O}),Error(`Failed to access repository ${q}: ${w.stderr}`);let j=await a8("gh",["api",`repos/${q}`,"--jq",".default_branch"]);if(j.code!==0)throw d("tengu_setup_github_actions_failed",{reason:"failed_to_get_default_branch",exit_code:j.code,...O}),Error(`Failed to get default branch: ${j.stderr}`);let H=j.stdout.trim(),J=await a8("gh",["api",`repos/${q}/git/ref/heads/${H}`,"--jq",".object.sha"]);if(J.code!==0)throw d("tengu_setup_github_actions_failed",{reason:"failed_to_get_branch_sha",exit_code:J.code,...O}),Error(`Failed to get branch SHA: ${J.stderr}`);let M=J.stdout.trim(),X=null;if(!Y){z(),X=`add-claude-github-actions-${Date.now()}`;let P=await a8("gh",["api","--method","POST",`repos/${q}/git/refs`,"-f",`ref=refs/heads/${X}`,"-f",`sha=${M}`]);if(P.code!==0)throw d("tengu_setup_github_actions_failed",{reason:"failed_to_create_branch",exit_code:P.code,...O}),Error(`Failed to create branch: ${P.stderr}`);z();let W=[];if($.includes("claude"))W.push({path:".github/workflows/claude.yml",content:mVK,message:"Claude PR Assistant workflow"});if($.includes("claude-review"))W.push({path:".github/workflows/claude-code-review.yml",content:BVK,message:"Claude Code Review workflow"});for(let D of W)await ZJY(q,X,D.path,D.content,_,D.message,O)}if(z(),K){let P=await a8("gh",["secret","set",_,"--body",K,"--repo",q]);if(P.code!==0){d("tengu_setup_github_actions_failed",{reason:"failed_to_set_api_key_secret",exit_code:P.code,...O});let W=` |
| 6077 | |
| 6078 | Need help? Common issues: |
| 6079 | `+`· Permission denied → Run: gh auth refresh -h github.com -s repo |
| 6080 | `+`· Not authorized → Ensure you have admin access to the repository |
| 6081 | `+"· For manual setup → Visit: https://github.com/anthropics/claude-code-action";throw Error(`Failed to set API key secret: ${P.stderr||"Unknown error"}${W}`)}}if(!Y&&X){z();let P=`https://github.com/${q}/compare/${H}...${X}?quick_pull=1&title=${encodeURIComponent(uVK)}&body=${encodeURIComponent(pVK)}`;await m3(P)}d("tengu_setup_github_actions_completed",{skip_workflow:Y,has_api_key:!!K,auth_type:A,using_default_secret_name:_==="ANTHROPIC_API_KEY",selected_claude_workflow:$.includes("claude"),selected_claude_review_workflow:$.includes("claude-review"),...O}),b8((P)=>({...P,githubActionSetupCount:(P.githubActionSetupCount??0)+1}))}catch(w){if(!w||!(w instanceof Error)||!w.message.includes("Failed to"))d("tengu_setup_github_actions_failed",{reason:"unexpected_error",...O});if(w instanceof Error)H6(w);throw w}}var wNK=y(()=>{k8();V1();hH();XK();E8()});function jNK(q){let K=z6(8),{warnings:_,onContinue:z}=q,Y;if(K[0]===Symbol.for("react.memo_cache_sentinel"))Y={context:"Confirmation"},K[0]=Y;else Y=K[0];P1("confirm:yes",z,Y);let $;if(K[1]===Symbol.for("react.memo_cache_sentinel"))$=a0.default.createElement(u,{flexDirection:"column",marginBottom:1},a0.default.createElement(k,{bold:!0},t6.warning," Setup Warnings"),a0.default.createElement(k,{dimColor:!0},"We found some potential issues, but you can continue anyway")),K[1]=$;else $=K[1];let A;if(K[2]!==_)A=_.map(GJY),K[2]=_,K[3]=A;else A=K[3];let O;if(K[4]===Symbol.for("react.memo_cache_sentinel"))O=a0.default.createElement(u,{marginTop:1},a0.default.createElement(k,{bold:!0,color:"permission"},"Press Enter to continue anyway, or Ctrl+C to exit and fix issues")),K[4]=O;else O=K[4];let w;if(K[5]===Symbol.for("react.memo_cache_sentinel"))w=a0.default.createElement(u,{marginTop:1},a0.default.createElement(k,{dimColor:!0},"You can also try the manual setup steps if needed:"," ",a0.default.createElement(k,{color:"claude"},fd))),K[5]=w;else w=K[5];let j;if(K[6]!==A)j=a0.default.createElement(a0.default.Fragment,null,a0.default.createElement(u,{flexDirection:"column",borderStyle:"round",paddingX:1},$,A,O,w)),K[6]=A,K[7]=j;else j=K[7];return j}function GJY(q,K){return a0.default.createElement(u,{key:K,flexDirection:"column",marginBottom:1},a0.default.createElement(k,{color:"warning",bold:!0},q.title),a0.default.createElement(k,null,q.message),q.instructions.length>0&&a0.default.createElement(u,{flexDirection:"column",marginLeft:2,marginTop:1},q.instructions.map(TJY)))}function TJY(q,K){return a0.default.createElement(k,{key:K,dimColor:!0},"• ",q)}var a0;var HNK=y(()=>{q8();bq();s6();Oq();a0=O6(D6(),1)});var JNK={};T8(JNK,{call:()=>VJY});function kJY(q){let[K]=yw.useState(()=>zv()),[_,z]=yw.useState({...vJY,useExistingKey:!!K,selectedApiKeyOption:K?"existing":WJ()?"oauth":"new"});o5(),yw.default.useEffect(()=>{d("tengu_install_github_app_started",{})},[]);let Y=yw.useCallback(async()=>{let E=[];if((await m_("gh --version",{shell:!0,reject:!1})).exitCode!==0)E.push({title:"GitHub CLI not found",message:"GitHub CLI (gh) does not appear to be installed or accessible.",instructions:["Install GitHub CLI from https://cli.github.com/","macOS: brew install gh","Windows: winget install --id GitHub.cli","Linux: See installation instructions at https://github.com/cli/cli#installation"]});let R=await m_("gh auth status -a",{shell:!0,reject:!1});if(R.exitCode!==0)E.push({title:"GitHub CLI not authenticated",message:"GitHub CLI does not appear to be authenticated.",instructions:["Run: gh auth login","Follow the prompts to authenticate with GitHub","Or set up authentication using environment variables or other methods"]});else{let I=R.stdout.match(/Token scopes:.*$/m);if(I){let B=I[0],p=[];if(!B.includes("repo"))p.push("repo");if(!B.includes("workflow"))p.push("workflow");if(p.length>0){z((C)=>({...C,step:"error",error:`GitHub CLI is missing required permissions: ${p.join(", ")}.`,errorReason:"Missing required scopes",errorInstructions:[`Your GitHub CLI authentication is missing the "${p.join('" and "')}" ${A7(p.length,"scope")} needed to manage GitHub Actions and secrets.`,"","To fix this, run:"," gh auth refresh -h github.com -s repo,workflow","","This will add the necessary permissions to manage workflows and secrets."]}));return}}}let x=await Fe()??"";d("tengu_install_github_app_step_completed",{step:"check-gh"}),z((I)=>({...I,warnings:E,currentRepo:x,selectedRepoName:x,useCurrentRepo:!!x,step:E.length>0?"warnings":"choose-repo"}))},[]);yw.default.useEffect(()=>{if(_.step==="check-gh")Y()},[_.step,Y]);let $=yw.useCallback(async(E,S)=>{z((R)=>({...R,step:"creating",currentWorkflowInstallStep:0}));try{await ONK(_.selectedRepoName,E,S,()=>{z((R)=>({...R,currentWorkflowInstallStep:R.currentWorkflowInstallStep+1}))},_.workflowAction==="skip",_.selectedWorkflows,_.authType,{useCurrentRepo:_.useCurrentRepo,workflowExists:_.workflowExists,secretExists:_.secretExists}),d("tengu_install_github_app_step_completed",{step:"creating"}),z((R)=>({...R,step:"success"}))}catch(R){let x=R instanceof Error?R.message:"Failed to set up GitHub Actions";if(x.includes("workflow file already exists"))d("tengu_install_github_app_error",{reason:"workflow_file_exists"}),z((I)=>({...I,step:"error",error:"A Claude workflow file already exists in this repository.",errorReason:"Workflow file conflict",errorInstructions:["The file .github/workflows/claude.yml already exists","You can either:"," 1. Delete the existing file and run this command again"," 2. Update the existing file manually using the template from:",` ${fd}`]}));else d("tengu_install_github_app_error",{reason:"setup_github_actions_failed"}),z((I)=>({...I,step:"error",error:x,errorReason:"GitHub Actions setup failed",errorInstructions:[]}))}},[_.selectedRepoName,_.workflowAction,_.selectedWorkflows,_.useCurrentRepo,_.workflowExists,_.secretExists,_.authType]);async function A(){await m3("https://github.com/apps/claude")}async function O(E){try{let S=await a8("gh",["api",`repos/${E}`,"--jq",".permissions.admin"]);if(S.code===0)return{hasAccess:S.stdout.trim()==="true"};if(S.stderr.includes("404")||S.stderr.includes("Not Found"))return{hasAccess:!1,error:"repository_not_found"};return{hasAccess:!1}}catch{return{hasAccess:!1}}}async function w(E){return(await a8("gh",["api",`repos/${E}/contents/.github/workflows/claude.yml`,"--jq",".sha"])).code===0}async function j(){let E=await a8("gh",["secret","list","--app","actions","--repo",_.selectedRepoName]);if(E.code===0)if(E.stdout.split(` |
| 6082 | `).some((x)=>{return/^ANTHROPIC_API_KEY\s+/.test(x)}))z((x)=>({...x,secretExists:!0,step:"check-existing-secret"}));else if(K)z((x)=>({...x,apiKeyOrOAuthToken:K,useExistingKey:!0})),await $(K,_.secretName);else z((x)=>({...x,step:"api-key"}));else if(K)z((S)=>({...S,apiKeyOrOAuthToken:K,useExistingKey:!0})),await $(K,_.secretName);else z((S)=>({...S,step:"api-key"}))}let H=async()=>{if(_.step==="warnings")d("tengu_install_github_app_step_completed",{step:"warnings"}),z((E)=>({...E,step:"install-app"})),setTimeout(A,0);else if(_.step==="choose-repo"){let E=_.useCurrentRepo?_.currentRepo:_.selectedRepoName;if(!E.trim())return;let S=[];if(E.includes("github.com")){let I=E.match(/github\.com[:/]([^/]+\/[^/]+)(\.git)?$/);if(!I)S.push({title:"Invalid GitHub URL format",message:"The repository URL format appears to be invalid.",instructions:["Use format: owner/repo or https://github.com/owner/repo","Example: anthropics/claude-cli"]});else E=I[1]?.replace(/\.git$/,"")||""}if(!E.includes("/"))S.push({title:"Repository format warning",message:'Repository should be in format "owner/repo"',instructions:["Use format: owner/repo","Example: anthropics/claude-cli"]});let R=await O(E);if(R.error==="repository_not_found")S.push({title:"Repository not found",message:`Repository ${E} was not found or you don't have access.`,instructions:[`Check that the repository name is correct: ${E}`,"Ensure you have access to this repository",'For private repositories, make sure your GitHub token has the "repo" scope',"You can add the repo scope with: gh auth refresh -h github.com -s repo,workflow"]});else if(!R.hasAccess)S.push({title:"Admin permissions required",message:`You might need admin permissions on ${E} to set up GitHub Actions.`,instructions:["Repository admins can install GitHub Apps and set secrets","Ask a repository admin to run this command if setup fails","Alternatively, you can use the manual setup instructions"]});let x=await w(E);if(S.length>0){let I=[..._.warnings,...S];z((B)=>({...B,selectedRepoName:E,workflowExists:x,warnings:I,step:"warnings"}))}else d("tengu_install_github_app_step_completed",{step:"choose-repo"}),z((I)=>({...I,selectedRepoName:E,workflowExists:x,step:"install-app"})),setTimeout(A,0)}else if(_.step==="install-app")if(d("tengu_install_github_app_step_completed",{step:"install-app"}),_.workflowExists)z((E)=>({...E,step:"check-existing-workflow"}));else z((E)=>({...E,step:"select-workflows"}));else if(_.step==="check-existing-workflow")return;else if(_.step==="select-workflows")return;else if(_.step==="check-existing-secret")if(d("tengu_install_github_app_step_completed",{step:"check-existing-secret"}),_.useExistingSecret)await $(null,_.secretName);else await $(_.apiKeyOrOAuthToken,_.secretName);else if(_.step==="api-key"){if(_.selectedApiKeyOption==="oauth")return;let E=_.selectedApiKeyOption==="existing"?K:_.apiKeyOrOAuthToken;if(!E){d("tengu_install_github_app_error",{reason:"api_key_missing"}),z((R)=>({...R,step:"error",error:"API key is required"}));return}z((R)=>({...R,apiKeyOrOAuthToken:E,useExistingKey:_.selectedApiKeyOption==="existing"}));let S=await a8("gh",["secret","list","--app","actions","--repo",_.selectedRepoName]);if(S.code===0)if(S.stdout.split(` |
| 6083 | `).some((I)=>{return/^ANTHROPIC_API_KEY\s+/.test(I)}))d("tengu_install_github_app_step_completed",{step:"api-key"}),z((I)=>({...I,secretExists:!0,step:"check-existing-secret"}));else d("tengu_install_github_app_step_completed",{step:"api-key"}),await $(E,_.secretName);else d("tengu_install_github_app_step_completed",{step:"api-key"}),await $(E,_.secretName)}},J=(E)=>{z((S)=>({...S,selectedRepoName:E}))},M=(E)=>{z((S)=>({...S,apiKeyOrOAuthToken:E}))},X=(E)=>{z((S)=>({...S,selectedApiKeyOption:E}))},P=yw.useCallback(()=>{d("tengu_install_github_app_step_completed",{step:"api-key"}),z((E)=>({...E,step:"oauth-flow"}))},[]),W=yw.useCallback((E)=>{d("tengu_install_github_app_step_completed",{step:"oauth-flow"}),z((S)=>({...S,apiKeyOrOAuthToken:E,useExistingKey:!1,secretName:"CLAUDE_CODE_OAUTH_TOKEN",authType:"oauth_token"})),$(E,"CLAUDE_CODE_OAUTH_TOKEN")},[$]),D=yw.useCallback(()=>{z((E)=>({...E,step:"api-key"}))},[]),f=(E)=>{if(E&&!/^[a-zA-Z0-9_]+$/.test(E))return;z((S)=>({...S,secretName:E}))},G=(E)=>{z((S)=>({...S,useCurrentRepo:E,selectedRepoName:E?S.currentRepo:""}))},Z=(E)=>{z((S)=>({...S,useExistingKey:E}))},T=(E)=>{z((S)=>({...S,useExistingSecret:E,secretName:E?"ANTHROPIC_API_KEY":""}))},v=async(E)=>{if(E==="exit"){q.onDone("Installation cancelled by user");return}if(d("tengu_install_github_app_step_completed",{step:"check-existing-workflow"}),z((S)=>({...S,workflowAction:E})),E==="skip"||E==="update")if(K)await j();else z((S)=>({...S,step:"api-key"}))};function V(E){if(E.preventDefault(),_.step==="success")d("tengu_install_github_app_completed",{});q.onDone(_.step==="success"?"GitHub Actions setup complete!":_.error?`Couldn't install GitHub App: ${_.error} |