Something went wrong. Try again.
CLI tools and operational extensions for the void architecture on ATProtocol.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123#!/usr/bin/env python3"""Helper script to generate properly formatted outbox.yaml entries.Prevents schema errors by enforcing correct structure."""
import sysimport yaml
def generate_reply(target_id, text, annotation_text=None, quote=None, memory_handle=None, memory_facts=None): """Generate a reply action with proper schema.""" action = { "action": "reply", "target_id": target_id, "posts": [text] # Always use posts array } if annotation_text: action["annotation"] = {"text": annotation_text} if quote: action["annotation"]["quote"] = quote if memory_handle and memory_facts: action["memory_update"] = { "target_handle": memory_handle, "facts": memory_facts if isinstance(memory_facts, list) else [memory_facts] } return action
def generate_post(texts, standalone=True, annotation_text=None): """Generate a post action (standalone or thread).""" if isinstance(texts, str): texts = [texts] action = { "action": "post", "posts": texts } if annotation_text: action["annotation"] = {"text": annotation_text} config = {"standalone_post": standalone} return config, action
def generate_annotate(target_id, text, motivation="commenting", quote=None): """Generate a standalone annotation action.""" action = { "action": "annotate", "target_id": target_id, "text": text, "motivation": motivation } if quote: action["quote"] = quote return action
def main(): if len(sys.argv) < 2: print("Usage: generate_outbox.py <command> [args]") print("\nCommands:") print(" reply <target_id> <text> [annotation]") print(" post <text> [annotation]") print(" thread <text1> <text2> ...") print(" annotate <target_id> <text>") sys.exit(1) command = sys.argv[1] if command == "reply": if len(sys.argv) < 4: print("Usage: generate_outbox.py reply <target_id> <text> [annotation]") sys.exit(1) target_id = sys.argv[2] text = sys.argv[3] annotation = sys.argv[4] if len(sys.argv) > 4 else None action = generate_reply(target_id, text, annotation) outbox = {"actions": [action]} print(yaml.dump(outbox, sort_keys=False)) elif command == "post": if len(sys.argv) < 3: print("Usage: generate_outbox.py post <text> [annotation]") sys.exit(1) text = sys.argv[2] annotation = sys.argv[3] if len(sys.argv) > 3 else None config, action = generate_post(text, standalone=True, annotation_text=annotation) outbox = {"config": config, "actions": [action]} print(yaml.dump(outbox, sort_keys=False)) elif command == "thread": if len(sys.argv) < 3: print("Usage: generate_outbox.py thread <text1> <text2> ...") sys.exit(1) texts = sys.argv[2:] config, action = generate_post(texts, standalone=True) outbox = {"config": config, "actions": [action]} print(yaml.dump(outbox, sort_keys=False)) elif command == "annotate": if len(sys.argv) < 4: print("Usage: generate_outbox.py annotate <target_id> <text>") sys.exit(1) target_id = sys.argv[2] text = sys.argv[3] action = generate_annotate(target_id, text) outbox = {"actions": [action]} print(yaml.dump(outbox, sort_keys=False)) else: print(f"Unknown command: {command}") sys.exit(1)
if __name__ == "__main__": main()