from datetime import datetime import os def save_to_file(filename, file_content): if not filename.startswith("agent/"): filename = os.path.join("agent", filename) os.makedirs(os.path.dirname(filename), exist_ok=True) print(f"Creating file: {filename}") with open(filename, "w", encoding="utf-8") as file: file.write(file_content) print(f"File {filename} created successfully.") def build_robotstxt_file(): content = "User-agent: *\nDisallow: /" save_to_file("agent/robots.txt", content) def build_license_file(): year = datetime.now().year content = f''' Copyright {year} Agent-3Web Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ''' save_to_file("agent/LICENSE", content) def build_css_file(): content = """ /*====================================== = Base Reset Styles = ======================================*/ html, body { margin: 0; padding: 0; } """ save_to_file("agent/s.css", content) def auto_detect_html_and_link_css(): html_dir = "agent" css_link = '\n' for filename in os.listdir(html_dir): if filename.endswith(".html"): filepath = os.path.join(html_dir, filename) with open(filepath, "r", encoding="utf-8") as f: content = f.read() if css_link.strip() not in content: if "" in content: content = content.replace("", f"{css_link}") else: content = css_link + content with open(filepath, "w", encoding="utf-8") as f: f.write(content)