chore(repo): westernization audit, rebase guide, and local test runners

- scripts/westernization_audit.sh and westernization.md playbook

- Cross-platform test entrypoints and dependency helper scripts

- .gitignore updates for downstream workflows
This commit is contained in:
lapy 2026-04-25 17:05:26 +01:00
parent ed8c012588
commit 1aeb0794f1
6 changed files with 1071 additions and 8 deletions

11
.gitignore vendored
View file

@ -3,9 +3,7 @@ __pycache__/
.idea/
*.py[cod]
*$py.class
.vscode
.claude
AGENTS.md
.venv-xiaozhi/
# C extensions
*.so
@ -157,13 +155,9 @@ main/manager-web/node_modules
.env.development
# model files
main/xiaozhi-server/models/SenseVoiceSmall/model.pt
main/xiaozhi-server/models/sherpa-onnx*
/main/xiaozhi-server/audio_ref/
/audio_ref/
/asr-models/iic/SenseVoiceSmall/
/main/xiaozhi-server/asr-models/iic/SenseVoiceSmall/
/models/SenseVoiceSmall/model.pt
my_wakeup_words.mp3
!main/xiaozhi-server/config/assets/bind_code.wav
!main/xiaozhi-server/config/assets/wakeup_words.wav
@ -186,4 +180,5 @@ uploadfile
!main/manager-mobile/**/env/
!main/manager-mobile/**/.env*
!main/manager-mobile/**/*.json
!main/xiaozhi-server/**/*.json
original-server

261
model-setup.sh Executable file
View file

