From 66f82eb214d11ee8db7e60e9ecc02a9684041c8a Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 22 May 2026 22:08:05 +0200 Subject: [PATCH] Add --print-rules-info CLI flag for host cache freshness lookup --- rcjav/cli.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/rcjav/cli.py b/rcjav/cli.py index bb27ba1..d7f3dcc 100644 --- a/rcjav/cli.py +++ b/rcjav/cli.py @@ -409,6 +409,10 @@ def main(): "using the current ID extraction rules. No rclone calls — " "fast path for picking up rule changes without re-scanning. " "Outputs JSON when --format json, plain otherwise.") + ap.add_argument("--print-rules-info", action="store_true", + help="Print cache contract version constants and current " + "rules signature as JSON, then exit. Used by the native-" + "messaging host to surface cache freshness in the UI.") ap.add_argument("--basic", action="store_true", help="Plain text output, no rich tables/panels/progress bars. " "Useful for piping or low-bandwidth terminals.") @@ -485,6 +489,18 @@ def main(): args.catalog = list(DEFAULT_CATALOG) # --library-issues: read-only cache scan for non-canonical filenames. + # --print-rules-info: report current cache contract constants + rules signature. + if args.print_rules_info: + from rcjav.cache import CACHE_SCHEMA_VERSION, ID_RULES_VERSION + from rcjav.ids import current_rules_signature + print(json.dumps({ + "ok": True, + "cache_schema": CACHE_SCHEMA_VERSION, + "id_rules": ID_RULES_VERSION, + "id_rules_signature": current_rules_signature(), + })) + sys.exit(0) + # --reextract: rebuild jav_id values from current rules without re-scanning. if args.reextract: from rcjav.ids import current_rules_signature