# src/npl/nipbox/nipbox.nim import std/[strutils, tables] # --- COMMANDS --- proc do_echo(args: seq[string]) = echo args.join(" ") proc do_ls(args: seq[string]) = # A Sovereign 'ls' - eventually this will query the NPL filesystem echo ". .." echo "kernel subject" echo "matrix ion" echo "vault pki" const CMD_GPU_MATRIX = 0x100 const CMD_GPU_CLEAR = 0x101 proc nexus_syscall(cmd: uint32, arg: uint32): cint {.importc, cdecl.} proc do_matrix(args: seq[string]) = let enable = if args.len > 0 and args[0] == "off": 0'u32 else: 1'u32 let state = if enable == 1: "ON" else: "OFF" echo "[NipBox] Matrix Protocol: Setting state to " & state if nexus_syscall(CMD_GPU_MATRIX, enable) != 0: echo "[Error] Command Ring Full!" else: echo "[NipBox] Command Sent Successfully." proc do_help(args: seq[string]) = echo "NipBox v0.1 (Sovereign Coreutils)" echo " echo [args...] : Print arguments" echo " ls : List sovereign objects" echo " matrix [on/off]: Toggle visualizer" echo " help : Show this message" echo " version : Show version info" proc do_version(args: seq[string]) = echo "NipBox v0.1.0" echo "Built: 2025-12-31" echo "Architect: Markus Maiwald | Voxis Forge (AI)" const CMD_GET_GPU_STATUS = 0x102 proc do_status(args: seq[string]) = echo "[NipBox] Querying GPU Status..." let status = nexus_syscall(CMD_GET_GPU_STATUS, 0) echo "GPU Status: ", if status == 1: "ONLINE (Retina Active)" else: "OFFLINE" # --- DISPATCHER --- const commands = { "echo": do_echo, "ls": do_ls, "matrix": do_matrix, "status": do_status, "help": do_help, "version": do_version }.toTable proc main() = proc nexus_yield() {.importc, cdecl.} echo "\n[NipBox] Shell Ready. Waiting for orders..." while true: stdout.write("root@nexus:# ") stdout.flushFile() let line = try: stdin.readLine() except: "" if line.len == 0: nexus_yield() continue let parts = line.split(' ') if parts.len == 0: continue let cmd = parts[0] let args = if parts.len > 1: parts[1..^1] else: @[] if commands.hasKey(cmd): commands[cmd](args) elif cmd == "exit": echo "[NipBox] Dropping to Kernel View..." break else: echo "nipbox: command not found: ", cmd when isMainModule: main()