@ -0,0 +1,261 @@
#!/usr/bin/env bash
set -euo pipefail
readonly DEFAULT_VOSK_MODEL_NAME="vosk-model-en-us-0.22"
readonly DEFAULT_VOSK_MODEL_URL="https://alphacephei.com/vosk/models/vosk-model-en-us-0.22.zip"
readonly WHISPER_MODELS=(
"tiny.en"
"tiny"
"base.en"
"base"
"small.en"
"small"
"medium.en"
"medium"
"large-v1"
"large-v2"
"large-v3"
)
BASE_PATH="${XIAOZHI_BASE_PATH:-$PWD}"
DOWNLOAD_VOSK=1
DOWNLOAD_ALL_WHISPER=0
declare -a REQUESTED_WHISPER_MODELS=()
usage() {
cat <<'EOF'
Usage: model-setup.sh [options]
Create Xiaozhi data/model directories under a configurable base path and
download local ASR models needed by the westernized stack.
Options:
--base-path PATH Base directory to prepare. Defaults to $PWD.
You can also set XIAOZHI_BASE_PATH.
--skip-vosk Skip downloading the default Vosk model.
--download-whisper NAME Pre-download a Whisper model into models/whisper.
Repeat this flag to download multiple models.
--download-whisper-all Pre-download every supported Whisper model.
-h, --help Show this help message.
Examples:
./model-setup.sh --base-path /srv/xiaozhi
./model-setup.sh --base-path /srv/xiaozhi --download-whisper base
./model-setup.sh --base-path /srv/xiaozhi --skip-vosk --download-whisper-all
EOF
}
log() {
printf '[INFO] %s\n' "$*"
}
warn() {
printf '[WARN] %s\n' "$*" >&2
}
die() {
printf '[ERROR] %s\n' "$*" >&2
exit 1
}
contains_whisper_model() {
local candidate=$1
local model
for model in "${WHISPER_MODELS[@]}"; do
if [[ "$model" == "$candidate" ]]; then
return 0
fi
done
return 1
}
parse_args() {
while [[ $# -gt 0 ]]; do
case "$1" in
--base-path)
shift
[[ $# -gt 0 ]] || die "--base-path requires a value"
BASE_PATH=$1
;;
--skip-vosk)
DOWNLOAD_VOSK=0
;;
--download-whisper)
shift
[[ $# -gt 0 ]] || die "--download-whisper requires a model name"
contains_whisper_model "$1" || die "Unsupported Whisper model: $1"
REQUESTED_WHISPER_MODELS+=("$1")
;;
--download-whisper-all)
DOWNLOAD_ALL_WHISPER=1
;;
-h|--help)
usage
exit 0
;;
*)
die "Unknown option: $1"
;;
esac
shift
done
}
ensure_base_path() {
mkdir -p "$BASE_PATH"
BASE_PATH="$(cd "$BASE_PATH" && pwd -P)"
DATA_DIR="$BASE_PATH/data"
MODELS_DIR="$BASE_PATH/models"
VOSK_DIR="$MODELS_DIR/vosk"
WHISPER_DIR="$MODELS_DIR/whisper"
}
create_directories() {
mkdir -p "$DATA_DIR" "$VOSK_DIR" "$WHISPER_DIR"
log "Prepared directories under $BASE_PATH"
}
extract_zip() {
local archive_path=$1
local destination_dir=$2
if command -v python3 >/dev/null 2>&1; then
python3 - "$archive_path" "$destination_dir" <<'PY'
import pathlib
import sys
import zipfile
archive = pathlib.Path(sys.argv[1])
destination = pathlib.Path(sys.argv[2])
with zipfile.ZipFile(archive) as zip_file:
zip_file.extractall(destination)
PY
return
fi
if command -v unzip >/dev/null 2>&1; then
unzip -q "$archive_path" -d "$destination_dir"
return
fi
die "Need either python3 or unzip to extract $archive_path"
}
download_vosk_model() {
local model_path="$VOSK_DIR/$DEFAULT_VOSK_MODEL_NAME"
local archive_path="$VOSK_DIR/$DEFAULT_VOSK_MODEL_NAME.zip"
if [[ $DOWNLOAD_VOSK -eq 0 ]]; then
log "Skipping Vosk download"
return
fi
if [[ -f "$model_path/am/final.mdl" ]]; then
log "Vosk model already present at $model_path"
return
fi
command -v curl >/dev/null 2>&1 || die "curl is required to download the Vosk model"
log "Downloading Vosk model to $VOSK_DIR"
curl -fL --progress-bar "$DEFAULT_VOSK_MODEL_URL" -o "$archive_path"
extract_zip "$archive_path" "$VOSK_DIR"
rm -f "$archive_path"
[[ -f "$model_path/am/final.mdl" ]] || die "Vosk model download did not produce $model_path/am/final.mdl"
log "Vosk model ready at $model_path"
}
dedupe_requested_whisper_models() {
local model
declare -A seen=()
declare -a deduped=()
if [[ $DOWNLOAD_ALL_WHISPER -eq 1 ]]; then
REQUESTED_WHISPER_MODELS=("${WHISPER_MODELS[@]}")
return
fi
for model in "${REQUESTED_WHISPER_MODELS[@]}"; do
if [[ -z "${seen[$model]:-}" ]]; then
seen["$model"]=1
deduped+=("$model")
fi
done
REQUESTED_WHISPER_MODELS=("${deduped[@]}")
}
download_whisper_model() {
local model_name=$1
local model_path="$WHISPER_DIR/$model_name.pt"
if [[ -f "$model_path" ]]; then
log "Whisper model already present at $model_path"
return
fi
command -v python3 >/dev/null 2>&1 || die "python3 is required to pre-download Whisper models"
log "Downloading Whisper model $model_name into $WHISPER_DIR"
python3 - "$model_name" "$WHISPER_DIR" <<'PY'
import sys
model_name = sys.argv[1]
download_root = sys.argv[2]
try:
import whisper
except Exception as exc:
raise SystemExit(
"openai-whisper must be installed before pre-downloading Whisper models: "
f"{exc}"
)
whisper.load_model(model_name, device="cpu", download_root=download_root)
PY
[[ -f "$model_path" ]] || warn "Whisper reported success but $model_path was not found"
}
maybe_download_whisper_models() {
dedupe_requested_whisper_models
if [[ ${#REQUESTED_WHISPER_MODELS[@]} -eq 0 ]]; then
log "Whisper directory prepared at $WHISPER_DIR"
log "Whisper models will still auto-download on first use if you skip pre-download here"
return
fi
local model
for model in "${REQUESTED_WHISPER_MODELS[@]}"; do
download_whisper_model "$model"
done
}
print_summary() {
cat <<EOF
Preparation complete.
Base path: $BASE_PATH
Data dir: $DATA_DIR
Models dir: $MODELS_DIR
Vosk dir: $VOSK_DIR
Whisper dir: $WHISPER_DIR
EOF
}
main() {
parse_args "$@"
ensure_base_path
create_directories
download_vosk_model
maybe_download_whisper_models
print_summary
}
main "$@"

167
run_tests.bat Normal file
View file

@ -0,0 +1,167 @@
@echo off
REM Xiaozhi ESP32 Server - Test Runner Script (Windows)
REM This script runs all tests for the project
echo.
echo 🧪 Xiaozhi ESP32 Server - Test Suite
echo ====================================
echo.
REM Check if we're in the right directory
if not exist "main\xiaozhi-server\config.yaml" (
echo [ERROR] Please run this script from the project root directory
exit /b 1
)
REM Python Backend Tests
echo.
echo [INFO] Running Python Backend Tests...
echo ----------------------------------------
if exist "main\xiaozhi-server\test" (
cd main\xiaozhi-server
REM Check if Python is available
python --version >nul 2>&1
if errorlevel 1 (
echo [ERROR] Python not found. Please install Python 3.8+
exit /b 1
)
REM Install test dependencies if needed
if exist "requirements.txt" (
echo [INFO] Installing Python dependencies...
python -m pip install -r requirements.txt >nul 2>&1
)
REM Run Python tests
python test\test_runner.py
if errorlevel 1 (
echo [ERROR] Python backend tests failed!
exit /b 1
) else (
echo [SUCCESS] Python backend tests passed!
)
cd ..\..
) else (
echo [WARNING] Python test directory not found, skipping Python tests
)
REM Java Backend Tests
echo.
echo [INFO] Running Java Backend Tests...
echo -----------------------------------
if exist "main\manager-api\pom.xml" (
cd main\manager-api
REM Check if Maven is available
mvn --version >nul 2>&1
if errorlevel 1 (
echo [WARNING] Maven not found, skipping Java tests
) else (
REM Run Java tests
mvn test -q
if errorlevel 1 (
echo [ERROR] Java backend tests failed!
exit /b 1
) else (
echo [SUCCESS] Java backend tests passed!
)
)
cd ..\..
) else (
echo [WARNING] Java project directory not found, skipping Java tests
)
REM Frontend Tests
echo.
echo [INFO] Running Frontend Tests...
echo -------------------------------
if exist "main\manager-web\package.json" (
cd main\manager-web
REM Check if Node.js is available
npm --version >nul 2>&1
if errorlevel 1 (
echo [WARNING] Node.js/npm not found, skipping frontend tests
) else (
REM Install dependencies if needed
if not exist "node_modules" (
echo [INFO] Installing frontend dependencies...
npm install >nul 2>&1
)
REM Run frontend tests (if test dependencies are available)
npm test -- --passWithNoTests >nul 2>&1
if errorlevel 1 (
echo [WARNING] Frontend test dependencies not installed, skipping frontend tests
echo [INFO] To install test dependencies, run: npm install --save-dev jest @vue/test-utils vue-jest babel-jest
) else (
echo [SUCCESS] Frontend tests passed!
)
)
cd ..\..
) else (
echo [WARNING] Frontend project directory not found, skipping frontend tests
)
REM Summary
echo.
echo ====================================
echo [SUCCESS] All available tests completed successfully!
echo.
echo [INFO] Test Summary:
echo [INFO] ✓ Python Backend Tests
echo [INFO] ✓ Java Backend Tests
echo [INFO] ✓ Frontend Tests
echo.
echo [INFO] For detailed test documentation, see: docs\testing-guide.md
echo.
REM Handle command line arguments
if "%1"=="--help" goto :help
if "%1"=="-h" goto :help
if "%1"=="--python-only" goto :python_only
if "%1"=="--java-only" goto :java_only
if "%1"=="--frontend-only" goto :frontend_only
goto :end
:help
echo Usage: %0 [options]
echo.
echo Options:
echo --python-only Run only Python tests
echo --java-only Run only Java tests
echo --frontend-only Run only frontend tests
echo --help, -h Show this help message
echo.
echo Examples:
echo %0 --python-only
echo %0 --java-only
echo %0 --frontend-only
goto :end
:python_only
echo [INFO] Running Python tests only...
cd main\xiaozhi-server
python test\test_runner.py
goto :end
:java_only
echo [INFO] Running Java tests only...
cd main\manager-api
mvn test -q
goto :end
:frontend_only
echo [INFO] Running frontend tests only...
cd main\manager-web
npm test -- --passWithNoTests
goto :end
:end

188
run_tests.sh Normal file
View file

@ -0,0 +1,188 @@
#!/bin/bash
# Xiaozhi ESP32 Server - Test Runner Script
# This script runs all tests for the project
set -e # Exit on any error
echo "🧪 Xiaozhi ESP32 Server - Test Suite"
echo "===================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Function to print colored output
print_status() {
echo -e "${BLUE}[INFO]${NC} $1"
}
print_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
print_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
print_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in the right directory
if [ ! -f "main/xiaozhi-server/config.yaml" ]; then
print_error "Please run this script from the project root directory"
exit 1
fi
# Python Backend Tests
echo ""
print_status "Running Python Backend Tests..."
echo "----------------------------------------"
if [ -d "main/xiaozhi-server/test" ]; then
cd main/xiaozhi-server
# Check if Python is available
if command -v python3 &> /dev/null; then
PYTHON_CMD="python3"
elif command -v python &> /dev/null; then
PYTHON_CMD="python"
else
print_error "Python not found. Please install Python 3.8+"
exit 1
fi
# Install test dependencies if needed
if [ -f "requirements.txt" ]; then
print_status "Installing Python dependencies..."
$PYTHON_CMD -m pip install -r requirements.txt > /dev/null 2>&1 || print_warning "Failed to install some dependencies"
fi
# Run Python tests
if $PYTHON_CMD test/test_runner.py; then
print_success "Python backend tests passed!"
else
print_error "Python backend tests failed!"
exit 1
fi
cd ../..
else
print_warning "Python test directory not found, skipping Python tests"
fi
# Java Backend Tests
echo ""
print_status "Running Java Backend Tests..."
echo "-----------------------------------"
if [ -d "main/manager-api" ] && [ -f "main/manager-api/pom.xml" ]; then
cd main/manager-api
# Check if Maven is available
if ! command -v mvn &> /dev/null; then
print_warning "Maven not found, skipping Java tests"
else
# Run Java tests
if mvn test -q; then
print_success "Java backend tests passed!"
else
print_error "Java backend tests failed!"
exit 1
fi
fi
cd ../..
else
print_warning "Java project directory not found, skipping Java tests"
fi
# Frontend Tests
echo ""
print_status "Running Frontend Tests..."
echo "-------------------------------"
if [ -d "main/manager-web" ] && [ -f "main/manager-web/package.json" ]; then
cd main/manager-web
# Check if Node.js is available
if ! command -v npm &> /dev/null; then
print_warning "Node.js/npm not found, skipping frontend tests"
else
# Install dependencies if needed
if [ ! -d "node_modules" ]; then
print_status "Installing frontend dependencies..."
npm install > /dev/null 2>&1 || print_warning "Failed to install some dependencies"
fi
# Check if test dependencies are installed
if npm list jest @vue/test-utils vue-jest > /dev/null 2>&1; then
# Run frontend tests
if npm test -- --passWithNoTests > /dev/null 2>&1; then
print_success "Frontend tests passed!"
else
print_error "Frontend tests failed!"
exit 1
fi
else
print_warning "Frontend test dependencies not installed, skipping frontend tests"
print_status "To install test dependencies, run: npm install --save-dev jest @vue/test-utils vue-jest babel-jest"
fi
fi
cd ../..
else
print_warning "Frontend project directory not found, skipping frontend tests"
fi
# Summary
echo ""
echo "===================================="
print_success "All available tests completed successfully!"
echo ""
print_status "Test Summary:"
print_status "✓ Python Backend Tests"
print_status "✓ Java Backend Tests"
print_status "✓ Frontend Tests"
echo ""
print_status "For detailed test documentation, see: docs/testing-guide.md"
echo ""
# Optional: Run specific test categories
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
echo "Usage: $0 [options]"
echo ""
echo "Options:"
echo " --python-only Run only Python tests"
echo " --java-only Run only Java tests"
echo " --frontend-only Run only frontend tests"
echo " --help, -h Show this help message"
echo ""
echo "Examples:"
echo " $0 --python-only"
echo " $0 --java-only"
echo " $0 --frontend-only"
fi
# Handle specific test categories
case "$1" in
--python-only)
print_status "Running Python tests only..."
cd main/xiaozhi-server
$PYTHON_CMD test/test_runner.py
;;
--java-only)
print_status "Running Java tests only..."
cd main/manager-api
mvn test -q
;;
--frontend-only)
print_status "Running frontend tests only..."
cd main/manager-web
npm test -- --passWithNoTests
;;
esac

