Cloudflare Worker that handles ?go-get=1 requests and emits go-import meta tags routing go.moleculesai.app/<area>/* to the canonical Gitea repo for that area. See molecule-ai/internal#71 for design + module map. Files: - worker.js: stateless responder (~170 lines, vendor-portable) - wrangler.toml: route binding + zone config - README.md: deploy + smoke-test instructions Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|---|---|---|
| README.md | ||
| worker.js | ||
| wrangler.toml | ||
go.moleculesai.app — Go-import vanity responder
Tiny Cloudflare Worker that handles ?go-get=1 requests for go.moleculesai.app/* and emits the <meta name="go-import"> tag pointing at our actual SCM (Gitea today).
Why
Source code never names the SCM host. Imports look like go.moleculesai.app/core/platform/handlers; this responder tells go get where the source actually lives. When the SCM changes, this is the one config that updates — every Go import statement stays put.
Origin: molecule-ai/internal#71. Pre-2026-05-06, our Go modules were under github.com/Molecule-AI/...; the suspension of that org made every import a dead link. The migration moved imports to a vanity host we control instead of relocating the lock-in to Gitea.
Module map
| Vanity prefix | Gitea repo |
|---|---|
go.moleculesai.app/core/... |
molecule-ai/molecule-core |
go.moleculesai.app/controlplane/... |
molecule-ai/molecule-controlplane |
go.moleculesai.app/cli/... |
molecule-ai/molecule-cli |
go.moleculesai.app/plugin/gh-identity/... |
molecule-ai/molecule-ai-plugin-gh-identity |
Adding a new repo: append one entry to MODULE_MAP in worker.js and wrangler deploy. No code change anywhere else.
Deploy
# Once: install wrangler
npm install -g wrangler
# Authenticate (set CLOUDFLARE_API_TOKEN env var, or `wrangler login`)
export CLOUDFLARE_API_TOKEN=<token-with-Workers-Scripts-Edit-+-Zone-DNS-Edit>
# Deploy
wrangler deploy
The token needs:
Account.Workers Scripts.Edit(push the worker)Zone.DNS.Editon themoleculesai.appzone (so wrangler can bind the route)
Or use the Worker route in the Cloudflare dashboard manually — doesn't require token DNS scope.
Smoke test
curl -s 'https://go.moleculesai.app/core/platform?go-get=1' | grep go-import
# expected:
# <meta name="go-import" content="go.moleculesai.app/core git https://git.moleculesai.app/molecule-ai/molecule-core">
End-to-end:
go install go.moleculesai.app/cli/cmd/molecule@latest
# Should resolve via the responder, fetch from Gitea, build a `molecule` binary on PATH.
What this responder deliberately does NOT do
- Per-version/per-tag rewrite. We don't encode semver in the path; standard Go module versioning in
go.moddoes that. - Authentication. Vanity-URL discovery is public read;
go getitself authenticates against the actual SCM (git.moleculesai.app) for private repos. - Rate limiting. Cloudflare's edge handles abuse; the worker doesn't store state.
Related
- Issue: molecule-ai/internal#71
- Migration PRs: plugin-gh-identity#3, cli#2, controlplane#32, core#82