import streamlit as st import os import re # --- ARCHON Core Scoring Logic (Adapted for Web) --- def score_content(content): scores = { "Async-First": 0, "Structured Output": 0, "Config Discipline": 0 } # 1. Async Compliance if "async " in content or "await " in content: scores["Async-First"] = 100 elif any(kw in content for kw in ["requests.get(", "requests.post(", "urllib.", "time.sleep("]): scores["Async-First"] = 0 # Major penalty for blocking I/O else: scores["Async-First"] = 100 # No I/O detected # 2. Structured Output if any(kw in content for kw in ["json.dumps", "pydantic", "BaseModel", "Zod"]): scores["Structured Output"] = 100 elif "print(" in content: scores["Structured Output"] = 50 else: scores["Structured Output"] = 100 # 3. Config Discipline if any(kw in content for kw in ["os.getenv", "environ", "config("]): scores["Config Discipline"] = 100 elif any(kw in content for kw in ["api_key =", "secret =", "password =", "token ="]): scores["Config Discipline"] = 0 else: scores["Config Discipline"] = 85 return scores # --- Streamlit UI --- st.set_page_config(page_title="ARCHON Showroom", page_icon="🛡️", layout="wide") st.markdown(""" """, unsafe_allow_html=True) st.title("🛡️ ARCHON Dev Engine – Showroom") st.subheader("Test your AI-generated backend for production discipline.") col1, col2 = st.columns([2, 1]) with col1: code_input = st.text_area("Paste code here (Python / TS / JS):", height=400, placeholder="import requests\n\ndef get_data():\n return requests.get(url) # ARCHON will veto this!") score_btn = st.button("RUN ARCHON CHECK") with col2: if score_btn and code_input: res = score_content(code_input) overall = sum(res.values()) / len(res) st.metric("ARCHON SCORE", f"{overall:.1f}%") # Display breakdown for k, v in res.items(): color = "green" if v > 80 else "orange" if v > 40 else "red" st.markdown(f"**{k}**: :{color}[{v}%]") st.progress(v / 100) st.markdown("---") if overall > 90: st.success("✅ **ELITE**: This code meets ARCHON production standards.") elif overall > 60: st.warning("⚠️ **STABLE**: Usable, but improvements recommended.") else: st.error("❌ **FRAGILE**: Immediate refactor required for production.") st.info("ARCHON is a Cursor Plugin that enforces this discipline in real-time. [Get the plugin on GitHub](https://github.com/Omran1983/archon-dev-engine)") else: st.write("Ready for analysis. Paste code and hit the button.") st.markdown(""" ### Why ARCHON? - **Prevents** blocking I/O in async paths. - **Enforces** structured data handling. - **Protects** against hardcoded secrets. """) st.sidebar.image("https://raw.githubusercontent.com/Omran1983/archon-dev-engine/main/demo.gif") st.sidebar.markdown(""" **v0.1.0 Open Alpha** Developed by A-ONE GLOBAL RESOURCING LTD. [GitHub Repo](https://github.com/Omran1983/archon-dev-engine) """)