Skip to content
← 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.

FollowFork

Files

github.ts

30 lines · 925 B · TypeScript
import type { RepoAdapter, RepoHost } from './types.ts'

export const githubRepoAdapter: RepoAdapter = {
	id: 'github',
	displayName: 'GitHub',
	parseRef(ref) {
		const cleaned = ref.replace(/^https?:\/\/github\.com\//, '').replace(/\.git$/, '')
		return { ref: cleaned, defaultBranch: 'main' }
	},
	changeRequestUrl({ ref, branch, title }) {
		const base = encodeURIComponent(branch)
		return `https://github.com/${ref}/compare/main...${base}?expand=1&title=${encodeURIComponent(title)}`
	},
}

export const githubRepoHost: RepoHost = {
	id: 'github',
	async proposeChange(input) {
		if (input.dryRun) {
			return {
				ok: true,
				note: `dry-run: would push ${input.files.length} file(s) to ${input.repo.ref}@${input.branch}`,
			}
		}
		return {
			ok: false,
			note: 'GitHub proposeChange is stubbed in v1; wire credential(github) and REST/GraphQL in a follow-up. Keep using ship-pr externally for merges.',
		}
	},
}