icoa-cli 2.19.562 → 2.19.564
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 T}from"./commands/ctf4vla.js";import{registerDemo2Command as v}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";const B=z(q(import.meta.url)),Q=JSON.parse(X(K(B,"..","package.json"),"utf-8")).version,Z=chalk.cyan(" ─────────────────────────────────────────────────────"),oo=`\n${Z}\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${Q}`)}\n\n${Z}\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 eo=new o;if(eo.name("icoa").version(Q).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(oo);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(eo,s)}),e(eo),n(eo),s(eo),r(eo),t(eo),i(eo),l(eo),a(eo),c(eo),m(eo),g(eo),d(eo),p(eo),y(eo),h(eo),f(eo),u(eo),w(eo),b(eo),j(eo),$(eo),T(eo),v(eo),A(eo),I(eo),E(eo),C(eo),_(eo),x(eo),S(eo),L(eo),k(eo),R(eo),N(eo),O(eo),F(eo),eo.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)))}eo.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()}()}),eo.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";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();
|
package/dist/lib/learn-flow.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{appendFileSync as t,mkdirSync as s}from"node:fs";import{homedir as i}from"node:os";import{join as h}from"node:path";import chalk from"chalk";const r=new Set(["back","b","quit","q","exit"]);function
|
|
1
|
+
import{appendFileSync as t,mkdirSync as s}from"node:fs";import{homedir as i}from"node:os";import{join as h}from"node:path";import chalk from"chalk";const r=new Set(["back","b","quit","q","exit"]);function e(t,s=" "){const i=Math.max(40,Math.min(process.stdout.columns||80,100))-s.length-2,h=[];for(const r of t.split("\n")){const t=r.replace(/\s+$/,"");if(""===t.trim()){h.push("");continue}let e="";for(const r of t.split(" ")){const t=e?`${e} ${r}`:r;if(t.length<=i)e=t;else{e&&h.push(s+e);let t=r;for(;t.length>i;)h.push(s+t.slice(0,i)),t=t.slice(i);e=t}}e&&h.push(s+e)}return h}export class FlowRunner{cardNumber;steps;zh;print;idx=0;fork=null;forkRec=null;forkShownAt=0;askStep=null;askMisses=0;recs=[];forkNo=0;constructor(t){this.steps=t.steps,this.zh=t.zh,this.cardNumber=t.cardNumber,this.print=t.print}start(){return this.print(""),this.print(chalk.gray(" ")+chalk.bold.magenta(this.zh?"⚔ 互动流程":"⚔ Interactive walk")+chalk.gray(this.zh?" — 每一步都要你动手;选错不扣分,墙上写着为什么。":" — every step asks you; a wrong turn costs nothing, the wall says why.")),this.print(chalk.gray(this.zh?" (back 退出流程回到卡片)":" (back leaves the walk and returns to the card)")),this.print(""),this.advance()}records(){return this.recs.slice()}handle(t){const s=t.trim(),i=s.toLowerCase();return this.fork&&this.resolveChoice(s,this.fork)?this.handleFork(s):r.has(i)?"exit":this.fork?this.handleFork(s):this.askStep?this.handleAsk(s):this.advance()}handleAsk(t){const s=this.askStep;if(""===t)return this.askMisses++,this.askMisses>=2&&(this.zh?s.hint_zh:s.hint_en)?this.print(chalk.gray(" "+(this.zh?"提示:":"hint: ")+(this.zh?s.hint_zh:s.hint_en))):this.print(chalk.gray(this.zh?" 写下你的想法(哪怕只有一个词),或敲 skip 直接看。":" Write your thought (one word is fine), or type skip to see it.")),"input";this.askStep=null,this.askMisses=0;const i=this.zh?s.reveal_zh:s.reveal_en;this.print("");for(const t of e(i," "))this.print(chalk.white(t));return this.print(""),this.advance()}handleFork(t){const s=this.fork,i=this.forkRec,h=this.resolveChoice(t,s);if(!h){const t=s.opts.map(t=>t.k).join(" / ");return this.print(chalk.gray(" "+(this.zh?`请选 ${t}(或 back 退出)`:`Choose ${t} (or back to leave)`))),"input"}i.choices.push(h.k),i.first||(i.first=h.k),this.print(""),this.print(chalk.gray(" ▸ ")+chalk.white(this.zh?`你选了 ${h.k}。`:`You chose ${h.k}.`));const r=this.zh?h.text_zh:h.text_en;if(r)for(const t of e(r," "))this.print(chalk.white(t));return"wall"===h.kind?(i.walls++,this.print(""),this.print(chalk.yellow(" 🧭 ")+chalk.gray(this.zh?"回到这个分叉,重选。":"Back to this fork — choose again.")),this.printForkOptions(s),"input"):(i.final=h.k,i.ms=Date.now()-this.forkShownAt,this.recs.push(i),this.fork=null,this.forkRec=null,"ok"===h.kind&&this.print(chalk.green(" ✅ ")+chalk.gray(this.zh?"也是一条满分路。":"Also a full-mark route.")),this.print(""),this.advance())}resolveChoice(t,s){const i=t.trim().toLowerCase();if(!i)return null;const h=s.opts.find(t=>t.k.toLowerCase()===i);if(h)return h;const r=Number.parseInt(i,10);if(Number.isInteger(r)&&r>=1&&r<=s.opts.length)return s.opts[r-1];const e=/^(?:option|choose|pick|选|选择)?\s*([a-c])\b/.exec(i);if(e)return s.opts.find(t=>t.k.toLowerCase()===e[1])??null;const n=i.split(/\s+/)[0],o=s.opts.filter(t=>(this.zh?t.zh:t.en).toLowerCase().startsWith(n));return 1===o.length?o[0]:null}printForkOptions(t){this.print("");for(const s of t.opts){const t=e(this.zh?s.zh:s.en," ");this.print(chalk.bold.cyan(` ${s.k} `)+chalk.white(t[0]?.trimStart()??""));for(const s of t.slice(1))this.print(chalk.white(s))}this.print(""),this.print(chalk.gray(" "+(this.zh?"你选哪条? ":"Your move? ")+t.opts.map(t=>t.k).join(" / ")))}advance(){for(;this.idx<this.steps.length;){const t=this.steps[this.idx++];switch(t.t){case"text":for(const s of e(this.zh?t.zh:t.en))this.print(chalk.white(s));this.print("");break;case"mother":this.print(chalk.bold.yellow(" ▶ "+(this.zh?"母题":"MOTHER PROBLEM")));for(const s of e(this.zh?t.zh:t.en," "))this.print(chalk.white(s));this.print("");break;case"ask":this.print(chalk.bold.cyan(" 🎯 GUESS N CHECK"));for(const s of e(this.zh?t.zh:t.en," "))this.print(chalk.white(s));return this.print(chalk.gray(" "+(this.zh?"> 写下你的答案(不判分):":"> your answer (not graded):"))),this.askStep=t,"input";case"fork":this.forkNo++,this.print(chalk.bold.magenta(` ⚔ ${this.zh?"分叉":"FORK"} ${this.forkNo}`));for(const s of e(this.zh?t.zh:t.en," "))this.print(chalk.white(s));return this.fork=t,this.forkRec={fork_id:t.id,first:"",final:"",walls:0,ms:0,choices:[],started_at:(new Date).toISOString()},this.forkShownAt=Date.now(),this.printForkOptions(t),"input";case"review":this.print(chalk.bold.yellow(" 🧭 "+(this.zh?"复盘":"REVIEW")));for(const t of this.pathSummary())this.print(chalk.gray(" "+t));this.print("");for(const s of e(this.zh?t.zh:t.en," "))this.print(chalk.white(s));this.print("");break;case"rule":this.print(chalk.bold.green(" 💡 "+(this.zh?"举一反三 · 迁移判据":"TRANSFER — same idea, next problem")));for(const s of e(this.zh?t.zh:t.en," "))this.print(chalk.white(s));this.print("");break;case"extend":this.print(chalk.bold.cyan(" 🔗 "+(this.zh?"延展 — 母题讲完,同一招再走一步":"EXTEND — same idea, one step further")));for(const s of e(this.zh?t.zh:t.en," "))this.print(chalk.white(s));this.print("");break;case"stretch":this.print(chalk.bold.white(" ⭐ "+(this.zh?"拔高(可选,不判分)":"STRETCH (optional, not graded)")));for(const s of e(this.zh?t.zh:t.en," "))this.print(chalk.gray(s));this.print("")}}return this.spool(),"done"}pathSummary(){return this.recs.map((t,s)=>{const i=t.choices.join(" → "),h=t.walls?this.zh?` · 撞墙 ${t.walls} 次`:` · ${t.walls} wall${t.walls>1?"s":""}`:"";return`${this.zh?"分叉":"Fork"} ${s+1}: ${i}${h}`})}spool(){try{const r=h(i(),".icoa");s(r,{recursive:!0});for(const s of this.recs)t(h(r,"learn-flow.jsonl"),JSON.stringify({card:this.cardNumber,...s})+"\n")}catch{}}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "icoa-cli",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.564",
|
|
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",
|