github/pr-create
githubRead-writeCreate a GitHub pull request
github.com
Last 7 days
0
Last 30 days
0
All time
0
github/pr-create.js
/* @meta
{
"name": "github/pr-create",
"description": "Create a GitHub pull request",
"domain": "github.com",
"args": {
"repo": {"required": true, "description": "Target repo (owner/repo)"},
"title": {"required": true, "description": "PR title"},
"head": {"required": true, "description": "Source branch (user:branch or branch)"},
"base": {"required": false, "description": "Target branch (default: main)"},
"body": {"required": false, "description": "PR description (markdown)"}
},
"capabilities": ["network"],
"readOnly": false,
"example": "tap site github/pr-create vaayne/tap-sites --title \"feat(weibo): add hot adapter\" --head myuser:feat-weibo --body \"Adds weibo/hot.js\""
}
*/
async function(args) {
if (!args.repo) return {error: 'Missing argument: repo'};
if (!args.title) return {error: 'Missing argument: title'};
if (!args.head) return {error: 'Missing argument: head', hint: 'Provide source branch as "user:branch" or "branch"'};
const resp = await fetch('https://api.github.com/repos/' + args.repo + '/pulls', {
method: 'POST',
credentials: 'include',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
title: args.title,
head: args.head,
base: args.base || 'main',
body: args.body || ''
})
});
if (!resp.ok) {
const status = resp.status;
if (status === 401 || status === 403) return {error: 'HTTP ' + status, hint: 'Not logged in to GitHub'};
if (status === 404) return {error: 'Repo not found: ' + args.repo};
if (status === 422) {
const d = await resp.json().catch(() => null);
const msg = d?.errors?.[0]?.message || d?.message || 'Validation failed';
return {error: msg, hint: 'Check that the head branch exists and has commits ahead of base'};
}
return {error: 'HTTP ' + status};
}
const pr = await resp.json();
return {
number: pr.number,
title: pr.title,
url: pr.html_url,
state: pr.state
};
}
Updated Mar 31, 2026Created Mar 31, 2026SHA-256: 1b28d23b9f30…