--- description: Reset Gitea configuration with interactive setup wizard agent: general subtask: true --- Launch an interactive configuration wizard to set up or reset Gitea configuration. ## 工作目录 **macOS / Linux:** ``` ~/.config/gitea/ ``` **Windows:** ``` %USERPROFILE%\.config\gitea\ ``` 配置文件和 Runner 目录都将存储在此位置。 Please perform the following: 1. **Create configuration directory:** **macOS / Linux:** ```bash mkdir -p ~/.config/gitea/runners ``` **Windows PowerShell:** ```powershell New-Item -Path "$env:USERPROFILE\.config\gitea\runners" -ItemType Directory -Force ``` 2. **Interactive input - Gitea URL:** - Prompt: "请输入 Gitea 实例地址 (例如: https://git.digitevents.com):" - Validate: Must start with http:// or https:// - Remove trailing slash 3. **Interactive input - Personal Access Token:** - Prompt: "请输入 Personal Access Token:" - Before input, show help: ``` 提示:获取 Personal Access Token 的步骤: 1. 登录 Gitea 2. 右上角头像 → 设置 → 应用 → 访问令牌 3. 点击 "生成新令牌" 4. 设置令牌名称(如 opencode-cli) 5. 选择权限:repo, admin:org, write:runner(推荐) 6. 点击 "生成令牌" 7. 复制生成的 Token ``` - Validate: Not empty - Use `read -sp` for secure input (password style) 4. **Test connection:** - API: `GET ${GITEA_URL}/api/v1/user` - If fails: Show error and possible reasons - If success: Show username 5. **Validate token permissions:** - Check `repo`: `GET /api/v1/user/repos` (required) - Check `admin:org`: `GET /api/v1/user/orgs` (optional, for org runners) - Check `write:runner`: Try to get registration token (optional, for runners) - Warn if missing required permissions 6. **Input default organization (optional):** - Prompt: "请输入默认组织名称 (回车跳过):" - If provided, validate it exists: `GET /api/v1/orgs/${org_name}` 7. **Save configuration:** **macOS / Linux** - Save to `~/.config/gitea/config.env`: ```bash GITEA_URL=... GITEA_TOKEN=... GITEA_DEFAULT_ORG=... (if set) GITEA_RUNNER_CAPACITY=2 GITEA_RUNNER_TIMEOUT=3h ``` - Set permissions: `chmod 600 ~/.config/gitea/config.env` - Create `.gitignore` to exclude sensitive files **Windows** - Save to `%USERPROFILE%\.config\gitea\config.env`: ```bash GITEA_URL=... GITEA_TOKEN=... GITEA_DEFAULT_ORG=... (if set) GITEA_RUNNER_CAPACITY=2 GITEA_RUNNER_TIMEOUT=3h ``` - Set file permissions to restrict access (see setup-guide.md for PowerShell script) - Create `.gitignore` to exclude sensitive files 8. **Display completion summary in Chinese:** **macOS / Linux:** ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 配置完成 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 配置文件: ~/.config/gitea/config.env Runner 目录: ~/.config/gitea/runners 下一步: - 查看配置: /gitea-config - 创建 Runner: 告诉 AI '创建一个 runner' - 创建仓库: /create-gitea-repo ``` **Windows:** ``` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 配置完成 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 配置文件: %USERPROFILE%\.config\gitea\config.env Runner 目录: %USERPROFILE%\.config\gitea\runners 下一步: - 查看配置: /gitea-config - 创建 Runner: 告诉 AI '创建一个 runner' - 创建仓库: /create-gitea-repo ``` **Security notes:** - Config file permissions: 600 (owner read/write only) - Token is never displayed after initial input - Sensitive files excluded in .gitignore