From 3c1a04a58708cdca57238572f8d0c16a894e8b5b Mon Sep 17 00:00:00 2001 From: Panniantong Date: Sat, 28 Feb 2026 11:11:55 +0100 Subject: [PATCH 1/2] fix: sync Twitter cookies to xreach session.json on configure When running 'agent-reach configure twitter-cookies', credentials are now automatically written to ~/.config/xfetch/session.json so that 'xreach auth check' works without manual intervention. Preserves existing session.json fields if the file already exists. Falls back gracefully if the sync fails (still saves to agent-reach config). Fixes #50 --- agent_reach/cli.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/agent_reach/cli.py b/agent_reach/cli.py index c484416..647e664 100644 --- a/agent_reach/cli.py +++ b/agent_reach/cli.py @@ -704,7 +704,25 @@ def _cmd_configure(args): if auth_token and ct0: config.set("twitter_auth_token", auth_token) config.set("twitter_ct0", ct0) - print(f"✅ Twitter cookies configured!") + + # Sync credentials to xreach's session.json so xreach auth check works + try: + import json + xfetch_dir = os.path.join(os.path.expanduser("~"), ".config", "xfetch") + os.makedirs(xfetch_dir, exist_ok=True) + session_path = os.path.join(xfetch_dir, "session.json") + session_data = {} + if os.path.exists(session_path): + with open(session_path, "r", encoding="utf-8") as sf: + session_data = json.load(sf) + session_data["authToken"] = auth_token + session_data["ct0"] = ct0 + with open(session_path, "w", encoding="utf-8") as sf: + json.dump(session_data, sf, indent=2) + print("✅ Twitter cookies configured (synced to xreach)!") + except Exception as e: + print("✅ Twitter cookies configured!") + print(f"⚠️ Could not sync to xreach session.json: {e}") print("Testing Twitter access...", end=" ") try: From 4f529422603a6f7a9b1a174304af3b10ed2d2214 Mon Sep 17 00:00:00 2001 From: Panniantong Date: Sat, 28 Feb 2026 13:28:14 +0100 Subject: [PATCH 2/2] improve: add chmod 0o600 for session.json (from PR #51 suggestion) --- agent_reach/cli.py | 1 + 1 file changed, 1 insertion(+) diff --git a/agent_reach/cli.py b/agent_reach/cli.py index 647e664..caa7a22 100644 --- a/agent_reach/cli.py +++ b/agent_reach/cli.py @@ -719,6 +719,7 @@ def _cmd_configure(args): session_data["ct0"] = ct0 with open(session_path, "w", encoding="utf-8") as sf: json.dump(session_data, sf, indent=2) + os.chmod(session_path, 0o600) print("✅ Twitter cookies configured (synced to xreach)!") except Exception as e: print("✅ Twitter cookies configured!")