Files
blackroad/bin/br-color
Alexa Amundson 78fbe80f2a Initial monorepo — everything BlackRoad in one place
bin/       230 CLI tools (ask-*, br-*, agent-*, roadid, carpool)
scripts/   99 automation scripts
fleet/     Node configs and deployment
workers/   Cloudflare Worker sources (roadpay, road-search, squad webhooks)
roadc/     RoadC programming language
roadnet/   Mesh network (5 APs, WireGuard)
operator/  Memory system scripts
config/    System configs
dotfiles/  Shell configs
docs/      Documentation

BlackRoad OS — Pave Tomorrow.

RoadChain-SHA2048: d1a24f55318d338b
RoadChain-Identity: alexa@sovereign
RoadChain-Full: d1a24f55318d338b24b60bad7be39286379c76ae5470817482100cb0ddbbcb97e147d07ac7243da0a9f0363e4e5c833d612b9c0df3a3cd20802465420278ef74875a5b77f55af6fe42a931b8b635b3d0d0b6bde9abf33dc42eea52bc03c951406d8cbe49f1a3d29b26a94dade05e9477f34a7d4d4c6ec4005c3c2ac54e73a68440c512c8e83fd9b1fe234750b898ef8f4032c23db173961fe225e67a0432b5293a9714f76c5c57ed5fdf35b9fb40fd73c03ebf88b7253c6a0575f5afb6a6b49b3bda310602fb1ef676859962dad2aebbb2875814b30eee0a8ba195e482d4cbc91d8819e7f38f6db53e8063401649c77bb994371473cabfb917fb53e8cbe73d60
2026-03-14 17:08:41 -05:00

153 lines
4.5 KiB
Python
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
br-color
Query and display BR color semantics.
"""
import sys
RESET = "\x1b[0m"
# Zone definitions from BR_COLOR_SPEC.md
ZONES = {
"OS_LAYER": (0, 15, "Core system primitives"),
"PERCEPTION": (16, 51, "Input, sensors, listeners"),
"EXECUTION": (52, 87, "Actions, mutations, writes"),
"MEMORY": (88, 123, "State, cache, persistence"),
"AUTONOMY": (124, 159, "Agents, decision, delegation"),
"TENSION": (160, 195, "Warnings, drift, uncertainty"),
"PARADOX": (196, 231, "Errors, contradiction, halt"),
"META": (232, 255, "Null, silence, void, escape"),
}
# Token definitions for key colors
TOKENS = {
0: "NULL", 1: "ERROR", 2: "SUCCESS", 3: "WARN", 4: "INFO", 5: "DEBUG",
6: "SYSCALL", 7: "NEUTRAL", 8: "NULL_BRIGHT", 9: "ERROR_BRIGHT",
10: "SUCCESS_BRIGHT", 11: "WARN_BRIGHT", 12: "INFO_BRIGHT", 13: "DEBUG_BRIGHT",
14: "SYSCALL_BRIGHT", 15: "NEUTRAL_BRIGHT",
16: "RAW_SENSOR", 28: "VALID_INPUT", 40: "STREAM_LIVE",
64: "EXEC_HIGH", 76: "EXEC_ATOMIC", 202: "EXEC_FORCE",
88: "MEM_VOLATILE", 100: "MEM_PERSIST", 118: "MEM_ARCHIVE",
130: "AGENT_THINK", 136: "AGENT_EXEC", 154: "AGENT_META",
166: "WARN_MEMORY", 178: "WARN_DRIFT", 190: "WARN_DEGRADE",
196: "ERROR_FATAL", 208: "ERROR_DATA", 226: "ERROR_CASCADE",
232: "META_NULL", 244: "META_ESCAPE", 255: "META_BRIGHT",
}
# Shape mappings
SHAPES = {
range(0, 16): "",
range(16, 52): "",
range(52, 88): "",
range(88, 124): "",
range(124, 160): "",
range(160, 196): "",
range(196, 232): "",
range(232, 256): "",
}
SPECIAL_SHAPES = {
0: "·", 1: "", 2: "", 3: "",
196: "", 202: "", 226: "", 232: "", 255: "",
}
def get_zone(color):
"""Get zone name for a color."""
for zone_name, (start, end, _) in ZONES.items():
if start <= color <= end:
return zone_name
return "UNKNOWN"
def get_shape(color):
"""Get shape for a color."""
if color in SPECIAL_SHAPES:
return SPECIAL_SHAPES[color]
for color_range, shape in SHAPES.items():
if color in color_range:
return shape
return "?"
def display_color(color):
"""Display full info for a color."""
zone = get_zone(color)
token = TOKENS.get(color, f"COLOR_{color}")
shape = get_shape(color)
bg = f"\x1b[48;5;{color}m"
fg = f"\x1b[38;5;{255 - color}m"
print(f"\n{bg}{fg} {color:>3} {RESET}")
print(f"Token: {token}")
print(f"Zone: {zone}")
print(f"Shape: {shape}")
for zone_name, (start, end, desc) in ZONES.items():
if zone_name == zone:
print(f"Range: {start}{end}")
print(f"Desc: {desc}")
break
print()
def list_zone(zone_name):
"""List all colors in a zone."""
zone_name = zone_name.upper()
if zone_name not in ZONES:
print(f"Error: Unknown zone '{zone_name}'")
print(f"Available zones: {', '.join(ZONES.keys())}")
return
start, end, desc = ZONES[zone_name]
print(f"\n{zone_name} ({start}{end}): {desc}\n")
for i in range(start, end + 1):
bg = f"\x1b[48;5;{i}m"
fg = f"\x1b[38;5;{255 - i}m"
token = TOKENS.get(i, f"COLOR_{i}")
shape = get_shape(i)
print(f"{bg}{fg} {i:>3} {RESET} {shape} {token}")
print()
def show_all():
"""Show all zones overview."""
print("\nBR COLOR ZONES\n")
for zone_name, (start, end, desc) in ZONES.items():
print(f"{zone_name:12} {start:>3}{end:<3} {desc}")
print()
def main():
if len(sys.argv) < 2:
print("Usage:")
print(" br-color <color> # Show info for color index")
print(" br-color zone <zone> # List all colors in zone")
print(" br-color show # Show all zones")
print()
print("Zones: OS_LAYER, PERCEPTION, EXECUTION, MEMORY,")
print(" AUTONOMY, TENSION, PARADOX, META")
sys.exit(1)
cmd = sys.argv[1]
if cmd == "show":
show_all()
elif cmd == "zone":
if len(sys.argv) < 3:
print("Error: zone requires a zone name")
sys.exit(1)
list_zone(sys.argv[2])
else:
try:
color = int(cmd)
if 0 <= color <= 255:
display_color(color)
else:
print("Error: color must be 0-255")
sys.exit(1)
except ValueError:
print(f"Error: '{cmd}' is not a valid color index")
sys.exit(1)
if __name__ == "__main__":
main()