code wiki / _hdl_build / nx_context_packer.nx
nx_context_packer.nx
buildroot/runtime/_hdl_build/nx_context_packer.nx
about
nx_context_packer.nx -- THE sovereign "push a document into an LLM natively" CLI: read a text file (a book's
extracted chapters, a research doc, anything), pack it into an LLM context that fits a TOKEN BUDGET (with a 10%
safety margin), and write an LLM-ready context file. Greedy in-order line packing + an honest truncation marker
when the document exceeds the budget. No 3rd-party tokenizer/SDK -- pure Nishi. Composes nx_token_counter.
usage: nx_context_packer <infile> <budget_tokens> <outfile> license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_token_counter.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 7 | const K_MAGIC_65536: i64 = 65536 |
functions
| 9 | func cp_slen(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} return n } |
| 10 | func cp_w(s: *u8) -> i64 { sys_write(1, s, cp_slen(s)); return 0 } |
| 11 | func cp_atoi(s: *u8) -> i64 { var v: i64=0; var i: i64=0; while s[i]!=(0 as u8){ let c: i64=s[i] as i64; if c>=48 { if c<=57 { v=v*10+(c-48) } } i=i+1 } return v } called by 1: main |
| 12 | func cp_wn(v: i64) -> i64 |
| 21 | func main(argc: i64, argv: *i64) -> i64 |