feat: 海外化改造(新加坡市场)—— 阶段 0-3
Some checks failed
Tests / test (push) Has been cancelled

按 U-Claw-海外化改造方案.md 与 范围决策记录.md 实施。这是 fork,不回上游:
海外版删掉的正是上游的中国市场默认值。

阶段 0 地基
- 下载源全部改国际:脚本/CI 61 处 + lockfile 880 条 npmmirror URL 归零
  (lockfile 那 880 条是 npm 的 resolved 字段,脚本层参数化根本绕不过它)
- 移除 install.ps1 里三个第三方 GitHub 加速代理,bundle 改直连 + SHA256 校验
  (原来只检查"文件大于 1MB"就解压运行)
- 技能内容与分发分离:skills/manifest.json 单一来源,install.sh 1170→658 行、
  install.ps1 721→546 行,两者技能内容归零
  实测原来是三份不一致:skills-cn 完整、install.sh 约 40%、install.ps1 约 17%,
  且 7 个通用技能只有 U 盘版有 —— 一键安装的用户一个能用的技能都没有
- Node 版本三种(v22.14/16/22.1)统一,新建 NODE_VERSION 单一来源
- Config 页三份合一。portable/Config.html 用根相对路径调 API 却只从 file:// 打开,
  保存功能已静默失效两个月;现缩为 120 行重定向壳
- 测试接入 CI(此前 node --test 无人运行,所有断言形同虚设)

