code wiki / (root) / nx_writer_page.nx

nx_writer_page.nx source

↩ module page · 161 lines · 11611 B

1// u26d4RETIRED 2026-08-05: superseded by nx_writer_serve (the LIVE /writer daemon: page+score+factcheck 2// +swarm /write+/modes). This organ still reads the TOMBSTONED write_modes.tsv -- do not deploy it; 3// if ever revived, repoint to the writemode- seg-store plane first (sts_load, see nx_write). 4// nx_writer_page.nx -- EMIT the nishifamily.com/writer showcase page. 5// 6// The UI surface for the Nishi Writer (operator law feedback-every-capability- 7// needs-iterating-ui: every capability gets a live UI we iterate on). This organ 8// AUTHORS the page; no JS/HTML is hand-written. Same emit -> push -> verify loop 9// every property reuses (publishing is the separate sovereign step nx_aw_push). 10// 11// DATA-DRIVEN (CLAUDE.md #11): the modes table is generated FROM the registry 12// knowledge/registry/write_modes.tsv at render time -- add a mode row there and it 13// appears here with zero edits. The seam (erotica -> local lane) is visible in the 14// data itself, not asserted in prose. 15// 16// HONEST SCOPE: a READ-ONLY showcase, safe to be public -- it surfaces the modes, 17// the measured/gate-proven capabilities, and how to drive the tool. It does NOT 18// generate prose (the generation SEAT is the next rung) and exposes no control 19// surface (generation/actuation will sit behind operator-only OPAQUE auth). 20// 21// license_tier: ORIGINAL 22// module: nishi-core.write.page 23// capability: WRITE_UI_PAGE 24import "nx_syscalls_x86_64.nx" 25import "nx_mode.nx" 26import "nx_scenario.nx" 27 28const WP_OUT: *u8 = "web_assets/writer.html" 29const WP_BYTES: i64 = 131072 30 31func wp_cat(dst: *u8, off: i64, s: *u8) -> i64 { 32 var o: i64 = off 33 var i: i64 = 0 34 while s[i] != 0 as u8 { dst[o] = s[i]; o = o + 1; i = i + 1 } 35 return o 36} 37func wp_putn(v: i64) -> i64 { 38 let nb: *u8 = sys_mmap(28) 39 var k: i64 = 0 40 var m: i64 = v 41 if m == 0 { nb[0] = 48 as u8; k = 1 } 42 while m > 0 { nb[k] = (48 + (m % 10)) as u8; m = m / 10; k = k + 1 } 43 let ob: *u8 = sys_mmap(28) 44 var j: i64 = 0 45 while j < k { ob[j] = nb[k - 1 - j]; j = j + 1 } 46 sys_write(1, ob, k) 47 return 0 48} 49 50// data-driven modes table body: one <tr> per non-comment registry row 51func wp_modes_rows(h: *u8, off: i64, reg: *u8, rn: i64) -> i64 { 52 var w: i64 = off 53 var i: i64 = 0 54 let cell: *u8 = sys_mmap(256) 55 var go: i64 = 1 56 while go == 1 { 57 if i >= rn { go = 0 } 58 else { 59 let c: i64 = reg[i] as i64 60 if c == 10 { i = i + 1 } 61 else { 62 if c == 35 { i = sc_next_line(reg, rn, i) } // '#' comment row 63 else { 64 w = wp_cat(h, w, "<tr><td><b>" as *u8) 65 md_col(reg, rn, i, 0, cell, 256); w = wp_cat(h, w, cell) 66 w = wp_cat(h, w, "</b></td><td>" as *u8) 67 md_col(reg, rn, i, 1, cell, 256); w = wp_cat(h, w, cell) 68 w = wp_cat(h, w, "</td><td>" as *u8) 69 md_col(reg, rn, i, 2, cell, 256); w = wp_cat(h, w, cell) 70 w = wp_cat(h, w, "</td><td>" as *u8) 71 md_col(reg, rn, i, 4, cell, 256); w = wp_cat(h, w, cell) 72 w = wp_cat(h, w, "</td></tr>\n" as *u8) 73 i = sc_next_line(reg, rn, i) 74 } 75 } 76 } 77 } 78 return w 79} 80 81func main() -> i64 { 82 let lenp: *i64 = sys_mmap(16) as *i64 83 let reg: *u8 = sys_read_file_x86_64("knowledge/registry/write_modes.tsv\x00" as *u8, lenp) 84 var rn: i64 = 0 85 if reg != (0 as *u8) { rn = lenp[0] } 86 87 let h: *u8 = sys_mmap(WP_BYTES) 88 var w: i64 = 0 89 90 w = wp_cat(h, w, "<!doctype html><html lang=\"en\"><head><meta charset=\"utf-8\">\n" as *u8) 91 w = wp_cat(h, w, "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1\">\n" as *u8) 92 w = wp_cat(h, w, "<title>Nishi Writer &mdash; one assistant, every mode</title>\n" as *u8) 93 w = wp_cat(h, w, "<style>\n" as *u8) 94 w = wp_cat(h, w, ":root{--bg:#0b0f14;--panel:#131b24;--ink:#e6edf3;--mut:#8aa0b4;--acc:#4cc2ff;--good:#3fb950;--warn:#d29922;--line:#243140}\n" as *u8) 95 w = wp_cat(h, w, "*{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.55 system-ui,Segoe UI,Roboto,sans-serif}\n" as *u8) 96 w = wp_cat(h, w, "header{padding:30px 20px 16px;max-width:960px;margin:0 auto}h1{margin:0;font-size:29px}\n" as *u8) 97 w = wp_cat(h, w, ".sub{color:var(--mut);margin:.5em 0 0}.stamp{color:var(--mut);font-size:12.5px;margin:.4em 0 0}\n" as *u8) 98 w = wp_cat(h, w, "main{max-width:960px;margin:0 auto;padding:0 20px 60px}section{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px 18px;margin:16px 0}\n" as *u8) 99 w = wp_cat(h, w, "h2{margin:.1em 0 .5em;font-size:18px}code{color:var(--acc);font-size:.92em}\n" as *u8) 100 w = wp_cat(h, w, "table{border-collapse:collapse;width:100%;margin:.4em 0}th,td{padding:6px 9px;text-align:left;border-bottom:1px solid var(--line);font-size:13.5px}\n" as *u8) 101 w = wp_cat(h, w, "th{color:var(--mut);font-weight:600;font-size:12px;text-transform:uppercase;letter-spacing:.4px}\n" as *u8) 102 w = wp_cat(h, w, ".good{color:var(--good)}.warn{color:var(--warn)}\n" as *u8) 103 w = wp_cat(h, w, ".note{background:#10261a;border:1px solid #1c3b28;border-radius:9px;padding:10px 12px;color:#9fd2af;font-size:13px}\n" as *u8) 104 w = wp_cat(h, w, ".seam{background:#241a10;border:1px solid #3b2c1c;border-radius:9px;padding:10px 12px;color:#d2b48c;font-size:13px}\n" as *u8) 105 w = wp_cat(h, w, "pre{background:#0e1620;border:1px solid var(--line);border-radius:9px;padding:11px 13px;overflow:auto;font-size:12.5px;color:#cde3f5}\n" as *u8) 106 w = wp_cat(h, w, "footer{max-width:960px;margin:0 auto;padding:8px 20px 40px;color:var(--mut);font-size:12.5px}\n" as *u8) 107 w = wp_cat(h, w, "</style></head><body>\n" as *u8) 108 109 w = wp_cat(h, w, "<header><h1>Nishi Writer</h1>\n" as *u8) 110 w = wp_cat(h, w, "<p class=\"sub\">One assistant, every mode &mdash; write to people in your tone, make manga, draft research papers, spin up scenarios, run a couple's language practice, and coach real social confidence. Built 100&percnt; on the sovereign Nishi stack: no Python, no hand-written JS/HTML. This page was emitted by the organ <code>nx_writer_page</code>.</p>\n" as *u8) 111 w = wp_cat(h, w, "<p class=\"stamp\">Read-only showcase. The engine structures, governs, and measures; the model that actually writes plugs in as a separate &ldquo;seat&rdquo;. No generation or control surface is exposed here.</p></header>\n" as *u8) 112 w = wp_cat(h, w, "<main>\n" as *u8) 113 114 // ===== modes (data-driven from write_modes.tsv) ===== 115 w = wp_cat(h, w, "<section><h2>Modes</h2>\n" as *u8) 116 w = wp_cat(h, w, "<p class=\"stamp\">This table is generated from the registry <code>knowledge/registry/write_modes.tsv</code> at render time &mdash; add a row there and it appears here.</p>\n" as *u8) 117 w = wp_cat(h, w, "<table><tr><th>Mode</th><th>Register</th><th>Lane</th><th>What it does</th></tr>\n" as *u8) 118 w = wp_modes_rows(h, w, reg, rn) 119 w = wp_cat(h, w, "</table>\n" as *u8) 120 w = wp_cat(h, w, "<p class=\"seam\">The seam: a <b>lane</b> of <code>local</code> means generation runs on your own hardware &mdash; the assistant never authors explicit prose. This isn't a promise: the router organ <code>nx_mode</code> runs a mechanical seam audit that <i>fails</i> if any explicit-register mode is pointed at the shared lane.</p></section>\n" as *u8) 121 122 // ===== shipped capabilities (measured, gate-proven) ===== 123 w = wp_cat(h, w, "<section><h2>Shipped &mdash; measured, gate-proven</h2>\n" as *u8) 124 w = wp_cat(h, w, "<table><tr><th>Organ</th><th>Capability</th><th>Proof</th></tr>\n" as *u8) 125 w = wp_cat(h, w, "<tr><td><code>nx_tone</code></td><td>Voice fingerprint &mdash; write in your tone</td><td class=\"good\">&#10003; matches voice, weighted + drift</td></tr>\n" as *u8) 126 w = wp_cat(h, w, "<tr><td><code>nx_scenario</code></td><td>Scenario engine (write / role-play / practise)</td><td class=\"good\">&#10003; parse + validate + brief</td></tr>\n" as *u8) 127 w = wp_cat(h, w, "<tr><td><code>nx_convo</code></td><td>Language tutor + social coach</td><td class=\"good\">&#10003; keep-topics + respect-gated</td></tr>\n" as *u8) 128 w = wp_cat(h, w, "<tr><td><code>nx_manga</code></td><td>Page/panel script &rarr; image prompts</td><td class=\"good\">&#10003; counts + panel emit</td></tr>\n" as *u8) 129 w = wp_cat(h, w, "<tr><td><code>nx_cite</code></td><td>Citations APA / MLA / Chicago / IEEE</td><td class=\"good\">&#10003; exact, all 4 styles</td></tr>\n" as *u8) 130 w = wp_cat(h, w, "<tr><td><code>nx_mode</code></td><td>Mode router + mechanical seam audit</td><td class=\"good\">&#10003; tamper caught</td></tr>\n" as *u8) 131 w = wp_cat(h, w, "<tr><td><code>nx_writer_run</code></td><td>Unified runner (one tool, every mode)</td><td class=\"good\">&#10003; run-proven, 3 modes</td></tr>\n" as *u8) 132 w = wp_cat(h, w, "<tr><td><code>nx_writer_page</code></td><td>This showcase</td><td class=\"good\">&#10003; live</td></tr>\n" as *u8) 133 w = wp_cat(h, w, "</table>\n" as *u8) 134 w = wp_cat(h, w, "<p class=\"stamp\">Each &#10003; is a sovereign gate with a negative control, not a marketing claim. Every organ compiles <code>nx_cc &rarr; nxasm_x86</code> &mdash; no gcc.</p></section>\n" as *u8) 135 136 // ===== live sample (real numbers from a real run) ===== 137 w = wp_cat(h, w, "<section><h2>&ldquo;Write in my tone&rdquo; &mdash; a real run</h2>\n" as *u8) 138 w = wp_cat(h, w, "<p>Scoring a stiff, formal draft against a warm, casual writing sample. The engine reports how far the draft is from your voice and which dimension to fix:</p>\n" as *u8) 139 w = wp_cat(h, w, "<pre>mode: correspondence\nregister: sfw lane: tutor structure: tone\n voice fingerprinted (cadence dim0=12250)\n draft voice-distance: 9441\n largest drift on dim 0 (signed 6750)\n -&gt; seat: steer that dim toward 0 to match your voice.</pre>\n" as *u8) 140 w = wp_cat(h, w, "<p class=\"stamp\">Dimension 0 is sentence cadence: the formal draft runs far longer than your voice, so the fix is &ldquo;shorten your sentences&rdquo; &mdash; computed, not guessed.</p></section>\n" as *u8) 141 142 // ===== how to use ===== 143 w = wp_cat(h, w, "<section><h2>How to drive it</h2>\n" as *u8) 144 w = wp_cat(h, w, "<p>Pick a mode and drop your content into the staging folder, then run the tool:</p>\n" as *u8) 145 w = wp_cat(h, w, "<pre>echo correspondence &gt; knowledge/staging/writer/mode.txt\n# add voice.txt (your writing) + draft.txt (to score)\n./_offc/nx_sov_build_run.elf nx_writer_run</pre>\n" as *u8) 146 w = wp_cat(h, w, "<p class=\"note\">The tool enforces the seam as a hard gate, resolves the mode, and emits the structured brief the generation seat expands. Output goes to <code>knowledge/staging/writer/out.txt</code>.</p></section>\n" as *u8) 147 148 w = wp_cat(h, w, "</main>\n" as *u8) 149 w = wp_cat(h, w, "<footer>Sovereign Nishi stack &middot; emitted by <code>nx_writer_page</code> &middot; modes model: <code>knowledge/registry/write_modes.tsv</code> &middot; published via <code>nx_aw_push</code> &middot; nishifamily.com/writer</footer>\n" as *u8) 150 w = wp_cat(h, w, "</body></html>\n" as *u8) 151 152 let fd: i64 = sys_openat_wr(WP_OUT, 0x1a4) 153 if fd < 0 { sys_write(2, "FATAL: cannot open web_assets/writer.html\n" as *u8, 42); sys_exit(2); return 2 } 154 sys_write(fd, h, w) 155 sys_close(fd) 156 sys_write(1, "[nx_writer_page] wrote web_assets/writer.html bytes=" as *u8, 52) 157 wp_putn(w) 158 sys_write(1, "\n" as *u8, 1) 159 sys_exit(0) 160 return 0 161}