Bootstrap China Network Environment
One-stop configuration and diagnostics for all development tools in China. Diagnose first, then apply fixes.
All setup scripts are bundled under this skill's scripts/ directory as resources — they are not loaded into context but invoked via bash.
Steps
1. Determine SKILL_DIR
All script paths are relative to this skill's directory:
SKILL_DIR="<absolute path to skills/bootstrap-china-network>"
Use the directory where this SKILL.md resides.
2. Diagnose (if user wants diagnostics or troubleshooting)
If the user wants to diagnose their environment, check what's configured, or understand why things are slow:
bash "$SKILL_DIR/scripts/diagnose.sh"
This will:
- - Collect system info and detect proxy conflicts
- Scan installed development tools and their mirror configurations
- Test connectivity to official sources and Chinese mirrors (with timing)
- Output structured recommendations (HIGH/MEDIUM/LOW priority)
After diagnostics, review the recommendations and offer to apply fixes for unconfigured tools.
3. Quick environment scan (for direct configuration)
CODEBLOCK2
4. Check for proxy conflicts
If HTTP_PROXY or HTTPS_PROXY is set, warn the user:
Proxy environment variables are set. In China, using a VPN/proxy alongside mirrors can cause conflicts. Consider: INLINECODE3
5. Apply mirror configurations
For each detected tool, run the corresponding script. Ask the user for preferences or use sensible defaults:
| Tool | Script (relative to SKILL_DIR) | Default Mirror |
|---|
| pip/uv/poetry | INLINECODE4 | tuna |
| npm/yarn/pnpm |
scripts/node/setup.sh | npmmirror |
| APT (Ubuntu/Debian) |
sudo scripts/apt/setup.sh | tuna |
| Docker CE + Hub |
sudo scripts/docker/setup.sh | tuna |
| Homebrew |
scripts/homebrew/setup.sh | tuna |
| Conda/Anaconda |
scripts/conda/setup.sh | tuna |
| Cargo/Rust |
scripts/rust/setup.sh | ustc |
| Go modules |
scripts/go/setup.sh | goproxy |
| Flutter/Dart |
scripts/flutter/setup.sh | tuna |
| GitHub Releases/Clone |
scripts/github/setup.sh | tuna (支持
--proxy-clone 全局加速 clone) |
All scripts support these flags:
- -
-m / --mirror <name> — choose mirror source - INLINECODE16 — force overwrite
- INLINECODE17 — preview changes without applying
- INLINECODE18 — skip confirmation prompts
Run scripts for detected tools. Each script is idempotent — safe to run multiple times.
Example:
CODEBLOCK3
6. Verify configurations
After applying, run a quick verification for each configured tool:
CODEBLOCK4
7. Provide summary
Report:
- - What was configured (tool -> mirror URL)
- Any warnings (proxy conflicts, permission issues, tool not found)
- How to restore: INLINECODE19
Dry Run
If the user wants to preview changes first, add --dry-run to each script:
CODEBLOCK5
Backup & Restore
Backups are stored in ~/.china-mirror-backup/.
CODEBLOCK6
技能名称: bootstrap-china-network
详细描述:
中国网络环境引导配置
针对中国境内所有开发工具的一站式配置与诊断。先诊断,再修复。
所有设置脚本均作为资源打包在此技能的 scripts/ 目录下——它们不会加载到上下文中,而是通过 bash 调用。
步骤
1. 确定 SKILL_DIR
所有脚本路径均相对于此技能目录:
bash
SKILL_DIR=
使用此 SKILL.md 文件所在的目录。
2. 诊断(如果用户需要诊断或故障排查)
如果用户想要诊断其环境、检查已配置的内容,或了解为何运行缓慢:
bash
bash $SKILL_DIR/scripts/diagnose.sh
此操作将:
- - 收集系统信息并检测代理冲突
- 扫描已安装的开发工具及其镜像配置
- 测试到官方源和中国镜像的连接(含计时)
- 输出结构化建议(高/中/低优先级)
诊断后,查看建议并提供为未配置工具应用修复的选项。
3. 快速环境扫描(用于直接配置)
bash
检测已安装的工具
for tool in pip uv npm yarn pnpm docker cargo go conda flutter brew; do
which $tool 2>/dev/null && echo ✓ $tool || true
done
检查代理冲突
[[ -n $HTTP
PROXY$HTTPSPROXY$http
proxy$httpsproxy ]] && echo ⚠️ 检测到代理
4. 检查代理冲突
如果设置了 HTTPPROXY 或 HTTPSPROXY,请警告用户:
代理环境变量已设置。在中国,将 VPN/代理与镜像一起使用可能会导致冲突。请考虑:unset httpproxy httpsproxy HTTPPROXY HTTPSPROXY
5. 应用镜像配置
对于每个检测到的工具,运行相应的脚本。询问用户偏好或使用合理的默认值:
| 工具 | 脚本(相对于 SKILL_DIR) | 默认镜像 |
|---|
| pip/uv/poetry | scripts/python/setup.sh | tuna |
| npm/yarn/pnpm |
scripts/node/setup.sh | npmmirror |
| APT(Ubuntu/Debian) | sudo scripts/apt/setup.sh | tuna |
| Docker CE + Hub | sudo scripts/docker/setup.sh | tuna |
| Homebrew | scripts/homebrew/setup.sh | tuna |
| Conda/Anaconda | scripts/conda/setup.sh | tuna |
| Cargo/Rust | scripts/rust/setup.sh | ustc |
| Go 模块 | scripts/go/setup.sh | goproxy |
| Flutter/Dart | scripts/flutter/setup.sh | tuna |
| GitHub Releases/Clone | scripts/github/setup.sh | tuna(支持 --proxy-clone 全局加速 clone) |
所有脚本均支持以下标志:
- - -m / --mirror <名称> — 选择镜像源
- -f / --force — 强制覆盖
- -d / --dry-run — 预览更改而不应用
- -y / --yes — 跳过确认提示
为检测到的工具运行脚本。每个脚本都是幂等的——多次运行是安全的。
示例:
bash
bash $SKILL_DIR/scripts/python/setup.sh --mirror tuna
bash $SKILL_DIR/scripts/node/setup.sh --mirror npmmirror
sudo bash $SKILL_DIR/scripts/apt/setup.sh --mirror tuna
6. 验证配置
应用后,对每个配置的工具进行快速验证:
bash
pip config get global.index-url 2>/dev/null
npm config get registry 2>/dev/null
go env GOPROXY 2>/dev/null
cat ~/.cargo/config.toml 2>/dev/null | grep index
7. 提供摘要
报告:
- - 已配置的内容(工具 -> 镜像 URL)
- 任何警告(代理冲突、权限问题、未找到工具)
- 如何恢复:bash $SKILLDIR/scripts/restoreconfig.sh --tool <名称> --latest
试运行
如果用户想先预览更改,请在每个脚本中添加 --dry-run:
bash
bash $SKILL_DIR/scripts/python/setup.sh --dry-run
bash $SKILL_DIR/scripts/node/setup.sh --dry-run
备份与恢复
备份存储在 ~/.china-mirror-backup/ 中。
bash
备份所有工具配置
bash $SKILL
DIR/scripts/backupconfig.sh --all
备份特定工具
bash $SKILL
DIR/scripts/backupconfig.sh --tool pip
恢复工具的最新备份
bash $SKILL
DIR/scripts/restoreconfig.sh --tool pip --latest
列出所有备份
bash $SKILL
DIR/scripts/restoreconfig.sh --list