阶段 1 双语可用
- 浏览器侧 i18n:JSON 为源、生成经典 script(file:// 下 fetch 本地 JSON 被拦)
  语言跟盘走不跟机器走:启动器写 data/.openclaw/locale.js
- 8 处硬编码 lang="zh-CN" 归零,data-i18n 覆盖 213 处,词条 en/zh 各 279 条
- B3 单框 Key:12 张模型卡 → 一个输入框,前缀识别 provider,
  服务端 /api/test-key 发 1-token 请求实测,错误映射成人话
  Key 填错到得知:从"直到对话失败"降到 ≤1 秒
- 区域格式 SG:DD/MM/YYYY、12 小时、S$、Asia/Singapore
  (ICU 在 en-SG 下把 SGD 渲染成裸 $,与美元无法区分,故自行拼 S$)
- README 内容分叉而非翻译,§1.3 证据清单逐条清零

阶段 2 降门槛
- 启动逻辑上移 lib/start.mjs:Windows-Start.bat 220→28 行、
  Mac-Start.command 235→33 行
  修掉 Mac 侧两个 bug:控制台端口硬编码 18788(回落时打开死页)、
  微信插件从未在 Mac 上安装
- U 盘根目录 23 → 3 个可点文件,其余进 advanced/
- 首启向导:语言 → 用途(7 角色,manifest 驱动)→ 密钥,答过不再问
- 三档界面,Simple 档隐藏一切技术名词
- 自动自愈:启动失败先自查自修,修不好导出脱敏诊断包
  (Doctor 从"用户要知道去点的工具"变成后台机制)

阶段 3 技能库
- 19 个英文技能,planned 归零。sg-weather / sg-transport 的端点均实测过
- SkillHub 从 56 张手写第三方卡片改为 manifest 生成:703→125 行,中文归零

其他
- origin.json 收拢所有运行时地址,tests/origin.test.mjs 保证迁移不会漏
- portable/ 下用户可见中文归零(由断言保证)
- 82 项测试

未验证(本机无 Windows / 无 pwsh):
- install.ps1、setup.ps1 约 210 行改动从未经 PowerShell 解析器
- 完整启动路径仅在假 node + 假 openclaw 上冒烟
- 8 个 .bat 的盘根推导仅静态断言
详见 U盘实测清单.md

受阻:
- 隐藏黑窗口 —— 需代码签名证书(.vbs 已被 Windows 弃用,替代方案都要签名)
- 场景卡 —— OpenClaw 上游 Dashboard 无预填 prompt 接口
- 官网 36 条 —— 上游 2026-04-14 拆到私有仓库,无权限
This commit is contained in:
2026-08-17 18:37:49 +08:00
parent 9a23aec097
commit b076815171
123 changed files with 13396 additions and 14723 deletions

View File

@@ -22,9 +22,16 @@ $RUNTIME_DIR = "$UCLAW_DIR\runtime"
$CORE_DIR = "$UCLAW_DIR\core"
$DATA_DIR = "$UCLAW_DIR\data"
$CONFIG_PATH = "$DATA_DIR\.openclaw\openclaw.json"
$NODE_VERSION = "v22.16.0"
$MIRROR = "https://registry.npmmirror.com"
$NODE_MIRROR = "https://npmmirror.com/mirrors/node"
$NODE_VERSION = "v22.22.1"
$MIRROR = "https://registry.npmjs.org"
$NODE_MIRROR = "https://nodejs.org/dist"
$OPENCLAW_VERSION = "2026.7.1-2"
# Skills: content lives in skills/, described by skills/manifest.json.
# UCLAW_REF pins which revision irm|iex pulls skill content from.
$UCLAW_LOCALE = if ($env:UCLAW_LOCALE) { $env:UCLAW_LOCALE } else { "en" }
$UCLAW_REF = if ($env:UCLAW_REF) { $env:UCLAW_REF } else { "main" }
$SKILL_INSTALLER_URL = "https://gitea.fanghe.it.com/zhenghy/u-claw/raw/branch/$UCLAW_REF/lib/install-skills.mjs"
# ---- Color helpers ----
function Write-Green($msg) { Write-Host $msg -ForegroundColor Green }
@@ -170,11 +177,8 @@ if (Test-Path "$CORE_DIR\node_modules\openclaw") {
Write-Green " [OK] OpenClaw already installed, skip"
} else {
Write-Cyan " Downloading pre-bundled package (no npm install needed)..."
$BUNDLE_GITHUB_URL = "https://github.com/dongsheng123132/u-claw/releases/download/v1.0.0-bundle/openclaw-bundle.zip"
$BUNDLE_GITHUB_URL = "https://gitea.fanghe.it.com/zhenghy/u-claw/releases/download/v1.0.0-bundle/openclaw-bundle.zip"
$BUNDLE_MIRRORS = @(
"https://ghfast.top/https://github.com/dongsheng123132/u-claw/releases/download/v1.0.0-bundle/openclaw-bundle.zip",
"https://ghproxy.net/https://github.com/dongsheng123132/u-claw/releases/download/v1.0.0-bundle/openclaw-bundle.zip",
"https://gh.idayer.com/https://github.com/dongsheng123132/u-claw/releases/download/v1.0.0-bundle/openclaw-bundle.zip",
$BUNDLE_GITHUB_URL
)
$bundleZip = "$env:TEMP\openclaw-bundle.zip"
@@ -205,8 +209,6 @@ if (Test-Path "$CORE_DIR\node_modules\openclaw") {
if (-not $downloaded) {
Write-Host " Trying curl fallback..." -ForegroundColor DarkGray
$curlMirrors = @(
"https://ghfast.top/https://github.com/dongsheng123132/u-claw/releases/download/v1.0.0-bundle/openclaw-bundle.zip",
"https://ghproxy.net/https://github.com/dongsheng123132/u-claw/releases/download/v1.0.0-bundle/openclaw-bundle.zip",
$BUNDLE_GITHUB_URL
)
foreach ($curlUrl in $curlMirrors) {
@@ -226,6 +228,32 @@ if (Test-Path "$CORE_DIR\node_modules\openclaw") {
exit 1
}
# Integrity check. Until this landed the installer only checked that the
# download was larger than 1MB, then extracted and ran it -- the same
# "fetch and execute, unverified" shape we warn about elsewhere.
# The publisher writes <asset>.sha256 next to the bundle; see release.yml.
$expectedHash = $null
try {
$hashBody = (Invoke-WebRequest -Uri "$BUNDLE_GITHUB_URL.sha256" -UseBasicParsing -TimeoutSec 30).Content
$expectedHash = ($hashBody -split '\s+')[0].Trim().ToLower()
} catch {
$expectedHash = $null
}
if ($expectedHash) {
$actualHash = (Get-FileHash -Path $bundleZip -Algorithm SHA256).Hash.ToLower()
if ($actualHash -ne $expectedHash) {
Remove-Item -Force $bundleZip -ErrorAction SilentlyContinue
Write-Red " [FAIL] The downloaded file does not match its published checksum."
Write-Yellow " It was damaged in transit, or it is not the file we published."
Write-Yellow " Nothing was installed. Try again on a different network."
exit 1
}
Write-Green " [OK] Checksum verified"
} else {
Write-Yellow " [!] No published checksum found - integrity was not verified."
}
Write-Host " Extracting..." -ForegroundColor Cyan
$tempExtract = "$env:TEMP\openclaw-bundle-extract"
if (Test-Path $tempExtract) { Remove-Item -Recurse -Force $tempExtract }
@@ -254,213 +282,36 @@ if (Test-Path "$CORE_DIR\node_modules\@sliverp\qqbot") {
Write-Host ""
# ============================================================
# Step 4: China-optimized skills (10 skills)
# Step 4: Install skills from the manifest
# ============================================================
Write-Host " [3/6] Install China skills (10) ..." -ForegroundColor White
# Skill content lives in skills/ and is described by skills/manifest.json.
# This script carries none of it, which is what keeps the shell and PowerShell
# installers identical (tests/skills-manifest.test.mjs enforces that) and keeps
# non-ASCII bytes out of the launchers.
Write-Host " [3/6] Installing skills ..." -ForegroundColor White
$SKILLS_TARGET = "$CORE_DIR\node_modules\openclaw\skills"
if (-not (Test-Path $SKILLS_TARGET)) { New-Item -ItemType Directory -Force -Path $SKILLS_TARGET | Out-Null }
$skillCount = 0
$skills = @{
"bilibili-helper" = @'
---
name: bilibili-helper
description: "Bilibili content helper - video title, tags, cover design, category selection"
metadata: { "openclaw": { "emoji": "TV" } }
---
# Bilibili Content Helper
Optimize video titles, descriptions, tags and covers for better recommendations on Bilibili.
## Title formulas
1. Question: "Why XX? You'll understand after watching"
2. Tutorial: "XX Tutorial | Step by step from scratch"
3. Review: "Spent XX yuan on XX, is it worth it?"
4. Challenge: "Challenge XX days using only XX"
5. Ranking: "Top 10 XX of the year"
'@
"china-search" = @'
---
name: china-search
description: "China search engines - Baidu, Sogou, Bing China search"
metadata: { "openclaw": { "emoji": "search" } }
---
# China Search Engine Helper
Search via Baidu, Sogou, Bing China using curl.
## Commands
```bash
curl -s -L "https://www.baidu.com/s?wd=keyword" -H "User-Agent: Mozilla/5.0"
curl -s -L "https://weixin.sogou.com/weixin?query=keyword" -H "User-Agent: Mozilla/5.0"
curl -s -L "https://cn.bing.com/search?q=keyword" -H "User-Agent: Mozilla/5.0"
```
'@
"china-translate" = @'
---
name: china-translate
description: "CN-EN translation - tech docs, UI localization, cultural adaptation"
metadata: { "openclaw": { "emoji": "globe" } }
---
# CN-EN Translation Helper
Professional Chinese-English bidirectional translation for tech docs and product localization.
## Common terms
| English | Chinese |
|---------|---------|
| Deploy | Bu Shu |
| Repository | Cang Ku |
| Container | Rong Qi |
| Middleware | Zhong Jian Jian |
| Token | Token / Ling Pai |
| Prompt | Ti Shi Ci |
'@
"china-weather" = @'
---
name: china-weather
description: "China city weather query - supports Chinese city names, wttr.in API"
metadata: { "openclaw": { "emoji": "sun" } }
---
# China Weather Query
```bash
curl -s "wttr.in/Shenzhen?lang=zh"
curl -s "wttr.in/Beijing?format=j1"
```
'@
"deepseek-helper" = @'
---
name: deepseek-helper
description: "DeepSeek API helper - model selection, API guide, pricing info"
metadata: { "openclaw": { "emoji": "robot" } }
---
# DeepSeek API Helper
## Models
| Model | Use case | Context |
|-------|----------|---------|
| deepseek-v4-flash | Daily chat, fast and cheap | 128K |
| deepseek-v4-pro | Complex reasoning, code | 128K |
> Note: the legacy names `deepseek-chat` / `deepseek-coder` / `deepseek-reasoner` are
> no longer accepted by api.deepseek.com and return HTTP 400.
- OpenAI-compatible API, base_url: https://api.deepseek.com
- Direct access in China, API Key: https://platform.deepseek.com
'@
"douyin-script" = @'
---
name: douyin-script
description: "Douyin/Kuaishou short video script - hook, structure, hashtag strategy"
metadata: { "openclaw": { "emoji": "video" } }
---
# Douyin/Kuaishou Script Helper
## First 3-second Hook formulas
1. Counter-intuitive: "What you've been doing is actually wrong"
2. Number shock: "Only 100 yuan but better than 1000 yuan"
3. Suspense: "Guess what this is for?"
4. Emotional: "Workers fell silent after watching..."
5. Result first: "The final result is amazing!"
## Hashtags: large + medium + small topics, 5-8 total
## Best time: 7-9am, 12-2pm, 6-10pm
'@
"wechat-article" = @'
---
name: wechat-article
description: "WeChat article writing - structure, formatting, conversion optimization"
metadata: { "openclaw": { "emoji": "green" } }
---
# WeChat Article Writing Helper
## Formatting rules
- Body font 15-16px, line height 1.75-2x
- Body color #3f3f3f, accent #007AFF
- 3-5 lines per paragraph, 1 image per 300 chars
- Title under 30 chars, first 15 chars must catch attention
'@
"weibo-poster" = @'
---
name: weibo-poster
description: "Weibo content creation - 140-char optimization, trending topics, images"
metadata: { "openclaw": { "emoji": "red" } }
---
# Weibo Content Helper
## 140-char tips: Write then trim, one point per post, end with golden quote
## Images: 1 for highlight / 3 for comparison / 6 for narrative / 9 for grid
## Timing: Weekday lunch + after work, Weekend morning + evening
'@
"xiaohongshu-writer" = @'
---
name: xiaohongshu-writer
description: "Xiaohongshu note writer - title optimization, emoji strategy, hashtags"
metadata: { "openclaw": { "emoji": "book" } }
---
# Xiaohongshu Note Writer
## Title formulas
1. Numbers: "5 ways / 10 types / under 100 yuan"
2. Contrast: "3K salary vs 30K salary"
3. Review: "Personally tested, really works!"
4. Collection: "XX Collection | All in one post"
## Tips: Max 3 lines per paragraph, 1-2 emoji per paragraph, 3-8 hashtags
'@
"zhihu-writer" = @'
---
name: zhihu-writer
description: "Zhihu answer/article writing - structure, professional tone, citations"
metadata: { "openclaw": { "emoji": "pen" } }
---
# Zhihu Writing Helper
## Answer structure: Conclusion first -> Point-by-point -> Summary
## Style: Confident not arrogant, professional but accessible
## Quality: 500-3000 chars, original, reply to comments, focus on 2-3 topics
'@
}
foreach ($skillName in $skills.Keys) {
$skillDir = "$SKILLS_TARGET\$skillName"
if (-not (Test-Path $skillDir)) {
New-Item -ItemType Directory -Force -Path $skillDir | Out-Null
[IO.File]::WriteAllText("$skillDir\SKILL.md", $skills[$skillName], (New-Object System.Text.UTF8Encoding $false))
$skillCount++
$skillInstaller = Join-Path $PSScriptRoot "..\lib\install-skills.mjs"
$skillTemp = $null
if (-not (Test-Path $skillInstaller)) {
# irm | iex has no checkout: fetch the installer, then let it fetch content.
$skillTemp = Join-Path $env:TEMP "uclaw-install-skills.mjs"
try {
Invoke-WebRequest -Uri $SKILL_INSTALLER_URL -OutFile $skillTemp -UseBasicParsing -TimeoutSec 60
$skillInstaller = $skillTemp
} catch {
Write-Host " [!] Could not download the skill installer - skipping skills." -ForegroundColor Yellow
Write-Host " You can add them later from the Skill Hub." -ForegroundColor DarkGray
$skillInstaller = $null
}
}
Write-Green " [OK] China skills installed (+$skillCount)"
if ($skillInstaller) {
& $INSTALL_NODE $skillInstaller --target $SKILLS_TARGET --locale $UCLAW_LOCALE --ref $UCLAW_REF
if ($skillTemp) { Remove-Item -Force $skillTemp -ErrorAction SilentlyContinue }
}
Write-Host ""
# ============================================================