← 返回 Skills 市场
normdist-ai

China Mirrors

作者 NormDist · GitHub ↗ · v1.2.1 · MIT-0
cross-platform ✓ 安全检测通过
135
总下载
0
收藏
0
当前安装
3
版本数
在 OpenClaw 中安装
/install china-mirrors
功能描述
自动配置 Python pip、npm、yarn、pnpm、cargo、go mod、NuGet、RubyGems、Conda、Homebrew、Gradle 等包管理器的国内镜像源。使用当用户提到下载慢、安装依赖、配置镜像、加速包下载、设置国内源,或在中国大陆开发需要加速依赖安装时。支持阿里云、腾讯云、清华大学...
使用说明 (SKILL.md)

中国国内镜像源配置技能(Agent 自执行版)

核心设计理念:本技能不附带任何预置脚本。Agent 应根据本文档的指导,直接在用户计算机上编写并执行配置命令,实现镜像源配置功能。

工作流程(Agent 必须遵循)

Phase 1: 需求检测与环境分析

当触发本技能时,Agent 按以下步骤操作:

1.1 触发条件识别

  • 用户明确提及:下载慢、安装依赖慢、配置镜像、加速下载、设置国内源
  • 检测到项目包含依赖文件:package.jsonrequirements.txtCargo.tomlgo.modGemfile.nuspecenvironment.ymlbuild.gradlepom.xmlcomposer.json

1.2 与用户确认

询问内容:
1. 需要配置哪些包管理器?(如未指定,根据项目依赖文件自动判断)
2. 有偏好的镜像源吗?(默认推荐阿里云或华为云)
3. 配置范围:全局配置 or 项目级配置?

1.3 环境检测命令 Agent 执行以下命令检测已安装的工具:

# Windows PowerShell 检测
python --version 2>$null; node --version 2>$null; npm --version 2>$null
cargo --version 2>$null; go version 2>$null; dotnet --version 2>$null
ruby --version 2>$null; conda --version 2>$null; gradle --version 2>$null
brew --version 2>$null
# Linux/Mac Bash 检测
for cmd in python node npm cargo go dotnet ruby conda gradle brew; do
    $cmd --version 2>/dev/null && echo "✓ $cmd available"
done

Phase 2: 选择镜像源

根据下表为用户选择最优镜像。标记 ⭐ 的为当前推荐

包管理器 推荐镜像 URL 备选1 备选2
pip (Python) 阿里云 ⭐ https://mirrors.aliyun.com/pypi/simple/ 清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/ 腾讯云 https://mirrors.cloud.tencent.com/pypi/simple/
npm/yarn/pnpm 华为云 ⭐ https://repo.huaweicloud.com/repository/npm/ 阿里云 https://registry.npmmirror.com 腾讯云 https://mirrors.cloud.tencent.com/npm/
cargo (Rust) 阿里云 ⭐ https://mirrors.aliyun.com/crates.io-index/ 清华大学 https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/ 中科大 https://mirrors.ustc.edu.cn/crates.io-index/
go mod (Go) 阿里云 ⭐ https://mirrors.aliyun.com/goproxy/ 七牛云 https://goproxy.cn 官方中国 https://goproxy.io
Maven (Java) 阿里云 ⭐ https://maven.aliyun.com/repository/public - -
Gradle (Java/Kotlin) 腾讯云 ⭐ https://mirrors.cloud.tencent.com/gradle/ 阿里云 https://maven.aliyun.com/repository/gradle-plugin/ -
NuGet (.NET) 华为云 ⭐ https://repo.huaweicloud.com/repository/nuget/v3/index.json 清华大学 https://mirrors.tuna.tsinghua.edu.cn/nuget/v3/index.json -
RubyGems (Ruby) 清华大学 ⭐ https://mirrors.tuna.tsinghua.edu.cn/rubygems/ 中科大 https://mirrors.ustc.edu.cn/rubygems/ -
Conda (Python) 清华大学 ⭐ https://mirrors.tuna.tsinghua.edu.cn/anaconda/ 中科大 https://mirrors.ustc.edu.cn/anaconda/ -
Homebrew (macOS) 中科大 ⭐ https://mirrors.ustc.edu.cn/homebrew-bottles/ 清华大学 https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/ -
Composer (PHP) 阿里云 ⭐ https://mirrors.aliyun.com/composer/ - -

Phase 3: 执行配置(Agent 直接运行命令)

重要:Agent 根据用户选择的包管理器和镜像,直接在终端执行以下对应命令。 不要创建临时脚本文件,直接使用原生命令或 Shell 命令完成配置。