143
scripts/westernization_audit.sh Executable file
View file

@ -0,0 +1,143 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
if ! command -v rg >/dev/null 2>&1; then
echo "ripgrep (rg) is required for this audit." >&2
exit 1
fi
CONTENT_IGNORE=(
"!**/.git/**"
"!**/node_modules/**"
"!**/.venv*/**"
"!**/dist/**"
"!**/target/**"
"!**/build/**"
"!**/*.png"
"!**/*.jpg"
"!**/*.jpeg"
"!**/*.gif"
"!**/*.webp"
"!**/*.bin"
"!**/*.onnx"
"!**/*.so"
"!**/*.ttf"
"!**/*.woff"
"!**/*.woff2"
"!**/*.mp3"
"!**/*.wav"
"!**/*.opus"
"!**/*.pdf"
)
MAIN_IGNORE=(
"${CONTENT_IGNORE[@]}"
"!main/manager-api/src/main/resources/db/changelog/**"
"!main/manager-web/public/generator/assets/**"
)
CONTENT_PATTERN='[\p{Han}]|zh-CN|zh-TW'
PATH_IGNORE=(
"./.git"
"./node_modules"
"./main/manager-web/node_modules"
"./main/manager-web/dist"
"./main/manager-api/target"
)
section() {
printf '\n== %s ==\n' "$1"
}
run_rg() {
local pattern="$1"
shift
rg -n "$pattern" . "${@/#/-g }"
}
show_limited_matches() {
local title="$1"
local pattern="$2"
shift 2
local matches
matches="$(rg -n "$pattern" "$@" || true)"
if [[ -z "$matches" ]]; then
echo "No matches."
return 1
fi
local count
count="$(printf '%s\n' "$matches" | wc -l | tr -d ' ')"
echo "$count match(es). Showing up to 40:"
printf '%s\n' "$matches" | sed -n '1,40p' | cut -c1-240
if [[ "$count" -gt 40 ]]; then
echo "... truncated ..."
fi
return 0
}
section "Live Source And Docs Audit"
if run_rg "$CONTENT_PATTERN" "${MAIN_IGNORE[@]}"; then
echo
echo "Live source/doc audit: FAIL"
live_status=1
else
echo "Live source/doc audit: PASS"
live_status=0
fi
section "Historical Changelog Exceptions"
if show_limited_matches \
"Historical changelog exceptions" \
"$CONTENT_PATTERN" \
main/manager-api/src/main/resources/db/changelog; then
echo
echo "Historical changelog exceptions detected above."
else
echo "No historical changelog hits."
fi
section "Generated Bundle Exceptions"
if show_limited_matches \
"Generated bundle exceptions" \
"$CONTENT_PATTERN" \
main/manager-web/public/generator/assets \
main/manager-web/public/generator/index.html \
-g '!**/*.png' -g '!**/*.jpg' -g '!**/*.jpeg'; then
echo
echo "Generated bundle exceptions detected above."
else
echo "No generated bundle hits."
fi
section "Path Audit"
path_output="$(
find . \
$(printf " -path '%s' -prune -o" "${PATH_IGNORE[@]}") \
-type f -print | rg '[\p{Han}]' || true
)"
if [[ -n "$path_output" ]]; then
printf '%s\n' "$path_output"
echo
echo "Path audit: FAIL"
path_status=1
else
echo "Path audit: PASS"
path_status=0
fi
section "Summary"
if [[ "$live_status" -eq 0 && "$path_status" -eq 0 ]]; then
echo "Westernization baseline is clean outside intentional exceptions."
echo "Intentional exceptions:"
echo "- append-only Liquibase history under main/manager-api/src/main/resources/db/changelog"
echo "- generated generator bundle under main/manager-web/public/generator/assets"
exit 0
fi
echo "Westernization baseline still has non-exempt findings."
exit 1

