Files
dygou_go/AGENTS.md
T

31 lines
3.0 KiB
Markdown

# Repository Guidelines
## Project Structure & Module Organization
`main.go` starts Wails and embeds `frontend/dist`. Backend code lives in `internal/`; keep Wails-callable methods in `internal/app/app_*.go` and domain logic in packages such as `client`, `seckill`, `config`, `logger`, and `image`. The Vue 3/TypeScript UI is under `frontend/src`, organized into `components/`, `composables/`, `styles/`, and `utils/`. Go tests sit beside source as `*_test.go`. `docs/` and `work/` hold reference material; `build/`, `frontend/dist/`, and generated `frontend/wailsjs/` are ignored.
## Build, Test, and Development Commands
- `./build.sh install`: install frontend dependencies.
- `./build.sh dev`: run the Wails app with frontend hot reload.
- `cd frontend && npm run type-check`: type-check Vue/TypeScript after `frontend/wailsjs/` exists.
- `go test ./internal/...`: run backend tests; the root package requires `frontend/dist` for embedding.
- `./build.sh build`: type-check and build the current platform into `build/bin/`.
- `./build.sh win|mac-arm|linux|release`: build target-specific releases.
- `./build.sh clean`: remove generated build artifacts.
Use `gofmt` on changed Go files. There is no configured frontend linter.
## Coding Style & Naming Conventions
Go follows standard `gofmt` style: tabs, short package names, `PascalCase` for exported identifiers, and `camelCase` for locals. Protect shared `App` state with the existing mutexes, and place frontend bindings method-by-domain in `app_*.go`. TypeScript/Vue uses two-space indentation, single quotes, and no semicolons. Use `PascalCase.vue` component filenames and `useX` names for composables. Prefer the configured `@/` and `@wails/` import aliases. Regenerate, but never edit or commit, generated `frontend/wailsjs/` bindings.
## Testing Guidelines
Backend tests use Go's `testing` package and are named `TestBehavior`. Prefer table-driven cases plus `t.TempDir()` and `httptest` for filesystem and HTTP isolation. Add regression tests for retry, scheduling, config, and Wails method changes. No frontend unit test framework or coverage threshold is configured; run `go test ./internal/...` and the frontend type check before submitting.
## Commit & Pull Request Guidelines
Most history uses concise Chinese descriptions; newer commits also use Conventional Commits prefixes. Prefer forms such as `feat(scope): summarize change`, `fix(scope): ...`, or `chore(version): ...`. Keep commits focused. Pull requests should explain behavior and risk, list verification commands, link related issues, and include screenshots for visible UI changes when available.
## Configuration & Security
Runtime data, cookies, account files, logs, `config.json`, and fonts must remain untracked. Use `DOUYU_DATA_DIR`, `DOUYU_CONFIG`, `DOUYU_USERS`, `DOUYU_LOG_DIR`, and related environment variables for local overrides.
## Agent-Specific Instructions
Do not launch browsers or browser automation for UI validation unless explicitly requested. Use type checks, builds, and existing tests.