4.0 KiB
AGENTS.md
Guidance for AI coding agents working in this repository.
Project Shape
fetch_contests.pyis the data generator. It fetches contests, normalizes records withplatform,title,start_time,end_time,status, andurl, then writescontests_all.jsonin the repository root.- Current contest providers are Codeforces, AtCoder, UOJ, and Nowcoder.
.github/workflows/deploy.ymlis the GitHub Actions automation. It installs Python dependencies, runsfetch_contests.py, and commits generated JSON changes.server/index.phpis the serving/display layer. It reads the public rawcontests_all.json, caches it locally, and renders upcoming plus recently finished contests.- User-facing documentation lives in README.md and README_zh.md. Keep both languages in sync.
Actions vs Server Responsibilities
- Actions side: update contest data only. Change
.github/workflows/deploy.ymlwhen editing schedule triggers, Python version, dependency installation, generated files to commit, or commit/push behavior. - Data-fetch side: change
fetch_contests.pywhen editing providers, normalization, filtering, output JSON shape, or output file policy. - Server side: change
server/index.phpwhen editing presentation, caching, raw JSON URL, platform labels/classes, countdown behavior, or PHP deployment behavior. The current page requires PHP 5.4 or newer. - Server localization:
server/index.phpdetects browser/system language and time zone, syncs them to cookies, and uses those cookies for first-render localized text and contest times. - Do not put scraping logic in
server/index.php; keep upstream fetching infetch_contests.pyso Actions can generate static JSON.
Adding or Removing a Contest Provider
When adding a new contest provider, check all relevant surfaces:
fetch_contests.py: add afetch_<provider>()function, normalize records throughmake_contest(), add it to both output flows inmain(), and preservestatussemantics.server/index.php: add the platform name to$platform_classand define a matching.platform.<class>CSS rule if the provider appears incontests_all.json.README.mdandREADME_zh.md: update supported platforms, data-source notes, and any changed usage/output details.AGENTS.md: update this guidance if the provider introduces a new pattern, dependency, output contract, or operational caveat..github/workflows/deploy.yml: update only if the provider needs new Python dependencies, generated files, secrets, or schedule behavior.
When removing a provider, remove or adjust the same surfaces so stale platform labels, CSS classes, docs, and workflow dependencies do not remain.
Output Contracts
contests_all.jsonis an object withgenerated_atandcontests;contestscontains contests that have not ended yet (upcomingandrunning) plus contests that finished within the last 30 days.- JSON timestamps are Unix timestamps in seconds.
- Keep record keys stable unless the README files and server rendering are updated in the same change.
Validation
Do not proactively create a Python virtual environment unless the user asks for one. Run Python commands directly with python.
After changing fetching, filtering, output shape, provider support, or workflow-generated files, run:
python fetch_contests.py
Then inspect the generated files with jq when available, for example:
jq '.contests | group_by(.status) | map({status: .[0].status, count: length})' contests_all.json
For PHP-only presentation changes, also check that server/index.php still reads contests_all.json and handles unknown platforms with the default styling.
Documentation Rule
Every feature addition, feature removal, provider change, output contract change, or workflow behavior change must update all three documentation files in the same change:
Link to existing docs instead of duplicating long explanations. Keep agent guidance concise and operational.