Packaging and CLI
Added pyproject.toml, package metadata, console script registration, version output,
and a management command surface for shim install, uninstall, doctor, config, and version.
This turn converted the repository from a Beads-initialized shell into a stdlib-only Python CLI package
with an opt-in gh wrapper for Codex.app workflows in Forgejo repositories.
gh-forgejo-shim command.gh.
Implemented V1 of gh-forgejo-shim: a Python 3.11+ package with no runtime dependencies,
a durable management CLI, a reversible generated gh wrapper, opt-in Forgejo host routing,
PR create/view/status behavior, GitHub-shaped JSON normalization, docs, and tests.
Added pyproject.toml, package metadata, console script registration, version output,
and a management command surface for shim install, uninstall, doctor, config, and version.
Added TOML config loading, env override merging, explicit host allowlisting, repository detection
from -R, GH_REPO, GH_HOST, and git remotes, plus delegation
to the real GitHub CLI when a command or host is out of scope.
Added PR create flag parsing, unsupported metadata flag errors, REST client calls, current branch view/status lookup, no-current-branch empty success behavior, and normalized JSON fields.
Added README, configuration docs, rollback docs, contributing notes, Python ignore rules, and a
focused stdlib unittest suite.
Codex.app expects GitHub-like PR commands in repositories. Forgejo repositories do not speak the full
GitHub CLI contract, so this project narrows the surface area to commands Codex is likely to call and
leaves everything else with the real gh. This keeps GitHub behavior intact while making
Forgejo repos less brittle under automation.
The repository uses Beads. The implementation issue is gh-forgejo-shim-uku. Two follow-up
Beads tasks were opened for work that should remain outside this V1 pass.
src/gh_forgejo_shim/routing.py decides whether to delegate or route to Forgejo.src/gh_forgejo_shim/repo.py parses HTTPS, SSH, scp-style SSH, host-prefixed, and plain owner/repo specs.src/gh_forgejo_shim/create.py translates supported gh pr create flags and rejects GitHub-only metadata flags.src/gh_forgejo_shim/forgejo.py implements the minimal REST client using urllib.src/gh_forgejo_shim/shim.py writes a marked wrapper and refuses unrelated files unless --force is passed.src/gh_forgejo_shim/doctor.py checks executable discovery, PATH ordering, hosts, and auth.
The snippets below use the Diffs FileDiff component, following the documented model of
rendering two versions of a file into a container. If the external renderer is unavailable, the static
fallback code blocks remain visible. Reference: Diffs documentation.
[project.scripts]
gh-forgejo-shim = "gh_forgejo_shim.cli:main"
if len(argv) < 2 or argv[0] != "pr" or argv[1] not in SUPPORTED_PR_COMMANDS:
return RouteDecision("delegate", "unsupported command")
detection = detect_repo(argv, env=env, cwd=cwd)
if detection.repo is None:
return RouteDecision("delegate", "no repository detected")
if not config.is_forgejo_host(detection.repo.host):
return RouteDecision("delegate", f"host {detection.repo.host} is not allowlisted", detection.repo)
return RouteDecision("forgejo", detection.source, detection.repo)
if pull is None:
if parsed.json_fields:
print("{}", file=stdout)
return 0
Users can install the package with pipx, explicitly allowlist Forgejo hosts, and install
the reversible gh wrapper. Codex.app can then run common PR create/status/view commands
in Forgejo repositories without breaking normal GitHub repositories on the same machine.
python3 -m unittest: passed, 32 tests.python3 -m compileall -q src tests: passed.PYTHONPATH=src python3 -m gh_forgejo_shim version: printed 0.1.0.PYTHONPATH=src python3 -m gh_forgejo_shim --help: printed the expected command list.python3 -m pip install .: built and installed gh-forgejo-shim-0.1.0, then printed 0.1.0.python3 -m pip install -e . --dry-run: blocked by PEP 668 externally managed environment protection, so the venv validation was used instead.bd dolt push: exited successfully; Beads reported that no Dolt remote is configured, so remote issue sync was skipped.gh pr create/new/status/view for Forgejo hosts; every other command delegates to real gh.fj/tea/gitea config discovery.--jq and broader GitHub CLI JSON behavior are not implemented in this V1 surface.gh-forgejo-shim-mte: Add live Forgejo integration coverage.gh-forgejo-shim-xq1: Add package release automation.