mirror of
https://github.com/AgriciDaniel/claude-seo.git
synced 2026-11-25 07:30:08 +01:00
4 new skills from community submissions, hreflang cultural profiles, DataForSEO cost guardrails, security audit fixes, and updated docs. Skills added (4): - seo-cluster: SERP-based semantic topic clustering with hub-spoke architecture and interactive SVG visualization (Lutfiya Miller) - seo-sxo: Search Experience Optimization with page-type detection and persona scoring (Florian Schmitz) - seo-drift: "git for SEO" baseline/diff monitoring with SQLite persistence and 17 comparison rules (Dan Colta) - seo-ecommerce: Product schema, DataForSEO Merchant API, marketplace intelligence (Matej Marjanovic) Skills enhanced (1): - seo-hreflang: DACH/FR/ES/JA cultural profiles, locale formats, content parity checks (Chris Muller) Agents added (4): - seo-cluster, seo-drift, seo-ecommerce, seo-sxo Scripts added (7): - drift_baseline.py, drift_compare.py, drift_history.py, drift_report.py - dataforseo_costs.py, dataforseo_merchant.py, dataforseo_normalize.py Security fixes: - Cost guardrail bypass: unknown endpoints now trigger approval instead of defaulting to $0 cost; reset requires --confirm + audit trail - XSS in cluster-map.html: cluster labels wrapped in escapeHtml() - File locking: fcntl used on cost ledger to prevent concurrent writes - CI coverage: 7 new scripts added to validation matrix Repo additions: - AGENTS.md: multi-platform bootstrap (Cursor, Antigravity) - CONTRIBUTORS.md: Pro Hub Challenge attribution credits - claude-seo-slides/: HTML slide deck for v1.9.0 community presentation - video-script-v1.7.2.md, youtube-shorts-research.md: content assets - skills/seo-dataforseo/references/cost-tiers.md: cost tier reference Plugin manifest: 1.9.0, 23 skills, 17 agents, 30 scripts tracked Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
128 lines
3.4 KiB
Python
128 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Query drift history for a URL from the SQLite database.
|
|
|
|
Usage:
|
|
python drift_history.py <url> [--limit N]
|
|
|
|
Output: JSON array of baselines and comparisons for the URL.
|
|
"""
|
|
|
|
import argparse
|
|
import json
|
|
import os
|
|
import sys
|
|
|
|
SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
sys.path.insert(0, SCRIPTS_DIR)
|
|
|
|
from drift_baseline import DB_PATH, init_db, normalize_url, url_hash # noqa: E402
|
|
|
|
|
|
def get_history(url: str, limit: int = 20) -> dict:
|
|
"""
|
|
Retrieve baselines and comparisons for a URL.
|
|
|
|
Args:
|
|
url: The URL to query history for.
|
|
limit: Maximum number of baselines to return.
|
|
|
|
Returns:
|
|
Dict with baselines and comparisons arrays.
|
|
"""
|
|
norm_url = normalize_url(url)
|
|
uhash = url_hash(url)
|
|
|
|
if not os.path.exists(DB_PATH):
|
|
return {"url": norm_url, "baselines": [], "comparisons": [], "note": "No database found. Run `drift baseline` first."}
|
|
|
|
conn = init_db()
|
|
try:
|
|
# Fetch baselines (all queries parameterized)
|
|
rows = conn.execute(
|
|
"""
|
|
SELECT id, url, timestamp, title, canonical, robots, h1,
|
|
status_code, html_hash, schema_hash,
|
|
CASE WHEN cwv_json IS NOT NULL THEN 1 ELSE 0 END as has_cwv
|
|
FROM baselines
|
|
WHERE url_hash = ?
|
|
ORDER BY id DESC
|
|
LIMIT ?
|
|
""",
|
|
(uhash, limit),
|
|
).fetchall()
|
|
|
|
baselines = []
|
|
for row in rows:
|
|
baselines.append({
|
|
"id": row[0],
|
|
"url": row[1],
|
|
"timestamp": row[2],
|
|
"title": row[3],
|
|
"canonical": row[4],
|
|
"robots": row[5],
|
|
"h1": row[6],
|
|
"status_code": row[7],
|
|
"html_hash": row[8][:12] + "..." if row[8] else None,
|
|
"schema_hash": row[9][:12] + "..." if row[9] else None,
|
|
"has_cwv": bool(row[10]),
|
|
})
|
|
|
|
# Fetch comparisons
|
|
comp_rows = conn.execute(
|
|
"""
|
|
SELECT id, baseline_id, timestamp, critical_count, warning_count, info_count
|
|
FROM comparisons
|
|
WHERE url_hash = ?
|
|
ORDER BY id DESC
|
|
LIMIT ?
|
|
""",
|
|
(uhash, limit),
|
|
).fetchall()
|
|
|
|
comparisons = []
|
|
for row in comp_rows:
|
|
comparisons.append({
|
|
"id": row[0],
|
|
"baseline_id": row[1],
|
|
"timestamp": row[2],
|
|
"critical": row[3],
|
|
"warning": row[4],
|
|
"info": row[5],
|
|
})
|
|
|
|
finally:
|
|
conn.close()
|
|
|
|
return {
|
|
"url": norm_url,
|
|
"baselines": baselines,
|
|
"comparisons": comparisons,
|
|
}
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
description="Query SEO drift history for a URL"
|
|
)
|
|
parser.add_argument("url", help="URL to query history for")
|
|
parser.add_argument(
|
|
"--limit", "-n",
|
|
type=int,
|
|
default=20,
|
|
help="Maximum number of entries to return (default: 20)",
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
result = get_history(args.url, limit=args.limit)
|
|
|
|
print(json.dumps(result, indent=2))
|
|
|
|
if not result["baselines"]:
|
|
print(f"\nNo baselines found for {result['url']}.", file=sys.stderr)
|
|
print("Run `python scripts/drift_baseline.py <url>` to capture the first baseline.", file=sys.stderr)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|