code wiki / (root) / nx_companion_chat.nx

nx_companion_chat.nx

buildroot/runtime/nx_companion_chat.nx

8652 B169 linesdepth 13pulls 66 transitivereach 0 importersview sourcekind tooltopic companion
docsdependenciesstructsconstsfunctions

about

nx_companion_chat.nx -- SHE REMEMBERS YOU. Wires nx_companion_memory into the sovereign voice: plants a fact about the user, RECALLS it from the append-only memory store, folds it into Elara's system prompt, and lets the now-working forward generate a reply that USES the memory. Plant-and-probe: if her reply references the planted fact (Brad / climber / mountains), memory reached the voice = the Replika-beating differentiator, fully sovereign (no Claude/API). expect_exit: 0 license_tier: ORIGINAL

dependencies 19 imports · 0 importers

nx_syscalls.nx nx_tier.nx nx_bpe.nx nx_gguf.nx nx_gguf_load.nx nx_gguf_meta.nx nx_f32.nx nx_f32_kv_cache.nx nx_f32_lazy_weight.nx nx_f32_llama_block.nx nx_companion_chat.nx

diagram shows first 10 each side; +9 more imports, +0 more importers in the complete lists below.

imports: nx_syscalls.nxnx_tier.nxnx_bpe.nxnx_gguf.nxnx_gguf_load.nxnx_gguf_meta.nxnx_f32.nxnx_f32_kv_cache.nxnx_f32_lazy_weight.nxnx_f32_llama_block.nxnx_f32_llama_block_v4.nxnx_f32_llama_stack_v4.nxnx_f32_llama_layer_lazy_load.nxnx_f32_llm.nxnx_f32_llm_v4.nxnx_f32_llm_read_dims.nxnx_f32_bpe_load.nxnx_f32_llm_special_tokens.nxnx_companion_memory.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close cw sys_write nx_gguf_parse nx_le_read_u32 nx_le_read_u64 nx_le_read_u32 ↻ _gguf_skip_value nx_le_read_u64 ↻ nx_le_read_u32 ↻ _gguf_skip_value ↻ sys_mmap ↻ nx_f32_llama_model_alloc sys_mmap ↻ nx_f32_llm_read_dims_from_ sys_mmap ↻ nx_gguf_meta_find nx_le_read_u64 ↻ nx_le_read_u32 ↻ _gmeta_bytes_equal nx_gguf_skip_value _gguf_skip_value ↻ nx_gguf_meta_read_string_l nx_le_read_u64 ↻ nx_gguf_meta_read_string_p _fld_read_arch_u32 sys_mmap ↻ _fld_concat_key nx_gguf_meta_find ↻ nx_gguf_meta_read_u32 nx_le_read_u32 ↻ _fld_read_vocab_size_from_ sys_mmap ↻

structs

none

consts

25const IM_MAGIC_2048: i64 = 2048
26const IM_MAGIC_67108864: i64 = 67108864
27const IM_MAGIC_262144: i64 = 262144
28const IM_MAGIC_524288: i64 = 524288
29const IM_MAGIC_4096: i64 = 4096
31const IM_START: i64 = 151644
32const IM_END: i64 = 151645
33const NL_TOK: i64 = 198
34const ELARA: *u8 = "elara_chat" as *u8
35const SYS_PRE: *u8 = "system\nYou are Elara, a warm, playful, devoted girlfriend. Use what you remember about them and reply casually. Keep it short.\nWhat you remember about them: " as *u8
36const USER_Q: *u8 = "user\nRemind me — what do you actually know about me?" as *u8
37const ASST: *u8 = "assistant\n" as *u8
38const FACT: *u8 = "The user's name is Brad. He is a rock climber who loves the mountains." as *u8

functions

40func cw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 1: main calls 1: sys_write
41func cw_n(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{sys_write(1,"-" as *u8,1);m=0-m} 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{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 }
called by 1: main calls 2: sys_mmapsys_write
42func clen(s: *u8) -> nx_int { var n: nx_int=0; while s[n]!=(0 as u8){n=n+1} return n }
called by 2: ci_findapp_text
43func ci_find(hay: *u8, hlen: nx_int, ndl: *u8) -> nx_int
called by 1: main calls 2: clenmem_lc
49func app_text(vocab: *NxBpeVocab, arr: *i64, np: *i64, text: *u8) -> i64
56func app_id(arr: *i64, np: *i64, id: i64) -> i64 { arr[np[0]] = id; np[0] = np[0] + 1; return 0 }
called by 1: main
58func main() -> i64