# Contributing to AntiFox [中文](#中文) | [English](#english) --- ## 中文 欢迎贡献代码、文档、翻译与问题反馈。 ### 从源码构建 前置:Go 1.24+、Node.js 20+、PostgreSQL、Python 3(报告渲染,需 `python-docx`)。 ```bash # 1. 前端静态导出 → 内嵌 cd web && NEXT_EXPORT=1 npx next build && cd .. rm -rf server/webui/dist && mkdir -p server/webui/dist && cp -r web/out/. server/webui/dist/ # 2. 内置 skill 库 → 内嵌(排除 report-generation,由 Go 生成) rm -rf server/skillsdist && mkdir -p server/skillsdist && cp -r skills/. server/skillsdist/ && rm -rf server/skillsdist/report-generation # 3. 编译单二进制(前端 + skill 内嵌) CGO_ENABLED=0 go build -tags embedui -o antifox ./cmd/antifox # 4. 运行(数据库连接用环境变量;dataDir 用持久目录) export ANTIFOX_PG_DSN="postgres://antifox:antifox@localhost:5432/antifox?sslmode=disable" ./antifox -addr :8787 -data ~/antifox-data ``` 打开 http://localhost:8787 ,首次进入 `/setup` 设置管理员密码。 数据库 schema 每次启动幂等自建/迁移,改 `db/schema.sql` 重启即生效。 ### 开发约定 - 改前端后重新执行上面的构建步骤(静态导出 → 内嵌 → 重编二进制)。 - 改 i18n 后运行 `scripts/check-i18n-keys.mjs` 对账三语键。 - 提交信息简洁、描述清楚改动动机。 ### 贡献流程 1. Fork 本仓库,基于 `main` 建分支。 2. 提交改动,保持编译通过(`go build ./...`)。 3. 发起 Pull Request,说明动机与影响范围。 ### 协议 本项目采用 **AGPL-3.0**。提交贡献即表示你同意你的贡献以相同协议授权。 --- ## English Contributions of code, docs, translations, and issue reports are welcome. ### Build from source Requirements: Go 1.24+, Node.js 20+, PostgreSQL, Python 3 (report rendering, needs `python-docx`). ```bash # 1. Frontend static export → embed cd web && NEXT_EXPORT=1 npx next build && cd .. rm -rf server/webui/dist && mkdir -p server/webui/dist && cp -r web/out/. server/webui/dist/ # 2. Built-in skills → embed (report-generation excluded, generated by Go) rm -rf server/skillsdist && mkdir -p server/skillsdist && cp -r skills/. server/skillsdist/ && rm -rf server/skillsdist/report-generation # 3. Build the single binary (frontend + skills embedded) CGO_ENABLED=0 go build -tags embedui -o antifox ./cmd/antifox # 4. Run (database via env var; use a persistent dataDir) export ANTIFOX_PG_DSN="postgres://antifox:antifox@localhost:5432/antifox?sslmode=disable" ./antifox -addr :8787 -data ~/antifox-data ``` Open http://localhost:8787 ; on first run go to `/setup` to set the admin password. The database schema is created/migrated idempotently on each start — edit `db/schema.sql` and restart. ### Conventions - After frontend changes, re-run the build steps above (static export → embed → rebuild binary). - After i18n changes, run `scripts/check-i18n-keys.mjs` to reconcile the trilingual keys. - Keep commit messages concise and explain the motivation. ### Workflow 1. Fork the repo and branch off `main`. 2. Make your change, keep the build green (`go build ./...`). 3. Open a Pull Request describing the motivation and scope. ### License This project is licensed under **AGPL-3.0**. By contributing, you agree that your contributions are licensed under the same terms.