3.1 Python pip 配置

Windows 全局配置:

New-Item -ItemType Directory -Force -Path "$env:USERPROFILE\pip"
Set-Content -Path "$env:USERPROFILE\pip\pip.ini" -Value @"
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

[install]
trusted-host = mirrors.aliyun.com
"@ -Encoding UTF8
Write-Host "✓ pip 已配置为阿里云镜像"

Linux/Mac 全局配置:

mkdir -p ~/.pip
cat > ~/.pip/pip.conf \x3C\x3C 'EOF'
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

[install]
trusted-host = mirrors.aliyun.com
EOF
echo "✓ pip 已配置为阿里云镜像"

项目级配置(在项目根目录):

# 创建 .piprc 或 setup.cfg
cat > pip.conf \x3C\x3C 'EOF'
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
EOF
echo "✓ pip 项目级配置已完成"

验证:

pip config list

3.2 Node.js npm/yarn/pnpm 配置

全局配置:

# npm
npm config set registry https://registry.npmmirror.com

# yarn(如已安装)
yarn config set registry https://registry.npmmirror.com 2>/dev/null || true

# pnpm(如已安装)
pnpm config set registry https://registry.npmmirror.com 2>/dev/null || true

echo "✓ Node.js 包管理器已配置"

项目级配置(创建 .npmrc):

echo "registry=https://registry.npmmirror.com" > .npmrc
echo "✓ npm 项目级配置已完成"

验证:

npm config get registry

3.3 Rust cargo 配置

全局配置:

mkdir -p ~/.cargo
cat > ~/.cargo/config.toml \x3C\x3C 'EOF'
[source.crates-io]
replace-with = 'aliyun'

[source.aliyun]
registry = "https://mirrors.aliyun.com/crates.io-index/"
EOF
echo "✓ cargo 已配置为阿里云镜像"

验证:

cat ~/.cargo/config.toml

3.4 Go mod 配置

Windows PowerShell:

[Environment]::SetEnvironmentVariable("GOPROXY", "https://mirrors.aliyun.com/goproxy/,direct", "User")
$env:GOPROXY = "https://mirrors.aliyun.com/goproxy/,direct"
Write-Host "✓ Go GOPROXY 已配置"

Linux/Mac:

echo 'export GOPROXY=https://mirrors.aliyun.com/goproxy/,direct' >> ~/.bashrc
export GOPROXY=https://mirrors.aliyun.com/goproxy/,direct
echo "✓ Go GOPROXY 已配置"

验证:

go env GOPROXY

3.5 NuGet (.NET) 配置

Windows:

$nugetPath = "$env:APPDATA\NuGet"
New-Item -ItemType Directory -Force -Path $nugetPath
Set-Content -Path "$nugetPath\NuGet.Config" -Value @"
\x3C?xml version="1.0" encoding="utf-8"?>
\x3Cconfiguration>
  \x3CpackageSources>
    \x3Cclear />
    \x3Cadd key="huawei" value="https://repo.huaweicloud.com/repository/nuget/v3/index.json" />
    \x3Cadd key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  \x3C/packageSources>
\x3C/configuration>
"@ -Encoding UTF8
Write-Host "✓ NuGet 已配置为华为云镜像"

Linux/Mac:

mkdir -p ~/.nuget
cat > ~/.nuget/NuGet.Config \x3C\x3C 'EOF'
\x3C?xml version="1.0" encoding="utf-8"?>
\x3Cconfiguration>
  \x3CpackageSources>
    \x3Cclear />
    \x3Cadd key="huawei" value="https://repo.huaweicloud.com/repository/nuget/v3/index.json" />
    \x3Cadd key="nuget.org" value="https://api.nuget.org/v3/index.json" />
  \x3C/packageSources>
\x3C/configuration>
EOF
echo "✓ NuGet 已配置为华为云镜像"

验证:

dotnet nuget list source

3.6 RubyGems 配置

全局配置:

gem sources --remove https://rubygems.org/ 2>/dev/null || true
gem sources -a https://mirrors.tuna.tsinghua.edu.cn/rubygems/
echo "✓ RubyGems 已配置为清华镜像"

Bundler 项目级配置:

bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems/
echo "✓ Bundler 镜像已配置"

验证:

gem sources -l

3.7 Conda 配置

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --set show_channel_urls yes
echo "✓ Conda 已配置为清华镜像"

验证:

conda config --show channels

3.8 Maven 配置

