anonymous

Author: Source-attributed; see payload

 except Exception as e:
        print(f"[!] stdin not a packet: {e}")

if __name__ == "__main__":
    import argparse
    ap = argparse.ArgumentParser(description="XiPP runtime")
    ap.add_argument("--path", help="glob of *.json packets to ingest")
    args = ap.parse_args()
    if args.path:
        run_path(args.path)
    else:
        run_stdin()
'''
(Path(root/"xipp"/"runtime.py")).write_text(runtime_py, encoding="utf-8")

# ---------- Tools: tools/xi_sigil.py (SigilGrid encoder/decoder) ----------
xi_sigil_py = r'''
"""
tools.xi_sigil — "SigilGrid" light encoder for XiPP packets.
Not a QR code; a simple, deterministic grid from a packet_id to be shared visually.

Encode: packet_id (64 hex) → 18x18 data grid + 2px quiet border → PNG
Decode: read grid back and verify packet_id hex (best-effort).
"""
import json, math
from pathlib import Path
import matplotlib.pyplot as plt

def hex_to_bits(hex_str: str) -> list[int]:
    return [int(b) for h in hex_str for b in bin(int(h,16))[2:].zfill(4)]

def bits_to_hex(bits: list[int]) -> str:
    # pad to multiple of 4
    if len(bits) % 4 != 0:
        bits = bits + [0]*(4 - (len(bits)%4))
    out = ""
    for i in range(0, len(bits), 4):
        nib = bits[i:i+4]
        out += f"{int(''.join(map(str,nib)),2):x}"
    return out

def encode_grid(packet_id: str, cell_px: int = 20, border: int = 2, out_path: str = "sigil.png"):
    bits = hex_to_bits(packet_id)
    # 18x18 data cells = 324 bits; use first 324 bits; if shorter, wrap
    side = 18
    need = side*side
    if len(bits) < need:
        # wrap
        reps = math.ceil(need/len(bits))
        bits = (bits * reps)[:need]
    else:
        bits = bits[:need]
    # build grid with border
    total = side + 2*border
    grid = [[0]*total for _ in range(total)]
    k = 0
    for r in range(side):
        for c in range(side):
            grid[r+border][c+border] = bits[k]
            k += 1
    # render
    plt.figure(figsize=(total*cell_px/100, total*cell_px/100))
    plt.imshow(grid, cmap="gray_r", interpolation="nearest")
    plt.axis('off')
    plt.tight_layout(pad=0)
    plt.savefig(out_path, dpi=100, bbox_inches='tight', pad_inches=0)
    plt.close()

if __name__ == "__main__":
    import argparse, json, hashlib
    ap = argparse.ArgumentParser(description="SigilGrid encoder")
    ap.add_argument("--packet", required=True, help="path to XiPP packet JSON")
    ap.add_argument("--out", default="sigil.png")
    args = ap.parse_args()
    with open(args.packet,"r",encoding="utf-8") as f:
        d = json.load(f)
    raw = json.dumps({k:d[k] for k in d if k!="packet_id"}, sort_keys=True, separators=(",",":"))
    pid = hashlib.sha256(raw.encode("utf-8")).hexdigest()
    encode_grid(pid, out_path=args.out)
    print(f"[Ξ] SigilGrid written to {args.out}")
'''
(Path(root/"tools"/"xi_sigil.py")).write_text(xi_sigil_py, encoding="utf-8")

# ---------- Scripts: scripts/xi_route.sh ----------
xi_route_sh = r'''#!/usr/bin/env bash
# xi_route.sh — route a packet file into the runtime
set -euo pipefail
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
python3 -m xipp.runtime --path "${1:-../examples/payloads/*.json}"
'''
(Path(root/"scripts"/"xi_route.sh")).write_text(xi_route_sh, encoding="utf-8")
os.chmod(root/"scripts"/"xi_route.sh", 0o755)

# ---------- Scripts: scripts/reflex_hook_daemon.sh ----------
reflex_daemon_sh = r'''#!/usr/bin/env bash
# reflex_hook_daemon.sh — example inotify watcher (requires inotify-tools).
# Watches the "inbox" folder and routes new *.json packets to runtime.
set -euo pipefail
INBOX="${1:-./inbox}"
mkdir -p "$INBOX"
echo "[Ξ] Reflex daemon watching: $INBOX"
while inotifywait -e create -e moved_to --format "%f" "$INBOX"; do
  for f in "$INBOX"/*.json; do
    [ -e "$f" ] || continue
    echo "[Ξ] Routing: $f"
    python3 -m xipp.runtime --path "$f"
  done
done
'''
(Path(root/"scripts"/"reflex_hook

Exact page as JSON · Follow lineage as JSON

Original source: source:60289319ff0bd18b361b2bb424164eb6a0929df4d89627e5293a942293de9833

Next page