Add modules/got with a got runner, version check, repository detection, and idempotent bare init. Route bare repository creation from InitRepositoryLocal through got; non-bare temp worktrees keep git. Add [git] GOT_PATH and tests, including an explicit no-fallback test. Assisted-by: OpenCode:DeepSeek-V4.1-Flash
11 KiB
11 KiB
gotea — AGENTS.md
Gotea is a fork of Gitea. The repository backend is moving from git to
got (Game of Trees), and the old-browser frontend
is a C99/POSIX CGI program serving HTML 4.01 with a CDE/Motif look. The Go forge
backend remains the source of truth for accounts, permissions, issues, API, and
storage.
Current state
- Base: upstream Gitea v28.4.0, full history,
upstreamremote kept. - Main module
gotea.dev; binarygotea. Identity strings and the English locale are renamed; upstream copyright notices stay. - The Go backend still calls
modules/gitfor most operations. Bare repository creation now goes throughmodules/got; the rest of the migration is open. cgi/gotea-cgiis the read-only old-browser frontend. It browses bare repositories withgot; it does not authenticate and has no write path.- Gotea Pages is a prototype: a
pagesbranch is checked out with got, built with the vendoredbbatthird_party/bb, and served from a separate host.
Architecture rules
- Do not rewrite the forge backend in C up front. Authentication, permissions, issues, pull requests, API, and migrations live in Go for good reasons. The C CGI is a presentation tier over the same repositories and can take over UI features incrementally.
- The CGI must not call Gotea over HTTP or read its database yet. Its contract is
GOTEA_REPO_ROOTplusgot; keep it that way until an auth design exists. - Keep the two tiers separable: the CGI must build and run with only libc, POSIX,
and
got.
Hard rules
- Brand: new code, UI strings, docs, and paths use gotea / Gotea, never gitea / Gitea. Upstream attribution and compatibility names are exceptions.
- Never blind-replace
gitwithgot. Keepgit-lfs,.git,.gitignore, Git wire-protocol names,github.comURLs, and the fact that gotea stores standard Git-format repositories. got is the engine, not a new object format. - Compatibility renames need an alias or migration, not
sed:GITEA_*env overrides,app.inikeys, DB table/column prefixes, dump formats, and API JSON fields are consumed by users and tooling. - No new direct
gitsubprocesses in runtime code. New or modified VCS code goes through one got wrapper (modules/got). The existingmodules/gitcalls are migration debt, not a pattern to copy. - If got genuinely cannot do an operation, stop and record the gap plus a proposed
design. Do not silently add a
gitfallback. - Copyright: keep upstream Gitea/MIT notices intact. New Go files get
// Copyright <year> The Gotea Authors.and// SPDX-License-Identifier: MIT. New C files use the same SPDX header in C comment form. - CGI security: HTML-escape every repository string; never invoke a shell;
validate repository names and reject
..; treatGOTEA_REPO_ROOTas public data. Private-repository access needs an auth layer first.
Frontend rules (cgi/)
- HTML 4.01 Transitional. No JavaScript, no
<script>, nojavascript:URLs, no external fonts, CSS frameworks, or images required for layout. - CSS1 is the ceiling. Prefer table layout and
bgcolor/<font>fallbacks so a pre-CSS browser still gets a usable page. Do not use flexbox, grid, CSS variables, or rounded corners. - The look is CDE/Motif: grey base, bevelled in/out borders, navy title bars, a
Front Panel sidebar. Colours come from the palette, not hard-coded literals.
GOTEA_PALETTEaccepts key=value themes and eight-slot CDE.dpfiles. - C99 + POSIX only (
-D_POSIX_C_SOURCE=200809L), no third-party libraries. Build with-Wall -Wextra -Wpedantic -Werror. - Keep
make -C cgi checkgreen. Tests may usegitonly to create fixtures. tidy -q -emust accept generated pages; add tablesummaryattributes rather than suppressing warnings.
Build and test
make gotea # Go backend binary
make build # full Gitea build (frontend needs pnpm/Node)
make -C cgi # CGI binary
make -C cgi check # CGI + pages tests, including a real bb build
make bb # vendored bb static site generator
make fmt # after .go edits
make tidy # after go.mod edits
make lint # or lint-backend / lint-frontend
make test-backend # single: make test-backend#TestName
make test-integration # needs git-lfs; SQLite default
make test-e2e # single: GITEA_TEST_E2E_FLAGS='<file>' make test-e2e
make generate-swagger # after API changes; verify with make swagger-check
make test-migration # after modelmigration changes
- Focused Go test:
go test -run '^TestName$' ./path/to/package/. - got tests:
go test ./modules/got; init wiring:go test ./modules/git -run 'TestInitRepositoryLocalBare'. - Raise
ulimit -n 12288beforemake watch. - The backend binary is
gotea; run it from the repository root with./gotea web.
got integration
- Put every got invocation in
modules/got(replacingmodules/git). Nothing else execs got or parses repository internals. Bare repo creation is already there; non-bare temp worktrees still use git and must be migrated deliberately. [git] GOT_PATHselects the got binary (defaultgot).- File changes require a work tree, whose metadata is
.got/(not.git/). A bare repository cannot be edited in place: server-side edits and merges need a temporarygot checkoutwork tree and agot commit. Serialize per repository and clean up. - A temporary
got checkoutleavesrefs/got/worktree/base-<uuid>in the repository. Delete it withgot ref -dwhen removing the worktree, or refs accumulate and block object cleanup.cgi/pages/publish.shdoes this. - Commits take their author from
GOT_AUTHOR(orgot.conf/Git config). Gitea'sGIT_AUTHOR_*variables are ignored by got; passGOT_AUTHORper command rather than mutating shared repository config. - Transports:
got clone/got fetchspeak smart HTTP(S), butgot sendis SSH-only.gotdis a Unix-socket daemon behindgotsh/SSH with no HTTP listener;gotwebdis a read-only web UI. got therefore cannot serve HTTPgit push. Settle the transport design before rewriting push and HTTP handlers. - Maintenance is
gotadmin:init,pack,cleanup(there is nogit gc),info,dump,load. got has no fast-export/fast-import equivalent, so mirrors, imports, and exports that relied on them need a new design. - got writes remotes to
.got/got.confas well as.git/config; keep both in sync when gotea changes a remote. - got has no documented Git-hook support; assume hooks do not run and invoke pre-receive/update-style hooks from gotea itself.
gotdcannot serve SHA-256 repositories. Keep SHA-1 until the whole serving path supports it.- Pin the minimum got version and test against it: got is pre-1.0 and flags drift (0.126 is current in Debian testing; 0.111 is in trixie).
- Wikis are repositories too; route them through the same got wrapper.
Gotea Pages
- A
pagesbranch is a bb project.cgi/pages/publish.shchecks it out withgot, runsthird_party/bb/bb build, and swapsdist/intoGOTEA_PAGES_ROOT/<owner>/<repo>/atomically. - The push path is
cgi/pages/install-hook.sh->hooks/post-receive.d/gotea-pages->publish.sh. Keep the hook non-fatal by default;GOTEA_PAGES_STRICT=1makes publish failures fail the push. - Never serve user HTML on the main app origin. Pages content is
attacker-controlled; same-origin means stored XSS against sessions and CSRF
tokens. Serve only when
GOTEA_PAGES_HOSTmatchesHTTP_HOST, withX-Content-Type-Options: nosniffandrealpathcontainment underGOTEA_PAGES_ROOT/<owner>/<repo>. - Pages inherit repository visibility: a private repository's site must not be readable anonymously, even via a guessed URL. The current publisher has no visibility check, so only public repos may be allowlisted.
GOTEA_PAGES_ALLOWis the serving allowlist;install-hook.shappends the repo to it. Do not serve a built tree that is not in it.- Publishing must be atomic and idempotent: stage aside, swap in, keep the last good version when a build or swap fails.
- bb is vendored under
third_party/bb; do not shell out to a system bb or edit the vendored copy in place. Update it from upstream deliberately and keepthird_party/bb/NOTICEcurrent.
Layout
- Backend:
routers/(HTTP),services/(logic),models/+modelmigration/(DB),modules/(infrastructure),templates/. - Backend VCS:
modules/gotfor migrated got calls;modules/gitis the remaining git surface. - Frontend:
web_src/(Vue + Vite) for the Gitea UI;cgi/for the HTML 4.01 frontend;cgi/pages/for publish/hook scripts. - Vendored:
third_party/bb(MIT static site generator). - Tests:
*_test.gobeside code,tests/integration/,_mock_data/recordings; CGI and pages tests incgi/tests/. - In
options/locale, edit onlylocale_en-US.json; other locales are synced automatically.
Repository conventions
- Never assume; verify before claiming. List targets with
make help. - Read relevant developer documentation in
docs/. - PR descriptions: minimal, what and why, no task or file listings. Screenshots for UI changes, before and after when modifying existing UI, under 1000 characters.
- Reference issues and PRs by full URL, not number.
- Conventional Commits for commit messages and PR titles, plus Gitea's
enhancetype for user-facing enhancements. - Add
Assisted-by: AGENT_NAME:MODEL_VERSIONto commit messages; neverCo-Authored-ByorSigned-off-by. - Attribute agent authorship on one trailing line in issue/PR comments, not as a description section.
- Never rewrite history unless asked; update PRs with new commits and normal push.
- Comments: almost none, short, explaining why. Never narrate the code or prompt.
- In TypeScript use
!instead of?./??when a value always exists. - In Go prefer modern language features; write sizes as
64 * 1024, not64 << 10. - For the Vue UI prefer
tw-*utilities over inline styles; this does not apply tocgi/, which stays CSS1/tables. - Run
make fmtafter.goedits,make tidyaftergo.modedits, and lint what changed withmake lint-go,lint-js,lint-css, orlint-templates. - Fix the cause rather than disabling a linter or weakening a test. If unavoidable, use the narrowest scope with a trailing reason comment.
- Write the fewest, fastest tests covering the behaviour. Aim for sub-2s integration and sub-4s e2e tests; wait on deterministic conditions, not sleeps.
Before calling work done
make fmt, make -C cgi check, tidy -q -e on generated HTML, and the relevant
test target must pass. Check that new runtime code does not add
exec.Command("git" (or exec.CommandContext) outside modules/git, tests, and
explicit compatibility shims.