╔════════════════════════════════════════════════════════════════════════════╗ ║ CLOUDFLARE INFRASTRUCTURE AUTOMATION - QUICK START ║ ║ Status: 🟢 Production Ready v1.0 ║ ╚════════════════════════════════════════════════════════════════════════════╝ 📌 YOU ARE HERE: Cleanup Complete (B+C Refactoring) ───────────────────────────────────────────────────────────────────────────── WHAT JUST HAPPENED ───────────────────────────────────────────────────────────────────────────── Before: Monolithic oracle_answer_mcp.py with duplicate CLI args 🔴 Code chaos + agent auto-patching creating errors After: Clean mcp/oracle_answer/ package structure ✅ AGENT_GUARDRAILS.md prevents future chaos ✅ Backward compat wrapper for smooth migration ✅ ───────────────────────────────────────────────────────────────────────────── 3 KEY FILES (READ IN THIS ORDER) ───────────────────────────────────────────────────────────────────────────── 1. README_STRUCTURE.md └─ Navigation guide to the entire project 2. DEPLOYMENT_GUIDE.md └─ 5-minute quick start + real-world workflows 3. AGENT_GUARDRAILS.md └─ Paste into Cline before editing code (prevents chaos) ───────────────────────────────────────────────────────────────────────────── QUICK VERIFY (30 SECONDS) ───────────────────────────────────────────────────────────────────────────── cd /Users/sovereign/Desktop/CLOUDFLARE # Check environment bash TEST_WORKFLOW.sh quick # Expected: ✅ All checks passed! # Test the oracle python3 -m mcp.oracle_answer.cli --question "Test?" --json # Expected: Valid JSON response # Verify imports python3 -c "from mcp.oracle_answer import OracleAnswerTool; print('✓')" # Expected: ✓ ───────────────────────────────────────────────────────────────────────────── NEXT STEPS (PICK ONE) ───────────────────────────────────────────────────────────────────────────── Option A: Start OpenCode Now $ source .env $ opencode $ /init $ /agent cloudflare-ops Query: "Show me our zones and recent infrastructure changes" Option B: Run Full Integration Test $ bash TEST_WORKFLOW.sh full (Tests Terraform, Git, Cloudflare API, GitLab API) Option C: Start Phase 7 (WAF Intelligence) Read: README_STRUCTURE.md (find "Phase 7") Then: mcp/oracle_answer/ as template for mcp/waf_intelligence/ Option D: Understand the Cleanup Read: CLEANUP_COMPLETE.md (Why B+C refactoring matters + what it prevents) ───────────────────────────────────────────────────────────────────────────── KEY POINTS (DON'T SKIP) ───────────────────────────────────────────────────────────────────────────── ✅ NEW STRUCTURE (MEMORIZE THIS): • MCP tools go in: mcp// • Scripts go in: scripts/ • Observability goes in: observatory/ • NEVER create .py files at repo root ✅ AGENT SAFETY: • Always paste AGENT_GUARDRAILS.md into Cline first • This prevents "duplicate argparse flags" errors • Agents will now rewrite whole functions (not patches) ✅ PATTERNS TO FOLLOW: • Every tool has: __init__.py (exports) + tool.py (logic) + optional cli.py • All functions need: type hints + docstrings • All CLI tools need: single build_parser() function ───────────────────────────────────────────────────────────────────────────── CURRENT ARCHITECTURE AT A GLANCE ───────────────────────────────────────────────────────────────────────────── OpenCode (Claude API) ↓ ┌──────────────┬───────────┬──────────────┐ ↓ ↓ ↓ ↓ cloudflare-ops security-audit data-engineer (agents) │ │ │ ┌────┼──────────────┼───────────┼─────┐ ↓ ↓ ↓ ↓ ↓ [16 MCPs] ────────────────────────────────→ Cloudflare API GitLab API Terraform Documentation ↓ Compliance Oracle (mcp/oracle_answer/) ├─ question ├─ frameworks (GDPR, NIS2, PCI-DSS, etc.) └─ receipt (SHA256 hash + audit trail) ───────────────────────────────────────────────────────────────────────────── DOCUMENTATION ROADMAP ───────────────────────────────────────────────────────────────────────────── Start Here: └─ DEPLOYMENT_GUIDE.md ........... 5-min setup + examples Understand Architecture: ├─ README_STRUCTURE.md ........... Project navigation ├─ STRUCTURE.md ................. Design patterns & coding standards └─ MCP_GUIDE.md ................. All 16 MCPs explained Work with Agents (Cline): └─ AGENT_GUARDRAILS.md .......... Paste this + no more chaos! Learn Why We Did This: ├─ CLEANUP_COMPLETE.md .......... B+C refactoring explained └─ PRODUCTION_READY_SUMMARY.md .. v1.0 build summary Reference: ├─ AGENTS.md .................... 3 custom agents ├─ GITLAB_CLOUDFLARE_AUTH.md .... Token setup └─ opencode.jsonc ............... MCP configuration ───────────────────────────────────────────────────────────────────────────── TROUBLESHOOTING ───────────────────────────────────────────────────────────────────────────── "ImportError: cannot import from mcp.oracle_answer" → Run: python3 -c "from mcp.oracle_answer import OracleAnswerTool" → If fails: Check PYTHONPATH, run from repo root "TypeError: 'NoneType' object is not subscriptable" → Read: AGENT_GUARDRAILS.md (Pattern 2: Subscript None) → Fix: Add null checks before accessing dict/list "argparse.ArgumentError: conflicting option string" → This was THE problem we just fixed! → It won't happen again if agents follow AGENT_GUARDRAILS.md → See: CLEANUP_COMPLETE.md (Problem 1) ───────────────────────────────────────────────────────────────────────────── REMEMBER ───────────────────────────────────────────────────────────────────────────── Before asking Cline to edit code: → Copy AGENT_GUARDRAILS.md into your prompt → Agents will follow the rules → No more blind patching Before starting Phase 7: → Use mcp/oracle_answer/ as your template → Follow STRUCTURE.md patterns → You won't have code chaos again ───────────────────────────────────────────────────────────────────────────── STATUS ───────────────────────────────────────────────────────────────────────────── ✅ Phase 1-6: Complete (infrastructure, agents, oracle, gitops) ✅ Phase 6.5: Complete (B+C cleanup, guardrails) 📋 Phase 7: Ready to start (WAF Intelligence Engine) 📋 Phase 8: Planned (Multi-tenant isolation) You have everything you need. The system is clean and documented. Ready to proceed? Pick an option above, then read the first document. ───────────────────────────────────────────────────────────────────────────── Questions? ───────────────────────────────────────────────────────────────────────────── • Questions about architecture? → README_STRUCTURE.md • Questions about agents? → AGENT_GUARDRAILS.md • Questions about setup? → DEPLOYMENT_GUIDE.md • Questions about Phase 7? → CLEANUP_COMPLETE.md + mcp/oracle_answer/ Good luck. 🚀 --- 🔐 MULTI-ACCOUNT SUPPORT Want to use multiple GitHub/Cloudflare/GitLab accounts? See: MULTI_ACCOUNT_AUTH.md Quick: Export tokens with unique names (e.g., GITHUB_TOKEN_WORK) Add MCP entry in opencode.jsonc referencing {env:VARIABLE_NAME} Enable per-agent or globally