docs/content/zh-Hans/docs/contributing/index.md
你好呀!感谢你有兴趣参与这个项目。本指南将帮助你快速上手
下载 Visual Studio, 根据这个教程安装 https://rust-lang.github.io/rustup/installation/windows-msvc.html#walkthrough-installing-visual-studio-2022
安装时请确保勾选了 Windows SDK 和 MSVC C++ build tools
::: tip
建议使用Visual Studio 2022 版以达到更好的兼容性
:::
打开 PowerShell
安装 scoop
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
通过 scoop 安装 git, Node.js, rustup 和 msvc
scoop install git nodejs rustup
# Rust 相关依赖
# 如果你不打算涉及 crates 或者 apps/tamagotchi 的开发,该步骤可跳过
scoop install main/rust-msvc
# Windows 平台所需内容
rustup toolchain install stable-x86_64-pc-windows-msvc
rustup default stable-x86_64-pc-windows-msvc
通过 corepack 安装 pnpm
corepack enable
corepack prepare pnpm@latest --activate
打开 Terminal, (或者 iTerm2, Ghostty, Kitty, etc.)
通过 brew 安装 git, node
brew install git node
通过 corepack 安装 pnpm
corepack enable
corepack prepare pnpm@latest --activate
打开 Terminal
请按照该说明的内容 nodesource/distributions: NodeSource Node.js Binary Distributions 安装 node
请参考该页面 Git 安装 git
通过 corepack 安装 pnpm
corepack enable
corepack prepare pnpm@latest --activate
如果你想进行桌面端的开发,你还需要下载如下依赖:
sudo apt install \
libssl-dev \
libglib2.0-dev \
libgtk-3-dev \
libjavascriptcoregtk-4.1-dev \
libwebkit2gtk-4.1-dev
::: tip
如果你并未克隆过该项目仓库,本步骤可跳过
:::
请确保你的本地仓库与主仓库保持最新同步:
git fetch --all
git checkout main
git pull upstream main --rebase
如果你有自己的开发/工作分支,请按照如下方式同步至主分支:
git checkout <your-branch-name>
git rebase main
请点击 moeru-ai/airi 页面右上角的 Fork 按钮来 fork(分叉一个归属于你的账户的副本)本项目。
git clone https://github.com/<your-github-username>/airi.git
cd airi
git checkout -b <your-branch-name>
corepack enable
pnpm install
# Rust相关依赖
# 如果你不打算涉及 crates 或者 apps/tamagotchi 的开发,该步骤可跳过
cargo fetch
::: tip
推荐安装 @antfu/ni 来简化脚本命令
corepack enable
npm i -g @antfu/ni
安装后,你可以:
ni 来替代 pnpm install、npm install 和 yarn install 命令。nr 来替代 pnpm run、npm run 和 yarn run 命令。你无需费心选择包管理器, ni 会自动适配。
:::
::: warning Visual Studio 2026 兼容提示
如果你使用的 Visual Studio 为 2026 版,安装依赖时可能会报错
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack Error: Could not find any Visual Studio installation to use
这是因为编译工具链使用的 node-gyp 暂未兼容新版 Visual Studio 2026。在 Powershell 中按如下操作强制指定新版 node-gyp 即可通过编译
npm i -g "node-gyp@>=12.2.0"
$env:npm_config_node_gyp = (Join-Path (npm root -g) "node-gyp\bin\node-gyp.js")
:::
提交前请确保代码已通过 Lint(静态分析器)和 类型安全检查:
pnpm lint && pnpm typecheck
::: tip
如果你安装了 @antfu/ni,你可以通过 nr 来运行命令:
nr lint && nr typecheck
:::
git add .
git commit -m "<your-commit-message>"
git push origin <your-branch-name> -u
现在,你应该可以在 GitHub 上看到你的分支。
::: tip
如果这是你第一次贡献本项目,请添加上游(upstream,指向本项目):
git remote add upstream https://github.com/moeru-ai/airi.git
:::
请前往 moeru-ai/airi 页面:
请检查并确认你的改动,最后点击 Create pull request 按钮完成拉取请求创建。
恭喜你成功地为本项目提交了首次贡献!现在可以等待项目的维护人员来审核你的拉取请求啦~