#!/bin/bash
# Manual rank entry - Run this and enter positions

echo "=== Manual Rank Entry ==="
echo ""
echo "For each keyword, enter the position (1-100) or 0 if not ranking:"
echo ""

cd ~/.openclaw/workspace/agents/marketing-seo
python3 << 'PYTHON'
import json
from datetime import datetime

state_path = "state/rank-data.json"

with open(state_path) as f:
    data = json.load(f)

keywords = list(data['positions'].keys())

print("Enter position for each keyword (or press Enter to skip):\n")
for kw in keywords:
    pos = input(f"'{kw}': ")
    if pos.strip():
        try:
            pos_int = int(pos)
            if pos_int > 0:
                data['positions'][kw] = pos_int
            else:
                data['positions'][kw] = None
        except:
            data['positions'][kw] = None

# Save
data['history'].append({
    "date": datetime.now().strftime('%Y-%m-%d'),
    "positions": data['positions'].copy()
})

with open(state_path, 'w') as f:
    json.dump(data, f, indent=2)

print("\n✅ Rankings saved!")
python3 scripts/rank-tracker.py report
PYTHON
