This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
VMess domain rotator: fetch candidate domains from an API, select a preferred domain, write runtime artifacts, and optionally auto-commit/push runtime changes to a dedicated branch (runtime-state).
python3 -m py_compile scripts/domain_updater.py
python3 -m py_compile scripts/update_vmess_links.py
bash -n scripts/run_update_and_commit.sh
bash -n scripts/install_debian.sh
bash -n scripts/uninstall_debian.sh
python3 scripts/domain_updater.py --config config.json
bash scripts/run_update_and_commit.sh config.json
bash scripts/run_update_and_commit.sh --force-commit config.json
# or
GIT_FORCE_COMMIT=1 bash scripts/run_update_and_commit.sh config.json
python3 scripts/update_vmess_links.py \
--input ./nodes.txt \
--output ./nodes.updated.txt \
--domain-file ./runtime/current_domain.txt
python3 scripts/update_vmess_links.py \
--input ./nodes.txt \
--output ./nodes.updated.txt \
--domain-file ./runtime/current_domain.txt \
--name-regex "(argo|cf|vm)"
python3 -m http.server 8080 --directory runtime
curl http://127.0.0.1:8080/current_domain.json
# Recommended default install (1h timer, push enabled, credential-helper mode)
sudo bash scripts/install_debian.sh
# Useful variants
sudo bash scripts/install_debian.sh --interval 5min
sudo bash scripts/install_debian.sh --git-push 0
sudo bash scripts/install_debian.sh --git-push-remote origin
sudo bash scripts/install_debian.sh --git-http-username aurora --git-http-token-file /root/.config/vmess-token --git-use-credential-store 1
sudo bash scripts/uninstall_debian.sh
sudo bash scripts/uninstall_debian.sh --keep-auth-files
tests/ directory or unit test suite.scripts/domain_updater.py is the core pipeline:
api block in config.json).parser.field_paths, parser.json_paths, or regex fallback.domain_filter).record_mapping.records_path and only accesses whitelisted fields from record_mapping.field_map.record_filter (API-specific strategy via config).scoring) with configurable weighted_average or lexicographic strategy.healthcheck).selection.top_n).runtime/.output.runtime_dir against the config file directory.last_good_domain from runtime/state.json when selection fails.scripts/run_update_and_commit.sh wraps the updater and git workflow:
runtime/current_domain.txt after updater run.runtime-state HEAD (runtime/current_domain.txt) and skips commit/push when unchanged (default behavior).runtime-state (same branch or temporary worktree).runtime/current_domain.txt, runtime/current_domain.json, runtime/state.json, runtime/substore_vars.json) when domain changes.--force-commit or GIT_FORCE_COMMIT=1; when no content changes it creates an empty commit with a manual: commit message that includes selected domain and UTC update time.GIT_CREDENTIAL_HELPER, e.g. store)GIT_HTTP_USERNAME + GIT_HTTP_TOKEN/GIT_HTTP_TOKEN_FILE)GIT_PUSH_REQUIRED defaults to GIT_PUSH_ENABLED; when enabled, push failure returns non-zero for systemd visibility.GIT_TERMINAL_PROMPT=0.scripts/update_vmess_links.py:
vmess:// payload JSON.add field with selected domain.ps field).substore/operator_template.js:
runtime/current_domain.json over HTTP.scriptResourceCache (default TTL 5 min).server for matched node names.config.json)Key top-level blocks:
api: endpoint/method/headers/params/body/timeoutparser: domain extraction paths/regexrecord_mapping: required whitelist registry (records_path, field_map, created time parse settings)record_filter: optional record-level exclusion rules (fields must come from record_mapping.field_map)domain_filter: include suffixes / exclude regexscoring: record ranking strategy (weighted_average / lexicographic) + within_hours + tie-breakershealthcheck: TLS probe settingsselection: candidate cut (top_n)output: runtime file names/pathsv2ray: optional token replacement renderingnotify: optional post-run command (AUTODOMAIN, AUTODOMAIN_STATUS env vars)Validation behavior:
record_mapping is mandatory.record_mapping.field_map.domain and record_mapping.field_map.created_at are mandatory.record_filter / scoring.weighted_fields / scoring.lexicographic_fields / scoring.tie_breakers must be pre-registered in field_map.Generated in runtime/:
current_domain.txt: selected domain (plain text)current_domain.json: selected domain + status + metadatastate.json: persistent state, including last_good_domainsubstore_vars.json: export-friendly variableslast_good_domain persistence is critical for resilience.runtime-state branch is intended to isolate frequently changing runtime outputs from main source history.main normally ignores runtime/ outputs via .gitignore; runtime artifacts are intended to be tracked on runtime-state.scripts/install_debian.sh) writes /etc/vmess-domain-rotator.env, configures oneshot service+timer, and sets push-required behavior when push is enabled.systemd/* static templates are intentionally not maintained; install script dynamically generates unit files under /etc/systemd/system/.SUDO_USER, and default auth mode is credential helper store.--keep-auth-files is set.