diff --git a/AGENTS.md b/AGENTS.md index d4f25d08c8..c6786dacb7 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,21 +1,175 @@ -- Never assume, verify before claiming -- List development targets with `make help` -- Read relevant developer documentation in the `docs` folder -- PR descriptions: minimal, only what and why, no task or file listings. Include screenshots for UI changes, before and after when modifying existing UI. Aim for less than 1000 characters -- Reference issues and PRs by full URL, not by number -- Use Conventional Commits for commit messages and PR titles, plus Gitea's `enhance` type for user-facing enhancements -- Add an `Assisted-by: AGENT_NAME:MODEL_VERSION` trailer to commit messages, never `Co-Authored-By` or `Signed-off-by` -- Attribute agent authorship on one trailing line in issue and PR comments, never as a PR description section -- Never rewrite git history unless asked, update PRs with new commits and normal push -- Comments: write almost none, short and preferably same-line, explaining why for a future reader. Never narrate code, the change or the prompt. Preserve existing ones that still apply. If you need to write a paragraph-long comment, rethink your implementation, it is likely too complicated -- Add the current year to copyright headers of new `.go` files -- In `options/locale`, only edit `locale_en-US.json`, other locales are synced automatically -- In TS, use `!` instead of `?.`/`??` when a value always exists -- In Go, prefer to use modern language features wherever possible -- Write sizes as multiplications like `64 * 1024`, not bit shifts like `64 << 10` -- Prefer `tw-*` utilities over inline `style` and `flex-*` helpers over per-child `tw-ml-*`/`tw-mr-*` margins, falling back to `tw-*` where specificity requires `!important` -- Run `make fmt` after `.go` edits, `make tidy` after `go.mod` edits, `make generate-swagger` after API changes, and lint what changed with `make lint-go`, `lint-js`, `lint-css` or `lint-templates` -- Fix the cause rather than disabling a linter or weakening a test. Where unavoidable, use the narrowest scope with a trailing comment giving the reason -- Run single tests with `go test -run '^TestName$' ./modulepath/` for Go, `pnpm exec vitest ` for TS and `GITEA_TEST_E2E_FLAGS='' make test-e2e` for e2e -- Write the fewest, fastest tests covering the behavior, extending an existing one where possible. Prefer unit tests where logic is testable in isolation -- Aim for sub-2s per integration test and sub-4s per e2e test. Wait on a deterministic condition rather than `sleep`, and prefer semantic locators in e2e tests +# gotea — AGENTS.md + +Gotea is a fork of Gitea. The repository backend is moving from `git` to +[got](https://got.gameoftrees.org/) (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, `upstream` remote kept. +- Main module `gotea.dev`; binary `gotea`. Identity strings and the English locale + are renamed; upstream copyright notices stay. +- The Go backend still calls `modules/git`; the got migration is the main open + backend task. Do not claim it is finished. +- `cgi/gotea-cgi` is the read-only old-browser frontend. It browses bare + repositories with `got`; it does not authenticate and has no write path. +- Gotea Pages is planned, not implemented. + +## 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_ROOT` plus `got`; 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 `git` with `got`.** Keep `git-lfs`, `.git`, `.gitignore`, + Git wire-protocol names, `github.com` URLs, 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.ini` keys, DB table/column prefixes, dump formats, and API JSON + fields are consumed by users and tooling. +- **No new direct `git` subprocesses in runtime code.** New or modified VCS code + goes through one got wrapper (`modules/got`). The existing `modules/git` calls 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 `git` fallback. +- **Copyright:** keep upstream Gitea/MIT notices intact. New Go files get + `// Copyright 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 `..`; treat `GOTEA_REPO_ROOT` as public + data. Private-repository access needs an auth layer first. + +## Frontend rules (cgi/) + +- HTML 4.01 Transitional. No JavaScript, no `