mkdir -p ~/.m2
cat > ~/.m2/settings.xml \x3C\x3C 'EOF'
\x3C?xml version="1.0" encoding="UTF-8"?>
\x3Csettings>
  \x3Cmirrors>
    \x3Cmirror>
      \x3Cid>aliyun\x3C/id>
      \x3CmirrorOf>central\x3C/mirrorOf>
      \x3Cname>Aliyun Maven\x3C/name>
      \x3Curl>https://maven.aliyun.com/repository/public\x3C/url>
    \x3C/mirror>
  \x3C/mirrors>
\x3C/settings>
EOF
echo "✓ Maven 已配置为阿里云镜像"

3.9 Gradle 配置

方式一:环境变量

# 添加到 init.gradle 或环境变量
echo 'GRADLE_USER_HOME=~/.gradle' >> ~/.bashrc
mkdir -p ~/.gradle/init.d
cat > ~/.gradle/init.d/mirror.init.gradle \x3C\x3C 'EOF'
allprojects {
    repositories {
        all { ArtifactRepository repo ->
            if (repo instanceof MavenArtifactRepository) {
                def url = repo.url.toString()
                if (url.startsWith("https://repo.maven.apache.org/maven2") ||
                    url.startsWith("https://jcenter.bintray.com")) {
                    project.logger.lifecycle "Repository ${repo.url} replaced with Tencent mirror."
                    remove repo
                }
            }
        }
        maven { url 'https://mirrors.cloud.tencent.com/nexus/repository/maven-public/' }
        maven { url 'https://maven.aliyun.com/repository/public' }
        mavenCentral()
    }
}
EOF
echo "✓ Gradle 已配置"

方式二:项目级 settings.gradle

dependencyResolutionManagement {
    repositories {
        maven { url = uri('https://mirrors.cloud.tencent.com/gradle/') }
        mavenCentral()
    }
}

3.10 Homebrew 配置 (macOS)

export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc
echo "✓ Homebrew 已配置为中科大镜像"

3.11 Composer 配置 (PHP)

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
echo "✓ Composer 已配置为阿里云镜像"

Phase 4: 验证与反馈

4.1 执行验证命令

配置完成后,Agent 自动运行对应的验证命令(见各小节末尾),并向用户展示结果。

4.2 向用户报告

报告格式示例:
─────────────────────────────────────
✅ 配置完成!已为您配置以下镜像源:

  • pip (Python)     → 阿里云 ⚡ 0.02s
  • npm (Node.js)    → 华为云 ⚡ 0.04s  
  • cargo (Rust)     → 阿里云 ⚡ 0.05s

📋 下次操作建议:
  • 运行 pip install / npm install 测试速度
  • 如需恢复默认配置,请告知我
─────────────────────────────────────

常见问题处理(Agent 参考)

