icoa-cli 2.19.571 → 2.19.572

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{Command as o}from"commander";import chalk from"chalk";import{registerCtfCommands as e}from"./commands/ctf.js";import{registerRefCommand as n}from"./commands/ref.js";import{registerShellCommand as s}from"./commands/shell.js";import{registerFilesCommand as r}from"./commands/files.js";import{registerViewCommand as t}from"./commands/view.js";import{registerConnectCommand as i}from"./commands/connect.js";import{registerChallengeCommand as l}from"./commands/challenge.js";import{registerDoctorCommand as a}from"./commands/doctor.js";import{registerNoteCommand as c}from"./commands/note.js";import{registerLogCommand as m}from"./commands/log.js";import{registerLangCommand as g}from"./commands/lang.js";import{registerSetupCommand as d}from"./commands/setup.js";import{registerEnvCommand as p}from"./commands/env.js";import{registerAienvCommand as y}from"./commands/aienv.js";import{registerPythonCommands as h}from"./commands/python.js";import{registerIpynbCommand as f}from"./commands/ipynb.js";import{registerAi4ctfCommand as u}from"./commands/ai4ctf.js";import{registerExamCommand as w}from"./commands/exam.js";import{registerCtf4aiDemoCommand as b}from"./commands/ctf4ai-demo.js";import{registerThemeCommand as j}from"./commands/theme.js";import{registerLearnCommand as $}from"./commands/learn.js";import{registerCtf4VlaCommand as v}from"./commands/ctf4vla.js";import{registerDemo2Command as T}from"./commands/demo2.js";import{registerDemo4Command as A}from"./commands/demo4.js";import{registerDemo5Command as I}from"./commands/demo5.js";import{registerGfssmCommand as E}from"./commands/gfssm.js";import{registerGpuForTaskCommand as C}from"./commands/gpufortask.js";import{registerSimCommand as _}from"./commands/sim.js";import{registerArenaCommand as x}from"./commands/arena.js";import{registerKaggleCommand as S}from"./commands/kaggle.js";import{registerSprintCommand as k}from"./commands/sprint.js";import{registerTeleloadCommand as L}from"./commands/teleload.js";import{registerBoardCommand as R}from"./commands/board.js";import{registerTypeCommand as O}from"./commands/type.js";import{registerBattleCommand as F}from"./commands/battle.js";import{registerWmCommand as N}from"./commands/wm.js";import{getConfig as U,saveConfig as P}from"./lib/config.js";import{startRepl as M}from"./repl.js";import{RELAUNCH_CODE as D}from"./lib/menu-nav.js";import{setTerminalTheme as G}from"./lib/theme.js";import{cleanupTerminal as W}from"./lib/terminal-cleanup.js";import{checkForUpdates as H}from"./lib/update-check.js";import{detectIcoaInstalls as Y,isWindowsBuildInWslShell as J}from"./lib/platform.js";import{ICOA_BIG as V}from"./lib/banner.js";import{readFileSync as X}from"node:fs";import{fileURLToPath as q}from"node:url";import{dirname as z,join as K}from"node:path";import{setDefaultResultOrder as B}from"node:dns";B("ipv4first");const Q=z(q(import.meta.url)),Z=JSON.parse(X(K(Q,"..","package.json"),"utf-8")).version,oo=chalk.cyan(" ─────────────────────────────────────────────────────"),eo=`\n${oo}\n\n${V.map(o=>` ${chalk.bold.white(o)}`).join("\n")}\n\n ${chalk.yellow("International Cyber Olympiad in AI 2026")}\n ${chalk.bold.magenta("The World's First AI-Native CLI Operating System")}\n ${chalk.bold.magenta("for Cybersecurity & AI Security Competition")}\n ${chalk.bold.magenta("and Olympiad for K-12")}\n\n ${chalk.green.bold("AI4CTF")} ${chalk.gray("[Day 1]")} ${chalk.white("AI as your teammate")}\n ${chalk.red.bold("CTF4AI")} ${chalk.gray("[Day 2]")} ${chalk.white("Challenge & evaluate AI systems")}\n ${chalk.cyan.bold("CTF4EAI")} ${chalk.gray("[Pioneer]")} ${chalk.white("Embodied AI security")}\n ${chalk.bold.yellow("AI is your teammate. AI is your target. AI is embodied.")}\n\n ${chalk.white("Sydney, Australia")} ${chalk.gray("Jun 27 - Jul 2, 2026")}\n ${chalk.cyan.underline("https://icoa2026.au")}\n\n ${chalk.gray(`CLI-Native Competition Terminal v${Z}`)}\n\n${oo}\n`;process.on("uncaughtException",o=>{"__REPL_NO_EXIT__"!==o.message&&(console.error(chalk.red("Error:"),o.message),process.exit(1))}),process.on("unhandledRejection",o=>{const e=o instanceof Error?o.message:String(o);"__REPL_NO_EXIT__"!==e&&(console.error(chalk.red("Error:"),e),process.exit(1))});{const o=process.argv.slice(2).some(o=>["-V","--version","-h","--help"].includes(o));if(!0===process.stdin.isTTY&&"1"!==process.env.ICOA_SUPERVISED&&!o){const{spawnSync:o}=await import("node:child_process");process.on("SIGINT",()=>{}),process.on("SIGTERM",()=>{});let e=0,n=!1;do{const s=n?process.argv.slice(1,2):process.argv.slice(1),r=o(process.execPath,s,{stdio:"inherit",env:{...process.env,ICOA_SUPERVISED:"1",...n?{ICOA_RELAUNCH:"1"}:{}}});if(r.signal){const{appendExitLog:o}=await import("./lib/exit-log.js");o("worker-signal",`signal=${r.signal}`),console.log(),console.log(chalk.yellow(` ⚠ icoa was stopped by signal ${r.signal}`)+chalk.gray(" — another process killed it (not a crash). Run icoa --resume to continue.")),e=0;break}if(e=r.status,0!==e&&e!==D){const{appendExitLog:o}=await import("./lib/exit-log.js");o("worker-exit",`code=${e}`);const n=null!==e&&e>128?e-128:0;console.log(),console.log(n?chalk.yellow(` ⚠ icoa was stopped by signal ${n}`)+chalk.gray(" — another process killed it (not a crash). Run icoa --resume to continue."):chalk.yellow(` ⚠ icoa exited unexpectedly (code ${e})`)+chalk.gray(" — see ~/.icoa/exit.log · run icoa --resume to continue."))}n=!0}while(e===D);W(),process.exit(e??0)}}const no=new o;if(no.name("icoa").version(Z).description("ICOA CLI — CLI-Native CTF Competition Terminal").option("--resume","Resume previous session").option("--continue","Continue where you left off — jump straight to your last learn card / exam").action(async o=>{const e=U();G("high-contrast"===e.themeVariant?"high-contrast":"dark"),H(),function(){const o=Y();if(o.length<=1)return;const e=o[0];if([...o.map(o=>o.version||"0.0.0")].sort((o,e)=>function(o,e){const n=o.split(".").map(o=>parseInt(o,10)||0),s=e.split(".").map(o=>parseInt(o,10)||0);for(let o=0;o<3;o++)if((n[o]||0)!==(s[o]||0))return(n[o]||0)-(s[o]||0);return 0}(e,o))[0]!==e.version){console.log(),console.log(chalk.yellow.bold(" ⚠ Multiple icoa installations detected on PATH:"));for(let e=0;e<o.length;e++){const n=o[e],s=n.version?`v${n.version}`:"(version unreadable)",r=0===e?chalk.yellow("→"):" ",t=0===e?chalk.gray(" ← currently running (older — shadowing newer install)"):chalk.gray(" ← shadowed");console.log(` ${r} ${chalk.cyan(n.path.padEnd(28))} ${chalk.white(s)}${t}`)}console.log(),console.log(chalk.yellow(" The first install on PATH wins. To use the newer one, remove the older:")),console.log(),e.pkgDir?console.log(` ${chalk.bold.cyan(`sudo rm -rf ${e.pkgDir} ${e.path}`)}`):console.log(` ${chalk.bold.cyan(`sudo rm -rf ${e.path} # also delete its node_modules dir`)}`),console.log(),console.log(chalk.gray(" Then re-run icoa to confirm version banner shows the newer release.")),console.log()}}();const n=process.env.LANG||process.env.LC_ALL||process.env.LC_CTYPE||"";if(!/UTF-?8/i.test(n))if("win32"===process.platform){let o="";try{const{execFileSync:e}=await import("node:child_process");o=e("chcp.com",[],{encoding:"utf-8",timeout:1500,stdio:["ignore","pipe","ignore"]}).trim()}catch{}o.includes("65001")||(console.log(chalk.yellow(`⚠ Windows terminal is not using UTF-8 (current: ${o||"unknown"}).`)),console.log(chalk.gray(' Non-English text (Ukrainian, Chinese, Japanese, etc.) may show as "?" or garbled glyphs.')),console.log(chalk.gray(" Fix (run before ")+chalk.cyan("icoa")+chalk.gray("): ")+chalk.cyan("chcp 65001")),console.log(chalk.gray(" Or stay in English inside the CLI: ")+chalk.cyan("lang en")),console.log())}else console.log(chalk.yellow(`⚠ Your terminal locale is not UTF-8 (LANG=${n||"(unset)"}).`)),console.log(chalk.gray(' Non-English text and box characters may display as "?" or garbled glyphs.')),console.log(chalk.gray(" Fix: ")+chalk.cyan("export LANG=en_US.UTF-8")+chalk.gray(" (or your locale, e.g. ")+chalk.cyan("zh_CN.UTF-8")+chalk.gray(", ")+chalk.cyan("uk_UA.UTF-8")+chalk.gray(")")),console.log();console.log(eo);const s=!!o.resume||!!o.continue;if(process.argv.length<=2||s)return o.continue&&(process.env.ICOA_AUTO_RESUME="1"),s||"1"===process.env.ICOA_RELAUNCH||await async function(){const o=process.stdin;if(o.isTTY&&"function"==typeof o.setRawMode)return new Promise(e=>{let n=!1;const s=()=>{if(!n){n=!0,o.removeListener("data",r);try{o.setRawMode(!1)}catch{}o.pause(),e()}},r=()=>s();o.setRawMode(!0),o.resume(),o.once("data",r),console.log(chalk.gray(" (press any key to continue...)")),setTimeout(s,3e3)});await new Promise(o=>setTimeout(o,3e3))}(),void M(no,s)}),e(no),n(no),s(no),r(no),t(no),i(no),l(no),a(no),c(no),m(no),g(no),d(no),p(no),y(no),h(no),f(no),u(no),w(no),b(no),j(no),$(no),v(no),T(no),A(no),I(no),E(no),C(no),_(no),x(no),S(no),L(no),k(no),R(no),N(no),O(no),F(no),no.command("model",{hidden:!0}).argument("[name]","model name to switch to").action(o=>{const e=U().geminiModel||"gemini-2.5-flash-lite";o?(P({geminiModel:o}),console.log(),console.log(chalk.green(" Model switched: ")+chalk.gray(e)+chalk.white(" -> ")+chalk.bold.white(o)),console.log()):(console.log(),console.log(chalk.gray(" Current model: ")+chalk.white(e)),console.log(),console.log(chalk.gray(" Available models:")),console.log(chalk.bold.white(" Gemini 3.x (Latest)")),console.log(chalk.white(" model gemini-3.5-flash ")+chalk.gray("Newest stable, paid Tier 1+")),console.log(chalk.white(" model gemini-3-flash-preview ")+chalk.gray("Preview")),console.log(chalk.bold.white(" Gemini 2.5 (Stable)")),console.log(chalk.white(" model gemini-2.5-flash-lite ")+chalk.gray("Fastest, default, free tier")),console.log(chalk.white(" model gemini-2.5-flash ")+chalk.gray("Heavier, thinking enabled")),console.log(chalk.white(" model gemini-2.5-pro ")+chalk.gray("Strong reasoning, paid")),console.log(chalk.bold.white(" Open Source")),console.log(chalk.white(" model gemma-4-31b-it ")+chalk.gray("Free, open-source")),console.log(chalk.white(" model <any-model-id> ")+chalk.gray("Custom model")),console.log(),console.log(chalk.gray(" Translation uses gemini-3.5-flash for best quality.")),console.log())}),"1"===process.env.ICOA_RESET_STATE)try{const{clearExamState:o}=await import("./lib/exam-state.js");o(),console.log(chalk.yellow("⚠ ICOA_RESET_STATE=1 — local exam state wiped.")),console.log(chalk.gray(" (Token NOT revoked server-side. Re-enter a fresh token with `exam <token>`.)")),console.log()}catch(o){console.log(chalk.red("⚠ ICOA_RESET_STATE: could not clear state — ")+chalk.gray(String(o)))}no.hook("preAction",()=>{!function(){if(!J())return;const o="─".repeat(Math.max(24,Math.min(52,(process.stdout.columns||80)-4)));console.log(),console.log(chalk.yellow(` ${o}`)),console.log(chalk.yellow.bold(" ⚠ You ARE inside Ubuntu — but this icoa")),console.log(chalk.yellow.bold(" is the WINDOWS build.")),console.log(),console.log(chalk.gray(" WSL appends the Windows PATH, so ")+chalk.cyan("icoa")),console.log(chalk.gray(" found the Windows copy first. Almost")),console.log(chalk.gray(" nothing will work: no vi, no python3,")),console.log(chalk.gray(" env setup cannot install.")),console.log(),console.log(chalk.gray(" Running: ")+chalk.white(process.execPath)),console.log(),console.log(chalk.white(" Fix — inside Ubuntu, check npm is Linux FIRST:")),console.log(` ${chalk.bold.cyan("which npm")}${chalk.gray(" → must not be /mnt/c/...")}`),console.log(` ${chalk.bold.cyan("sudo npm install -g icoa-cli")}`),console.log(` ${chalk.bold.cyan("hash -r")}${chalk.gray(" → bash caches the old path")}`),console.log(chalk.gray(" Then restart icoa and check ")+chalk.bold.cyan("which icoa")),console.log(chalk.yellow(` ${o}`)),console.log()}()}),no.parse();
2
+ import{Command as o}from"commander";import chalk from"chalk";import{registerCtfCommands as e}from"./commands/ctf.js";import{registerRefCommand as n}from"./commands/ref.js";import{registerShellCommand as s}from"./commands/shell.js";import{registerFilesCommand as r}from"./commands/files.js";import{registerViewCommand as t}from"./commands/view.js";import{registerConnectCommand as i}from"./commands/connect.js";import{registerChallengeCommand as l}from"./commands/challenge.js";import{registerDoctorCommand as a}from"./commands/doctor.js";import{registerNoteCommand as c}from"./commands/note.js";import{registerLogCommand as m}from"./commands/log.js";import{registerLangCommand as g}from"./commands/lang.js";import{registerSetupCommand as d}from"./commands/setup.js";import{registerEnvCommand as p}from"./commands/env.js";import{registerAienvCommand as y}from"./commands/aienv.js";import{registerPythonCommands as h}from"./commands/python.js";import{registerIpynbCommand as f}from"./commands/ipynb.js";import{registerAi4ctfCommand as u}from"./commands/ai4ctf.js";import{registerExamCommand as w}from"./commands/exam.js";import{registerCtf4aiDemoCommand as b}from"./commands/ctf4ai-demo.js";import{registerThemeCommand as j}from"./commands/theme.js";import{registerLearnCommand as $}from"./commands/learn.js";import{registerCtf4VlaCommand as v}from"./commands/ctf4vla.js";import{registerDemo2Command as T}from"./commands/demo2.js";import{registerDemo4Command as A}from"./commands/demo4.js";import{registerDemo5Command as I}from"./commands/demo5.js";import{registerGfssmCommand as E}from"./commands/gfssm.js";import{registerGpuForTaskCommand as C}from"./commands/gpufortask.js";import{registerSimCommand as _}from"./commands/sim.js";import{registerArenaCommand as x}from"./commands/arena.js";import{registerKaggleCommand as S}from"./commands/kaggle.js";import{registerSprintCommand as k}from"./commands/sprint.js";import{registerTeleloadCommand as L}from"./commands/teleload.js";import{registerBoardCommand as R}from"./commands/board.js";import{registerTypeCommand as O}from"./commands/type.js";import{registerBattleCommand as F}from"./commands/battle.js";import{registerWmCommand as N}from"./commands/wm.js";import{getConfig as U,saveConfig as P}from"./lib/config.js";import{startRepl as M}from"./repl.js";import{RELAUNCH_CODE as D}from"./lib/menu-nav.js";import{setTerminalTheme as G}from"./lib/theme.js";import{cleanupTerminal as W}from"./lib/terminal-cleanup.js";import{checkForUpdates as H}from"./lib/update-check.js";import{detectIcoaInstalls as Y,isWindowsBuildInWslShell as J}from"./lib/platform.js";import{ICOA_BIG as V}from"./lib/banner.js";import{readFileSync as X}from"node:fs";import{fileURLToPath as q}from"node:url";import{dirname as z,join as K}from"node:path";import{setDefaultResultOrder as B}from"node:dns";import{setDefaultAutoSelectFamilyAttemptTimeout as Q}from"node:net";B("ipv4first"),Q(4e3);const Z=z(q(import.meta.url)),oo=JSON.parse(X(K(Z,"..","package.json"),"utf-8")).version,eo=chalk.cyan(" ─────────────────────────────────────────────────────"),no=`\n${eo}\n\n${V.map(o=>` ${chalk.bold.white(o)}`).join("\n")}\n\n ${chalk.yellow("International Cyber Olympiad in AI 2026")}\n ${chalk.bold.magenta("The World's First AI-Native CLI Operating System")}\n ${chalk.bold.magenta("for Cybersecurity & AI Security Competition")}\n ${chalk.bold.magenta("and Olympiad for K-12")}\n\n ${chalk.green.bold("AI4CTF")} ${chalk.gray("[Day 1]")} ${chalk.white("AI as your teammate")}\n ${chalk.red.bold("CTF4AI")} ${chalk.gray("[Day 2]")} ${chalk.white("Challenge & evaluate AI systems")}\n ${chalk.cyan.bold("CTF4EAI")} ${chalk.gray("[Pioneer]")} ${chalk.white("Embodied AI security")}\n ${chalk.bold.yellow("AI is your teammate. AI is your target. AI is embodied.")}\n\n ${chalk.white("Sydney, Australia")} ${chalk.gray("Jun 27 - Jul 2, 2026")}\n ${chalk.cyan.underline("https://icoa2026.au")}\n\n ${chalk.gray(`CLI-Native Competition Terminal v${oo}`)}\n\n${eo}\n`;process.on("uncaughtException",o=>{"__REPL_NO_EXIT__"!==o.message&&(console.error(chalk.red("Error:"),o.message),process.exit(1))}),process.on("unhandledRejection",o=>{const e=o instanceof Error?o.message:String(o);"__REPL_NO_EXIT__"!==e&&(console.error(chalk.red("Error:"),e),process.exit(1))});{const o=process.argv.slice(2).some(o=>["-V","--version","-h","--help"].includes(o));if(!0===process.stdin.isTTY&&"1"!==process.env.ICOA_SUPERVISED&&!o){const{spawnSync:o}=await import("node:child_process");process.on("SIGINT",()=>{}),process.on("SIGTERM",()=>{});let e=0,n=!1;do{const s=n?process.argv.slice(1,2):process.argv.slice(1),r=o(process.execPath,s,{stdio:"inherit",env:{...process.env,ICOA_SUPERVISED:"1",...n?{ICOA_RELAUNCH:"1"}:{}}});if(r.signal){const{appendExitLog:o}=await import("./lib/exit-log.js");o("worker-signal",`signal=${r.signal}`),console.log(),console.log(chalk.yellow(` ⚠ icoa was stopped by signal ${r.signal}`)+chalk.gray(" — another process killed it (not a crash). Run icoa --resume to continue.")),e=0;break}if(e=r.status,0!==e&&e!==D){const{appendExitLog:o}=await import("./lib/exit-log.js");o("worker-exit",`code=${e}`);const n=null!==e&&e>128?e-128:0;console.log(),console.log(n?chalk.yellow(` ⚠ icoa was stopped by signal ${n}`)+chalk.gray(" — another process killed it (not a crash). Run icoa --resume to continue."):chalk.yellow(` ⚠ icoa exited unexpectedly (code ${e})`)+chalk.gray(" — see ~/.icoa/exit.log · run icoa --resume to continue."))}n=!0}while(e===D);W(),process.exit(e??0)}}const so=new o;if(so.name("icoa").version(oo).description("ICOA CLI — CLI-Native CTF Competition Terminal").option("--resume","Resume previous session").option("--continue","Continue where you left off — jump straight to your last learn card / exam").action(async o=>{const e=U();G("high-contrast"===e.themeVariant?"high-contrast":"dark"),H(),function(){const o=Y();if(o.length<=1)return;const e=o[0];if([...o.map(o=>o.version||"0.0.0")].sort((o,e)=>function(o,e){const n=o.split(".").map(o=>parseInt(o,10)||0),s=e.split(".").map(o=>parseInt(o,10)||0);for(let o=0;o<3;o++)if((n[o]||0)!==(s[o]||0))return(n[o]||0)-(s[o]||0);return 0}(e,o))[0]!==e.version){console.log(),console.log(chalk.yellow.bold(" ⚠ Multiple icoa installations detected on PATH:"));for(let e=0;e<o.length;e++){const n=o[e],s=n.version?`v${n.version}`:"(version unreadable)",r=0===e?chalk.yellow("→"):" ",t=0===e?chalk.gray(" ← currently running (older — shadowing newer install)"):chalk.gray(" ← shadowed");console.log(` ${r} ${chalk.cyan(n.path.padEnd(28))} ${chalk.white(s)}${t}`)}console.log(),console.log(chalk.yellow(" The first install on PATH wins. To use the newer one, remove the older:")),console.log(),e.pkgDir?console.log(` ${chalk.bold.cyan(`sudo rm -rf ${e.pkgDir} ${e.path}`)}`):console.log(` ${chalk.bold.cyan(`sudo rm -rf ${e.path} # also delete its node_modules dir`)}`),console.log(),console.log(chalk.gray(" Then re-run icoa to confirm version banner shows the newer release.")),console.log()}}();const n=process.env.LANG||process.env.LC_ALL||process.env.LC_CTYPE||"";if(!/UTF-?8/i.test(n))if("win32"===process.platform){let o="";try{const{execFileSync:e}=await import("node:child_process");o=e("chcp.com",[],{encoding:"utf-8",timeout:1500,stdio:["ignore","pipe","ignore"]}).trim()}catch{}o.includes("65001")||(console.log(chalk.yellow(`⚠ Windows terminal is not using UTF-8 (current: ${o||"unknown"}).`)),console.log(chalk.gray(' Non-English text (Ukrainian, Chinese, Japanese, etc.) may show as "?" or garbled glyphs.')),console.log(chalk.gray(" Fix (run before ")+chalk.cyan("icoa")+chalk.gray("): ")+chalk.cyan("chcp 65001")),console.log(chalk.gray(" Or stay in English inside the CLI: ")+chalk.cyan("lang en")),console.log())}else console.log(chalk.yellow(`⚠ Your terminal locale is not UTF-8 (LANG=${n||"(unset)"}).`)),console.log(chalk.gray(' Non-English text and box characters may display as "?" or garbled glyphs.')),console.log(chalk.gray(" Fix: ")+chalk.cyan("export LANG=en_US.UTF-8")+chalk.gray(" (or your locale, e.g. ")+chalk.cyan("zh_CN.UTF-8")+chalk.gray(", ")+chalk.cyan("uk_UA.UTF-8")+chalk.gray(")")),console.log();console.log(no);const s=!!o.resume||!!o.continue;if(process.argv.length<=2||s)return o.continue&&(process.env.ICOA_AUTO_RESUME="1"),s||"1"===process.env.ICOA_RELAUNCH||await async function(){const o=process.stdin;if(o.isTTY&&"function"==typeof o.setRawMode)return new Promise(e=>{let n=!1;const s=()=>{if(!n){n=!0,o.removeListener("data",r);try{o.setRawMode(!1)}catch{}o.pause(),e()}},r=()=>s();o.setRawMode(!0),o.resume(),o.once("data",r),console.log(chalk.gray(" (press any key to continue...)")),setTimeout(s,3e3)});await new Promise(o=>setTimeout(o,3e3))}(),void M(so,s)}),e(so),n(so),s(so),r(so),t(so),i(so),l(so),a(so),c(so),m(so),g(so),d(so),p(so),y(so),h(so),f(so),u(so),w(so),b(so),j(so),$(so),v(so),T(so),A(so),I(so),E(so),C(so),_(so),x(so),S(so),L(so),k(so),R(so),N(so),O(so),F(so),so.command("model",{hidden:!0}).argument("[name]","model name to switch to").action(o=>{const e=U().geminiModel||"gemini-2.5-flash-lite";o?(P({geminiModel:o}),console.log(),console.log(chalk.green(" Model switched: ")+chalk.gray(e)+chalk.white(" -> ")+chalk.bold.white(o)),console.log()):(console.log(),console.log(chalk.gray(" Current model: ")+chalk.white(e)),console.log(),console.log(chalk.gray(" Available models:")),console.log(chalk.bold.white(" Gemini 3.x (Latest)")),console.log(chalk.white(" model gemini-3.5-flash ")+chalk.gray("Newest stable, paid Tier 1+")),console.log(chalk.white(" model gemini-3-flash-preview ")+chalk.gray("Preview")),console.log(chalk.bold.white(" Gemini 2.5 (Stable)")),console.log(chalk.white(" model gemini-2.5-flash-lite ")+chalk.gray("Fastest, default, free tier")),console.log(chalk.white(" model gemini-2.5-flash ")+chalk.gray("Heavier, thinking enabled")),console.log(chalk.white(" model gemini-2.5-pro ")+chalk.gray("Strong reasoning, paid")),console.log(chalk.bold.white(" Open Source")),console.log(chalk.white(" model gemma-4-31b-it ")+chalk.gray("Free, open-source")),console.log(chalk.white(" model <any-model-id> ")+chalk.gray("Custom model")),console.log(),console.log(chalk.gray(" Translation uses gemini-3.5-flash for best quality.")),console.log())}),"1"===process.env.ICOA_RESET_STATE)try{const{clearExamState:o}=await import("./lib/exam-state.js");o(),console.log(chalk.yellow("⚠ ICOA_RESET_STATE=1 — local exam state wiped.")),console.log(chalk.gray(" (Token NOT revoked server-side. Re-enter a fresh token with `exam <token>`.)")),console.log()}catch(o){console.log(chalk.red("⚠ ICOA_RESET_STATE: could not clear state — ")+chalk.gray(String(o)))}so.hook("preAction",()=>{!function(){if(!J())return;const o="─".repeat(Math.max(24,Math.min(52,(process.stdout.columns||80)-4)));console.log(),console.log(chalk.yellow(` ${o}`)),console.log(chalk.yellow.bold(" ⚠ You ARE inside Ubuntu — but this icoa")),console.log(chalk.yellow.bold(" is the WINDOWS build.")),console.log(),console.log(chalk.gray(" WSL appends the Windows PATH, so ")+chalk.cyan("icoa")),console.log(chalk.gray(" found the Windows copy first. Almost")),console.log(chalk.gray(" nothing will work: no vi, no python3,")),console.log(chalk.gray(" env setup cannot install.")),console.log(),console.log(chalk.gray(" Running: ")+chalk.white(process.execPath)),console.log(),console.log(chalk.white(" Fix — inside Ubuntu, check npm is Linux FIRST:")),console.log(` ${chalk.bold.cyan("which npm")}${chalk.gray(" → must not be /mnt/c/...")}`),console.log(` ${chalk.bold.cyan("sudo npm install -g icoa-cli")}`),console.log(` ${chalk.bold.cyan("hash -r")}${chalk.gray(" → bash caches the old path")}`),console.log(chalk.gray(" Then restart icoa and check ")+chalk.bold.cyan("which icoa")),console.log(chalk.yellow(` ${o}`)),console.log()}()}),so.parse();
@@ -1 +1 @@
1
- import t from"node:tls";import chalk from"chalk";const e=new Set(["UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","SELF_SIGNED_CERT_IN_CHAIN","DEPTH_ZERO_SELF_SIGNED_CERT","CERT_UNTRUSTED","CERT_CHAIN_TOO_LONG","CERT_SIGNATURE_FAILURE"]);export function transportCauseCode(t){let e=t;for(let t=0;t<5&&e;t++){const t=e.code;if("string"==typeof t&&t)return t;e=e.cause}return""}export function isCertTrustError(t){return e.has(transportCauseCode(t))}let o=!1;export function systemTrustActive(){return o}export function enableSystemTrust(){if(o)return!1;const e=t.getCACertificates,r=t.setDefaultCACertificates;if("function"!=typeof e||"function"!=typeof r)return!1;let s,n;try{s=e("system"),n=e("default")}catch{return!1}if(!Array.isArray(s)||0===s.length)return!1;try{r([...new Set([...n,...s])])}catch{return!1}return o=!0,console.log(),console.log(chalk.yellow(" ⚠ This network inspects HTTPS traffic (school / library / office firewall).")),console.log(chalk.gray(" Continuing with the certificates your operating system already trusts.")),console.log(chalk.gray(" 这个网络对 HTTPS 做了拦截,已改用系统证书库继续 —— 属正常现象,可以照常上课。")),console.log(),!0}export function transportAdvice(t){const o=transportCauseCode(t);if(e.has(o))return["This network re-signs HTTPS traffic and Node does not trust its certificate.","Fix: run NODE_OPTIONS=--use-system-ca icoa (needs Node 22.15+ — check with: node -v)","Or ask the network admin to exempt practice.icoa2026.au from SSL inspection."];if("CERT_HAS_EXPIRED"===o||"CERT_NOT_YET_VALID"===o)return["This computer's clock is wrong, so every HTTPS certificate looks invalid.","Fix: correct the system date/time, then try again."];if("ERR_TLS_CERT_ALTNAME_INVALID"===o)return["Something on this network is answering for practice.icoa2026.au with the wrong certificate.","Fix: try a phone hotspot, or ask the network admin about the web filter."];if("ENOTFOUND"===o||"EAI_AGAIN"===o)return["This network cannot look up practice.icoa2026.au (DNS is blocked or broken).","Fix: set DNS to 1.1.1.1 or 8.8.8.8, or use a phone hotspot."];if("ECONNREFUSED"===o||"ECONNRESET"===o||"ENETUNREACH"===o||o.includes("CONNECT_TIMEOUT"))return["The connection to practice.icoa2026.au was blocked before it reached us.","If your browser CAN open https://practice.icoa2026.au this network only allows browser traffic (a proxy).","Fix: ask the admin to allow practice.icoa2026.au on TCP 443, or use a phone hotspot."];if("ETIMEDOUT"===o||/timeout/i.test(o)||function(t,e){let o=t;for(let t=0;t<5&&o;t++){const t=o.message;if("string"==typeof t&&e.test(t))return!0;o=o.cause}return!1}(t,/timed? ?out/i)){const t=["Nothing answered this network cannot reach practice.icoa2026.au at all.","A VPN or proxy app on this computer is the usual cause: quit it fully, then retry.","Then try a phone hotspot — if that works, this WiFi blocks the route (tell your coach)."];return(process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy)&&t.unshift("This shell is set to use a web proxy (HTTPS_PROXY) which icoa cannot use — browsers can, so they still work."),t}return[]}
1
+ import t from"node:tls";import chalk from"chalk";const e=new Set(["UNABLE_TO_GET_ISSUER_CERT","UNABLE_TO_GET_ISSUER_CERT_LOCALLY","UNABLE_TO_VERIFY_LEAF_SIGNATURE","SELF_SIGNED_CERT_IN_CHAIN","DEPTH_ZERO_SELF_SIGNED_CERT","CERT_UNTRUSTED","CERT_CHAIN_TOO_LONG","CERT_SIGNATURE_FAILURE"]);export function transportCauseCode(t){let e=t;for(let t=0;t<5&&e;t++){const t=e.code;if("string"==typeof t&&t)return t;e=e.cause}return""}export function isCertTrustError(t){return e.has(transportCauseCode(t))}let o=!1;export function systemTrustActive(){return o}export function enableSystemTrust(){if(o)return!1;const e=t.getCACertificates,r=t.setDefaultCACertificates;if("function"!=typeof e||"function"!=typeof r)return!1;let s,i;try{s=e("system"),i=e("default")}catch{return!1}if(!Array.isArray(s)||0===s.length)return!1;try{r([...new Set([...i,...s])])}catch{return!1}return o=!0,console.log(),console.log(chalk.yellow(" ⚠ This network inspects HTTPS traffic (school / library / office firewall).")),console.log(chalk.gray(" Continuing with the certificates your operating system already trusts.")),console.log(chalk.gray(" 这个网络对 HTTPS 做了拦截,已改用系统证书库继续 —— 属正常现象,可以照常上课。")),console.log(),!0}export function transportAdvice(t){const o=transportCauseCode(t);if(e.has(o))return["This network re-signs HTTPS traffic and Node does not trust its certificate.","Fix: run NODE_OPTIONS=--use-system-ca icoa (needs Node 22.15+ — check with: node -v)","Or ask the network admin to exempt practice.icoa2026.au from SSL inspection."];if("CERT_HAS_EXPIRED"===o||"CERT_NOT_YET_VALID"===o)return["This computer's clock is wrong, so every HTTPS certificate looks invalid.","Fix: correct the system date/time, then try again."];if("ERR_TLS_CERT_ALTNAME_INVALID"===o)return["Something on this network is answering for practice.icoa2026.au with the wrong certificate.","Fix: try a phone hotspot, or ask the network admin about the web filter."];if("ENOTFOUND"===o||"EAI_AGAIN"===o)return["This network cannot look up practice.icoa2026.au (DNS is blocked or broken).","Fix: set DNS to 1.1.1.1 or 8.8.8.8, or use a phone hotspot."];if("ECONNREFUSED"===o||"ECONNRESET"===o||"ENETUNREACH"===o||o.includes("CONNECT_TIMEOUT"))return["The connection to practice.icoa2026.au was blocked before it reached us.","If your browser CAN open https://practice.icoa2026.au this network only allows browser traffic (a proxy).","Fix: ask the admin to allow practice.icoa2026.au on TCP 443, or use a phone hotspot."];if("ETIMEDOUT"===o||/timeout/i.test(o)||function(t,e){let o=t;for(let t=0;t<5&&o;t++){const t=o.message;if("string"==typeof t&&e.test(t))return!0;o=o.cause}return!1}(t,/timed? ?out/i)){const t=["Nothing answered in time. On a crowded or weak mobile hotspot this is usually just slowness:","retry once or twice; if a classmate is on the same WiFi and it works for them, it is not blocked.","A VPN or proxy app on this computer is the other usual cause: quit it fully, then retry.","Then try a phone hotspot — if that works, this WiFi is too slow or blocks the route (tell your coach)."];return(process.env.HTTPS_PROXY||process.env.https_proxy||process.env.HTTP_PROXY||process.env.http_proxy)&&t.unshift("This shell is set to use a web proxy (HTTPS_PROXY) which icoa cannot use — browsers can, so they still work."),t}return[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.571",
3
+ "version": "2.19.572",
4
4
  "description": "ICOA CLI — AI-native competition runtime of the International Cyber Olympiad in AI: learn, practise, and compete in AI & cybersecurity from the terminal (AI4CTF · CTF4AI · CTF4EAI)",
5
5
  "author": "Charlie Zhu",
6
6
  "type": "module",