minions-ai-agents/antigravity_brain_export/tools/read_context.py

24 lines
842 B
Python

# .agent/tools/read_context.py
import sys
import os
def read_files(file_paths):
output = []
for path in file_paths:
abs_path = os.path.abspath(path)
if os.path.exists(abs_path) and os.path.isfile(abs_path):
try:
with open(abs_path, 'r', encoding='utf-8') as f:
content = f.read()
output.append(f"--- INICIO: {path} ---\n{content}\n--- FIM: {path} ---\n")
except Exception as e:
output.append(f"⚠️ Erro ao ler {path}: {str(e)}")
else:
output.append(f"⚠️ Arquivo não encontrado: {path}")
return "\n".join(output)
if __name__ == "__main__":
if len(sys.argv) < 2:
print("Uso: python read_context.py arquivo1.txt arquivo2.js ...")
else:
print(read_files(sys.argv[1:]))