AGENTS.md
143 lines · 4.4 KB · Markdown@kentcdodds/github — agent notes
Human setup and intent live in README.md. This file is for
agents: imports, smoke checks, snippets, and edge cases. Secrets by name
only — never paste token values. Do not disable live webhooks or jobs.
Auth / integrations
| Account | Integration | Default |
|---|---|---|
bot | github-bot (kody-bot) | Yes |
kent | github-kent (Kent C. Dodds) | No — explicit Kent request only |
Auth uses createAuthenticatedFetch('<integration>') against the saved OAuth
connection. Do not rely on mirrored user secrets like
github-botAccessToken / github-kentAccessToken — those are not required and
may be absent even when OAuth works.
Reconnect: /connect/oauth?provider=github-bot or
/connect/oauth?provider=github-kent.
Import paths
| Export | Import |
|---|---|
| overview | kody:@kentcdodds/github |
| accounts | kody:@kentcdodds/github/accounts |
| get-viewer | kody:@kentcdodds/github/get-viewer |
| graphql | kody:@kentcdodds/github/graphql |
| paginate | kody:@kentcdodds/github/paginate |
| request | kody:@kentcdodds/github/request |
| types | kody:@kentcdodds/github/types |
| pr/get-info | kody:@kentcdodds/github/pr/get-info |
| pr/get-checks | kody:@kentcdodds/github/pr/get-checks |
| pr/merge | kody:@kentcdodds/github/pr/merge |
| pr/merge-durable | kody:@kentcdodds/github/pr/merge-durable |
| pr/workflows-probe | kody:@kentcdodds/github/pr/workflows-probe |
| pr/set-review-status | kody:@kentcdodds/github/pr/set-review-status |
| actions/put-secret | kody:@kentcdodds/github/actions/put-secret |
Prefer static kody:@kentcdodds/github/... imports from execute. Do not lead
with packages.invoke. If you must invoke dynamically, pass bare kody id
github (not @kentcdodds/github).
Smoke test (read-only)
import getGithubViewer from 'kody:@kentcdodds/github/get-viewer'
export default async function main() {
return await getGithubViewer({ account: 'bot' })
// => { account: 'bot', login: 'kody-bot', id, type, ... }
}Optional workflows reachability probe (creates a trivial workflow):
import probe from 'kody:@kentcdodds/github/pr/workflows-probe'
export default async function main() {
return await probe({})
}Common snippets
REST:
import githubRequest from 'kody:@kentcdodds/github/request'
export default async function main() {
const response = await githubRequest({
account: 'bot',
path: '/repos/kentcdodds/kody',
throwOnError: true,
})
return response.data
}PR info:
import getPrInfo from 'kody:@kentcdodds/github/pr/get-info'
export default async function main() {
return await getPrInfo({
owner: 'kentcdodds',
repo: 'kody',
prNumber: 1,
account: 'bot',
})
}Merge (caller does not need to retry slow merges):
import mergePr from 'kody:@kentcdodds/github/pr/merge'
export default async function main() {
return await mergePr({
prUrl: 'https://github.com/kentcdodds/kody/pull/969',
mergeMethod: 'squash',
})
// Slow GitHub merge may return status: 'merge_dispatched' + workflowId.
}Put Actions secret (plaintext never returned; prefer generateBytes when minting):
import putActionsSecret from 'kody:@kentcdodds/github/actions/put-secret'
export default async function main() {
return await putActionsSecret({
owner: 'kentcdodds',
repo: 'kody',
name: 'EXAMPLE_SECRET_NAME',
generateBytes: 32,
})
}Edge cases
- Default
accountis alwaysbot. Never switch tokentunless the user explicitly asks to act as Kent C. Dodds / kentcdodds. - PR locators:
{ prUrl }or{ owner, repo, prNumber }(numberaliasesprNumber). Optionalaccounton all PR helpers. pr/mergebounds the direct attempt (timeoutMsdefault 25000), escalates to a durable workflow on abort, and stays under a ~55s call budget. Fail-fast for closed/draft/dirty/blocked/not-mergeable. Already-merged is idempotent.timed_out_unconfirmedonly when workflows are unavailable.pr/merge-durableis the workflow entry — agents normally do not call it.pr/set-review-status:status: 'draft' | 'ready' | 'toggle'; mutation bounded bytimeoutMs.requesthas no default timeout on ordinary reads; passtimeoutMs/signalfor long-lived mutations that can hang.actions/put-secret: passvalueorgenerateBytes(not both); never log or return the secret value.