cn-coding-mirrors 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,158 @@
1
+ #!/usr/bin/env bash
2
+ # check-mirrors.sh —— 实时探测技能里引用的所有国内镜像源,输出可用性表。
3
+ #
4
+ # ./scripts/check-mirrors.sh # 终端表格(人类看)
5
+ # ./scripts/check-mirrors.sh --md # Markdown 表格(可粘进文档)
6
+ # ./scripts/check-mirrors.sh --json # JSON(给脚本/CI 用)
7
+ # ./scripts/check-mirrors.sh --write # 覆盖写 MIRRORS-STATUS.md
8
+ # ./scripts/check-mirrors.sh --strict # 任何"关键源"失败 → 退出码 1(CI 用)
9
+ # ./scripts/check-mirrors.sh -t 8 -j 16 # 单源超时 8s、并发 16
10
+ #
11
+ # 探测方式是"取 1 KB 真实资源"(-r 0-1023),比 HEAD 更能反映真实可用性。
12
+ # 退出码:0 正常;1 表示 --strict 下有关键源不可用。
13
+ set -uo pipefail
14
+
15
+ TIMEOUT=10
16
+ JOBS=16
17
+ MODE="table"
18
+ WRITE=0
19
+ STRICT=0
20
+
21
+ while [ $# -gt 0 ]; do
22
+ case "$1" in
23
+ --md) MODE="md"; shift ;;
24
+ --json) MODE="json"; shift ;;
25
+ --write) WRITE=1; shift ;;
26
+ --strict) STRICT=1; shift ;;
27
+ -t|--timeout) TIMEOUT="${2:?}"; shift 2 ;;
28
+ -j|--jobs) JOBS="${2:?}"; shift 2 ;;
29
+ -h|--help) sed -n '2,14p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
30
+ *) echo "未知参数: $1" >&2; exit 2 ;;
31
+ esac
32
+ done
33
+
34
+ # 关键源标记 *:这些挂了说明该生态在国内基本没得用(用于 --strict)
35
+ # 格式:生态|标记|名称|探测 URL
36
+ CHECKS=$(cat <<'EOF'
37
+ Python|*|tuna pypi|https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/requests/
38
+ Python| |aliyun pypi|https://mirrors.aliyun.com/pypi/simple/requests/
39
+ Python| |tencent pypi|https://mirrors.cloud.tencent.com/pypi/simple/requests/
40
+ Python| |ustc pypi|https://mirrors.ustc.edu.cn/pypi/simple/requests/
41
+ Python| |huawei pypi|https://mirrors.huaweicloud.com/repository/pypi/simple/requests/
42
+ Node|*|npmmirror registry|https://registry.npmmirror.com/react
43
+ Node| |npmmirror node bin|https://npmmirror.com/mirrors/node/index.json
44
+ Node| |npmmirror electron|https://npmmirror.com/mirrors/electron/
45
+ Java|*|aliyun maven|https://maven.aliyun.com/repository/public/org/slf4j/slf4j-api/2.0.13/slf4j-api-2.0.13.pom
46
+ Java| |huawei maven|https://repo.huaweicloud.com/repository/maven/org/slf4j/slf4j-api/2.0.13/slf4j-api-2.0.13.pom
47
+ Java| |tencent maven|https://mirrors.cloud.tencent.com/nexus/repository/maven-public/org/slf4j/slf4j-api/2.0.13/slf4j-api-2.0.13.pom
48
+ Go|*|goproxy.cn|https://goproxy.cn/github.com/pkg/errors/@v/list
49
+ Go| |aliyun goproxy|https://mirrors.aliyun.com/goproxy/github.com/pkg/errors/@v/list
50
+ Rust|*|rsproxy sparse|https://rsproxy.cn/index/se/rd/serde
51
+ Rust| |tuna crates|https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/config.json
52
+ AI|*|hf-mirror|https://hf-mirror.com/api/models/bert-base-chinese
53
+ AI| |modelscope|https://www.modelscope.cn/api/v1/models/Qwen/Qwen2.5-7B-Instruct
54
+ AI| |aliyun pytorch|https://mirrors.aliyun.com/pytorch-wheels/cpu/
55
+ Docker|*|ghcr nju|https://ghcr.nju.edu.cn/v2/
56
+ Docker| |ghcr daocloud|https://ghcr.m.daocloud.io/v2/
57
+ Docker| |docker daocloud|https://docker.m.daocloud.io/v2/
58
+ Docker| |docker 1panel|https://docker.1panel.live/v2/
59
+ Docker| |k8s daocloud|https://k8s.m.daocloud.io/v2/
60
+ GitHub|*|ghproxy.net|https://ghproxy.net/https://github.com/sharkdp/fd/releases/download/v10.5.2/fd-v10.5.2-x86_64-unknown-linux-gnu.tar.gz
61
+ GitHub| |ghfast.top|https://ghfast.top/https://github.com/sharkdp/fd/releases/download/v10.5.2/fd-v10.5.2-x86_64-unknown-linux-gnu.tar.gz
62
+ GitHub| |gh-proxy.com|https://gh-proxy.com/https://github.com/sharkdp/fd/releases/download/v10.5.2/fd-v10.5.2-x86_64-unknown-linux-gnu.tar.gz
63
+ GitHub| |api.github.com|https://api.github.com/repos/sharkdp/fd
64
+ 系统| |tuna ubuntu|https://mirrors.tuna.tsinghua.edu.cn/ubuntu/dists/jammy/Release
65
+ 系统| |aliyun ubuntu|https://mirrors.aliyun.com/ubuntu/dists/jammy/Release
66
+ 系统| |ustc ubuntu|https://mirrors.ustc.edu.cn/ubuntu/dists/jammy/Release
67
+ 系统| |huawei ubuntu|https://repo.huaweicloud.com/ubuntu/dists/jammy/Release
68
+ Conda| |tuna anaconda|https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch/repodata.json
69
+ 其他| |flutter pub|https://pub.flutter-io.cn/api/packages/http
70
+ 其他| |aliyun composer|https://mirrors.aliyun.com/composer/packages.json
71
+ 其他| |huawei nuget|https://mirrors.huaweicloud.com/repository/nuget/v3/index.json
72
+ 其他| |tuna cran|https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/contrib/PACKAGES
73
+ 其他| |tuna rubygems|https://mirrors.tuna.tsinghua.edu.cn/rubygems/specs.4.8.gz
74
+ 其他| |huawei helm|https://mirrors.huaweicloud.com/helm/v3.16.2/
75
+ EOF
76
+ )
77
+
78
+ TMPD=$(mktemp -d)
79
+ trap 'rm -rf "$TMPD"' EXIT
80
+
81
+ probe_one() {
82
+ local idx="$1" line="$2"
83
+ local eco mark name url
84
+ IFS='|' read -r eco mark name url <<<"$line"
85
+ local out code t
86
+ out=$(curl -sS -L -r 0-1023 --connect-timeout "$TIMEOUT" --max-time "$TIMEOUT" \
87
+ -o /dev/null -w '%{http_code} %{time_total}' "$url" 2>/dev/null) || true
88
+ code="${out%% *}"; t="${out##* }"
89
+ [ -z "$code" ] && code="000"
90
+ local status
91
+ case "$code" in
92
+ 2*|3*) status="OK" ;;
93
+ 401|403) status="AUTH" ;;
94
+ 404) status="404" ;;
95
+ 000|"") status="FAIL" ;;
96
+ *) status="HTTP$code" ;;
97
+ esac
98
+ if [ "$status" = "OK" ] && awk -v t="${t:-0}" 'BEGIN{exit !(t>3)}'; then status="SLOW"; fi
99
+ printf '%s\t%s\t%s\t%s\t%s\t%s\n' "$eco" "$mark" "$name" "$status" "$code" "${t:-0}" > "$TMPD/$idx"
100
+ }
101
+
102
+ i=0
103
+ while IFS= read -r line; do
104
+ [ -z "$line" ] && continue
105
+ i=$((i + 1))
106
+ probe_one "$i" "$line" &
107
+ while [ "$(jobs -rp | wc -l)" -ge "$JOBS" ]; do wait -n 2>/dev/null || true; done
108
+ done <<<"$CHECKS"
109
+ wait
110
+
111
+ RESULTS="$TMPD/all.tsv"
112
+ : > "$RESULTS"
113
+ for f in $(ls "$TMPD" | grep -E '^[0-9]+$' | sort -n); do cat "$TMPD/$f" >> "$RESULTS"; done
114
+
115
+ total=$(wc -l < "$RESULTS")
116
+ ok=$(awk -F'\t' '$4=="OK"' "$RESULTS" | wc -l)
117
+ degraded=$(awk -F'\t' '$4=="SLOW"||$4=="AUTH"' "$RESULTS" | wc -l)
118
+ bad=$(awk -F'\t' '$4!="OK"&&$4!="SLOW"&&$4!="AUTH"' "$RESULTS" | wc -l)
119
+ critical_bad=$(awk -F'\t' '$4!="OK"&&$4!="SLOW"&&$4!="AUTH"&&$2=="*"' "$RESULTS" | wc -l)
120
+ stamp=$(date -u '+%Y-%m-%d %H:%M UTC')
121
+
122
+ emit_md() {
123
+ echo "# 镜像源实时可用性"
124
+ echo
125
+ echo "> 由 \`scripts/check-mirrors.sh --write\` 生成,勿手改。上次探测:**$stamp**"
126
+ echo "> 共 $total 项:**OK $ok** · 降级(SLOW/AUTH) $degraded · 不可用 $bad"
127
+ echo
128
+ echo "| 生态 | 源 | 状态 | HTTP | 耗时(s) |"
129
+ echo "|---|---|---|---|---|"
130
+ awk -F'\t' '{printf "| %s | %s%s | %s | %s | %s |\n", $1, ($2=="*"?"**":""), $3 ($2=="*"?"**":""), $4, $5, $6}' "$RESULTS"
131
+ echo
132
+ echo '图例:`OK` 正常 · `SLOW` >3s · `AUTH` 401/403(可达但需鉴权)· `404` 路径变更 · `FAIL` 超时/连不上。加粗为关键源。'
133
+ }
134
+
135
+ case "$MODE" in
136
+ table)
137
+ printf '%-8s %-24s %-6s %-5s %s\n' "生态" "源" "状态" "HTTP" "耗时s"
138
+ awk -F'\t' '{printf "%-8s %-24s %-6s %-5s %s\n", $1, $3, $4, $5, $6}' "$RESULTS"
139
+ printf '\n共 %s 项:OK %s · 降级 %s · 不可用 %s(探测时间 %s)\n' "$total" "$ok" "$degraded" "$bad" "$stamp"
140
+ ;;
141
+ md)
142
+ emit_md
143
+ ;;
144
+ json)
145
+ awk -F'\t' 'BEGIN{printf "["} {printf "%s{\"ecosystem\":\"%s\",\"critical\":%s,\"name\":\"%s\",\"status\":\"%s\",\"http\":\"%s\",\"seconds\":%s}", (NR>1?",":""), $1, ($2=="*"?"true":"false"), $3, $4, $5, $6} END{print "]"}' "$RESULTS"
146
+ ;;
147
+ esac
148
+
149
+ if [ "$WRITE" = 1 ]; then
150
+ emit_md > "$(cd "$(dirname "$0")/.." && pwd)/MIRRORS-STATUS.md"
151
+ [ "$MODE" = "table" ] && echo "已写入 MIRRORS-STATUS.md"
152
+ fi
153
+
154
+ if [ "$STRICT" = 1 ] && [ "$critical_bad" -gt 0 ]; then
155
+ echo "strict: $critical_bad 个关键源不可用" >&2
156
+ exit 1
157
+ fi
158
+ exit 0
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env bash
2
+ # 把 skills/ 下的技能安装到任意"Agent Skills"兼容目录。
3
+ #
4
+ # ./scripts/install.sh # 默认 ~/.agents/skills(跨智能体通用位置)
5
+ # ./scripts/install.sh ~/.claude/skills
6
+ # ./scripts/install.sh .agents/skills # 项目级
7
+ # ./scripts/install.sh --copy PATH # 复制而不是软链(发布/分享场景)
8
+ #
9
+ # 兼容:Pi / Pi-Bolt(~/.pi/agent/skills)、Claude Code、Codex 等实现 agentskills.io 规范的工具。
10
+ set -euo pipefail
11
+
12
+ MODE="link"
13
+ if [ "${1:-}" = "--copy" ]; then MODE="copy"; shift; fi
14
+ DEST="${1:-$HOME/.agents/skills}"
15
+ SRC="$(cd "$(dirname "$0")/.." && pwd)/skills"
16
+
17
+ [ -d "$SRC" ] || { echo "找不到 $SRC" >&2; exit 1; }
18
+ mkdir -p "$DEST"
19
+
20
+ for d in "$SRC"/*/; do
21
+ name="$(basename "$d")"
22
+ target="$DEST/$name"
23
+ if [ -e "$target" ] || [ -L "$target" ]; then
24
+ rm -rf "$target"
25
+ fi
26
+ if [ "$MODE" = "copy" ]; then
27
+ cp -r "$d" "$target"
28
+ echo "复制 $name -> $target"
29
+ else
30
+ ln -s "${d%/}" "$target"
31
+ echo "软链 $name -> $target"
32
+ fi
33
+ chmod +x "$target"/scripts/* 2>/dev/null || true
34
+ done
35
+
36
+ echo
37
+ echo "完成。已安装到 $DEST"
38
+ echo "Pi/Pi-Bolt 用户若想用 user skills 目录,可再执行:"
39
+ echo " $0 \"$HOME/.pi/agent/skills\""
@@ -0,0 +1,58 @@
1
+ ---
2
+ name: cn-coding-mirrors
3
+ description: 中国网络环境下的下载与镜像配置速查:pip/uv、npm/yarn/pnpm、maven/gradle、Go GOPROXY、cargo/rustup、apt/apk/brew、conda、HuggingFace/ModelScope、PyTorch wheels、Flutter、Composer、NuGet、CRAN 等。当包管理器下载极慢、超时、TLS 重置,或需要"改用国内源/换镜像/配代理"时使用。Use when installs are slow or failing in mainland China and you need the right domestic mirror endpoint or config command.
4
+ license: MIT
5
+ compatibility: 需要 curl;各生态的命令行工具按需(pip/uv/npm/mvn/cargo 等)。写系统级配置通常需要 sudo 或用户级配置文件。
6
+ metadata:
7
+ author: cn-coding-mirrors
8
+ scope: china-network
9
+ ---
10
+
11
+ # 国内镜像配置总入口
12
+
13
+ **不要凭记忆猜镜像地址**:先按下面的流程定位生态,再打开对应的 reference 文件,里面是最小可用的配置片段。
14
+
15
+ ## 使用流程
16
+
17
+ 1. 判断生态:Python / Node / Java / Go / Rust / 系统包 / AI 模型与权重 / 容器镜像 / VCS。
18
+ 2. 打开 `references/<生态>.md`,复制对应配置。
19
+ 3. 配置完**验证一次**(每个 reference 底部都有验证命令),把结果告诉用户。
20
+ 4. 需要"下载单个文件 / 拉镜像"这类非包管理器场景,别在本技能里硬写 curl,改用:
21
+ - GitHub release/资产 → 技能 `gh-download`(`scripts/ghdl`)
22
+ - Docker/OCI 镜像 → 技能 `docker-pull`(`scripts/dpull`)
23
+
24
+ ## Reference 索引
25
+
26
+ | 生态 | 文件 | 覆盖 |
27
+ |---|---|---|
28
+ | Python | `references/python.md` | pip、uv、poetry/pdm、conda |
29
+ | Node/JS | `references/node.md` | npm/yarn/pnpm、node 二进制、electron/sass/puppeteer |
30
+ | Java | `references/java.md` | maven、gradle、spring/sbt |
31
+ | Go | `references/go.md` | GOPROXY、sumdb |
32
+ | Rust | `references/rust.md` | cargo sparse index、rustup |
33
+ | 系统包 | `references/system.md` | apt/Ubuntu、apk/alpine、dnf/centos、brew |
34
+ | AI | `references/ai.md` | HuggingFace、ModelScope、PyTorch wheels、tiktoken 等 |
35
+ | 其他语言 | `references/misc.md` | Flutter/Dart、Composer/PHP、NuGet/.NET、CRAN/R、RubyGems、Helm |
36
+ | 容器镜像 | `references/docker.md` | registry 镜像源、`dpull` 用法 |
37
+ | 版本控制 | `references/vcs.md` | GitHub 代理、git 加速、Mercurial(hg)/SVN |
38
+
39
+ ## 源不可用时:先做实时探测
40
+
41
+ 不要凭猜测换源。技能自带探测脚本(相对本 SKILL.md 所在目录)会并发检查 38 个端点:
42
+
43
+ ```bash
44
+ bash ../../scripts/check-mirrors.sh # 表格
45
+ bash ../../scripts/check-mirrors.sh --json # 机器可读
46
+ ```
47
+
48
+ 按结果选择:优先用状态 `OK`、耗时低的源;`AUTH`(401/403) 说明可达但需登录,别当故障;
49
+ `404` 通常是路径变更,更新 reference 里的地址。同一个生态**至多试两个源**,还不行就报告
50
+ "该生态的国内镜像当前均不可用,建议配代理或稍后重试",不要把重试循环留给用户等。
51
+
52
+ ## 通用原则
53
+
54
+ - **优先用户级配置**(`~/.npmrc`、`~/.pip/pip.conf`、`~/.cargo/config.toml`),避免动系统文件;必须动系统文件时明确告知用户需要 sudo。
55
+ - **一次只改一个源**,改完立即验证;失败就回退到上一个可用源,别叠加多层配置。
56
+ - 镜像站会挂(403/429/超时),**永远准备 2–3 个备选**,reference 里已按优先级排好。
57
+ - 不要用 `curl | sh` 之类的安装脚本"顺手"改配置;显式写配置文件,用户可审计、可回滚。
58
+ - 报告结果时说清:改了哪个文件、原内容是否备份、验证命令与输出。
@@ -0,0 +1,65 @@
1
+ # AI 模型与权重(HuggingFace / ModelScope / PyTorch)
2
+
3
+ ## HuggingFace:hf-mirror.com(最常用)
4
+
5
+ ```bash
6
+ # 最省事:只改环境变量,huggingface_hub / transformers / diffusers 全部生效
7
+ export HF_ENDPOINT="https://hf-mirror.com"
8
+ ```
9
+
10
+ 持久化写到 `~/.bashrc` 或 `~/.config/huggingface/huggingface.toml`(新版 hub 支持 `endpoint = ...`)。
11
+
12
+ ```bash
13
+ # 下载单个仓库
14
+ hf download <repo_id> --repo-type model # 新版 CLI(huggingface_hub>=0.24)
15
+ huggingface-cli download <repo_id> --resume # 旧版
16
+ hugging-cli download <repo_id> # hf-mirror 自带的极简 CLI
17
+
18
+ # 代码里
19
+ import os
20
+ os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
21
+ from huggingface_hub import snapshot_download
22
+ snapshot_download("bert-base-chinese")
23
+ ```
24
+
25
+ 要点:
26
+ - `HF_ENDPOINT` 必须**在 import transformers/huggingface_hub 之前**设置。
27
+ - 大文件用 `resume`/断点续传;`hf-mirror` 支持 Range,中断后重跑即可续。
28
+ - 私有仓库/gated 模型仍需 `HF_TOKEN`;镜像不绕过授权。
29
+ - 备选:`https://hf-mirror.com` 为唯一成熟公共镜像;再不通就走代理 `HF_ENDPOINT` 保留官方 + `HTTPS_PROXY`。
30
+
31
+ ## ModelScope(国内权重源,常与 HF 互为备份)
32
+
33
+ ```bash
34
+ pip install modelscope -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
35
+ modelscope download --model Qwen/Qwen2.5-7B-Instruct --local_dir ./qwen
36
+ ```
37
+
38
+ ## PyTorch wheels(`download.pytorch.org` 国内慢)
39
+
40
+ ```bash
41
+ # 阿里云 wheel 镜像
42
+ pip install torch torchvision torchaudio \
43
+ --index-url https://mirrors.aliyun.com/pytorch-wheels/cu121
44
+ # CPU 版
45
+ pip install torch --index-url https://mirrors.aliyun.com/pytorch-wheels/cpu
46
+ ```
47
+
48
+ ## 其他常见卡点
49
+
50
+ ```bash
51
+ export TIKTOKEN_CACHE_DIR="$HOME/.cache/tiktoken" # 避免每次下载 BPE 文件
52
+ export HF_HUB_ENABLE_HF_TRANSFER=0 # hf_transfer 在国内常失败,先关掉
53
+ export TRANSFORMERS_OFFLINE=1 # 权重已就位、只想跑推理时
54
+ export OLLAMA_HOST="https://ollama.example.com" # ollama 拉模型仍走 registry
55
+ ```
56
+
57
+ Ollama 拉模型走 Docker Hub 风格 registry,卡住时用技能 `docker-pull` 的思路或配代理。
58
+
59
+ ## 验证
60
+
61
+ ```bash
62
+ curl -sI -m 8 https://hf-mirror.com/api/models/bert-base-chinese | head -1
63
+ HF_ENDPOINT=https://hf-mirror.com python -c "
64
+ from huggingface_hub import model_info; print(model_info('bert-base-chinese').modelId)"
65
+ ```
@@ -0,0 +1,48 @@
1
+ # 容器镜像(registry 镜像源与 dpull)
2
+
3
+ ## 优先方案:不用 `docker pull`,用 `dpull`
4
+
5
+ `docker pull` 在 ghcr.io / docker.io 上常被限速到几十 KB/s(实测 ghcr.io 单连接 ~70 KB/s)。
6
+ 技能 `docker-pull` 提供的 `scripts/dpull` 按 registry v2 协议分片下载 layer,走国内镜像源并校验 sha256,
7
+ 1.38 GB 镜像约 155 秒完成:
8
+
9
+ ```bash
10
+ python3 <this-skill-dir>/../docker-pull/scripts/dpull ghcr.io/usestrix/strix-sandbox:1.3.0
11
+ ```
12
+
13
+ ## 兜底方案:daemon 级 registry mirror
14
+
15
+ `/etc/docker/daemon.json`(需要 sudo + 重启 dockerd;且多数公共加速器已要求登录/已停服,成功率不稳定):
16
+
17
+ ```json
18
+ {
19
+ "registry-mirrors": [
20
+ "https://docker.m.daocloud.io",
21
+ "https://docker.1panel.live",
22
+ "https://hub.rat.dev"
23
+ ]
24
+ }
25
+ ```
26
+
27
+ ```bash
28
+ sudo systemctl restart docker && docker info | grep -A3 "Registry Mirrors"
29
+ ```
30
+
31
+ 分 registry 的镜像源(路径不变,替换 host 即可):
32
+
33
+ | 官方 | 国内镜像 |
34
+ |---|---|
35
+ | `docker.io` | `docker.m.daocloud.io`、`docker.1panel.live`、`hub.rat.dev` |
36
+ | `ghcr.io` | `ghcr.nju.edu.cn`(最稳)、`ghcr.m.daocloud.io`(常 403) |
37
+ | `gcr.io` / `registry.k8s.io` | `gcr.m.daocloud.io` / `k8s.m.daocloud.io` |
38
+ | `quay.io` | `quay.m.daocloud.io` |
39
+
40
+ 实测(2025,本机):`ghcr.nju.edu.cn` 单连接 4.9 MB/s、16 分片并发约 15 MB/s;
41
+ `ghcr.io` 直连 0.07 MB/s;`ghcr.m.daocloud.io` 对私有镜像返回 403。
42
+
43
+ ## 验证
44
+
45
+ ```bash
46
+ docker info | grep -A3 "Registry Mirrors"
47
+ time curl -sI -m 10 https://ghcr.nju.edu.cn/v2/ | head -1
48
+ ```
@@ -0,0 +1,34 @@
1
+ # Go(GOPROXY)
2
+
3
+ ```bash
4
+ # 写进 ~/.bashrc / ~/.zshrc(用户级,立即生效)
5
+ export GOPROXY="https://goproxy.cn,direct"
6
+ export GOSUMDB="sum.golang.org" # 或 off(不建议)
7
+ export GOPRIVATE="" # 私有仓库域名,逗号分隔,如 git.corp.com
8
+ ```
9
+
10
+ 备选(按顺位):
11
+
12
+ | 源 | URL |
13
+ |---|---|
14
+ | 七牛 | `https://goproxy.cn` |
15
+ | 阿里云 | `https://mirrors.aliyun.com/goproxy/` |
16
+ | 官方镜像 | `https://goproxy.io` |
17
+ | 腾讯云 | `https://mirrors.cloud.tencent.com/goproxy/` |
18
+
19
+ 持久化:`go env -w GOPROXY=https://goproxy.cn,direct`(写入 `$GOENV`,比 shell 变量更稳)。
20
+
21
+ ```bash
22
+ # 私有模块 + 公共代理共存
23
+ go env -w GOPROXY="https://goproxy.cn,direct"
24
+ go env -w GOPRIVATE="*.corp.example.com"
25
+ go env -w GONOSUMDB="*.corp.example.com"
26
+ ```
27
+
28
+ ## 验证
29
+
30
+ ```bash
31
+ go env GOPROXY
32
+ GOPROXY=https://goproxy.cn GONOSUMDB=* go install golang.org/x/tools/cmd/stringer@latest && echo go-ok
33
+ curl -sI -m 8 https://goproxy.cn/golang.org/x/text/@v/list | head -1
34
+ ```
@@ -0,0 +1,69 @@
1
+ # Java(maven、gradle、sbt)
2
+
3
+ ## maven
4
+
5
+ `~/.m2/settings.xml`(用户级,不需要 sudo):
6
+
7
+ ```xml
8
+ <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0">
9
+ <mirrors>
10
+ <mirror>
11
+ <id>aliyun-public</id>
12
+ <mirrorOf>central</mirrorOf>
13
+ <name>Aliyun Public</name>
14
+ <url>https://maven.aliyun.com/repository/public</url>
15
+ </mirror>
16
+ </mirrors>
17
+ </settings>
18
+ ```
19
+
20
+ 备选(按顺位):
21
+
22
+ | 源 | URL |
23
+ |---|---|
24
+ | 阿里云 | `https://maven.aliyun.com/repository/public` |
25
+ | 华为云 | `https://repo.huaweicloud.com/repository/maven/` |
26
+ | 腾讯云 | `https://mirrors.cloud.tencent.com/nexus/repository/maven-public/` |
27
+ | 中央仓库 | `https://repo1.maven.org/maven2` |
28
+
29
+ 需要 `plugin`/`google` 等仓库时,`<mirrorOf>*</mirrorOf>` 一把梭(会丢失细分仓库差异,可能引入解析差异,慎用)。
30
+
31
+ ## gradle
32
+
33
+ `~/.gradle/init.gradle`(全局生效,不污染项目):
34
+
35
+ ```groovy
36
+ allprojects {
37
+ repositories {
38
+ maven { url 'https://maven.aliyun.com/repository/public' }
39
+ maven { url 'https://maven.aliyun.com/repository/google' }
40
+ maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
41
+ mavenCentral()
42
+ }
43
+ }
44
+ ```
45
+
46
+ 或 `gradle.properties`:
47
+
48
+ ```properties
49
+ org.gradle.internal.repository.max.retries=5
50
+ systemProp.org.gradle.internal.http.connectionTimeout=60000
51
+ ```
52
+
53
+ ## sbt
54
+
55
+ `~/.sbt/repositories`:
56
+
57
+ ```properties
58
+ [repositories]
59
+ local
60
+ aliyun: https://maven.aliyun.com/repository/public
61
+ typesafe: https://repo.typesafe.com/typesafe/ivy-releases/,[organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
62
+ ```
63
+
64
+ ## 验证
65
+
66
+ ```bash
67
+ mvn -q dependency:get -Dartifact=org.slf4j:slf4j-api:2.0.13 && echo maven-ok
68
+ curl -sI -m 8 https://maven.aliyun.com/repository/public/org/slf4j/slf4j-api/2.0.13/slf4j-api-2.0.13.pom | head -1
69
+ ```
@@ -0,0 +1,52 @@
1
+ # 其他生态(Flutter / PHP / .NET / R / Ruby / Helm)
2
+
3
+ ## Flutter / Dart
4
+
5
+ ```bash
6
+ export PUB_HOSTED_URL="https://pub.flutter-io.cn"
7
+ export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"
8
+ ```
9
+
10
+ ## PHP / Composer
11
+
12
+ ```bash
13
+ composer config -g repos.packagist composer https://mirrors.aliyun.com/composer/
14
+ # 或 ~/.composer/config.json 里 "packagist.org": {"type":"composer","url":"https://mirrors.aliyun.com/composer/"}
15
+ ```
16
+
17
+ ## .NET / NuGet
18
+
19
+ ```bash
20
+ dotnet nuget add source https://mirrors.huaweicloud.com/repository/nuget/v3/index.json -n huaweicloud
21
+ ```
22
+
23
+ ## R / CRAN
24
+
25
+ ```r
26
+ options(repos = c(CRAN = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
27
+ # 永久:写入 ~/.Rprofile
28
+ ```
29
+
30
+ ## Ruby / RubyGems
31
+
32
+ ```bash
33
+ gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
34
+ bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems
35
+ ```
36
+
37
+ ## Helm
38
+
39
+ ```bash
40
+ # helm 二进制(华为云,实测 206 可下)
41
+ # https://mirrors.huaweicloud.com/helm/v3.16.2/helm-v3.16.2-linux-amd64.tar.gz
42
+ # 注意:https://mirrors.huaweicloud.com/helm/ 目录本身不可列,index.yaml 也 404,必须带具体版本路径
43
+ export HELM_MIRROR="https://mirrors.huaweicloud.com/helm"
44
+ ```
45
+
46
+ ## 验证
47
+
48
+ ```bash
49
+ flutter config --list 2>/dev/null | head -3
50
+ gem sources -l
51
+ Rscript -e 'getOption("repos")'
52
+ ```
@@ -0,0 +1,54 @@
1
+ # Node / JavaScript(npm、yarn、pnpm、二进制镜像)
2
+
3
+ ## registry
4
+
5
+ ```bash
6
+ # npm
7
+ npm config set registry https://registry.npmmirror.com
8
+ # 等价:~/.npmrc 里写 registry=https://registry.npmmirror.com
9
+
10
+ # yarn (v1)
11
+ yarn config set registry https://registry.npmmirror.com
12
+ # yarn berry: .yarnrc.yml -> npmRegistryServer: "https://registry.npmmirror.com"
13
+
14
+ # pnpm
15
+ pnpm config set registry https://registry.npmmirror.com
16
+ ```
17
+
18
+ 备选:`https://registry.npmmirror.com`(主)、`https://npm.mirrors.tuna.tsinghua.edu.cn`(tuna 已迁至 npmmirror,旧地址可能失效)、官方 `https://registry.npmjs.org`。
19
+
20
+ ## 二进制下载(安装卡 99% 的元凶)
21
+
22
+ ```bash
23
+ # 写进 ~/.bashrc,或项目 .npmrc
24
+ export NODEJS_ORG_MIRROR="https://npmmirror.com/mirrors/node"
25
+ export NVM_NODEJS_ORG_MIRROR="https://npmmirror.com/mirrors/node"
26
+ export ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"
27
+ export ELECTRON_BUILDER_BINARIES_MIRROR="https://npmmirror.com/mirrors/electron-builder-binaries/"
28
+ export SASS_BINARY_SITE="https://npmmirror.com/mirrors/node-sass"
29
+ export PUPPETEER_DOWNLOAD_HOST="https://cdn.npmmirror.com/binaries/chrome-for-testing"
30
+ export PUPPETEER_DOWNLOAD_BASE_URL="https://cdn.npmmirror.com/binaries/chrome-for-testing"
31
+ export PLAYWRIGHT_DOWNLOAD_HOST="https://npmmirror.com/mirrors/playwright"
32
+ export CYPRESS_DOWNLOAD_MIRROR="https://npmmirror.com/mirrors/cypress"
33
+ export PHANTOMJS_CDNURL="https://npmmirror.com/mirrors/phantomjs"
34
+ export SHARP_DIST_BASE_URL="https://npmmirror.com/mirrors/sharp"
35
+ export SENTRYCLI_CDNURL="https://npmmirror.com/mirrors/sentry-cli"
36
+ export npm_config_registry="https://registry.npmmirror.com"
37
+ ```
38
+
39
+ `.npmrc` 项目级等价(可提交到仓库):
40
+
41
+ ```ini
42
+ registry=https://registry.npmmirror.com
43
+ electron_mirror=https://npmmirror.com/mirrors/electron/
44
+ sass_binary_site=https://npmmirror.com/mirrors/node-sass
45
+ puppeteer_download_base_url=https://cdn.npmmirror.com/binaries/chrome-for-testing
46
+ ```
47
+
48
+ ## 验证
49
+
50
+ ```bash
51
+ npm config get registry
52
+ npm view react version --registry=https://registry.npmmirror.com
53
+ curl -sI -m 8 https://registry.npmmirror.com/react | head -1
54
+ ```
@@ -0,0 +1,87 @@
1
+ # Python(pip / uv / poetry / pdm / conda)
2
+
3
+ ## 源优先级
4
+
5
+ | 顺位 | 源 | 备注 |
6
+ |---|---|---|
7
+ | 1 | `https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple` | 最稳,全量同步 |
8
+ | 2 | `https://mirrors.aliyun.com/pypi/simple` | 快,偶有同步延迟 |
9
+ | 3 | `https://mirrors.cloud.tencent.com/pypi/simple` | 备用 |
10
+ | 4 | `https://mirrors.ustc.edu.cn/pypi/simple` | 常返回 403,最后考虑 |
11
+ | 5 | `https://pypi.org/simple` | 官方(可用但慢) |
12
+
13
+ > 实测(2025):tuna / aliyun / tencent 均 200;ustc 403;华为云 `mirrors.huaweicloud.com/repository/pypi/simple` 会 429 限流。
14
+
15
+ ## pip
16
+
17
+ ```bash
18
+ # 全局(推荐,用户级)
19
+ mkdir -p ~/.pip && cat > ~/.pip/pip.conf <<'EOF'
20
+ [global]
21
+ index-url = https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
22
+ extra-index-url = https://mirrors.aliyun.com/pypi/simple
23
+ trusted-host = mirrors.tuna.tsinghua.edu.cn
24
+ mirrors.aliyun.com
25
+ timeout = 60
26
+ EOF
27
+
28
+ # 单次
29
+ pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple <pkg>
30
+ ```
31
+
32
+ ## uv
33
+
34
+ ```bash
35
+ # 环境变量(~/.bashrc 或 ~/.config/uv/uv.toml)
36
+ export UV_DEFAULT_INDEX="https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
37
+ # uv.toml 等价写法
38
+ # [[index]]
39
+ # url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
40
+ # default = true
41
+
42
+ # 单次
43
+ uv pip install --index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple <pkg>
44
+ uv tool install <pkg> --index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
45
+ ```
46
+
47
+ > uv 下载 Python 解释器走 `github.com/astral-sh/python-build-standalone`,国内可能卡住:
48
+ > `export UV_PYTHON_INSTALL_MIRROR="https://ghproxy.net/https://github.com/astral-sh/python-build-standalone/releases/download"`
49
+ > 拉取 GitHub release 资产统一用技能 `gh-download`。
50
+
51
+ ## poetry / pdm
52
+
53
+ ```toml
54
+ # pyproject.toml
55
+ [[tool.poetry.source]]
56
+ name = "tuna"
57
+ url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
58
+ priority = "primary"
59
+
60
+ # pdm: ~/.config/pdm/config.toml
61
+ # [pypi]
62
+ # url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
63
+ ```
64
+
65
+ ## conda / mamba
66
+
67
+ ```bash
68
+ cat > ~/.condarc <<'EOF'
69
+ channels:
70
+ - defaults
71
+ default_channels:
72
+ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
73
+ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
74
+ custom_channels:
75
+ conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
76
+ pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
77
+ show_channel_urls: true
78
+ EOF
79
+ ```
80
+
81
+ ## 验证
82
+
83
+ ```bash
84
+ pip config list | grep index-url
85
+ uv pip install --dry-run requests 2>&1 | head -3
86
+ python -c "import urllib.request as u;print(u.urlopen('https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/',timeout=8).status)"
87
+ ```