Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.
fix(v1.9.8): Phase B bug fixes — Windows hook, OAuth refresh, missing imports, None guards (#81)
Agrici.Daniel75de512abc35
diff --git a/hooks/hooks.json b/hooks/hooks.jsonindex c4677c9..6d7eb08 100644--- a/hooks/hooks.json+++ b/hooks/hooks.json@@ -6,7 +6,7 @@"hooks": [{"type": "command",- "command": "python3 \"${CLAUDE_PLUGIN_ROOT}/hooks/validate-schema.py\" \"$FILE_PATH\""+ "command": "python \"${CLAUDE_PLUGIN_ROOT}/hooks/validate-schema.py\" \"$FILE_PATH\""}]}diff --git a/hooks/validate-schema.py b/hooks/validate-schema.pyindex c79fc8b..762214d 100755--- a/hooks/validate-schema.py+++ b/hooks/validate-schema.py@@ -128,6 +128,16 @@ def main():if not filepath.endswith(valid_extensions):sys.exit(0)+ # File-size guard: skip files >10MB to bound memory + hook latency.+ # Real source files almost never exceed this; bigger inputs are typically+ # generated, minified bundles or accidental binary writes.+ MAX_FILE_BYTES = 10 * 1024 * 1024 # 10 MiB+ try:+ if os.path.getsize(filepath) > MAX_FILE_BYTES:+ sys.exit(0)+ except OSError:+ sys.exit(0)+try:with open(filepath, "r", encoding="utf-8", errors="ignore") as f:content = f.read()diff --git a/scripts/dataforseo_normalize.py b/scripts/dataforseo_normalize.pyindex c6398d4..d6fb60f 100755--- a/scripts/dataforseo_normalize.py+++ b/scripts/dataforseo_normalize.py@@ -262,6 +262,8 @@ def normalize_merchant(items: list[dict[str, Any]]) -> list[dict[str, Any]]:Returns:List of normalized product dicts."""+ if not items:+ return []normalized = []for item in items:# Handle rating as dict or scalar@@ -318,6 +320,8 @@ def normalize_social(items: list[dict[str, Any]]) -> list[dict[str, Any]]:Returns:List of normalized social signal dicts."""+ if not items:+ return []normalized = []for item in items:signal = {@@ -353,6 +357,8 @@ def normalize_reviews(items: list[dict[str, Any]]) -> list[dict[str, Any]]:Returns:List of normalized review dicts."""+ if not items:+ return []normalized = []for item in items:review = {diff --git a/scripts/google_auth.py b/scripts/google_auth.pyindex e460cac..565e0ed 100644--- a/scripts/google_auth.py+++ b/scripts/google_auth.py@@ -177,6 +177,40 @@ def _save_oauth_token(token_data: dict):json.dump(token_data, f, indent=2)+def _persist_oauth_client_path(creds_path: str):+ """+ Persist the absolute path to the OAuth client_secret JSON file in the+ user config so future refresh_token flows can locate the client_secret+ without re-prompting. Stores the PATH only; never the secret itself.++ Closes the bug where every OAuth user 401'd within 1 hour because the+ refresh path could not find oauth_client_path in config.+ """+ abs_path = os.path.abspath(os.path.expanduser(creds_path))+ os.makedirs(os.path.dirname(CONFIG_PATH), exist_ok=True)+ config = {}+ if os.path.exists(CONFIG_PATH):+ try:+ with open(CONFIG_PATH, "r") as f:+ config = json.load(f)+ except (json.JSONDecodeError, IOError):+ config = {}+ config["oauth_client_path"] = abs_path+ # Atomic write: tempfile + replace+ import tempfile+ fd, tmp_path = tempfile.mkstemp(+ dir=os.path.dirname(CONFIG_PATH), prefix=".google-api.", suffix=".tmp"+ )+ try:+ with os.fdopen(fd, "w") as f:+ json.dump(config, f, indent=2)+ os.replace(tmp_path, CONFIG_PATH)+ except Exception:+ if os.path.exists(tmp_path):+ os.unlink(tmp_path)+ raise++def _refresh_oauth_token(client: dict, token_data: dict) -> Optional[dict]:"""Refresh an expired OAuth token using the refresh_token."""import urllib.parse@@ -325,11 +359,16 @@ def run_oauth_flow(creds_path: str):sys.exit(1)# Exchange code for tokens- _exchange_code(client, auth_code[0])+ _exchange_code(client, auth_code[0], creds_path)++def _exchange_code(client: dict, code: str, creds_path: Optional[str] = None):+ """Exchange an authorization code for tokens.-def _exchange_code(client: dict, code: str):- """Exchange an authorization code for tokens."""+ If creds_path is provided, persist its absolute path to the user config+ as 'oauth_client_path' so subsequent refresh flows can locate the+ client_secret file without re-prompting.+ """import urllib.parseimport urllib.request@@ -354,9 +393,20 @@ def _exchange_code(client: dict, code: str):_save_oauth_token(token_data)print("OAuth token saved successfully!")- # Also save the OAuth client path to config- config = load_config()- # Don't overwrite existing config, just suggest+ # Persist oauth_client_path so refresh works after process restart.+ # This is the PATH, never the client_secret value itself.+ if creds_path:+ try:+ _persist_oauth_client_path(creds_path)+ print(f"OAuth client path persisted to {CONFIG_PATH}")+ except Exception as e:+ print(+ f"Warning: Could not persist oauth_client_path: {e}. "+ f"Add 'oauth_client_path' to {CONFIG_PATH} manually for "+ f"automatic token refresh.",+ file=sys.stderr,+ )+print(f"\nToken saved to: {TOKEN_PATH}")except Exception as e:print(f"Error exchanging authorization code: {e}", file=sys.stderr)@@ -728,7 +778,7 @@ def main():sys.exit(1)client = _load_oauth_client(args.creds)if client:- _exchange_code(client, args.code)+ _exchange_code(client, args.code, args.creds)returnif args.setup:diff --git a/scripts/keyword_planner.py b/scripts/keyword_planner.pyindex fb25c5f..f4caef6 100644--- a/scripts/keyword_planner.py+++ b/scripts/keyword_planner.py@@ -28,6 +28,7 @@ Note: Accounts without active ad spend receive bucketed volume rangesimport argparseimport json+import osimport sysfrom typing import Optional@@ -41,7 +42,6 @@ except ImportError:try:from google_auth import load_configexcept ImportError:- import ossys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))from google_auth import load_config