#!/usr/bin/env python3 """Page-text slots: server defaults match the React app, and the model prompt shows them. No server or model needed. (Text edits are made by the model with set_theme copy; there is no rule-based text editing.)""" import os, sys sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..")) os.environ.pop("AGENT_MARKET_LLM_API_KEY_FILE", None) from market.copyedit import DEFAULT_COPY, current_copy from market import agent results = [] def check(name, ok, d=""): results.append(bool(ok)); print(("PASS " if ok else "FAIL ") + name + (f" [{d}]" if d else "")) app = open(os.path.join(os.path.dirname(__file__), "..", "web", "src", "App.tsx"), encoding="utf-8").read() ok = all(s in app for s in (DEFAULT_COPY["logo"], DEFAULT_COPY["headline"], DEFAULT_COPY["subhead"])) and \ all(c["label"] in app for c in DEFAULT_COPY["chips"]) and all(b.split("{fee}% ")[-1] in app for b in DEFAULT_COPY["bullets"]) check("DEFAULT_COPY in sync with web/src/App.tsx", ok) check("model prompt explains top-left = logo and includes PAGE_TEXT", "TOP-LEFT" in agent.UI_SCHEMA and '"logo": "Agent Market"' in agent._page_text("{}")) check("PAGE_TEXT follows the visitor's overrides", '"logo": "New Internet"' in agent._page_text('{"copy":{"logo":"New Internet"}}')) check("fee in bullets follows FEE_BPS", current_copy({}, 250)["bullets"][0].startswith("2.5% ")) check("local prompt carries examples (incl. a top-left text edit), hosted prompt doesn't", "EXAMPLES" in agent.LOCAL_EXAMPLES and '"copy":{"logo"' in agent.LOCAL_EXAMPLES and "EXAMPLES (" not in agent.UI_SCHEMA) gone = [n for n in ("fallback_agent", "_rules_check") if hasattr(agent, n)] import market.theme as th, market.copyedit as ce gone += [n for n in ("parse_look_command",) if hasattr(th, n)] + [n for n in ("parse_copy_edit",) if hasattr(ce, n)] check("no rule-based typed-message code left", not gone, gone) print(f"\n{sum(results)}/{len(results)} passed") sys.exit(0 if all(results) else 1)