问题 解决方案
配置后仍然慢 清除缓存:pip cache purge / npm cache clean --force
SSL 证书错误 添加 trusted-host 配置(已在上述命令中包含)
权限不足 使用用户级配置(非系统级),避免 sudo
想恢复默认 删除对应配置文件或执行:npm config delete registry / unset GOPROXY
特定项目需要不同镜像 使用项目级配置(.npmrc / .piprc / .cargo/config.toml

恢复默认配置命令速查

包管理器 恢复命令
pip rm -f ~/.pip/pip.confdel %USERPROFILE%\pip\pip.ini
npm npm config delete registry
yarn yarn config delete registry
pnpm pnpm config delete registry
cargo rm -f ~/.cargo/config.toml
Go unset GOPROXY 并从 shell 配置文件中删除
NuGet 删除 %APPDATA%\NuGet\NuGet.Config
RubyGems gem sources --remove \x3Cmirror-url> 并添加回 https://rubygems.org/
Conda conda config --remove channels \x3Cmirror-url>
Homebrew unset HOMEBREW_BOTTLE_DOMAIN

Agent 执行规范

  1. 直接执行:不要创建脚本文件,直接运行 Shell 命令
  2. 幂等性:配置命令可重复执行,不会产生副作用
  3. 用户确认:修改前简要告知用户将要做什么
  4. 错误处理:如果某个工具未安装,跳过并告知用户
  5. 平台适配:自动检测操作系统,选择正确的命令格式(PowerShell vs Bash)
安全使用建议
This skill appears coherent and does what it says: it will detect language dependency files and write configuration entries or environment variables to your user or project files to point package managers at Chinese mirrors. Before allowing it to run: ensure the agent actually prompts you for the three confirmation questions it describes; review the exact commands it will run; back up existing config files (e.g., ~/.pip/pip.conf, ~/.npmrc, ~/.cargo/config.toml, ~/.bashrc, %APPDATA%/NuGet/NuGet.Config) in case you want to revert; prefer project-level changes over global changes if you only want the mirror applied to one repo; and verify the mirror URLs meet your security/policy requirements (corporate networks may restrict third-party registries). Lack of bundled code reduces install risk, but granting permission to execute file-modifying commands still changes your system — proceed only after review.
功能分析
Type: OpenClaw Skill Name: china-mirrors Version: 1.2.1 The 'china-mirrors' skill bundle provides instructions for an AI agent to configure domestic mirror sources for various package managers (pip, npm, cargo, go, etc.) to improve download speeds in China. The commands in SKILL.md are standard configuration tasks, such as setting registry URLs and environment variables, and use reputable mirrors from Aliyun, Huawei, and major Chinese universities. No evidence of data exfiltration, malicious execution, or unauthorized persistence was found.
能力评估
Purpose & Capability
Name/description match the actions: detecting dependency files and configuring mirror URLs for many package managers. The requested actions (writing config files, setting env vars) are what such a feature needs.
Instruction Scope
SKILL.md instructs the agent to detect project files and to run shell/PowerShell commands that edit user configuration files (home and project-level). This is expected for the stated purpose, but these are privileged local file writes — the document does state the agent should ask for confirmation first. Users should ensure the agent actually prompts and that they review commands before execution.
Install Mechanism
No install spec and no bundled code — lowest-risk delivery. The skill is instruction-only and does not download or install third-party binaries.
Credentials
No environment variables, credentials, or config paths are requested by the skill metadata. The SKILL.md uses local user paths (~, APPDATA) appropriately for per-user configuration.
Persistence & Privilege
always:false (not forced). The skill will modify user config files when executed, which is necessary for its purpose. Because the platform allows autonomous invocation by default, confirm the agent will follow the documented 'ask for confirmation' step before making changes.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install china-mirrors
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /china-mirrors 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.2.1
**Major update: Skill package now relies on dynamic runtime commands, with all static reference/scripts removed.** - 移除了所有自带文档与脚本(如 README、examples、测试脚本等),技能核心内容完全迁移至 SKILL.md 指南。 - 新版指南明确要求 Agent 按阶段动态检测需求、确认用户意图、执行配置,不再调用或生成任何本地/静态脚本。 - 所有主流包管理器的国内镜像源配置命令清单全部内嵌在 SKILL.md,并提供交互式确认与验证指引。 - 推荐镜像源表进行了简化和更新,操作步骤更加聚焦终端原生命令执行。 - Skill 类型及元数据(如 author、license)正式补全,结构化更规范。
v1.2.0
china-mirrors 1.2.0 - Bumped version to 1.2.0 (from 1.1.1) in manifest. - No other changes detected.
v1.1.0
china-mirrors 1.1.0 - 全面更新和扩展文档,新增中文分步详细配置指南及常见包管理器的国内镜像源推荐列表。 - 增加 2026 年镜像测速数据,按速度推荐阿里云、清华、华为云等源,并列出具体测速结果。 - 覆盖 pip、npm、yarn、pnpm、cargo、go mod、NuGet、RubyGems、conda、Homebrew、Gradle、Maven、Composer 等多种包管理器。 - 新增典型使用场景和自动/主动建议触发条件说明,包括依赖文件检测和常见“下载慢”等需求描述。 - 增加详细分步配置方法(全局、项目级、临时)、配置验证指令和恢复/排错说明,提升易用性和针对性。
元数据
Slug china-mirrors
版本 1.2.1
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 3
常见问题

China Mirrors 是什么?

自动配置 Python pip、npm、yarn、pnpm、cargo、go mod、NuGet、RubyGems、Conda、Homebrew、Gradle 等包管理器的国内镜像源。使用当用户提到下载慢、安装依赖、配置镜像、加速包下载、设置国内源,或在中国大陆开发需要加速依赖安装时。支持阿里云、腾讯云、清华大学... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 135 次。

如何安装 China Mirrors?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install china-mirrors」即可一键安装,无需额外配置。

China Mirrors 是免费的吗?

是的,China Mirrors 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

China Mirrors 支持哪些平台?

China Mirrors 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 China Mirrors?

由 NormDist(@normdist-ai)开发并维护,当前版本 v1.2.1。

💬 留言讨论