← Public packages
@kody/kody-factory
Forkable multi-project software factory: signals, priority queue, project UI, sweep job. Agent runners and Sentry reach it by events.
Files
import { ownerGithubRequest } from './owner-github-request.ts'
import { pushBranchWith, validatePushInput, type PushBranchInput, type Request } from './push-branch-core.ts'
export type { PushBranchInput, PushFile } from './push-branch-core.ts'
/**
* Push file changes to a sweep branch and optionally open its PR as the
* owner's GitHub account (`githubOwner`). Sweep sessions use this instead of
* `git push`. Only sweep repos and `friction-log/` branches are accepted;
* never force-pushes (refuses when the branch moved since `expectedHeadSha`).
* Does not fall back to the bot `github` credential. Pass `dryRun: true` to
* validate and preview without calling GitHub.
*
* @example
* import pushBranch from 'kody:@kody/kody-factory/friction/push-branch'
* await pushBranch({
* repo: 'kody-hq/kody',
* branch: 'friction-log/2026-01-01-cli',
* message: 'fix(cli): clearer error',
* files: [{ path: 'README.md', content: '...' }],
* pullRequest: { title: 'fix(cli): clearer error', body: 'Fixes #1' },
* })
* // => { ok: true, commit: { sha, url, createdBranch: true }, pr: { number, url, author, created: true } }
*/
export default async function pushBranch(input: PushBranchInput) {
if (input?.dryRun === true) {
const planned = validatePushInput(input)
return {
ok: true,
dryRun: true,
repo: planned.repo,
branch: planned.branch,
base: planned.base,
action: planned.updateFromBase ? 'update-branch' : 'push',
fileCount: planned.files.length,
openPullRequest: Boolean(planned.pullRequest),
}
}
return await pushBranchWith(ownerGithubRequest as Request, input)
}