Something went wrong. Try again.
CLI tools and operational extensions for the void architecture on ATProtocol.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566import rewith open('src/void_tools/cli.py', 'r') as f: content = f.read()
replacement = """ def replace_facets_with_markdown(text, facets): if not facets: return text try: text_bytes = text.encode('utf-8') links = [] for facet in facets: for feature in getattr(facet, 'features', []): if hasattr(feature, 'uri'): links.append({ 'start': facet.index.byte_start, 'end': facet.index.byte_end, 'uri': feature.uri }) links.sort(key=lambda x: x['start'], reverse=True) for link in links: start, end, uri = link['start'], link['end'], link['uri'] link_text = text_bytes[start:end].decode('utf-8') markdown_link = f"[{link_text}]({uri})".encode('utf-8') text_bytes = text_bytes[:start] + markdown_link + text_bytes[end:] return text_bytes.decode('utf-8') except Exception as e: # Fallback to plain text if parsing fails return text
def format_thread_node(node, level=0): content = "" indent = " " * level if hasattr(node, 'post'): post = node.post author = post.author.handle # Apply facets to get full URLs raw_text = getattr(post.record, 'text', '') facets = getattr(post.record, 'facets', []) text = replace_facets_with_markdown(raw_text, facets) text = text.replace('\\n', '\\n' + indent + '> ') content += f"{indent}- **@{author}**: {text}\\n" if hasattr(node, 'replies') and node.replies:"""
# Locate the target block to replacetarget_block = """ def format_thread_node(node, level=0): content = "" indent = " " * level if hasattr(node, 'post'): post = node.post author = post.author.handle text = post.record.text.replace('\\n', '\\n' + indent + '> ') content += f"{indent}- **@{author}**: {text}\\n" if hasattr(node, 'replies') and node.replies:"""
if target_block in content: content = content.replace(target_block, replacement) with open('src/void_tools/cli.py', 'w') as f: f.write(content) print("Patch applied successfully.")else: print("Target block not found.")