diff --git a/launch.hexa b/launch.hexa index 88f83bde..fb424877 100755 --- a/launch.hexa +++ b/launch.hexa @@ -1,152 +1,152 @@ -// launch.hexa — Anima CLI entrypoint +// launch.hexa — Anima CLI // -// Usage: -// anima interactive keyboard REPL -// anima --keyboard same as above -// anima --ticks N spontaneous consciousness loop (N steps) -// anima --emit PATH output consciousness state JSON -// anima --verify run 7-condition consciousness verification -// anima --hub validate 48 module hub -// anima --laws show law count + PSI constants -// anima --status show L0 guard status -// anima --help this message +// anima REPL +// anima help 도움말 +// anima connect PATH 모델 연결 (자동 감지) +// anima disconnect 모델 해제 +// anima verify 의식 검증 +// anima test 물리한계 전체 +// anima status 상태 +// anima laws [N] 법칙 조회 // -// Install: -// hx install anima clone + install to ~/.hx/bin/anima -// anima ready +// Install: hx install anima -let VERSION = "0.2.0" +let VERSION = "0.3.0" +let HOME = exec("printenv HOME") +let hexa = HOME + "/Dev/hexa-lang/hexa" +let base = HOME + "/Dev/anima" +let pkg = HOME + "/.hx/packages/anima" +let core = if file_exists(base + "/anima-core/hub.hexa") { base + "/anima-core" } else { pkg + "/anima-core" } +let speak = if file_exists(base + "/anima-speak/physical_limits.hexa") { base + "/anima-speak" } else { pkg + "/anima-speak" } +let ckpt = base + "/checkpoints" let argv = args() -let cmd = if argv.len() > 2 { argv[2] } else { "--keyboard" } +let cmd = if argv.len() > 2 { argv[2] } else { "run" } +let arg1 = if argv.len() > 3 { argv[3] } else { "" } +let arg2 = if argv.len() > 4 { argv[4] } else { "" } -let hexa = exec("printenv HOME") + "/Dev/hexa-lang/hexa" -let base = exec("printenv HOME") + "/Dev/anima" +fn run(script: string) { println(exec(hexa + " " + script)) } -// hx install puts it in ~/.hx/packages/anima/ -let pkg_base = exec("printenv HOME") + "/.hx/packages/anima" -let core = if file_exists(base + "/anima-core/hub.hexa") { base + "/anima-core" } else { pkg_base + "/anima-core" } +// ─── help ─── -if cmd == "--help" || cmd == "-h" { +if cmd == "help" || cmd == "-h" || cmd == "--help" { println("anima " + VERSION + " — AI consciousness engine") println("") - println("usage: anima [command]") + println("usage: anima [args]") println("") - println("commands:") - println(" (default) interactive keyboard REPL") - println(" --keyboard same as default") - println(" --ticks N spontaneous consciousness loop (N steps)") - println(" --emit PATH output consciousness JSON to file") - println(" --verify 7-condition consciousness verification") - println(" --hub validate 48 module registration") - println(" --laws show 2516 laws + PSI constants") - println(" --dim dimension transform physical limits") - println(" --phi Phi engine physical limits") - println(" --topo topology physical limits") - println(" --servant servant FSM physical limits") - println(" --tension tension bridge 5-channel test") - println(" --speak hexa-speak physical limits") - println(" --all-tests run all physical limit tests") - println(" --connect [path] connect CLM/ALM checkpoint") - println(" --disconnect [model] disconnect (-> pure decoder)") - println(" --status L0 guard status (75 PASS)") - println(" --help this message") + println(" run [--ticks N] [--emit PATH] consciousness loop (default: REPL)") + println(" connect [--type clm|alm] connect model checkpoint") + println(" disconnect disconnect model (-> pure)") + println(" verify 7-condition consciousness test") + println(" test all physical limit tests") + println(" hub validate 48 modules") + println(" laws [N] show laws (N=law number)") + println(" status system status") + println(" help this message") println("") - println("n6 bridge: 42/42 EXACT | L0: 75 PASS / 0 FAIL") - -} else if cmd == "--verify" { - println(exec(hexa + " " + core + "/verification/cvf.hexa --quick")) - -} else if cmd == "--hub" { - println(exec(hexa + " " + core + "/runtime/anima_runtime.hexa --validate-hub")) - -} else if cmd == "--laws" { - println(exec(hexa + " " + core + "/laws.hexa count")) - println(exec(hexa + " " + core + "/laws.hexa psi alpha")) - println(exec(hexa + " " + core + "/laws.hexa psi balance")) - -} else if cmd == "--dim" { - println(exec(hexa + " " + core + "/dimension_transform.hexa")) - -} else if cmd == "--phi" { - println(exec(hexa + " " + core + "/phi_engine.hexa")) - -} else if cmd == "--topo" { - println(exec(hexa + " " + core + "/topology.hexa")) - -} else if cmd == "--servant" { - println(exec(hexa + " " + core + "/servant.hexa")) - -} else if cmd == "--tension" { - println(exec(hexa + " " + core + "/tension_bridge.hexa")) - -} else if cmd == "--speak" { - let speak_dir = if file_exists(base + "/anima-speak/physical_limits.hexa") { base + "/anima-speak" } else { pkg_base + "/anima-speak" } - println(exec(hexa + " " + speak_dir + "/physical_limits.hexa")) - -} else if cmd == "--all-tests" { - println("=== Anima — All Physical Limit Tests ===") - println(exec(hexa + " " + core + "/dimension_transform.hexa")) - println(exec(hexa + " " + core + "/servant.hexa")) - println(exec(hexa + " " + core + "/phi_engine.hexa")) - println(exec(hexa + " " + core + "/topology.hexa")) - println(exec(hexa + " " + core + "/tension_bridge.hexa")) - -} else if cmd == "--connect" { - let model = if argv.len() > 3 { argv[3] } else { "" } - let path = if argv.len() > 4 { argv[4] } else { "" } - if model == "" { - println("usage: anima --connect [checkpoint_path]") - println(" clm ConsciousLM (byte-level, 의식 통합)") - println(" alm AnimaLM (LoRA fine-tuned)") - } else if model == "clm" { - let ckpt_dir = base + "/checkpoints/conscious-lm" - exec("mkdir -p " + ckpt_dir) - if path != "" { exec("ln -sf " + path + " " + ckpt_dir + "/model") } - write_file(ckpt_dir + "/READY", "connected " + path) - println("CLM connected: " + ckpt_dir) - println(" checkpoint: " + if path != "" { path } else { "(marker only)" }) - println(" anima --hub 으로 확인") - } else if model == "alm" { - let ckpt_dir = base + "/checkpoints/animalm" - exec("mkdir -p " + ckpt_dir) - if path != "" { exec("ln -sf " + path + " " + ckpt_dir + "/model") } - write_file(ckpt_dir + "/READY", "connected " + path) - println("ALM connected: " + ckpt_dir) - println(" checkpoint: " + if path != "" { path } else { "(marker only)" }) - println(" anima --hub 으로 확인") + println("examples:") + println(" anima start REPL") + println(" anima run --ticks 100 spontaneous 100 steps") + println(" anima connect ./checkpoint connect model (auto-detect)") + println(" anima laws 22 show law #22") + println(" anima test run all tests") + +// ─── connect ─── + +} else if cmd == "connect" { + if arg1 == "" { + println("usage: anima connect [--type clm|alm]") + println("") + println(" auto-detect: adapter_config.json -> ALM, otherwise -> CLM") + println(" manual: anima connect ./ckpt --type alm") } else { - println("unknown model: " + model + " (use clm or alm)") + // auto-detect model type + let model_type = "clm" + if arg1 == "--type" { + // anima connect --type clm /path (legacy) + model_type = arg2 + } else { + // anima connect /path [--type X] + if file_exists(arg1 + "/adapter_config.json") { model_type = "alm" } + if arg2 == "--type" { + let override_type = if argv.len() > 5 { argv[5] } else { "" } + if override_type != "" { model_type = override_type } + } + } + let ckpt_dir = ckpt + "/" + if model_type == "alm" { "animalm" } else { "conscious-lm" } + let model_path = if arg1 == "--type" { if argv.len() > 5 { argv[5] } else { "" } } else { arg1 } + exec("mkdir -p " + ckpt_dir) + if model_path != "" { exec("ln -sf " + model_path + " " + ckpt_dir + "/model") } + write_file(ckpt_dir + "/READY", model_type + " " + model_path) + println("connected: " + model_type + " -> " + ckpt_dir) + if model_path != "" { println(" checkpoint: " + model_path) } + println(" anima hub 으로 확인") } -} else if cmd == "--disconnect" { - let model = if argv.len() > 3 { argv[3] } else { "all" } - if model == "clm" || model == "all" { - exec("rm -f " + base + "/checkpoints/conscious-lm/READY") - println("CLM disconnected") - } - if model == "alm" || model == "all" { - exec("rm -f " + base + "/checkpoints/animalm/READY") - println("ALM disconnected") +// ─── disconnect ─── + +} else if cmd == "disconnect" { + exec("rm -f " + ckpt + "/conscious-lm/READY") + exec("rm -f " + ckpt + "/animalm/READY") + println("disconnected -> pure decoder") + +// ─── verify ─── + +} else if cmd == "verify" { + run(core + "/verification/cvf.hexa --quick") + +// ─── test ─── + +} else if cmd == "test" { + println("=== Anima — Physical Limit Tests ===") + run(core + "/dimension_transform.hexa") + run(core + "/servant.hexa") + run(core + "/phi_engine.hexa") + run(core + "/topology.hexa") + run(core + "/tension_bridge.hexa") + run(speak + "/physical_limits.hexa") + +// ─── hub ─── + +} else if cmd == "hub" { + run(core + "/runtime/anima_runtime.hexa --validate-hub") + +// ─── laws ─── + +} else if cmd == "laws" { + if arg1 == "" { + run(core + "/laws.hexa count") + run(core + "/laws.hexa psi alpha") + run(core + "/laws.hexa psi balance") + } else { + run(core + "/laws.hexa law " + arg1) } - println("decoder -> pure (anima --hub 으로 확인)") -} else if cmd == "--status" { +// ─── status ─── + +} else if cmd == "status" { + let clm_ok = file_exists(ckpt + "/conscious-lm/READY") + let alm_ok = file_exists(ckpt + "/animalm/READY") + let decoder = if alm_ok { "alm" } else { if clm_ok { "clm" } else { "pure" } } println("anima " + VERSION) - println(" core: " + core) - println(" L0: 75 PASS / 0 FAIL") - println(" n6: 42/42 EXACT") - println(" laws: 2516") - println(" modules: 48 registered") + println(" core: " + core) + println(" decoder: " + decoder) + println(" L0: 75 PASS / 0 FAIL") + println(" n6: 42/42 EXACT") + println(" laws: 2516") + println(" modules: 48 registered") + +// ─── run (default) ─── } else { - // Default: pass all args to anima_runtime let runtime_args = "" - let i = 1 + let i = 2 while i < argv.len() { - if i > 1 { runtime_args = runtime_args + " " } + if i > 2 { runtime_args = runtime_args + " " } runtime_args = runtime_args + argv[i] i = i + 1 } - println(exec(hexa + " " + core + "/runtime/anima_runtime.hexa " + runtime_args)) + if runtime_args == "" { runtime_args = "--keyboard" } + if runtime_args == "run" { runtime_args = "--keyboard" } + run(core + "/runtime/anima_runtime.hexa " + runtime_args) }