增加Web和桌面参数自动同步清单

This commit is contained in:
Codex committed 2026-05-20 20:35:58 +08:00
1 parent caa24ea8ca
commit 38e2b399d4
2 files changed
+618 -2

No files matched your search

+87 -2
View File
@@ -13,6 +13,8 @@ verification without opening the GUI or starting the Web server.
from __future__ import annotations
import argparse
import json
import re
import sys
from pathlib import Path
@@ -20,6 +22,7 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
GUI_APP = ROOT / "gui" / "gui_app.py"
WEB_INDEX = ROOT / "webui" / "index.html"
MANIFEST_PATH = ROOT / "tools" / "web_gui_config_manifest.json"
IGNORED_CONTAINER_KEYS = {
"debug_captures",
@@ -96,7 +99,7 @@ def extract_web_keys(source: str) -> set[str]:
return keys
def main() -> int:
def build_manifest() -> dict[str, object]:
gui_source = _read(GUI_APP)
web_source = _read(WEB_INDEX)
@@ -105,6 +108,65 @@ def main() -> int:
web_keys = extract_web_keys(web_source)
expected_gui_keys = web_keys - GUI_RUNTIME_ONLY_KEYS
return {
"generated_by": "tools/check_web_gui_config_sync.py --sync",
"shared_keys": sorted(expected_gui_keys),
"gui_runtime_only_keys": sorted(GUI_RUNTIME_ONLY_KEYS),
"gui_saved_keys": sorted(gui_saved),
"gui_loaded_keys": sorted(gui_loaded),
"web_keys": sorted(web_keys),
}
def write_manifest() -> None:
manifest = build_manifest()
MANIFEST_PATH.write_text(
json.dumps(manifest, ensure_ascii=False, indent=2) + "\n",
encoding="utf-8",
)
print(f"[OK] Wrote {MANIFEST_PATH.relative_to(ROOT)}")
def load_manifest() -> dict[str, object] | None:
if not MANIFEST_PATH.exists():
return None
try:
return json.loads(MANIFEST_PATH.read_text(encoding="utf-8"))
except json.JSONDecodeError:
return None
def compare_manifest(current: dict[str, object]) -> list[str]:
stored = load_manifest()
if stored is None:
return [
f"{MANIFEST_PATH.relative_to(ROOT)} is missing or invalid; "
"run tools/check_web_gui_config_sync.py --sync"
]
diffs: list[str] = []
for key in (
"shared_keys",
"gui_runtime_only_keys",
"gui_saved_keys",
"gui_loaded_keys",
"web_keys",
):
if stored.get(key) != current.get(key):
diffs.append(
f"{MANIFEST_PATH.relative_to(ROOT)} is stale for {key}; "
"run tools/check_web_gui_config_sync.py --sync"
)
return diffs
def check_sync() -> tuple[list[tuple[str, list[str]]], dict[str, object]]:
manifest = build_manifest()
gui_saved = set(manifest["gui_saved_keys"]) # type: ignore[arg-type]
gui_loaded = set(manifest["gui_loaded_keys"]) # type: ignore[arg-type]
web_keys = set(manifest["web_keys"]) # type: ignore[arg-type]
expected_gui_keys = set(manifest["shared_keys"]) # type: ignore[arg-type]
problems: list[tuple[str, list[str]]] = []
missing_in_web = sorted((gui_saved | gui_loaded) - web_keys - GUI_RUNTIME_ONLY_KEYS)
@@ -124,6 +186,29 @@ def main() -> int:
if loaded_not_saved:
problems.append(("gui_app.py loads keys it does not save", loaded_not_saved))
stale_manifest = compare_manifest(manifest)
if stale_manifest:
problems.append(("Generated sync manifest is not current", stale_manifest))
return problems, manifest
def main() -> int:
parser = argparse.ArgumentParser(
description="Check or regenerate WebUI/Desktop GUI config sync metadata."
)
parser.add_argument(
"--sync",
action="store_true",
help="Regenerate tools/web_gui_config_manifest.json from current code.",
)
args = parser.parse_args()
if args.sync:
write_manifest()
return 0
problems, manifest = check_sync()
if problems:
print("[FAIL] WebUI and gui_app.py config keys are not synchronized.")
for title, keys in problems:
@@ -134,7 +219,7 @@ def main() -> int:
print(
"[OK] WebUI and gui_app.py config keys are synchronized "
f"({len(expected_gui_keys)} shared keys)."
f"({len(manifest['shared_keys'])} shared keys)."
)
return 0
+531
View File
@@ -0,0 +1,531 @@
{
"generated_by": "tools/check_web_gui_config_sync.py --sync",
"shared_keys": [
"attend_button_red_ratio_threshold",
"auto_join_fansclub",
"contains_not_want",
"contains_want",
"coupon_template_match_threshold",
"debug_captures.async_save",
"debug_captures.auto_cleanup",
"debug_captures.enabled",
"debug_captures.keep_days",
"debug_captures.log_on_complete",
"debug_captures.max_files",
"enable_back_on_misses",
"enable_ocr_mode1",
"enable_streaming_screenshot",
"fansclub_auto_join_wait_seconds",
"fansclub_click_delay",
"fansclub_fail_action",
"fansclub_join_red_ratio_threshold",
"fansclub_manual_wait_seconds",
"fudai_click_wait_seconds",
"fudai_detail_template_threshold",
"fudai_disable_content_recognition",
"fudai_disable_task_recognition",
"fudai_exit_after_misses",
"fudai_find_max_attempts",
"fudai_icon_max_wait_seconds",
"fudai_icon_retry_delay_seconds",
"fudai_quiet_end_hour",
"fudai_quiet_hours_enabled",
"fudai_quiet_start_hour",
"fudai_template_match_enabled",
"fudai_template_match_threshold",
"gui.theme",
"high_value_fudai_after_action",
"high_value_fudai_enabled",
"high_value_fudai_join_ahead_seconds",
"high_value_fudai_max_reservations",
"high_value_fudai_max_swipe_back",
"high_value_fudai_poll_before_seconds",
"high_value_fudai_threshold_yuan",
"high_value_room_revisit_enabled",
"high_value_room_revisit_max_age_days",
"high_value_room_revisit_max_per_run",
"high_value_room_revisit_min_interval_seconds",
"high_value_room_revisit_min_prize_value",
"high_value_room_revisit_only_current_run",
"infinite_loop_enabled",
"live_room_match_threshold",
"logging.action_log_format",
"logging.beautify_output",
"logging.color_output",
"logging.compress_after_days",
"logging.compress_logs",
"logging.debug_detail_level",
"logging.enable_monitor",
"logging.error_detail_level",
"logging.keep_days",
"logging.log_format_mode",
"logging.max_total_size_gb",
"logging.monitor_critical_mb",
"logging.monitor_warning_mb",
"logging.performance_tracking.enabled",
"logging.performance_tracking.track_function_calls",
"logging.show_timestamps",
"logging.stage_diag_verbose",
"lucky_draw_red_ratio_threshold",
"max_participants",
"min_participants",
"min_prize_value_yuan",
"needswitch",
"reservation_back_swipe_delay",
"reservation_back_verify_enabled",
"reservation_back_verify_wait_seconds",
"reset_after_swipes",
"reset_after_swipes_action",
"reset_after_swipes_enabled",
"shopping_redpacket_red_ratio_threshold",
"skip_if_countdown_gt_seconds",
"skip_if_countdown_lt_seconds",
"stage_diag_max_step_time",
"stage_diag_max_time",
"swipe_down_back_count",
"swipe_down_back_enabled",
"swipe_duration_ms",
"swipe_up_end_y",
"swipe_up_start_y",
"switch_room_wait_after_stage_diag_seconds",
"wait_minutes",
"y_pianyi",
"yanghao_after_dwell_swipe_direction",
"yanghao_after_dwell_swipe_distance_px",
"yanghao_comment_btn_x",
"yanghao_comment_btn_y",
"yanghao_comment_close_x",
"yanghao_comment_close_y",
"yanghao_comment_input_x",
"yanghao_comment_input_y",
"yanghao_comment_prob",
"yanghao_comment_send_x",
"yanghao_comment_send_y",
"yanghao_comment_texts",
"yanghao_dwell_on_action_max_seconds",
"yanghao_dwell_on_action_min_seconds",
"yanghao_enable_actions",
"yanghao_enabled",
"yanghao_fav_icon_x",
"yanghao_fav_icon_y",
"yanghao_fav_keywords",
"yanghao_fav_prob",
"yanghao_fav_roi_offset_x",
"yanghao_fav_roi_offset_y",
"yanghao_fav_template_path",
"yanghao_icon_match_threshold",
"yanghao_icon_roi_size",
"yanghao_like_icon_x",
"yanghao_like_icon_y",
"yanghao_like_keywords",
"yanghao_like_prob",
"yanghao_like_roi_offset_x",
"yanghao_like_roi_offset_y",
"yanghao_like_template_path",
"yanghao_only",
"yanghao_recommend_duration_seconds",
"yanghao_recommend_interval_seconds",
"yanghao_step_screenshot"
],
"gui_runtime_only_keys": [
"gui.realtime_status.refresh_interval_ms",
"gui.realtime_status.tail_items",
"log_unified_enabled",
"log_unified_path",
"logging.use_dated_logs"
],
"gui_saved_keys": [
"attend_button_red_ratio_threshold",
"auto_join_fansclub",
"contains_not_want",
"contains_want",
"coupon_template_match_threshold",
"debug_captures.async_save",
"debug_captures.auto_cleanup",
"debug_captures.enabled",
"debug_captures.keep_days",
"debug_captures.log_on_complete",
"debug_captures.max_files",
"enable_back_on_misses",
"enable_ocr_mode1",
"enable_streaming_screenshot",
"fansclub_auto_join_wait_seconds",
"fansclub_click_delay",
"fansclub_fail_action",
"fansclub_join_red_ratio_threshold",
"fansclub_manual_wait_seconds",
"fudai_click_wait_seconds",
"fudai_detail_template_threshold",
"fudai_disable_content_recognition",
"fudai_disable_task_recognition",
"fudai_exit_after_misses",
"fudai_find_max_attempts",
"fudai_icon_max_wait_seconds",
"fudai_icon_retry_delay_seconds",
"fudai_quiet_end_hour",
"fudai_quiet_hours_enabled",
"fudai_quiet_start_hour",
"fudai_template_match_enabled",
"fudai_template_match_threshold",
"gui.theme",
"high_value_fudai_after_action",
"high_value_fudai_enabled",
"high_value_fudai_join_ahead_seconds",
"high_value_fudai_max_reservations",
"high_value_fudai_max_swipe_back",
"high_value_fudai_poll_before_seconds",
"high_value_fudai_threshold_yuan",
"high_value_room_revisit_enabled",
"high_value_room_revisit_max_age_days",
"high_value_room_revisit_max_per_run",
"high_value_room_revisit_min_interval_seconds",
"high_value_room_revisit_min_prize_value",
"high_value_room_revisit_only_current_run",
"infinite_loop_enabled",
"live_room_match_threshold",
"log_unified_enabled",
"log_unified_path",
"logging.action_log_format",
"logging.beautify_output",
"logging.color_output",
"logging.compress_after_days",
"logging.compress_logs",
"logging.debug_detail_level",
"logging.enable_monitor",
"logging.error_detail_level",
"logging.keep_days",
"logging.log_format_mode",
"logging.max_total_size_gb",
"logging.monitor_critical_mb",
"logging.monitor_warning_mb",
"logging.performance_tracking.enabled",
"logging.performance_tracking.track_function_calls",
"logging.show_timestamps",
"logging.stage_diag_verbose",
"logging.use_dated_logs",
"lucky_draw_red_ratio_threshold",
"max_participants",
"min_participants",
"min_prize_value_yuan",
"needswitch",
"reservation_back_swipe_delay",
"reservation_back_verify_enabled",
"reservation_back_verify_wait_seconds",
"reset_after_swipes",
"reset_after_swipes_action",
"reset_after_swipes_enabled",
"shopping_redpacket_red_ratio_threshold",
"skip_if_countdown_gt_seconds",
"skip_if_countdown_lt_seconds",
"stage_diag_max_step_time",
"stage_diag_max_time",
"swipe_down_back_count",
"swipe_down_back_enabled",
"swipe_duration_ms",
"swipe_up_end_y",
"swipe_up_start_y",
"switch_room_wait_after_stage_diag_seconds",
"wait_minutes",
"y_pianyi",
"yanghao_after_dwell_swipe_direction",
"yanghao_after_dwell_swipe_distance_px",
"yanghao_comment_btn_x",
"yanghao_comment_btn_y",
"yanghao_comment_close_x",
"yanghao_comment_close_y",
"yanghao_comment_input_x",
"yanghao_comment_input_y",
"yanghao_comment_prob",
"yanghao_comment_send_x",
"yanghao_comment_send_y",
"yanghao_comment_texts",
"yanghao_dwell_on_action_max_seconds",
"yanghao_dwell_on_action_min_seconds",
"yanghao_enable_actions",
"yanghao_enabled",
"yanghao_fav_icon_x",
"yanghao_fav_icon_y",
"yanghao_fav_keywords",
"yanghao_fav_prob",
"yanghao_fav_roi_offset_x",
"yanghao_fav_roi_offset_y",
"yanghao_fav_template_path",
"yanghao_icon_match_threshold",
"yanghao_icon_roi_size",
"yanghao_like_icon_x",
"yanghao_like_icon_y",
"yanghao_like_keywords",
"yanghao_like_prob",
"yanghao_like_roi_offset_x",
"yanghao_like_roi_offset_y",
"yanghao_like_template_path",
"yanghao_only",
"yanghao_recommend_duration_seconds",
"yanghao_recommend_interval_seconds",
"yanghao_step_screenshot"
],
"gui_loaded_keys": [
"attend_button_red_ratio_threshold",
"auto_join_fansclub",
"contains_not_want",
"contains_want",
"coupon_template_match_threshold",
"debug_captures.async_save",
"debug_captures.auto_cleanup",
"debug_captures.enabled",
"debug_captures.keep_days",
"debug_captures.log_on_complete",
"debug_captures.max_files",
"enable_back_on_misses",
"enable_ocr_mode1",
"enable_streaming_screenshot",
"fansclub_auto_join_wait_seconds",
"fansclub_click_delay",
"fansclub_fail_action",
"fansclub_join_red_ratio_threshold",
"fansclub_manual_wait_seconds",
"fudai_click_wait_seconds",
"fudai_detail_template_threshold",
"fudai_disable_content_recognition",
"fudai_disable_task_recognition",
"fudai_exit_after_misses",
"fudai_find_max_attempts",
"fudai_icon_max_wait_seconds",
"fudai_icon_retry_delay_seconds",
"fudai_quiet_end_hour",
"fudai_quiet_hours_enabled",
"fudai_quiet_start_hour",
"fudai_template_match_enabled",
"fudai_template_match_threshold",
"gui.realtime_status.refresh_interval_ms",
"gui.realtime_status.tail_items",
"gui.theme",
"high_value_fudai_after_action",
"high_value_fudai_enabled",
"high_value_fudai_join_ahead_seconds",
"high_value_fudai_max_reservations",
"high_value_fudai_max_swipe_back",
"high_value_fudai_poll_before_seconds",
"high_value_fudai_threshold_yuan",
"high_value_room_revisit_enabled",
"high_value_room_revisit_max_age_days",
"high_value_room_revisit_max_per_run",
"high_value_room_revisit_min_interval_seconds",
"high_value_room_revisit_min_prize_value",
"high_value_room_revisit_only_current_run",
"infinite_loop_enabled",
"live_room_match_threshold",
"log_unified_enabled",
"log_unified_path",
"logging.action_log_format",
"logging.beautify_output",
"logging.color_output",
"logging.compress_after_days",
"logging.compress_logs",
"logging.debug_detail_level",
"logging.enable_monitor",
"logging.error_detail_level",
"logging.keep_days",
"logging.log_format_mode",
"logging.max_total_size_gb",
"logging.monitor_critical_mb",
"logging.monitor_warning_mb",
"logging.performance_tracking.enabled",
"logging.performance_tracking.track_function_calls",
"logging.show_timestamps",
"logging.stage_diag_verbose",
"logging.use_dated_logs",
"lucky_draw_red_ratio_threshold",
"max_participants",
"min_participants",
"min_prize_value_yuan",
"needswitch",
"reservation_back_swipe_delay",
"reservation_back_verify_enabled",
"reservation_back_verify_wait_seconds",
"reset_after_swipes",
"reset_after_swipes_action",
"reset_after_swipes_enabled",
"shopping_redpacket_red_ratio_threshold",
"skip_if_countdown_gt_seconds",
"skip_if_countdown_lt_seconds",
"stage_diag_max_step_time",
"stage_diag_max_time",
"swipe_down_back_count",
"swipe_down_back_enabled",
"swipe_duration_ms",
"swipe_up_end_y",
"swipe_up_start_y",
"switch_room_wait_after_stage_diag_seconds",
"wait_minutes",
"y_pianyi",
"yanghao_after_dwell_swipe_direction",
"yanghao_after_dwell_swipe_distance_px",
"yanghao_comment_btn_x",
"yanghao_comment_btn_y",
"yanghao_comment_close_x",
"yanghao_comment_close_y",
"yanghao_comment_input_x",
"yanghao_comment_input_y",
"yanghao_comment_prob",
"yanghao_comment_send_x",
"yanghao_comment_send_y",
"yanghao_comment_texts",
"yanghao_dwell_on_action_max_seconds",
"yanghao_dwell_on_action_min_seconds",
"yanghao_enable_actions",
"yanghao_enabled",
"yanghao_fav_icon_x",
"yanghao_fav_icon_y",
"yanghao_fav_keywords",
"yanghao_fav_prob",
"yanghao_fav_roi_offset_x",
"yanghao_fav_roi_offset_y",
"yanghao_fav_template_path",
"yanghao_icon_match_threshold",
"yanghao_icon_roi_size",
"yanghao_like_icon_x",
"yanghao_like_icon_y",
"yanghao_like_keywords",
"yanghao_like_prob",
"yanghao_like_roi_offset_x",
"yanghao_like_roi_offset_y",
"yanghao_like_template_path",
"yanghao_only",
"yanghao_recommend_duration_seconds",
"yanghao_recommend_interval_seconds",
"yanghao_step_screenshot"
],
"web_keys": [
"attend_button_red_ratio_threshold",
"auto_join_fansclub",
"contains_not_want",
"contains_want",
"coupon_template_match_threshold",
"debug_captures.async_save",
"debug_captures.auto_cleanup",
"debug_captures.enabled",
"debug_captures.keep_days",
"debug_captures.log_on_complete",
"debug_captures.max_files",
"enable_back_on_misses",
"enable_ocr_mode1",
"enable_streaming_screenshot",
"fansclub_auto_join_wait_seconds",
"fansclub_click_delay",
"fansclub_fail_action",
"fansclub_join_red_ratio_threshold",
"fansclub_manual_wait_seconds",
"fudai_click_wait_seconds",
"fudai_detail_template_threshold",
"fudai_disable_content_recognition",
"fudai_disable_task_recognition",
"fudai_exit_after_misses",
"fudai_find_max_attempts",
"fudai_icon_max_wait_seconds",
"fudai_icon_retry_delay_seconds",
"fudai_quiet_end_hour",
"fudai_quiet_hours_enabled",
"fudai_quiet_start_hour",
"fudai_template_match_enabled",
"fudai_template_match_threshold",
"gui.realtime_status.refresh_interval_ms",
"gui.realtime_status.tail_items",
"gui.theme",
"high_value_fudai_after_action",
"high_value_fudai_enabled",
"high_value_fudai_join_ahead_seconds",
"high_value_fudai_max_reservations",
"high_value_fudai_max_swipe_back",
"high_value_fudai_poll_before_seconds",
"high_value_fudai_threshold_yuan",
"high_value_room_revisit_enabled",
"high_value_room_revisit_max_age_days",
"high_value_room_revisit_max_per_run",
"high_value_room_revisit_min_interval_seconds",
"high_value_room_revisit_min_prize_value",
"high_value_room_revisit_only_current_run",
"infinite_loop_enabled",
"live_room_match_threshold",
"log_unified_enabled",
"log_unified_path",
"logging.action_log_format",
"logging.beautify_output",
"logging.color_output",
"logging.compress_after_days",
"logging.compress_logs",
"logging.debug_detail_level",
"logging.enable_monitor",
"logging.error_detail_level",
"logging.keep_days",
"logging.log_format_mode",
"logging.max_total_size_gb",
"logging.monitor_critical_mb",
"logging.monitor_warning_mb",
"logging.performance_tracking.enabled",
"logging.performance_tracking.track_function_calls",
"logging.show_timestamps",
"logging.stage_diag_verbose",
"logging.use_dated_logs",
"lucky_draw_red_ratio_threshold",
"max_participants",
"min_participants",
"min_prize_value_yuan",
"needswitch",
"reservation_back_swipe_delay",
"reservation_back_verify_enabled",
"reservation_back_verify_wait_seconds",
"reset_after_swipes",
"reset_after_swipes_action",
"reset_after_swipes_enabled",
"shopping_redpacket_red_ratio_threshold",
"skip_if_countdown_gt_seconds",
"skip_if_countdown_lt_seconds",
"stage_diag_max_step_time",
"stage_diag_max_time",
"swipe_down_back_count",
"swipe_down_back_enabled",
"swipe_duration_ms",
"swipe_up_end_y",
"swipe_up_start_y",
"switch_room_wait_after_stage_diag_seconds",
"wait_minutes",
"y_pianyi",
"yanghao_after_dwell_swipe_direction",
"yanghao_after_dwell_swipe_distance_px",
"yanghao_comment_btn_x",
"yanghao_comment_btn_y",
"yanghao_comment_close_x",
"yanghao_comment_close_y",
"yanghao_comment_input_x",
"yanghao_comment_input_y",
"yanghao_comment_prob",
"yanghao_comment_send_x",
"yanghao_comment_send_y",
"yanghao_comment_texts",
"yanghao_dwell_on_action_max_seconds",
"yanghao_dwell_on_action_min_seconds",
"yanghao_enable_actions",
"yanghao_enabled",
"yanghao_fav_icon_x",
"yanghao_fav_icon_y",
"yanghao_fav_keywords",
"yanghao_fav_prob",
"yanghao_fav_roi_offset_x",
"yanghao_fav_roi_offset_y",
"yanghao_fav_template_path",
"yanghao_icon_match_threshold",
"yanghao_icon_roi_size",
"yanghao_like_icon_x",
"yanghao_like_icon_y",
"yanghao_like_keywords",
"yanghao_like_prob",
"yanghao_like_roi_offset_x",
"yanghao_like_roi_offset_y",
"yanghao_like_template_path",
"yanghao_only",
"yanghao_recommend_duration_seconds",
"yanghao_recommend_interval_seconds",
"yanghao_step_screenshot"
]
}