code wiki / (root) / nx_nishi_desktop.nx

nx_nishi_desktop.nx source

↩ module page · 93 lines · 7330 B

1// nx_nishi_desktop.nx -- the NISHI SYSTEM "desktop": a unified status + launcher view of the whole 2// ecosystem, read DATA-DRIVEN from knowledge/registry/replacement_tools.tsv. Emits a styled HTML 3// "desktop" (coverage bar + a live tool grid color-coded by status + the DATA-DRIVEN gap list + 4// NishiOS boot/data-layer status) to knowledge/status/nishi_desktop.html, and prints the same census 5// to the CLI -- with the gap list derived from the catalog (no more hardcoded-stale gap string). 6// HONEST: a web desktop dashboard, not a real compositor/window-manager (that = deeper gui rung). 7// No hardware writes (Rule 26). expect_exit: 0 license_tier: ORIGINAL 8import "nx_syscalls.nx" 9const K_MAGIC_32768: i64 = 32768 10const K_MAGIC_1024: i64 = 1024 11const K_MAGIC_65536: i64 = 65536 12 13func dk_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } 14func dk_putn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } 15func dk_streq(a: *u8, b: *u8) -> i64 { var i: i64=0; while 1==1 { if a[i]!=b[i] { return 0 } if a[i]==(0 as u8) { return 1 } i=i+1 } return 1 } 16func wa(buf: *u8, off: i64, s: *u8) -> i64 { var i: i64=0; while s[i]!=(0 as u8){ buf[off+i]=s[i]; i=i+1 } return off+i } 17func wn(buf: *u8, off: i64, v: i64) -> i64 { var o: i64=off; if v==0 { buf[o]=48 as u8; return o+1 } let t: *u8=sys_mmap(28); var m: i64=v; var k: i64=0; while m>0 { t[k]=(48+(m%10)) as u8; m=m/10; k=k+1 } var i: i64=0; while i<k { buf[o+i]=t[k-1-i]; i=i+1 } return o+k } 18func dk_field(buf: *u8, ls: i64, le: i64, f: i64, out: *u8) -> i64 { var cur: i64=0; var i: i64=ls; var o: i64=0; while cur<f { if i>=le { out[0]=0 as u8; return 0 } if buf[i]==(9 as u8) { cur=cur+1 } i=i+1 } var go: i64=1; while go==1 { if i>=le { go=0 } else { if buf[i]==(9 as u8) { go=0 } else { out[o]=buf[i]; o=o+1; i=i+1 } } } out[o]=0 as u8; return o } 19 20func main() -> i64 { 21 let lenp: *i64 = sys_mmap(8) as *i64 22 let tsv: *u8 = sys_read_file("knowledge/registry/replacement_tools.tsv\x00" as *u8, lenp) 23 if (tsv as i64)==0 { dk_puts("replacement_tools.tsv not found\n" as *u8); sys_exit(1); return 1 } 24 let n: i64 = lenp[0] 25 26 let grid: *u8 = sys_mmap(K_MAGIC_32768) 27 var go: i64 = 0 28 let gaps: *u8 = sys_mmap(K_MAGIC_1024) 29 var gpo: i64 = 0 30 var nv: i64=0 31 var np: i64=0 32 var ne: i64=0 33 var ng: i64=0 34 var nt: i64=0 35 let nbuf: *u8 = sys_mmap(128) 36 let sbuf: *u8 = sys_mmap(64) 37 let cbuf: *u8 = sys_mmap(64) 38 39 var i: i64=0 40 while i<n { 41 let ls: i64=i 42 var le: i64=i 43 var f: i64=1 44 while f==1 { if le>=n { f=0 } else { if tsv[le]==(0x0A as u8) { f=0 } else { le=le+1 } } } 45 var lineend: i64=le 46 if lineend>ls { if tsv[lineend-1]==(0x0D as u8) { lineend=lineend-1 } } 47 if lineend>ls { if tsv[ls]!=(0x23 as u8) { 48 dk_field(tsv, ls, lineend, 0, cbuf) 49 dk_field(tsv, ls, lineend, 2, nbuf) 50 dk_field(tsv, ls, lineend, 3, sbuf) 51 nt=nt+1 52 go = wa(grid, go, "<div class=card><span class=" as *u8) 53 if dk_streq(sbuf, "VERIFIED\x00" as *u8)==1 { nv=nv+1; go=wa(grid,go,"bv" as *u8) } 54 if dk_streq(sbuf, "PARTIAL\x00" as *u8)==1 { np=np+1; go=wa(grid,go,"bp" as *u8) } 55 if dk_streq(sbuf, "EXISTS\x00" as *u8)==1 { ne=ne+1; go=wa(grid,go,"be" as *u8) } 56 if dk_streq(sbuf, "GAP\x00" as *u8)==1 { ng=ng+1; go=wa(grid,go,"bg" as *u8); gpo=wa(gaps,gpo,cbuf); gpo=wa(gaps,gpo," " as *u8) } 57 go = wa(grid, go, ">" as *u8); go = wa(grid, go, sbuf); go = wa(grid, go, "</span> <b>" as *u8); go = wa(grid, go, cbuf); go = wa(grid, go, "</b><br>" as *u8); go = wa(grid, go, nbuf); go = wa(grid, go, "</div>" as *u8) 58 } } 59 i=le+1 60 } 61 gaps[gpo]=0 as u8 62 var cov: i64 = 0 63 if nt>0 { cov = ((nv*3)+(np*2)+ne)*1000/(nt*3) } 64 65 // ---- assemble the desktop HTML ---- 66 let html: *u8 = sys_mmap(K_MAGIC_65536) 67 var o: i64 = 0 68 o = wa(html, o, "<!doctype html><html><head><meta charset=utf-8><title>Nishi System Desktop</title><style>" as *u8) 69 o = wa(html, o, "body{background:#060a08;color:#cfe;font-family:ui-monospace,monospace;margin:0;padding:26px}" as *u8) 70 o = wa(html, o, ".wrap{max-width:1000px;margin:0 auto}h1{color:#7fd;letter-spacing:3px;font-size:18px}" as *u8) 71 o = wa(html, o, ".bar{height:24px;background:#022;border:1px solid #094;border-radius:5px;overflow:hidden;margin:8px 0}.fill{height:100%;background:linear-gradient(90deg,#0a6,#6f9)}" as *u8) 72 o = wa(html, o, ".hud{color:#9fb;font-size:13px;margin-bottom:14px}.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:10px}" as *u8) 73 o = wa(html, o, ".card{background:#0b1310;border:1px solid #163;border-radius:7px;padding:10px;font-size:12px;color:#bdd}.card b{color:#7fd}" as *u8) 74 o = wa(html, o, ".bv,.bp,.be,.bg{font-weight:700;padding:1px 6px;border-radius:4px;font-size:10px}.bv{background:#063;color:#7fd}.bp{background:#640;color:#fd7}.be{background:#036;color:#7df}.bg{background:#600;color:#f99}" as *u8) 75 o = wa(html, o, ".foot{margin-top:16px;color:#6a8;font-size:12px}</style></head><body><div class=wrap>" as *u8) 76 o = wa(html, o, "<h1>NISHI SYSTEM &middot; USE ONLY OUR SYSTEM</h1>" as *u8) 77 o = wa(html, o, "<div class=bar><div class=fill style=width:" as *u8); o = wn(html, o, cov/10); o = wa(html, o, "%></div></div>" as *u8) 78 o = wa(html, o, "<div class=hud>coverage <b>" as *u8); o = wn(html, o, cov); o = wa(html, o, " permil</b> &middot; " as *u8); o = wn(html, o, nt); o = wa(html, o, " tools &middot; VERIFIED " as *u8); o = wn(html, o, nv); o = wa(html, o, " / PARTIAL " as *u8); o = wn(html, o, np); o = wa(html, o, " / EXISTS " as *u8); o = wn(html, o, ne); o = wa(html, o, " / GAP " as *u8); o = wn(html, o, ng) 79 if ng > 0 { o = wa(html, o, " &middot; remaining gaps: " as *u8); o = wa(html, o, gaps) } 80 o = wa(html, o, "</div><div class=grid>" as *u8) 81 var gi: i64=0 82 while gi<go { html[o]=grid[gi]; o=o+1; gi=gi+1 } 83 o = wa(html, o, "</div><div class=foot>kernel: NishiOS boots on the sovereign rv64 emu (NISHI) &middot; data layer: UXF content-addressed formats &middot; CLI: nx_sh + coreutils + grep/find/sort &middot; bridge: Claude drives the system</div></div></body></html>" as *u8) 84 let fd: i64 = sys_openat_wr("knowledge/status/nishi_desktop.html\x00" as *u8, 0x1a4) 85 if fd>0 { sys_write(fd, html, o); sys_close(fd) } 86 87 // ---- CLI census (data-driven gaps; no stale string) ---- 88 dk_puts("NISHI SYSTEM DESKTOP -- coverage=" as *u8); dk_putn(cov); dk_puts(" permil tools=" as *u8); dk_putn(nt); dk_puts(" (V=" as *u8); dk_putn(nv); dk_puts(" P=" as *u8); dk_putn(np); dk_puts(" E=" as *u8); dk_putn(ne); dk_puts(" GAP=" as *u8); dk_putn(ng); dk_puts(")\n" as *u8) 89 if ng>0 { dk_puts(" remaining full gaps: " as *u8); dk_puts(gaps); dk_puts("\n" as *u8) } else { dk_puts(" remaining full gaps: NONE -- every daily-driver tool has >= a partial sovereign replacement\n" as *u8) } 90 dk_puts(" wrote knowledge/status/nishi_desktop.html (open in a browser)\n" as *u8) 91 sys_exit(0) 92 return 0 93}