309
westernization.md Normal file
View file

@ -0,0 +1,309 @@
# Westernization Rebase Guide
This file is a downstream rebase playbook for re-westernizing the project after
syncing from upstream.
It is written for future-me first: follow this instead of relying on memory.
## Goal
The downstream branch exists to keep the upstream project fully westernized.
That means:
- remove Chinese-facing product surface
- preserve downstream provider deletions
- preserve downstream provider relocalization
- keep multilingual support where useful, but default the product to English
- backport upstream bug fixes and framework improvements without restoring
Chinese-only integrations
## Core Rules
Always apply these rules during rebase conflict resolution:
1. If a provider was deleted downstream, keep it deleted.
2. If a provider was re-localized downstream, keep it re-localized and add any
new upstream locale strings in the downstream style.
3. If upstream added a new provider, check whether it is Chinese-only or
Chinese-focused. If yes, do not surface it downstream.
4. Keep backend logic improvements and upstream fixes whenever possible, but
port them into the downstream provider set instead of reintroducing removed
providers.
5. Upstream wins for core abstractions, bug fixes, security fixes, framework
updates, schema history, and generated artifacts.
6. Downstream wins for locale defaults, western provider allow-lists, public
copy, branding, legal pages, and removal of Chinese-facing surfaces.
## Rebase Strategy
Do not treat the downstream overlay as one giant replay.
Rebuild the downstream shape in these slices:
1. `providers-runtime`
2. `admin-api`
3. `admin-web-mobile`
4. `docs-branding`
5. `ops-tests`
Use an integration branch first. Do not rewrite downstream `main` in place
until the integration branch is validated.
## What To Check In Each Slice
### 1. Providers Runtime
Files and areas:
- `main/xiaozhi-server/core/providers/**`
- `main/xiaozhi-server/core/utils/**`
- `main/xiaozhi-server/plugins_func/**`
- `main/xiaozhi-server/config/**`
- `main/xiaozhi-server/requirements.txt`
- server Docker and compose files
Actions:
- remove Chinese-only ASR/LLM/TTS/news providers from shipped/default runtime
- keep western or provider-neutral replacements
- preserve downstream provider naming and localization
- keep runtime prompts, errors, MCP/tool text, and logs English-first
- keep server-facing defaults provider-neutral where possible
### 2. Admin API
Files and areas:
- `main/manager-api/src/main/java/**`
- `main/manager-api/src/main/resources/i18n/**`
- `main/manager-api/src/main/resources/db/changelog/**`
Actions:
- preserve provider filtering and downstream westernized metadata
- never rewrite Liquibase history destructively
- add follow-up migrations only; keep changelog append-only
- keep Chinese-only providers out of surfaced configs, selectors, and defaults
- keep upstream backend fixes even when downstream surface differs
Important:
- historical Liquibase SQL is an intentional exception zone
- do not "clean it up" casually if it would rewrite shipped history
- if a new migration adds Chinese-facing defaults, add a downstream cleanup
migration rather than editing old history
### 3. Admin Web And Mobile
Files and areas:
- `main/manager-web/src/**`
- `main/manager-web/public/**`
- `main/manager-mobile/src/**`
Actions:
- keep supported languages shared and non-duplicated
- default to English
- keep non-Chinese locales where useful
- remove Chinese-facing public routes, legal pages, selectors, assets, and
fallback copy from shipped downstream surfaces
- preserve upstream UI/framework improvements
### 4. Docs And Branding
Files and areas:
- `README*`
- `docs/**`
- internal reference docs used by downstream maintainers
Actions:
- rewrite docs in English or westernized multilingual form
- remove Chinese screenshots/copy where they are part of downstream surface
- prefer compact English reference docs over huge translated carry-overs
### 5. Ops And Tests
Files and areas:
- setup scripts
- Dockerfiles
- CI/test harnesses
- `main/xiaozhi-server/test/**`
Actions:
- keep tests runnable after rebase
- keep public or interactive test harness text English-first
- preserve useful downstream validation tools
## Generator Rule
Treat this as special:
- `main/manager-web/public/generator/assets/**` is generated output
- `main/manager-web/public/generator/index.html` is tied to that output
Do not hand-edit the built bundle unless absolutely necessary.
Preferred flow:
1. update generator source
2. rebuild generator
3. sync rebuilt assets into `main/manager-web/public/generator`
Generator source currently lives outside the main repo worktree during rebuild
work:
- `/tmp/xiaozhi-assets-generator`
If Han-script appears in the generated bundle, check generator source locales
first before attempting bundle surgery.
## Audit Workflow
Use the audit script after meaningful rebase batches:
```bash
./scripts/westernization_audit.sh
```
What it enforces:
- live source/docs must be clean of Han-script and `zh-CN` / `zh-TW`
- path names must be clean of Han-script
Intentional exception zones:
- `main/manager-api/src/main/resources/db/changelog`
- `main/manager-web/public/generator/assets`
If the audit fails outside those areas, fix the violations before moving on.
## Verification Workflow
Run the owning subsystem checks after each slice when possible.
### Python server
```bash
python3 main/xiaozhi-server/test/test_runner.py
```
Or project venv if needed:
```bash
./.venv-xiaozhi/bin/python main/xiaozhi-server/test/test_runner.py
```
### Manager API
```bash
cd main/manager-api
mvn -q -DskipTests compile
mvn test -q
```
Liquibase final-state validation matters here. Do not rely only on compile or
Spring tests that skip Liquibase.
Use the dedicated fresh-DB integration harness too:
```bash
cd main/manager-api
mvn -q -Dtest=LiquibaseWesternizationIntegrationTest test
```
What it checks:
- replays the full changelog chain on a fresh H2 database
- applies downstream append-only cleanup migrations
- writes a final seed dump to
`main/manager-api/target/liquibase-h2-seed-dump.txt`
- asserts that westernized final-state rows are present
- asserts that Chinese-facing seeded rows/tokens do not survive in the final
surfaced data
Harness files:
- `main/manager-api/src/test/java/xiaozhi/modules/sys/LiquibaseWesternizationIntegrationTest.java`
- `main/manager-api/src/test/java/xiaozhi/modules/sys/H2JsonFunctions.java`
### Manager Web
```bash
cd main/manager-web
npm run build
```
### Manager Mobile
```bash
cd main/manager-mobile
pnpm build:h5
pnpm type-check
```
If a verification step fails because of an upstream baseline issue, note that
clearly and avoid mixing that fix with unrelated westernization work unless it
blocks progress.
## High-Risk Areas
Be extra careful in these zones:
- Liquibase history
- provider metadata and seeded defaults
- generated web assets
- locale registries
- firmware/device dictionaries and model voice lists
- anything that can silently re-surface a removed Chinese provider
## Good Outcomes
A rebase is in good shape when all of these are true:
- deleted downstream providers stay deleted
- relocalized downstream providers stay relocalized
- upstream fixes are retained in surviving abstractions
- web/mobile shipped surfaces are English-first and non-Chinese-facing
- server runtime prompts and tool text are westernized
- docs and filenames are clean outside intentional exception zones
- `./scripts/westernization_audit.sh` passes
- `mvn -q -Dtest=LiquibaseWesternizationIntegrationTest test` passes
## Bad Smells
Stop and correct course if any of these happen:
- a removed provider reappears in config, UI, migrations, or docs
- Chinese locale assumptions return as defaults
- generated assets are edited directly without checking source
- large translated docs get copied forward when a shorter English reference
would do
- old migrations are rewritten instead of adding cleanup migrations
- the branch drifts into a single giant mixed overlay again
## Practical Order On Future Rebases
When upstream moves a lot, use this order:
1. rebase or merge upstream into an integration branch
2. restore provider/runtime deletions and relocalization
3. restore admin API provider filtering and downstream cleanup migrations
4. restore web/mobile surface cleanup
5. restore docs/branding cleanup
6. rebuild generator from source if needed
7. run the audit script
8. run subsystem validation
9. only then promote the integration branch
## Final Reminder
The purpose of downstream is not "translate upstream."
The purpose is to preserve a westernized product surface while still inheriting
upstream engineering improvements.