Files
opencode/command/gitea-reset.md

3.7 KiB
Raw Blame History

description, agent, subtask
description agent subtask
Reset Gitea configuration with interactive setup wizard general 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:

mkdir -p ~/.config/gitea/runners

Windows PowerShell:

New-Item -Path "$env:USERPROFILE\.config\gitea\runners" -ItemType Directory -Force
  1. Interactive input - Gitea URL:

    • Prompt: "请输入 Gitea 实例地址 (例如: https://git.digitevents.com):"
    • Validate: Must start with http:// or https://
    • Remove trailing slash
  2. 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)
  1. Test connection:

    • API: GET ${GITEA_URL}/api/v1/user
    • If fails: Show error and possible reasons
    • If success: Show username
  2. 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
  3. Input default organization (optional):

    • Prompt: "请输入默认组织名称 (回车跳过):"
    • If provided, validate it exists: GET /api/v1/orgs/${org_name}
  4. Save configuration:

macOS / Linux - Save to ~/.config/gitea/config.env:

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:

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
  1. Display completion summary in Chinese:

macOS / Linux:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
配置完成
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  配置文件: ~/.config/gitea/config.env
  Runner 目录: ~/.config/gitea/runners

下一步:
  - 查看配置: /gitea-config
  - 创建 Runner: 告诉 AI '创建一个 runner'
  - 创建仓库: /create-gitea-repo <repo-name>

Windows:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
配置完成
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  配置文件: %USERPROFILE%\.config\gitea\config.env
  Runner 目录: %USERPROFILE%\.config\gitea\runners

下一步:
  - 查看配置: /gitea-config
  - 创建 Runner: 告诉 AI '创建一个 runner'
  - 创建仓库: /create-gitea-repo <repo-name>

Security notes:

  • Config file permissions: 600 (owner read/write only)
  • Token is never displayed after initial input
  • Sensitive files excluded in .gitignore