from pathlib import Path # Clean BOM for path in Path("app").rglob("*.py"): text = path.read_text(encoding="utf-8-sig") text = text.replace("\ufeff", "") path.write_text(text, encoding="utf-8") hf_path = Path("app/deployment/hf_status.py") text = hf_path.read_text(encoding="utf-8-sig") text = text.replace("\ufeff", "") append_code = r''' # ===================================================== # Phase 36 override: restore graph actions in user app # ===================================================== try: _phase36_previous_get_product_app_html = get_product_app_html except NameError: _phase36_previous_get_product_app_html = None def get_product_app_html() -> str: if _phase36_previous_get_product_app_html is None: return "

GraphResearcher App

App UI is unavailable.

" html = _phase36_previous_get_product_app_html() graph_section = """

Graph View

Open the entity-relation graph created from the selected document.

""" if "id=\"graphActionsPhase36\"" not in html: if '
' in html and "Advanced Settings" in html: html = html.replace( '
\n

Advanced Settings

', graph_section + '\n
\n

Advanced Settings

', 1 ) elif "" in html: html = html.replace("", graph_section + "\n ", 1) sidebar_buttons = """ """ if "openGraphViewerPhase36" not in html.split("", 1)[0]: if "Clear Workspace Cache" in html: html = html.replace( '', '\n' + sidebar_buttons, 1 ) elif '' in html: html = html.replace( '', '\n' + sidebar_buttons, 1 ) js = """ """ if "Phase 36: restore View Graph" not in html: html = html.replace("", js + "\n") return html ''' if "Phase 36 override: restore graph actions in user app" not in text: text += "\n\n" + append_code print("Phase 36 restore View Graph patch added.") else: print("Phase 36 patch already exists.") hf_path.write_text(text, encoding="utf-8") print("Done.")