icoa-cli 2.19.574 → 2.19.575
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/commands/ai4ctf.js +1 -1
- package/dist/commands/ctf4ai-demo.js +1 -1
- package/dist/commands/ctf4vla.js +1 -1
- package/dist/commands/duck.js +1 -0
- package/dist/commands/exam.js +1 -1
- package/dist/commands/learn.js +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/commands.js +1 -1
- package/dist/lib/learn-render.js +1 -1
- package/dist/repl.js +1 -1
- package/package.json +1 -1
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 m}from"./commands/note.js";import{registerLogCommand as c}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{registerMujocoCommands as f}from"./commands/mujoco.js";import{registerIpynbCommand as u}from"./commands/ipynb.js";import{registerAi4ctfCommand as w}from"./commands/ai4ctf.js";import{registerExamCommand as b}from"./commands/exam.js";import{registerCtf4aiDemoCommand as j}from"./commands/ctf4ai-demo.js";import{registerThemeCommand as $}from"./commands/theme.js";import{registerLearnCommand as v}from"./commands/learn.js";import{registerCtf4VlaCommand as T}from"./commands/ctf4vla.js";import{registerDemo2Command as A}from"./commands/demo2.js";import{registerDemo4Command as I}from"./commands/demo4.js";import{registerDemo5Command as E}from"./commands/demo5.js";import{registerGfssmCommand as C}from"./commands/gfssm.js";import{registerGpuForTaskCommand as _}from"./commands/gpufortask.js";import{registerSimCommand as x}from"./commands/sim.js";import{registerArenaCommand as S}from"./commands/arena.js";import{registerKaggleCommand as k}from"./commands/kaggle.js";import{registerSprintCommand as L}from"./commands/sprint.js";import{registerTeleloadCommand as R}from"./commands/teleload.js";import{registerBoardCommand as O}from"./commands/board.js";import{registerTypeCommand as F}from"./commands/type.js";import{registerBattleCommand as N}from"./commands/battle.js";import{registerWmCommand as U}from"./commands/wm.js";import{getConfig as P,saveConfig as M}from"./lib/config.js";import{registerMicroduckCommand as D}from"./commands/microduck.js";import{startRepl as G}from"./repl.js";import{RELAUNCH_CODE as W}from"./lib/menu-nav.js";import{setTerminalTheme as H}from"./lib/theme.js";import{cleanupTerminal as Y}from"./lib/terminal-cleanup.js";import{checkForUpdates as J}from"./lib/update-check.js";import{detectIcoaInstalls as V,isWindowsBuildInWslShell as X}from"./lib/platform.js";import{ICOA_BIG as q}from"./lib/banner.js";import{readFileSync as z}from"node:fs";import{fileURLToPath as K}from"node:url";import{dirname as B,join as Q}from"node:path";import{setDefaultResultOrder as Z}from"node:dns";import{setDefaultAutoSelectFamilyAttemptTimeout as oo}from"node:net";Z("ipv4first"),oo(4e3);const eo=B(K(import.meta.url)),no=JSON.parse(z(Q(eo,"..","package.json"),"utf-8")).version,so=chalk.cyan(" ─────────────────────────────────────────────────────"),ro=`\n${so}\n\n${q.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${no}`)}\n\n${so}\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!==W){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===W);Y(),process.exit(e??0)}}const to=new o;if(to.name("icoa").version(no).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=P();H("high-contrast"===e.themeVariant?"high-contrast":"dark"),J(),function(){const o=V();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(ro);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 G(to,s)}),e(to),n(to),s(to),r(to),t(to),i(to),l(to),a(to),m(to),c(to),g(to),d(to),p(to),y(to),h(to),f(to),u(to),w(to),b(to),j(to),$(to),v(to),T(to),A(to),I(to),E(to),C(to),_(to),x(to),S(to),k(to),R(to),L(to),O(to),U(to),F(to),N(to),D(to),to.command("model",{hidden:!0}).argument("[name]","model name to switch to").action(o=>{const e=P().geminiModel||"gemini-2.5-flash-lite";o?(M({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)))}to.hook("preAction",()=>{!function(){if(!X())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()}()}),to.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 m}from"./commands/note.js";import{registerLogCommand as c}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{registerMujocoCommands as f}from"./commands/mujoco.js";import{registerDuckCommand as u}from"./commands/duck.js";import{registerIpynbCommand as w}from"./commands/ipynb.js";import{registerAi4ctfCommand as b}from"./commands/ai4ctf.js";import{registerExamCommand as j}from"./commands/exam.js";import{registerCtf4aiDemoCommand as $}from"./commands/ctf4ai-demo.js";import{registerThemeCommand as v}from"./commands/theme.js";import{registerLearnCommand as T}from"./commands/learn.js";import{registerCtf4VlaCommand as A}from"./commands/ctf4vla.js";import{registerDemo2Command as I}from"./commands/demo2.js";import{registerDemo4Command as E}from"./commands/demo4.js";import{registerDemo5Command as C}from"./commands/demo5.js";import{registerGfssmCommand as _}from"./commands/gfssm.js";import{registerGpuForTaskCommand as x}from"./commands/gpufortask.js";import{registerSimCommand as S}from"./commands/sim.js";import{registerArenaCommand as k}from"./commands/arena.js";import{registerKaggleCommand as L}from"./commands/kaggle.js";import{registerSprintCommand as R}from"./commands/sprint.js";import{registerTeleloadCommand as O}from"./commands/teleload.js";import{registerBoardCommand as F}from"./commands/board.js";import{registerTypeCommand as N}from"./commands/type.js";import{registerBattleCommand as U}from"./commands/battle.js";import{registerWmCommand as P}from"./commands/wm.js";import{getConfig as M,saveConfig as D}from"./lib/config.js";import{registerMicroduckCommand as G}from"./commands/microduck.js";import{startRepl as W}from"./repl.js";import{RELAUNCH_CODE as H}from"./lib/menu-nav.js";import{setTerminalTheme as Y}from"./lib/theme.js";import{cleanupTerminal as J}from"./lib/terminal-cleanup.js";import{checkForUpdates as V}from"./lib/update-check.js";import{detectIcoaInstalls as X,isWindowsBuildInWslShell as q}from"./lib/platform.js";import{ICOA_BIG as z}from"./lib/banner.js";import{readFileSync as K}from"node:fs";import{fileURLToPath as B}from"node:url";import{dirname as Q,join as Z}from"node:path";import{setDefaultResultOrder as oo}from"node:dns";import{setDefaultAutoSelectFamilyAttemptTimeout as eo}from"node:net";oo("ipv4first"),eo(4e3);const no=Q(B(import.meta.url)),so=JSON.parse(K(Z(no,"..","package.json"),"utf-8")).version,ro=chalk.cyan(" ─────────────────────────────────────────────────────"),to=`\n${ro}\n\n${z.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${so}`)}\n\n${ro}\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!==H){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===H);J(),process.exit(e??0)}}const io=new o;if(io.name("icoa").version(so).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=M();Y("high-contrast"===e.themeVariant?"high-contrast":"dark"),V(),function(){const o=X();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(to);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 W(io,s)}),e(io),n(io),s(io),r(io),t(io),i(io),l(io),a(io),m(io),c(io),g(io),d(io),p(io),y(io),h(io),f(io),u(io),w(io),b(io),j(io),$(io),v(io),T(io),A(io),I(io),E(io),C(io),_(io),x(io),S(io),k(io),L(io),O(io),R(io),F(io),P(io),N(io),U(io),G(io),io.command("model",{hidden:!0}).argument("[name]","model name to switch to").action(o=>{const e=M().geminiModel||"gemini-2.5-flash-lite";o?(D({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)))}io.hook("preAction",()=>{!function(){if(!q())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()}()}),io.parse();
|
package/dist/lib/commands.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const REGISTRY=[{name:"join",mapsTo:["ctf","join"],rest:!0,help:{order:0,section:"Competition",label:"join <url>",text:"Connect to CTFd"}},{name:"activate",mapsTo:["ctf","activate"],rest:!0},{name:"challenges",mapsTo:["ctf","challenges"],help:{order:1,section:"Competition",label:"challenges (ch)",text:"List challenges by category"}},{name:"ch",mapsTo:["ctf","challenges"]},{name:"open",mapsTo:["ctf","open"],rest:!0,help:{order:2,section:"Competition",label:"open <id>",text:"Read challenge + get next steps"}},{name:"submit",mapsTo:["ctf","submit"],rest:!0,help:{order:3,section:"Competition",label:"submit <id> <flag>",text:"Submit a flag"}},{name:"flag",mapsTo:["ctf","submit"],rest:!0},{name:"scoreboard",mapsTo:["ctf","scoreboard"],rest:!0,help:{order:4,section:"Competition",label:"scoreboard (sb)",text:"Live rankings"}},{name:"sb",mapsTo:["ctf","scoreboard"],rest:!0},{name:"status",mapsTo:["ctf","status"],help:{order:5,section:"Competition",label:"status",text:"Your score & timer"}},{name:"time",mapsTo:["ctf","time"],help:{order:6,section:"Competition",label:"time",text:"Countdown timer"}},{name:"ref",help:{order:8,section:"Tools",label:"ref [topic]",text:"Quick reference (linux, web, crypto...)"}},{name:"shell",help:{order:9,section:"Tools",label:"shell",text:"Interactive CTF shell (sandbox if present, else host)"}},{name:"files",help:{order:10,section:"Tools",label:"files <id>",text:"Download challenge files"}},{name:"view"},{name:"connect",help:{order:11,section:"Tools",label:"connect <id>",text:"Connect to remote target"}},{name:"challenge",subs:["start","stop","status"]},{name:"note",help:{order:12,section:"Tools",label:"note [text]",text:"Add a logbook entry (in-exam: tags current Q)"}},{name:"notes"},{name:"logbook",help:{order:13,section:"Tools",label:"logbook [n]",text:"View your logbook (in-exam: filter by Q)"}},{name:"log",help:{order:14,section:"Tools",label:"log",text:"Session history"}},{name:"man"},{name:"manual"},{name:"lang",help:{order:21,section:"System",label:"lang [code]",text:"Switch language (15 supported)"}},{name:"setup"},{name:"env"},{name:"aienv"},{name:"python",subs:["setup","status"]},{name:"mujoco",subs:["setup","status"]},{name:"mojoco",mapsTo:["mujoco"],rest:!0},{name:"ipynb"},{name:"kaggle"},{name:"teleload"},{name:"pandahelpme31"},{name:"gpufortask"},{name:"guide"},{name:"ai4ctf",help:{order:7,section:"AI Teammate",label:"ai4ctf",text:"Free-chat with your AI teammate"}},{name:"model"},{name:"ctf",subs:["challenges","open","submit","scoreboard","status","join","logout","time"]},{name:"exam",subs:["list","start","q","answer","submit","review","result","next","prev","mark","unmark","help"]},{name:"demo",mapsTo:["exam","demo"]},{name:"retry",mapsTo:["exam","demo-retry"]},{name:"nations",mapsTo:["exam","nations"]},{name:"next",mapsTo:["exam","next"]},{name:"prev",mapsTo:["exam","prev"]},{name:"continue"},{name:"logout",mapsTo:["ctf","logout"],help:{order:22,section:"System",label:"logout",text:"Disconnect"}},{name:"ctf4ai"},{name:"mark",mapsTo:["exam","mark"],rest:!0},{name:"unmark",mapsTo:["exam","unmark"],rest:!0},{name:"review",mapsTo:["exam","review"]},{name:"learn",subs:["start","continue"]},{name:"demo2"},{name:"demo4"},{name:"demo5"},{name:"gfssm"},{name:"ctf4eai"},{name:"ctf4vla"},{name:"theme"},{name:"sim"},{name:"arena",subs:["eai"]},{name:"eai"},{name:"wm"},{name:"microduck"},{name:"battle",subs:["edit","syntax","play","replay","submit","status","bots"]},{name:"type",subs:["15","30","60","words","python","shell","history"],help:{order:15,section:"Tools",label:"type [30]",text:"Typing speed trainer — WPM, live colours, no token"}},{name:"board"},{name:"learn-pull"},{name:"doctor",help:{order:19,section:"System",label:"doctor",text:"Self-check: version, Python, network/firewall, server"}},{name:"bg",nav:!0,help:{order:17,section:"System",label:"bg <command>",text:"Run a shell command in the background"}},{name:"tasks",nav:!0,help:{order:18,section:"System",label:"tasks [id]",text:"Background task panel / view output"}},{name:"drafts",nav:!0,help:{order:16,section:"System",label:"drafts",text:"Review staged draft answers"}},{name:"help",nav:!0},{name:"menu",nav:!0},{name:"quit",nav:!0},{name:"q",nav:!0},{name:"exit",nav:!0,help:{order:24,section:"System",label:"exit",text:"Quit (session saved)"}},{name:"back",nav:!0},{name:"resume",nav:!0,help:{order:15,section:"System",label:"resume",text:"Continue your last learn card / exam"}},{name:"clear",nav:!0,help:{order:23,section:"System",label:"clear",text:"Clear screen"}},{name:"cls",nav:!0}];export const surface=()=>REGISTRY.map(e=>e.name);export const dispatchable=()=>REGISTRY.filter(e=>!e.nav).map(e=>e.name);export function shortcutFor(e,t){const a=REGISTRY.find(t=>t.name===e&&t.mapsTo);return a?.mapsTo?a.rest?[...a.mapsTo,...t]:[...a.mapsTo]:null}export const subcommandsOf=e=>REGISTRY.find(t=>t.name===e)?.subs;export const helpRows=e=>REGISTRY.filter(t=>t.help?.section===e).sort((e,t)=>e.help.order-t.help.order).map(e=>({label:e.help.label,text:e.help.text}));
|
|
1
|
+
export const REGISTRY=[{name:"join",mapsTo:["ctf","join"],rest:!0,help:{order:0,section:"Competition",label:"join <url>",text:"Connect to CTFd"}},{name:"activate",mapsTo:["ctf","activate"],rest:!0},{name:"challenges",mapsTo:["ctf","challenges"],help:{order:1,section:"Competition",label:"challenges (ch)",text:"List challenges by category"}},{name:"ch",mapsTo:["ctf","challenges"]},{name:"open",mapsTo:["ctf","open"],rest:!0,help:{order:2,section:"Competition",label:"open <id>",text:"Read challenge + get next steps"}},{name:"submit",mapsTo:["ctf","submit"],rest:!0,help:{order:3,section:"Competition",label:"submit <id> <flag>",text:"Submit a flag"}},{name:"flag",mapsTo:["ctf","submit"],rest:!0},{name:"scoreboard",mapsTo:["ctf","scoreboard"],rest:!0,help:{order:4,section:"Competition",label:"scoreboard (sb)",text:"Live rankings"}},{name:"sb",mapsTo:["ctf","scoreboard"],rest:!0},{name:"status",mapsTo:["ctf","status"],help:{order:5,section:"Competition",label:"status",text:"Your score & timer"}},{name:"time",mapsTo:["ctf","time"],help:{order:6,section:"Competition",label:"time",text:"Countdown timer"}},{name:"ref",help:{order:8,section:"Tools",label:"ref [topic]",text:"Quick reference (linux, web, crypto...)"}},{name:"shell",help:{order:9,section:"Tools",label:"shell",text:"Interactive CTF shell (sandbox if present, else host)"}},{name:"files",help:{order:10,section:"Tools",label:"files <id>",text:"Download challenge files"}},{name:"view"},{name:"connect",help:{order:11,section:"Tools",label:"connect <id>",text:"Connect to remote target"}},{name:"challenge",subs:["start","stop","status"]},{name:"note",help:{order:12,section:"Tools",label:"note [text]",text:"Add a logbook entry (in-exam: tags current Q)"}},{name:"notes"},{name:"logbook",help:{order:13,section:"Tools",label:"logbook [n]",text:"View your logbook (in-exam: filter by Q)"}},{name:"log",help:{order:14,section:"Tools",label:"log",text:"Session history"}},{name:"man"},{name:"manual"},{name:"lang",help:{order:21,section:"System",label:"lang [code]",text:"Switch language (15 supported)"}},{name:"setup"},{name:"env"},{name:"aienv"},{name:"python",subs:["setup","status"]},{name:"mujoco",subs:["setup","status"]},{name:"mojoco",mapsTo:["mujoco"],rest:!0},{name:"ipynb"},{name:"kaggle"},{name:"teleload"},{name:"pandahelpme31"},{name:"gpufortask"},{name:"guide"},{name:"ai4ctf",help:{order:7,section:"AI Teammate",label:"ai4ctf",text:"Free-chat with your AI teammate"}},{name:"model"},{name:"ctf",subs:["challenges","open","submit","scoreboard","status","join","logout","time"]},{name:"exam",subs:["list","start","q","answer","submit","review","result","next","prev","mark","unmark","help"]},{name:"demo",mapsTo:["exam","demo"]},{name:"retry",mapsTo:["exam","demo-retry"]},{name:"nations",mapsTo:["exam","nations"]},{name:"next",mapsTo:["exam","next"]},{name:"prev",mapsTo:["exam","prev"]},{name:"continue"},{name:"logout",mapsTo:["ctf","logout"],help:{order:22,section:"System",label:"logout",text:"Disconnect"}},{name:"ctf4ai"},{name:"mark",mapsTo:["exam","mark"],rest:!0},{name:"unmark",mapsTo:["exam","unmark"],rest:!0},{name:"review",mapsTo:["exam","review"]},{name:"learn",subs:["start","continue"]},{name:"demo2"},{name:"demo4"},{name:"demo5"},{name:"gfssm"},{name:"ctf4eai"},{name:"ctf4vla"},{name:"theme"},{name:"sim"},{name:"arena",subs:["eai"]},{name:"eai"},{name:"wm"},{name:"microduck"},{name:"battle",subs:["edit","syntax","play","replay","submit","status","bots"]},{name:"duck",subs:["edit","syntax","run","replay","submit","scenarios","status"]},{name:"type",subs:["15","30","60","words","python","shell","history"],help:{order:15,section:"Tools",label:"type [30]",text:"Typing speed trainer — WPM, live colours, no token"}},{name:"board"},{name:"learn-pull"},{name:"doctor",help:{order:19,section:"System",label:"doctor",text:"Self-check: version, Python, network/firewall, server"}},{name:"bg",nav:!0,help:{order:17,section:"System",label:"bg <command>",text:"Run a shell command in the background"}},{name:"tasks",nav:!0,help:{order:18,section:"System",label:"tasks [id]",text:"Background task panel / view output"}},{name:"drafts",nav:!0,help:{order:16,section:"System",label:"drafts",text:"Review staged draft answers"}},{name:"help",nav:!0},{name:"menu",nav:!0},{name:"quit",nav:!0},{name:"q",nav:!0},{name:"exit",nav:!0,help:{order:24,section:"System",label:"exit",text:"Quit (session saved)"}},{name:"back",nav:!0},{name:"resume",nav:!0,help:{order:15,section:"System",label:"resume",text:"Continue your last learn card / exam"}},{name:"clear",nav:!0,help:{order:23,section:"System",label:"clear",text:"Clear screen"}},{name:"cls",nav:!0}];export const surface=()=>REGISTRY.map(e=>e.name);export const dispatchable=()=>REGISTRY.filter(e=>!e.nav).map(e=>e.name);export function shortcutFor(e,t){const a=REGISTRY.find(t=>t.name===e&&t.mapsTo);return a?.mapsTo?a.rest?[...a.mapsTo,...t]:[...a.mapsTo]:null}export const subcommandsOf=e=>REGISTRY.find(t=>t.name===e)?.subs;export const helpRows=e=>REGISTRY.filter(t=>t.help?.section===e).sort((e,t)=>e.help.order-t.help.order).map(e=>({label:e.help.label,text:e.help.text}));
|
package/dist/lib/learn-render.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import chalk from"chalk";import e from"string-width";import{localized as o}from"./learn-curricula.js";import{t as n}from"./learn-i18n.js";import{getConfig as t}from"./config.js";import{icoaBannerLines as r}from"./banner.js";import{renderCharts as l,detectCaps as a}from"./render-card.js";import{replyChipLabel as s}from"./learn-replies.js";function c(){return(t().language||"en").toLowerCase()}let g="normal";export function resolveLearnWidth(e){return"normal"===e.learnWidth||"wide"===e.learnWidth||"wider"===e.learnWidth||"widest"===e.learnWidth?e.learnWidth:e.learnWide?"wide":"normal"}export function setLearnWidth(e){g=e}export function learnWidthCap(e=g){return"widest"===e?160:"wider"===e?120:"wide"===e?96:64}export function learnW(){const e=process.stdout.columns||69,o=Math.max(40,Math.min(64,e-5));return"normal"===g?o:Math.max(o,Math.min(e-6,learnWidthCap()))}const i=learnW;function d(e="─"){return e.repeat(i()+2)}function h(o,n){if(e(o)<=n)return o;let t=o;for(;t.length>0&&e(t)>Math.max(1,n-1);)t=t.slice(0,-1);return t.trimEnd()+"…"}function y(e,o,n=20){const t=o>0?e/o:0,r=Math.floor(t*n),l=n-r;return`${chalk.green("█".repeat(r))+chalk.gray("░".repeat(l))} ${(100*t).toFixed(1)}%`}function u(e){return e>=30?chalk.red("🔥🔥🔥 "+e+" days"):e>=7?chalk.yellow("🔥 "+e+" days"):e>=1?chalk.gray("· "+e+" day"+(e>1?"s":"")):chalk.gray("—")}export function renderWelcome(e,o,t){const r=c(),l=o.cardsCompleted.length,a=e.totalCards,s=a-l,g=e.modules.find(e=>o.currentCard>=e.cardRange[0]&&o.currentCard<=e.cardRange[1]),p=/demo/i.test(e.id);if(console.log(),console.log(chalk.cyan(" ╭"+d("═"))),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ║ ")+chalk.bold.white(" "+(e.name?.trim()||n("academy_title",r)))),console.log(chalk.cyan(" ║")),t)console.log(chalk.cyan(" ║ ")+chalk.white(" "+n(p?"welcome_new_demo":"welcome_new",r)));else{const e=new Date(o.lastSeenAt),t=Math.floor((Date.now()-e.getTime())/36e5),l=t<1?n("just_now",r):t<24?`${t}${n("ago_hours",r)}`:`${Math.floor(t/24)}${n("ago_days",r)}`;console.log(chalk.cyan(" ║ ")+chalk.white(` ${n("welcome_back",r)} ${l}`))}console.log(chalk.cyan(" ║"));const m=h(g?`${g.number}. ${g.name}`:"—",i()-14);console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("module",r).padEnd(11))+chalk.white(m)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("progress",r).padEnd(11))+y(l,a,Math.max(6,Math.min(20,i()-26-`${l}/${a}`.length)))+chalk.gray(` (${l}/${a})`)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("streak",r).padEnd(11))+u(o.streakDays)),s>0&&o.currentCard<=a&&console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("next_card",r).padEnd(11))+chalk.white(`#${o.currentCard} ${n("of",r)} ${a}`)),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ╰"+d("═"))),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const b=0===l?n("continue_start",r):`${n("continue_resume",r)} ${o.currentCard}`;console.log(chalk.bold.green(" continue")+chalk.gray(" "+b)),console.log(chalk.yellow(" status")+chalk.gray(" "+n("status_full",r))),o.bookmarks.length>0&&console.log(chalk.yellow(" bookmarks")+chalk.gray(` ${o.bookmarks.length} ${n("bookmarks_desc",r)}`)),console.log(chalk.gray(" quit")+chalk.gray(" "+n("quit_desc",r))),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log()}function p(o,t){const r=c(),l=o.module,a=t.modules.find(e=>e.number===l),s=a?a.name:n("unknown_module",r),g=n("module",r).replace(":","").trim(),d=h(`${n("card",r)} ${o.number} / ${t.totalCards} · ${g} ${l} · ${s}`,i()-4);console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(d)+" "+chalk.cyan("─".repeat(Math.max(0,i()-e(d)-4))))}function m(){console.log(chalk.cyan(" ╰"+d())),console.log()}function b(e){console.log(chalk.cyan(" │ ")+chalk.white(e))}function f(){console.log(chalk.cyan(" │"))}const $=/[┌┐└┘├┤┬┴┼─│╔╗╚╝═║╠╣╦╩╬▓▒░█]/;function w(e){return/^(?: {4}|\t)/.test(e)||$.test(e)||/ {3,}/.test(e)}export function wrapMixed(o,n){const t=[];let r="",l=0,a=!1;for(const s of function(o){const n=[],t=o=>{let t="";const r=()=>{t&&(n.push({t:"atom",s:t}),t="")};for(const l of o)" "===l?(r(),n.push({t:"space"})):2===e(l)?(r(),n.push({t:"wide",s:l})):t+=l;r()},r=/`[^`]*`/g;let l,a=0;for(;null!==(l=r.exec(o));)t(o.slice(a,l.index)),n.push({t:"code",s:l[0]}),a=l.index+l[0].length;return t(o.slice(a)),n}(o)){if("space"===s.t){""!==r&&(a=!0);continue}const o=s.s,c=e("code"===s.t?o.replace(/`/g,""):o),g=a?1:0,i="atom"===s.t&&o.length<=2&&/^[.,;:!?)\]}…'"]+$/.test(o);""!==r&&!i&&l+g+c>n?(t.push(r),r=o,l=c,a=!1):(a&&(r+=" ",l+=1,a=!1),r+=o,l+=c)}return r&&t.push(r),t}const _=/\b(?:Common bug|Common mistake|Common error|Pitfall|Gotcha|Footgun)\b[::]?|\b(?:Warning|Caution)\b[::]|(?:常见错误|常见陷阱|常见误区|陷阱|注意|警告|误区)[::]/gi;function k(e,o){const n=o?chalk.bold.white:chalk.white;let t,r="",l=0;for(_.lastIndex=0;null!==(t=_.exec(e));)t.index>l&&(r+=n(e.slice(l,t.index))),r+=chalk.bold.yellow(t[0]),l=t.index+t[0].length;return l<e.length&&(r+=n(e.slice(l))),r}function x(e,o=!1){let n="",t=0;const r=/`([^`]*)`/g;let l;for(;null!==(l=r.exec(e));)l.index>t&&(n+=k(e.slice(t,l.index),o)),n+=chalk.cyan(l[1]),t=l.index+l[0].length;return t<e.length&&(n+=k(e.slice(t),o)),n}function C(e,o=!1){let n=!1;for(const t of e.split("\n"))if(/^\s*```/.test(t))n=!n;else if(n)console.log(chalk.cyan(" │ ")+chalk.cyan(` ${t}`));else if(""!==t)if(w(t))console.log(chalk.cyan(" │ ")+chalk.white(t));else for(const e of wrapMixed(t,i()-4))console.log(chalk.cyan(" │ ")+` ${x(e,o)}`);else f()}function v(e,o){const n=[];for(const t of e.split("\n")){if(""===t){n.push("");continue}if(w(t)){n.push(t);continue}let e="";for(const r of t.split(" "))(e+" "+r).trim().length>o?(n.push(e.trim()),e=r):e=(e+" "+r).trim();e&&n.push(e)}return n}let M=!1;export function setLearnAiEnabled(e){M=e}let S=new Set;export function setLearnPqsViewCards(e){S=e}let A=new Map;export function setLearnHonorRanks(e){A=e}const W=["①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩"];let j=[];export function setLearnReplies(e){j=e}let z=[];export function setLearnFaqs(e){z=e}let R=null;export function setLearnHometask(e){R=e}let P="full";export function setLearnFooterProfile(e){P=e}let L=null;export function setLearnFooterExtra(e){L=e}function q(){const e=L?.();e&&console.log(chalk.gray(" "+e))}let E=null;export function setLearnPracticeChips(e){E=e}let N=!1;export function setLearnShellLane(e){N=e}let T=!1;export function setLearnArenaLane(e){T=e}let O=null;export function setLearnPracticeCount(e){O=e}export function renderHonorWall(e){const o=c().startsWith("zh"),{totals:n,chapters:t}=e,r=n.gold+n.silver+n.bronze,l=(e,o)=>o>0?chalk.bold.white(`${e}×${o}`):chalk.gray(`${e}×0`);if(console.log(chalk.gray(" ─────────────────────────────────────────")),console.log(chalk.bold.white(o?" 🏅 奖牌墙 ":" 🏅 Medal wall ")+l("🥇",n.gold)+chalk.gray(" · ")+l("🥈",n.silver)+chalk.gray(" · ")+l("🥉",n.bronze)+chalk.gray(o?" (永久 — 挂上墙就不会摘下)":" (permanent — once earned, never removed)")),0===r){const n=null!=e.floor?`${e.floor}+`:o?"高分":"a high score";return console.log(chalk.gray(o?` 还没有奖牌 — 单卡提问评分 ${n} 并进入该卡前三,即可永久挂墙 🥇🥈🥉`:` No medals yet — score ${n} on a card and hold its top-3 to hang one 🥇🥈🥉`)),void console.log(chalk.gray(" ─────────────────────────────────────────"))}const a=t.map(e=>{const o=`Ch${e.chapter}`,n=(e.gold>0?`🥇${e.gold}`:"")+(e.silver>0?`🥈${e.silver}`:"")+(e.bronze>0?`🥉${e.bronze}`:"");return n?chalk.white(`${o} ${n}`):chalk.gray(`${o} —`)}).join(chalk.gray(" "));console.log(" "+a);const s=t.flatMap(e=>e.cards.map(o=>({...o,chapter:e.chapter})));s.sort((e,o)=>e.rank-o.rank||e.chapter-o.chapter||e.card-o.card);for(const e of s.slice(0,24)){const n=(e.since||"").slice(0,10);console.log(chalk.white(` ${e.icon} `)+chalk.gray(`Ch${e.chapter} · `)+chalk.white(o?`第 ${e.card} 张`:`card ${e.card}`)+chalk.gray(` · ${e.score}`)+(n?chalk.gray(o?` · 始于 ${n}`:` · since ${n}`):""))}s.length>24&&console.log(chalk.gray(o?` …还有 ${s.length-24} 枚`:` …and ${s.length-24} more`)),console.log(chalk.gray(" ─────────────────────────────────────────"))}export function renderKnowledgeCard(t,r){const d=c(),h=o(t,d);p(h,r),f();const y=wrapMixed(h.title,i()-4);for(const e of y)b(chalk.bold.yellow(e));b(chalk.gray("─".repeat(Math.min(Math.max(...y.map(o=>e(o))),i()))));const u=!!(t.chart_ids&&t.chart_ids.length>0);if(u&&l(t.chart_ids.slice(0,1),r.charts,a()),h.key_point&&""!==h.key_point.trim()?(u||f(),function(e,o,n){const t=c().startsWith("zh"),r=a().cols,l="-".repeat(Math.min(i(),Math.max(24,r-6))),s=t?"要点":"KEY POINT",g=t?`第 ${o} / ${n} 张`:`Card ${o} / ${n}`;console.log(chalk.cyan(" │ ")+chalk.green(l)),console.log(chalk.cyan(" │ ")+chalk.green(`${s} · ${g}`));for(const o of wrapMixed(e,i()-4))console.log(chalk.cyan(" │ ")+chalk.bold.green(" "+o));console.log(chalk.cyan(" │ ")+chalk.green(l)),f()}(h.key_point,h.number,r.totalCards)):u||f(),h.body.filter(e=>null!=e&&""!==e.trim()).forEach((e,o)=>{const n=0===o?e.match(/^([\s\S]*?(?:[.!?](?=\s|$)|[。!?]))(\s[\s\S]*)?$/):null;if(n&&n[1].trim().length<=180){C(n[1],!0);const e=n[2]?.trimStart();e&&C(e,!1)}else C(e,!1);f()}),h.icoaConnection){b(chalk.magenta(" "+n("icoa_connection",d))),b(chalk.gray(" "+"─".repeat(20)));for(const e of wrapMixed(h.icoaConnection,i()-4))b(" "+chalk.magenta(e));f()}if(t.check){const e=d.startsWith("zh"),o=t._zh?.checkStatement??t._zh?.check?.statement,n=e?o??t.check.statement:t.check.statement;for(const o of wrapMixed(e?"请回答 (输 y 或 n):":"Quick comprehension check (type y or n):",i()-8))b(chalk.cyan(" 🤔 "+o));b(chalk.gray(" "+"─".repeat(20)));for(const e of wrapMixed(n,i()-4))b(" "+chalk.white(e));f()}m(),function(o,n){const t=c().startsWith("zh"),r=a().cols,l="-".repeat(Math.min(i(),Math.max(24,r-6))),d=chalk.gray(" ");if("minimal"===P){const e=E?E(o.number):null;console.log(chalk.gray(" "+l)),console.log(chalk.gray(" "+(t?`第 ${o.number} / ${n.totalCards} 张`:`Card ${o.number} / ${n.totalCards}`))+(e?chalk.gray(t?" · 本卡练习 ":" · practice ")+e:""));const r=[];if(o.check?(r.push(chalk.bold.green("[y]")+chalk.gray(t?" 是":" yes")),r.push(chalk.bold.green("[n]")+chalk.gray(t?" 否":" no"))):r.push(chalk.bold.green("[ok]")+chalk.gray(t?" 下一张":" next")),e){const o=Math.max(1,(e.match(/\[\d\]/g)??[]).length),n=Array.from({length:o},(e,o)=>`[${o+1}]`).join("");r.push(chalk.bold.cyan(n)+chalk.gray(t?" 练习":" practice"))}return N&&r.push(chalk.bold.magenta("[sh]")+chalk.gray(t?" 实验台":" shell")),T&&r.push(chalk.bold.magenta("[battle]")+chalk.gray(t?" 进竞技场":" arena")),o.flow&&o.flow.length>0&&r.push(chalk.bold.magenta("[flow]")+chalk.gray(t?" 互动走一遍":" walk it")),r.push(chalk.bold.cyan("[b]")+chalk.gray(t?" 上一张":" back")),r.push(chalk.bold.yellow("[e]")+chalk.gray(t?" 求助":" help")),r.push(chalk.gray("[quit]")+(t?chalk.gray(" 退出"):"")),console.log(" "+r.join(d)),q(),void console.log()}const h=[];o.check?(h.push(chalk.bold.green("[y]")+chalk.gray(t?" 是":" yes")),h.push(chalk.bold.green("[n]")+chalk.gray(t?" 否":" no"))):h.push(chalk.bold.green("[ok]")+chalk.gray(t?" 继续":" next")),o.flow&&o.flow.length>0&&h.push(chalk.bold.magenta("[flow]")+chalk.gray(t?" 互动走一遍":" walk it")),M&&(h.push(chalk.bold.magenta("[/ai]")+chalk.gray(t?" 🐼 熊猫导师":" 🐼 Panda tutor")),h.push(chalk.bold.magenta("[/submit]")+chalk.gray(t?" 提问评分":" prompt score")));const y=A.get(o.number);var u;h.push(chalk.bold.magenta(y?`[/honors ${u=y,W[u-1]??`#${u}`}]`:"[/honors]")+chalk.gray(t?" 排行":" board")),"normal"===g?h.push(chalk.bold.cyan("[wide]")+chalk.gray(t?" 宽屏":" widen")):("wide"===g?h.push(chalk.bold.cyan("[wider]")+chalk.gray(t?" 更宽":" wider")):"wider"===g?(h.push(chalk.bold.cyan("[widest]")+chalk.gray(t?" 最宽":" widest")),h.push(chalk.bold.cyan("[wide]")+chalk.gray(t?" 回宽屏":" back to wide"))):h.push(chalk.bold.cyan("[wider]")+chalk.gray(t?" 回 wider":" back to wider")),h.push(chalk.bold.cyan("[normal]")+chalk.gray(t?" 标准":" standard")));const p=s(j,z,o.number,t),m=p.startsWith("💬");if(h.push((m?chalk.bold.yellow("[r]"):chalk.gray("[r]"))+(m?chalk.bold.white(` ${p}`):chalk.gray(` ${p}`))),h.push(chalk.bold.yellow("[e]")+chalk.gray(t?" 提问或报告":" ask or report")),R){const e=R,o=`${e.done}/${e.total}`,n=e.completedAt?chalk.bold.green:chalk.bold.cyan;h.push(n("[task]")+chalk.gray(t?` 本周 ${o}`:` week ${o}`))}h.push(chalk.bold.cyan("[b]")+chalk.gray(t?" 上一张":" back")),h.push(chalk.bold.cyan("[card N]")+chalk.gray(t?" 跳转":" jump")),h.push(chalk.gray("[reload]")+(t?chalk.gray(" 刷新"):"")),h.push(chalk.gray("[quit]")+(t?chalk.gray(" 退出"):""));const b=e(l);console.log(chalk.gray(" "+l)),console.log(chalk.gray(" "+(t?`第 ${o.number} / ${n.totalCards} 张`:`Card ${o.number} / ${n.totalCards}`)));let f="",$=0;for(const o of h){const n=e(o);f&&$+2+n>b?(console.log(" "+f),f=o,$=n):(f=f?f+d+o:o,$=f===o?n:$+2+n)}f&&console.log(" "+f),console.log(" "+chalk.magenta("✍ ")+chalk.magenta("[/py]")+chalk.gray(t?" Python 草稿本":" Python scratchpad")+d+chalk.magenta("[/pylist]")+chalk.gray(t?" 我的草稿":" my files")),console.log(chalk.gray(" "+l));const w=[t?"e = 就这张卡提问,或报告问题":"e = ask about this card, or report a problem",t?"更多: bookmark / unbookmark · status · lang zh/en · link":"more: bookmark / unbookmark · status · lang zh/en · link"];for(const e of w)for(const o of wrapMixed(e,b))console.log(chalk.gray(" "+o));q(),console.log()}(t,r)}export function renderCheckFeedback(e,o,n,t=!1){const r=c().startsWith("zh");if(console.log(),n)console.log(chalk.green(" ✓ ")+chalk.white(r?"答对了。":"Correct."));else if(console.log(chalk.yellow(" ✗ ")+chalk.white(r?"记下了,继续。":"Noted — moving on.")),t){const o="y"===e.check?.answer?r?"是":"Yes":r?"否":"No";console.log(chalk.gray(" "+(r?"正确答案: ":"Answer: ")+o+". "+(r?"回看上面那段。":"Re-read the paragraph above.")))}const l=r?e._zh?.solution??e.solution:e.solution;if(l&&l.length>0){console.log(),console.log(chalk.cyan(" 📝 "+(r?"解答:":"Worked solution:")));for(const e of l){for(const o of wrapMixed(e,i()-4))console.log(chalk.white(" "+o));console.log()}}console.log()}function F(e){return[chalk.white(" "+(e?"编著:Charlie Zhu":"Created & edited by Charlie Zhu")),chalk.gray(" "+(e?"ICOA 2026 创始人 · 课程总架构师":"Founder & Chief Curriculum Architect · ICOA 2026"))]}export function renderPhaseComplete(e,o,n,t,l,a){const s=c().startsWith("zh"),[g,d]=n.cardRange,h=o.checkResults||{};let y=0,u=0;for(let e=g;e<=d;e++){const o=h[String(e)];o&&(y++,o.correct&&u++)}const p="-".repeat(48);console.log();for(const e of r(" "))console.log(e);console.log(),console.log(chalk.bold.yellow(" "+p)),console.log(chalk.bold.yellow(" "+(s?`阶段 ${n.number} 完成`:`Phase ${n.number} complete`))+chalk.gray(" · ")+chalk.white(n.name));const m=y>0&&u===y?chalk.bold.green:chalk.bold.white;console.log(chalk.gray(" "+(s?"理解检查得分: ":"comprehension score: "))+m(`${u}/${y}`)+chalk.gray(0===y?s?" (本阶段未作答 y/n)":" (no y/n answered)":""));const b=String(d).length;let f=!1,$=0,w=0,_=0,k=0;for(let o=g;o<=d;o++){const n=e.cards.find(e=>e.number===o);if(!n)continue;const t=n,r=t.title??t.badge??"",l=(s?t._zh?.title??t._zh?.badge??r:r)||"",a=null!=n.check,c=h[String(o)];let g;g=c?c.correct?chalk.green("✓"):chalk.red("✗"):a?chalk.gray("○"):chalk.gray("·");const d=O?O(o):null;d&&(f=!0);const y=d?(d.solved>=d.total?chalk.green:d.solved>0?chalk.yellow:chalk.gray)(` ⚔${d.solved}/${d.total}`):"";d&&($++,d.solved>=d.total&&w++,_+=d.solved,k+=d.total);const u=wrapMixed(l,i()-10-b-(d?6:0)),p=u[0]+(u.length>1?"…":"");console.log(chalk.gray(` ${String(o).padStart(b)} `)+g+y+chalk.white(" "+p))}if(console.log(chalk.gray(s?" ✓ 答对 · ✗ 答错 · ○ 未作答 · 无 y/n 的卡不计分":" ✓ correct · ✗ wrong · ○ unanswered · cards without a y/n are unscored")),f&&console.log(chalk.bold.cyan(" ⚔ "+(s?"卡片练习: ":"practice: "))+(w>=$?chalk.bold.green:chalk.bold.white)(`${w}/${$}`)+chalk.gray(s?` 卡全完成 · ${_}/${k} 题 AC · 行内 ⚔已过/共(绿 完成 · 黄 部分 · 灰 未碰)`:` cards complete · ${_}/${k} problems AC · ⚔solved/total per row (green done · yellow partial · gray untouched)`)),l){const e=e=>"green"===e?chalk.bold.green:"blue"===e?chalk.bold.cyan:"yellow"===e?chalk.bold.yellow:chalk.bold.red;console.log(chalk.bold.magenta(" ⭐ "+(s?"提问得分 (best): ":"Prompt scores (best): "))+(0===l.length?chalk.gray(s?"本阶段尚未提问 — 用 /ai 研究,再 /submit 评分":"none this phase — research with /ai, then /submit"):l.map(o=>chalk.gray((s?"卡":"#")+o.card+" ")+e(o.tier)(String(o.score))).join(chalk.gray(" · "))))}if(a&&!a.configured){const o=d-g+1>12,n="fill"===e.practiceMode;console.log(chalk.gray(o?s?" 🔒 本阶段通关标准制作中 — 很快更新(360 层第二阶段标准设计中)":" 🔒 Pass criteria for this phase are in production — coming soon (360-tier second-stage standard in design)":n?s?" 🔒 本阶段 3 场判分赛制作中 — 很快更新;赛场挂在卡 4 / 8 / 12,3 场全过解锁下一阶段(本轨无 research)":" 🔒 This phase’s 3 judged arenas are in production — coming soon; they hang on cards 4 / 8 / 12 and all 3 unlock the next phase (no research on this track)":s?" 🔒 本阶段通关标准制作中 — 很快更新(标准范式:3 场练习赛 + 3 卡研究)":" 🔒 Pass criteria for this phase are in production — coming soon (standard: 3 arenas + 3 research cards)"))}if(a?.configured&&a.contest){const e=a.contest;if(e.slots&&e.slots.length>0)for(const o of e.slots){const e=chalk.bold.cyan(` ⚔ ${s?"练习赛":"arena"} ${n.number}-${o.slot}: `);o.passed?console.log(e+chalk.bold.green(`${o.best_ac}/${o.n} AC ✅`)):0===o.attempts?console.log(e+chalk.white(s?`${o.n} 题 · 过 ${o.need} 题 — `:`${o.n} problems · AC ${o.need} — `)+chalk.bold.green(`contest ${o.slot}`)):console.log(e+chalk.yellow(s?`最好 ${o.best_ac}/${o.n}(需 ${o.need})· 已试 ${o.attempts} 次 — `:`best ${o.best_ac}/${o.n} (need ${o.need}) · ${o.attempts} attempt(s) — `)+chalk.bold.green(`contest ${o.slot}`))}else{const o=chalk.bold.cyan(" ⚖ "+(s?"判分赛: ":"Contest: "));e.passed?console.log(o+chalk.bold.green(`${e.best_ac}/${e.n} AC ✅ `+(s?"已过关":"passed"))):0===e.attempts?console.log(o+chalk.white(s?`${e.n} 题 · 过 ${e.need} 题解锁 — 输入 `:`${e.n} problems · AC ${e.need} to pass — type `)+chalk.bold.green("contest")+chalk.white(s?" 开始":" to start")):console.log(o+chalk.yellow(s?`最好 ${e.best_ac}/${e.n} AC(需 ${e.need})· 已试 ${e.attempts} 次 — 输入 `:`best ${e.best_ac}/${e.n} AC (need ${e.need}) · ${e.attempts} attempt(s) — type `)+chalk.bold.green("contest")+chalk.yellow(s?" 再战":" to retry"))}}t&&console.log(chalk.gray(" "+(s?"下一阶段: ":"next: "))+chalk.bold.cyan(s?`阶段 ${t.number}`:`Phase ${t.number}`)+chalk.gray(" · ")+chalk.white(t.name)),console.log(chalk.bold.yellow(" "+p));for(const e of F(s))console.log(e)}export function renderCurriculumComplete(e,o){const n=c().startsWith("zh"),t=o.checkResults||{},l="-".repeat(48);let a=0,s=0;console.log();for(const e of r(" "))console.log(e);console.log(),console.log(chalk.bold.green(" "+l)),console.log(chalk.bold.green(" 🏆 "+(n?`${e.name} — 全部完成!`:`${e.name} — complete!`))),console.log(chalk.bold.green(" "+l));for(const o of e.modules){const[e,r]=o.cardRange;let l=0,c=0;for(let o=e;o<=r;o++){const e=t[String(o)];e&&(l++,e.correct&&c++)}a+=l,s+=c;const g=l>0&&c===l?chalk.green:chalk.white;console.log(chalk.gray(" "+(n?`阶段 ${o.number}`:`Phase ${o.number}`).padEnd(8))+g(`${c}/${l}`.padEnd(7))+chalk.gray(o.name))}console.log(chalk.bold.green(" "+l)),console.log(chalk.bold.green(" "+(n?"总分 / overall: ":"Overall: "))+chalk.bold.white(`${s}/${a}`)),console.log(chalk.bold.green(" "+l));for(const e of F(n))console.log(e);console.log()}export function renderMCQCard(e,t){const r=c(),l=o(e,r);p(l,t),f(),b(chalk.bold.yellow("🎯 "+l.title)),b(chalk.gray("─".repeat(Math.min(l.title.length+4,i())))),f();for(const e of v(l.question,i()-4))b(" "+e);f();for(const e of["A","B","C","D"])b(chalk.cyan(` ${e}.`)+" "+chalk.white(l.options[e]));f(),m(),console.log(chalk.gray(" "+(r.startsWith("zh")?"输入 ":"Type "))+chalk.bold.green("A")+chalk.gray(" / ")+chalk.bold.green("B")+chalk.gray(" / ")+chalk.bold.green("C")+chalk.gray(" / ")+chalk.bold.green("D")+chalk.gray(" "+n("type_to_answer",r))),console.log(chalk.gray(" ")+chalk.bold.cyan("back")+chalk.gray(r.startsWith("zh")?" 上一张 · ":" previous card · ")+chalk.bold.cyan("card N")+chalk.gray(r.startsWith("zh")?" 跳转":" jump")),console.log()}export function renderMCQFeedback(e,t,r,l){const a=c(),s=o(e,a);console.log(),r?console.log(" "+chalk.bold.green(n("correct",a)+" ")+chalk.gray(`${n("one_point",a)} · ${t} = ${s.options[t]}`)):console.log(" "+chalk.bold.red(n("not_quite",a)+" ")+chalk.gray(`${n("you_chose",a)} ${t}; ${n("answer_is",a)} ${s.answer}.`)),console.log(),console.log(chalk.gray(" "+n("explanation",a)));for(const e of v(s.explanation,i()-4))console.log(chalk.gray(" "+e));const g=Object.values(l.mcqResults),d=g.filter(e=>e.correct).length;console.log(),console.log(chalk.gray(" "+n("mcq_accuracy_so_far",a)+" ")+chalk.white(`${d}/${g.length}`)),console.log(),r||(console.log(chalk.gray(" "+n("press_ok_continue",a)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",a))),console.log())}export function renderPracticalCard(e,t){const r=c(),l=o(e,r);p(l,t),f(),b(chalk.bold.yellow("🛠 "+l.title)),b(chalk.gray("─".repeat(Math.min(l.title.length+4,i())))),f();for(const e of v(l.task,i()-4))b(" "+e);if(l.starterCode){f(),b(chalk.gray(" "+n("starter_code",r))),f();for(const e of l.starterCode.split("\n"))b(" "+chalk.cyan(e))}f(),m(),console.log(chalk.gray(" "+n("try_in_sandbox",r)+" ")+chalk.bold.cyan("!python3")+chalk.gray(" "+n("drops_into_python",r))),console.log(chalk.gray(" "+n("when_done",r))),console.log(chalk.gray(" ")+chalk.bold.green("done")+chalk.gray(" "+n("done_desc",r))),console.log(chalk.gray(" ")+chalk.bold.yellow("skip")+chalk.gray(" "+n("skip_desc",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log()}export function renderPracticalSuccess(e){const t=c(),r=o(e,t);console.log(),console.log(" "+chalk.bold.green(n("practical_recorded",t))),console.log(),console.log(chalk.gray(" "+n("reference_answer",t)));for(const e of v(r.successHint,i()-4))console.log(chalk.gray(" "+e));console.log(),console.log(chalk.gray(" "+n("press_ok_continue",t)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",t))),console.log()}export function renderSimDemoCard(e,t){const r=c(),l=o(e,r);p(l,t),f(),b(chalk.bold.yellow("🎬 "+l.title)),f();for(const e of v(l.description,i()-4))b(" "+e);f(),b(chalk.gray(" "+n("sim_requires",r))),f(),m(),console.log(chalk.gray(" ")+chalk.bold.cyan("sim")+chalk.gray(" "+n("sim_launch_desc",r))),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",r))),console.log(chalk.gray(" bookmark "+n("bookmark_desc",r))),console.log(chalk.gray(" back "+n("back_desc",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",r))),console.log()}export function renderArenaTaskCard(e,n){const t=c(),r=t.startsWith("zh"),l=o(e,t);p(l,n),f(),b(chalk.bold.cyan("🏟 "+l.title)),b(chalk.gray(" "+l.origin+" · "+l.domain+" · "+l.metric)),f();for(const e of l.statement){for(const o of v(e,i()-4))b(" "+o);f()}b(chalk.bold.green(r?" 核心要点 — baseline → 解法的关键变化":" CORE DELTA — baseline → solution"));for(const e of l.core_delta)for(const o of v("• "+e,i()-6))b(" "+chalk.white(o));f(),b(chalk.gray((r?" 提交格式: ":" Submission: ")+l.submission_format)),l.hints&&b(chalk.gray(r?" 本题有 5 级提示 (a–e),进入 arena 后逐级解锁。":" 5 progressive hints (a–e) unlock inside the arena.")),f(),m(),console.log(chalk.gray(" ")+chalk.bold.cyan("arena "+l.task_id)+chalk.gray(r?" 动手做这道题(下载 / 提示 / 提交 / 榜单)":" open the arena (download / hints / submit / board)")),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续下一张":" continue to next")),console.log(chalk.gray(" back "+(r?"上一张":"previous"))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderComingSoonCard(e,n){const t=c(),r=t.startsWith("zh"),l=o(e,t);p(l,n),f(),b(chalk.bold.yellow("🔜 "+l.title)),f();const a=l.note||(r?"这道竞技场题目正在编写中,敬请期待。":"This arena task is coming soon.");for(const e of v(a,i()-4))b(" "+chalk.gray(e));f(),m(),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续":" continue")),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderMilestone(e,t){const r=c(),l=o(e,r),a=e.number===t.totalCards;console.log(),console.log(chalk.bold.yellow(" ╭"+d("═"))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+chalk.white(" "+n("milestone_header",r))),console.log(chalk.bold.yellow(" ║"));const s=` ${l.badge} ${l.emoji}`;console.log(chalk.bold.yellow(" ║ ")+chalk.bold.green(s)),console.log(chalk.bold.yellow(" ║ ")+chalk.gray(" ─".repeat(Math.max(1,Math.floor(l.badge.length/2+2))))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("in_wild_corresponds",r)));for(const e of v(l.realWorldLevel,i()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(e));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("whats_next",r)));for(const e of v(l.unlockedNext,i()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(e));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ╰"+d("═"))),console.log(),a?(console.log(chalk.gray(" "+n("demo_complete",r))),console.log(),console.log(chalk.gray(" "+n("unlock_full",r)+" ")+chalk.white(n("curriculum_name",r))+chalk.gray(",")),console.log(chalk.gray(" "+n("contact_team_leader",r)+" ")+chalk.bold.yellow("EA")+chalk.gray(" "+n("learn_token",r))),console.log(chalk.gray(" "+n("or_email",r)+" ")+chalk.cyan("australia@icoa2026.au")+chalk.gray(" "+n("for_partnership",r))),console.log(),console.log(chalk.gray(" "+n("type_quit",r)+" ")+chalk.bold.green("quit")+chalk.gray(" "+n("to_exit",r)+" ")+chalk.bold.green("status")+chalk.gray(" "+n("for_dashboard",r)))):(console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",r))),console.log(chalk.gray(" status "+n("status_full",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",r)))),console.log()}export function renderStatus(o,t,r={}){const l=c(),a=l.startsWith("zh"),s=t.cardsCompleted.length,g=o.totalCards,d=t.checkResults||{},p=r.gate??null,$=!!r.gated,w=r.focus??"current",_=r.posForSlot??(e=>4===e?10:4*e),k=t.currentCard,x=o.modules.find(e=>k>=e.cardRange[0]&&k<=e.cardRange[1]),C=(o,n)=>o+" ".repeat(Math.max(0,n-e((e=>e.replace(/\x1b\[[0-9;]*m/g,""))(o))));console.log();const v=`${o.name} — ${a?"状态":"Status"}`;console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(v)+" "+chalk.cyan("─".repeat(Math.max(4,i()-2-e(v))))),f(),b(" "+chalk.gray(n("total_progress",l)+" ")+y(s,g)+chalk.gray(` (${s}/${g})`)+chalk.gray(" "+n("streak",l)+" ")+u(t.streakDays));{let n=0,l=0,s=0,c=0,g=0,h=0,y=!1;for(const e of o.modules){for(let t=e.cardRange[0];t<=e.cardRange[1];t++){const e=O?O(t):null;e&&(n++,e.solved>=e.total&&l++);const r=o.cards.find(e=>e.number===t);null!=r?.check&&(s++,d[String(t)]?.correct&&c++)}const t=p?.phases.find(o=>o.phase===e.number);if(t?.configured)for(const e of t.contest?.slots??[])g++,e.passed&&h++;t?.research&&(y=!0)}const u=(e,o)=>(e>=o?chalk.green:chalk.white)(`${e}/${o}`),m=[];n&&m.push(chalk.gray(a?"⚔ 练习卡 ":"⚔ practice cards ")+u(l,n)),g&&m.push(chalk.gray(a?"赛场 ":"arena ")+u(h,g)),s&&m.push(chalk.gray(a?"✓ 自测 ":"✓ checks ")+u(c,s)),m.length&&b(" "+m.join(chalk.gray(" "))),r._anyResearch=y;{let n=0;const r=[];let l=0,c=0,y=0;for(const e of o.modules)for(let a=e.cardRange[0];a<=e.cardRange[1];a++){c++,t.cardsCompleted.includes(a)&&l++;const e=o.cards.find(e=>e.number===a);null!=e?.check&&d[String(a)]&&y++;const s=O?O(a):null;s&&s.solved<s.total&&(n+=s.total-s.solved,r.push(a))}const u=a?"▸ 通关还差 ":"▸ to finish ",p=[];if(l<c&&p.push(chalk.gray(a?"卡片 ":"cards ")+chalk.white(""+(c-l))+chalk.gray(a?" 张未读":" unread")),s&&y<s&&p.push(chalk.gray("✓ ")+chalk.white(""+(s-y))+chalk.gray(a?" 题自测未答":" checks unanswered")),n>0){const o=a?`练习还差 ${n} 题`:`${n} practice problem${n>1?"s":""}`,t=a?"(卡 ":" (cards ",l=")",s=" │ ⚔ ",c=i()-e(s)-e(u)-e(o)-e(t+l),g=e=>{const o=[];let n=0;for(const t of r){const r=String(t).length+(o.length?3:0);if(n+r>e)break;n+=r,o.push(t)}return o};let d=g(c);d.length<r.length&&(d=g(c-e(` +${r.length}`))),!d.length&&r.length&&(d=[r[0]]);const h=r.length-d.length,y=d.join(" · ")+(h>0?` +${h}`:"");p.push(chalk.gray("⚔ ")+chalk.white(o)+chalk.gray(t+y+l))}g&&h<g&&p.push(chalk.gray(a?"赛 ":"arena ")+chalk.white(""+(g-h))+chalk.gray(a?" 场未过":" to pass"));const m=l>0;m&&p.length?p.forEach((o,n)=>b(" "+(0===n?chalk.bold.yellow(u):" ".repeat(e(u)))+o)):m&&!p.length&&b(" "+chalk.bold.green(a?"✅ 通关条件已全部达成":"✅ every completion gate met"))}}f();const M=e=>a?`阶段 ${e}`:`Phase ${e}`,S=Math.max(10,Math.min(28,i()-54));for(const e of o.modules){const[n,r]=e.cardRange,l=r-n+1,s=t.cardsCompleted.filter(e=>e>=n&&e<=r).length,c=$&&!!p&&e.number>p.unlocked_through_phase,g=p?.phases.find(o=>o.phase===e.number);let y=0,u=0,m=0;const f=[],v=[];let A=0,W=0,j=0;const z=[];for(let e=n;e<=r;e++){const n=o.cards.find(o=>o.number===e);if(null!=n?.check){y++;const o=d[String(e)];o?(u++,o.correct?m++:v.push(e)):f.push(e)}const t=O?O(e):null;t&&(A++,j+=t.solved,t.solved>=t.total?W++:z.push(`${e}:${t.solved}/${t.total}`))}const R=g?.configured?g.contest?.slots??[]:[],P=e=>e.passed?chalk.green("✅"):e.attempts>0?chalk.yellow("❌"):chalk.gray("⬜"),L=s>=l&&(0===y||m===y)&&(0===A||W===A)&&(0===R.length||R.every(e=>e.passed))&&(!g?.research||g.research.passed),q=s>0||u>0||j>0||R.some(e=>e.attempts>0),E=c?chalk.gray("🔒"):L?chalk.green("✅"):e.number===x?.number?chalk.bold.cyan("▶ "):q?chalk.yellow("▶ "):chalk.gray("⬜"),N=h(e.name,S),T=[];if(T.push((s>=l?chalk.green:chalk.white)(`${s}/${l}`)+chalk.gray(a?"卡":"c")),y>0&&T.push(chalk.gray("✓")+(m===y?chalk.green:chalk.white)(`${m}/${y}`)),A>0&&T.push(chalk.gray("⚔")+(W===A?chalk.green:chalk.white)(`${W}/${A}`)+chalk.gray(a?"卡":"c")),R.length>0&&T.push(chalk.gray(a?"赛":"arena ")+R.map(P).join("")),g?.research&&T.push(chalk.gray("⭐")+(g.research.passed?chalk.green:chalk.white)(`${g.research.good_cards}/${g.research.need_cards}`)),b(" "+E+" "+chalk.white(C(M(e.number),a?5:8))+chalk.gray(C(N,S+1))+T.join(chalk.gray(" · "))),c||"all"!==w&&w!==e.number&&("current"!==w||e.number!==x?.number)){if(!c&&q&&!L){const o=[],t=R.filter(e=>!e.passed).map(o=>(o.attempts>0?chalk.yellow:chalk.gray)(`${e.number}-${o.slot}@${a?"卡":"card "}${n+_(o.slot)-1}`));t.length&&o.push(chalk.gray(a?"赛 ":"arena ")+t.join(chalk.gray(" · ")));const r=(e,o)=>e.slice(0,8).join(o)+(e.length>8?chalk.gray(" +"+(e.length-8)):"");z.length&&o.push(chalk.gray("⚔ ")+chalk.white(r(z," "))),v.length&&o.push(chalk.red("✗ ")+chalk.white(r(v.map(String),","))),f.length&&o.push(chalk.gray("○ ")+chalk.white(r(f.map(String),","))),g?.research&&!g.research.passed&&o.push(chalk.gray(`⭐ ${g.research.good_cards}/${g.research.need_cards}`)),o.forEach((e,o)=>b(chalk.gray(0===o?a?" 待办: ":" todo: ":" ")+e))}}else{const t=String(r).length;for(let s=n;s<=r;s++){const r=o.cards.find(e=>e.number===s);if(!r)continue;const c=r,g=c.title??c.badge??"",h=(a?c._zh?.title??c._zh?.badge??g:g)||"",y=null!=r.check,u=d[String(s)],p=u?u.correct?chalk.green("✓"):chalk.red("✗"):y?chalk.gray("○"):chalk.gray("·"),m=O?O(s):null,f=m?(m.solved>=m.total?chalk.green:m.solved>0?chalk.yellow:chalk.gray)(`⚔${m.solved}/${m.total}`):" ",$=s===k?chalk.bold.cyan("▶"):" ",w=wrapMixed(h,Math.max(16,i()-14-t)),x=w[0]+(w.length>1?"…":"");b(` ${$} `+chalk.gray(String(s).padStart(t))+" "+p+" "+C(f,5)+" "+chalk.white(x));const v=12===l?R.find(e=>n+_(e.slot)-1===s):void 0;if(v){const o=chalk.gray(` ${" ".repeat(t)} ⚔ ${a?"练习赛":"arena"} ${e.number}-${v.slot}: `);v.passed?b(o+chalk.bold.green(`${v.best_ac}/${v.n} AC ✅`)):0===v.attempts?b(o+chalk.gray("⬜ ")+chalk.white(a?`未开始 · ${v.n} 题 · 过 ${v.need} 题 → `:`not started · ${v.n} problems · AC ${v.need} → `)+chalk.bold.green(`contest ${v.slot}`)):b(o+chalk.yellow(a?`❌ 最好 ${v.best_ac}/${v.n}(需 ${v.need})· 已试 ${v.attempts} 次 → `:`❌ best ${v.best_ac}/${v.n} (need ${v.need}) · ${v.attempts} attempt(s) → `)+chalk.bold.green(`contest ${v.slot}`))}}if(12!==l)for(const o of R){const n=chalk.gray(` ⚔ ${a?"练习赛":"arena"} ${e.number}-${o.slot}: `);o.passed?b(n+chalk.bold.green(`${o.best_ac}/${o.n} AC ✅`)):0===o.attempts?b(n+chalk.gray("⬜ ")+chalk.white(a?`未开始 · ${o.n} 题 · 过 ${o.need} 题 → `:`not started · ${o.n} problems · AC ${o.need} → `)+chalk.bold.green(`contest ${o.slot}`)):b(n+chalk.yellow(a?`❌ 最好 ${o.best_ac}/${o.n}(需 ${o.need})· 已试 ${o.attempts} 次 → `:`❌ best ${o.best_ac}/${o.n} (need ${o.need}) · ${o.attempts} attempt(s) → `)+chalk.bold.green(`contest ${o.slot}`))}g?.research&&!g.research.passed&&b(chalk.gray(a?` ⭐ 研究: ${g.research.good_cards}/${g.research.need_cards} 卡达 ${g.research.min_score} 分 — /ai 研究后 /submit`:` ⭐ research: ${g.research.good_cards}/${g.research.need_cards} cards at ${g.research.min_score}+ — /ai then /submit`)),g&&!g.configured&&b(chalk.gray(a?" 🔒 本阶段通关标准制作中 — 很快更新":" 🔒 pass criteria for this phase in production — coming soon"))}}f(),b(chalk.gray(a?" ✓ 答对 ✗ 答错 ○ 未答 · ⚔ 练习 已过/共 · 赛 ✅ 过 ❌ 试过 ⬜ 未碰"+(r._anyResearch?" · ⭐ 研究":""):" ✓ right ✗ wrong ○ unanswered · ⚔ practice solved/total"+(r._anyResearch?" · ⭐ research":""))),b(chalk.gray(a?" 展开某阶段: ":" arena ✅ passed ❌ tried ⬜ untouched · expand: ")+chalk.bold.green("status all")+chalk.gray(" / ")+chalk.bold.green("status N")),t.achievements.length>0&&b(" "+chalk.gray(n("achievements",l)+" ")+t.achievements.map(e=>chalk.bold.yellow("★ ")+chalk.white(e)).join(chalk.gray(" · "))),f(),m()}function D(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}export function renderArenaIntro(){const e=c().startsWith("zh"),o=!!process.stdout.isTTY&&!/^(C|POSIX)$/i.test(process.env.LANG||"")&&!process.env.ICOA_TEST_BOOT_MODE,n=e?[chalk.bold.yellow(" ⚔ 你读完 4 张卡了 — 前面是第一个检查点。"),chalk.white(" ⚔ 每 4 张卡有一场判分赛:")+chalk.bold.yellow("卡 4 / 8 / 12")+chalk.white(",一个阶段共 3 场。"),chalk.white(" · 敲 ")+chalk.bold.green("contest 1")+chalk.white(" 开始 — 计时器同时开始,题目在赛场里读。"),chalk.white(" · 判分机会真的跑你的代码,不是对答案。"),chalk.white(" · 3 场全过 → 解锁下一阶段。"),chalk.gray(" ▸ 现在不想打?敲 ")+chalk.bold.green("next")+chalk.gray(" 继续读卡,赛场一直在那儿等你。")]:[chalk.bold.yellow(" ⚔ Four cards down — a checkpoint is waiting."),chalk.white(" ⚔ Every 4 cards there is a judged arena: ")+chalk.bold.yellow("cards 4 / 8 / 12")+chalk.white(", three per phase."),chalk.white(" · Type ")+chalk.bold.green("contest 1")+chalk.white(" to start — the clock starts with it; the problems are read inside."),chalk.white(" · The judge really runs your code. It is not an answer key."),chalk.white(" · Pass all three → the next phase unlocks."),chalk.gray(" ▸ Not now? Type ")+chalk.bold.green("next")+chalk.gray(" and keep reading — the arena waits for you.")];console.log();for(const e of n)console.log(e),o&&D(200);console.log()}
|
|
1
|
+
import chalk from"chalk";import e from"string-width";import{localized as o}from"./learn-curricula.js";import{t as n}from"./learn-i18n.js";import{getConfig as t}from"./config.js";import{icoaBannerLines as r}from"./banner.js";import{renderCharts as l,detectCaps as a}from"./render-card.js";import{replyChipLabel as s}from"./learn-replies.js";function c(){return(t().language||"en").toLowerCase()}let g="normal";export function resolveLearnWidth(e){return"normal"===e.learnWidth||"wide"===e.learnWidth||"wider"===e.learnWidth||"widest"===e.learnWidth?e.learnWidth:e.learnWide?"wide":"normal"}export function setLearnWidth(e){g=e}export function learnWidthCap(e=g){return"widest"===e?160:"wider"===e?120:"wide"===e?96:64}export function learnW(){const e=process.stdout.columns||69,o=Math.max(40,Math.min(64,e-5));return"normal"===g?o:Math.max(o,Math.min(e-6,learnWidthCap()))}const i=learnW;function d(e="─"){return e.repeat(i()+2)}function h(o,n){if(e(o)<=n)return o;let t=o;for(;t.length>0&&e(t)>Math.max(1,n-1);)t=t.slice(0,-1);return t.trimEnd()+"…"}function y(e,o,n=20){const t=o>0?e/o:0,r=Math.floor(t*n),l=n-r;return`${chalk.green("█".repeat(r))+chalk.gray("░".repeat(l))} ${(100*t).toFixed(1)}%`}function u(e){return e>=30?chalk.red("🔥🔥🔥 "+e+" days"):e>=7?chalk.yellow("🔥 "+e+" days"):e>=1?chalk.gray("· "+e+" day"+(e>1?"s":"")):chalk.gray("—")}export function renderWelcome(e,o,t){const r=c(),l=o.cardsCompleted.length,a=e.totalCards,s=a-l,g=e.modules.find(e=>o.currentCard>=e.cardRange[0]&&o.currentCard<=e.cardRange[1]),p=/demo/i.test(e.id);if(console.log(),console.log(chalk.cyan(" ╭"+d("═"))),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ║ ")+chalk.bold.white(" "+(e.name?.trim()||n("academy_title",r)))),console.log(chalk.cyan(" ║")),t)console.log(chalk.cyan(" ║ ")+chalk.white(" "+n(p?"welcome_new_demo":"welcome_new",r)));else{const e=new Date(o.lastSeenAt),t=Math.floor((Date.now()-e.getTime())/36e5),l=t<1?n("just_now",r):t<24?`${t}${n("ago_hours",r)}`:`${Math.floor(t/24)}${n("ago_days",r)}`;console.log(chalk.cyan(" ║ ")+chalk.white(` ${n("welcome_back",r)} ${l}`))}console.log(chalk.cyan(" ║"));const m=h(g?`${g.number}. ${g.name}`:"—",i()-14);console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("module",r).padEnd(11))+chalk.white(m)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("progress",r).padEnd(11))+y(l,a,Math.max(6,Math.min(20,i()-26-`${l}/${a}`.length)))+chalk.gray(` (${l}/${a})`)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("streak",r).padEnd(11))+u(o.streakDays)),s>0&&o.currentCard<=a&&console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("next_card",r).padEnd(11))+chalk.white(`#${o.currentCard} ${n("of",r)} ${a}`)),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ╰"+d("═"))),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const b=0===l?n("continue_start",r):`${n("continue_resume",r)} ${o.currentCard}`;console.log(chalk.bold.green(" continue")+chalk.gray(" "+b)),console.log(chalk.yellow(" status")+chalk.gray(" "+n("status_full",r))),o.bookmarks.length>0&&console.log(chalk.yellow(" bookmarks")+chalk.gray(` ${o.bookmarks.length} ${n("bookmarks_desc",r)}`)),console.log(chalk.gray(" quit")+chalk.gray(" "+n("quit_desc",r))),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log()}function p(o,t){const r=c(),l=o.module,a=t.modules.find(e=>e.number===l),s=a?a.name:n("unknown_module",r),g=n("module",r).replace(":","").trim(),d=h(`${n("card",r)} ${o.number} / ${t.totalCards} · ${g} ${l} · ${s}`,i()-4);console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(d)+" "+chalk.cyan("─".repeat(Math.max(0,i()-e(d)-4))))}function m(){console.log(chalk.cyan(" ╰"+d())),console.log()}function b(e){console.log(chalk.cyan(" │ ")+chalk.white(e))}function f(){console.log(chalk.cyan(" │"))}const $=/[┌┐└┘├┤┬┴┼─│╔╗╚╝═║╠╣╦╩╬▓▒░█]/;function w(e){return/^(?: {4}|\t)/.test(e)||$.test(e)||/ {3,}/.test(e)}export function wrapMixed(o,n){const t=[];let r="",l=0,a=!1;for(const s of function(o){const n=[],t=o=>{let t="";const r=()=>{t&&(n.push({t:"atom",s:t}),t="")};for(const l of o)" "===l?(r(),n.push({t:"space"})):2===e(l)?(r(),n.push({t:"wide",s:l})):t+=l;r()},r=/`[^`]*`/g;let l,a=0;for(;null!==(l=r.exec(o));)t(o.slice(a,l.index)),n.push({t:"code",s:l[0]}),a=l.index+l[0].length;return t(o.slice(a)),n}(o)){if("space"===s.t){""!==r&&(a=!0);continue}const o=s.s,c=e("code"===s.t?o.replace(/`/g,""):o),g=a?1:0,i="atom"===s.t&&o.length<=2&&/^[.,;:!?)\]}…'"]+$/.test(o);""!==r&&!i&&l+g+c>n?(t.push(r),r=o,l=c,a=!1):(a&&(r+=" ",l+=1,a=!1),r+=o,l+=c)}return r&&t.push(r),t}const _=/\b(?:Common bug|Common mistake|Common error|Pitfall|Gotcha|Footgun)\b[::]?|\b(?:Warning|Caution)\b[::]|(?:常见错误|常见陷阱|常见误区|陷阱|注意|警告|误区)[::]/gi;function k(e,o){const n=o?chalk.bold.white:chalk.white;let t,r="",l=0;for(_.lastIndex=0;null!==(t=_.exec(e));)t.index>l&&(r+=n(e.slice(l,t.index))),r+=chalk.bold.yellow(t[0]),l=t.index+t[0].length;return l<e.length&&(r+=n(e.slice(l))),r}function x(e,o=!1){let n="",t=0;const r=/`([^`]*)`/g;let l;for(;null!==(l=r.exec(e));)l.index>t&&(n+=k(e.slice(t,l.index),o)),n+=chalk.cyan(l[1]),t=l.index+l[0].length;return t<e.length&&(n+=k(e.slice(t),o)),n}function C(e,o=!1){let n=!1;for(const t of e.split("\n"))if(/^\s*```/.test(t))n=!n;else if(n)console.log(chalk.cyan(" │ ")+chalk.cyan(` ${t}`));else if(""!==t)if(w(t))console.log(chalk.cyan(" │ ")+chalk.white(t));else for(const e of wrapMixed(t,i()-4))console.log(chalk.cyan(" │ ")+` ${x(e,o)}`);else f()}function v(e,o){const n=[];for(const t of e.split("\n")){if(""===t){n.push("");continue}if(w(t)){n.push(t);continue}let e="";for(const r of t.split(" "))(e+" "+r).trim().length>o?(n.push(e.trim()),e=r):e=(e+" "+r).trim();e&&n.push(e)}return n}let M=!1;export function setLearnAiEnabled(e){M=e}let S=new Set;export function setLearnPqsViewCards(e){S=e}let A=new Map;export function setLearnHonorRanks(e){A=e}const W=["①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩"];let j=[];export function setLearnReplies(e){j=e}let z=[];export function setLearnFaqs(e){z=e}let L=null;export function setLearnHometask(e){L=e}let R="full";export function setLearnFooterProfile(e){R=e}let P=null;export function setLearnFooterExtra(e){P=e}function q(){const e=P?.();e&&console.log(chalk.gray(" "+e))}let E=null;export function setLearnPracticeChips(e){E=e}let N=!1;export function setLearnShellLane(e){N=e}let T=!1;export function setLearnArenaLane(e){T=e}let O=!1;export function setLearnDuckLane(e){O=e}let D=null;export function setLearnPracticeCount(e){D=e}export function renderHonorWall(e){const o=c().startsWith("zh"),{totals:n,chapters:t}=e,r=n.gold+n.silver+n.bronze,l=(e,o)=>o>0?chalk.bold.white(`${e}×${o}`):chalk.gray(`${e}×0`);if(console.log(chalk.gray(" ─────────────────────────────────────────")),console.log(chalk.bold.white(o?" 🏅 奖牌墙 ":" 🏅 Medal wall ")+l("🥇",n.gold)+chalk.gray(" · ")+l("🥈",n.silver)+chalk.gray(" · ")+l("🥉",n.bronze)+chalk.gray(o?" (永久 — 挂上墙就不会摘下)":" (permanent — once earned, never removed)")),0===r){const n=null!=e.floor?`${e.floor}+`:o?"高分":"a high score";return console.log(chalk.gray(o?` 还没有奖牌 — 单卡提问评分 ${n} 并进入该卡前三,即可永久挂墙 🥇🥈🥉`:` No medals yet — score ${n} on a card and hold its top-3 to hang one 🥇🥈🥉`)),void console.log(chalk.gray(" ─────────────────────────────────────────"))}const a=t.map(e=>{const o=`Ch${e.chapter}`,n=(e.gold>0?`🥇${e.gold}`:"")+(e.silver>0?`🥈${e.silver}`:"")+(e.bronze>0?`🥉${e.bronze}`:"");return n?chalk.white(`${o} ${n}`):chalk.gray(`${o} —`)}).join(chalk.gray(" "));console.log(" "+a);const s=t.flatMap(e=>e.cards.map(o=>({...o,chapter:e.chapter})));s.sort((e,o)=>e.rank-o.rank||e.chapter-o.chapter||e.card-o.card);for(const e of s.slice(0,24)){const n=(e.since||"").slice(0,10);console.log(chalk.white(` ${e.icon} `)+chalk.gray(`Ch${e.chapter} · `)+chalk.white(o?`第 ${e.card} 张`:`card ${e.card}`)+chalk.gray(` · ${e.score}`)+(n?chalk.gray(o?` · 始于 ${n}`:` · since ${n}`):""))}s.length>24&&console.log(chalk.gray(o?` …还有 ${s.length-24} 枚`:` …and ${s.length-24} more`)),console.log(chalk.gray(" ─────────────────────────────────────────"))}export function renderKnowledgeCard(t,r){const d=c(),h=o(t,d);p(h,r),f();const y=wrapMixed(h.title,i()-4);for(const e of y)b(chalk.bold.yellow(e));b(chalk.gray("─".repeat(Math.min(Math.max(...y.map(o=>e(o))),i()))));const u=!!(t.chart_ids&&t.chart_ids.length>0);if(u&&l(t.chart_ids.slice(0,1),r.charts,a()),h.key_point&&""!==h.key_point.trim()?(u||f(),function(e,o,n){const t=c().startsWith("zh"),r=a().cols,l="-".repeat(Math.min(i(),Math.max(24,r-6))),s=t?"要点":"KEY POINT",g=t?`第 ${o} / ${n} 张`:`Card ${o} / ${n}`;console.log(chalk.cyan(" │ ")+chalk.green(l)),console.log(chalk.cyan(" │ ")+chalk.green(`${s} · ${g}`));for(const o of wrapMixed(e,i()-4))console.log(chalk.cyan(" │ ")+chalk.bold.green(" "+o));console.log(chalk.cyan(" │ ")+chalk.green(l)),f()}(h.key_point,h.number,r.totalCards)):u||f(),h.body.filter(e=>null!=e&&""!==e.trim()).forEach((e,o)=>{const n=0===o?e.match(/^([\s\S]*?(?:[.!?](?=\s|$)|[。!?]))(\s[\s\S]*)?$/):null;if(n&&n[1].trim().length<=180){C(n[1],!0);const e=n[2]?.trimStart();e&&C(e,!1)}else C(e,!1);f()}),h.icoaConnection){b(chalk.magenta(" "+n("icoa_connection",d))),b(chalk.gray(" "+"─".repeat(20)));for(const e of wrapMixed(h.icoaConnection,i()-4))b(" "+chalk.magenta(e));f()}if(t.check){const e=d.startsWith("zh"),o=t._zh?.checkStatement??t._zh?.check?.statement,n=e?o??t.check.statement:t.check.statement;for(const o of wrapMixed(e?"请回答 (输 y 或 n):":"Quick comprehension check (type y or n):",i()-8))b(chalk.cyan(" 🤔 "+o));b(chalk.gray(" "+"─".repeat(20)));for(const e of wrapMixed(n,i()-4))b(" "+chalk.white(e));f()}m(),function(o,n){const t=c().startsWith("zh"),r=a().cols,l="-".repeat(Math.min(i(),Math.max(24,r-6))),d=chalk.gray(" ");if("minimal"===R){const e=E?E(o.number):null;console.log(chalk.gray(" "+l)),console.log(chalk.gray(" "+(t?`第 ${o.number} / ${n.totalCards} 张`:`Card ${o.number} / ${n.totalCards}`))+(e?chalk.gray(t?" · 本卡练习 ":" · practice ")+e:""));const r=[];if(o.check?(r.push(chalk.bold.green("[y]")+chalk.gray(t?" 是":" yes")),r.push(chalk.bold.green("[n]")+chalk.gray(t?" 否":" no"))):r.push(chalk.bold.green("[ok]")+chalk.gray(t?" 下一张":" next")),e){const o=Math.max(1,(e.match(/\[\d\]/g)??[]).length),n=Array.from({length:o},(e,o)=>`[${o+1}]`).join("");r.push(chalk.bold.cyan(n)+chalk.gray(t?" 练习":" practice"))}return N&&r.push(chalk.bold.magenta("[sh]")+chalk.gray(t?" 实验台":" shell")),T&&r.push(chalk.bold.magenta("[battle]")+chalk.gray(t?" 进竞技场":" arena")),O&&r.push(chalk.bold.magenta("[duck]")+chalk.gray(t?" 跑仿真":" sim bench")),o.flow&&o.flow.length>0&&r.push(chalk.bold.magenta("[flow]")+chalk.gray(t?" 互动走一遍":" walk it")),r.push(chalk.bold.cyan("[b]")+chalk.gray(t?" 上一张":" back")),r.push(chalk.bold.yellow("[e]")+chalk.gray(t?" 求助":" help")),r.push(chalk.gray("[quit]")+(t?chalk.gray(" 退出"):"")),console.log(" "+r.join(d)),q(),void console.log()}const h=[];o.check?(h.push(chalk.bold.green("[y]")+chalk.gray(t?" 是":" yes")),h.push(chalk.bold.green("[n]")+chalk.gray(t?" 否":" no"))):h.push(chalk.bold.green("[ok]")+chalk.gray(t?" 继续":" next")),o.flow&&o.flow.length>0&&h.push(chalk.bold.magenta("[flow]")+chalk.gray(t?" 互动走一遍":" walk it")),M&&(h.push(chalk.bold.magenta("[/ai]")+chalk.gray(t?" 🐼 熊猫导师":" 🐼 Panda tutor")),h.push(chalk.bold.magenta("[/submit]")+chalk.gray(t?" 提问评分":" prompt score")));const y=A.get(o.number);var u;h.push(chalk.bold.magenta(y?`[/honors ${u=y,W[u-1]??`#${u}`}]`:"[/honors]")+chalk.gray(t?" 排行":" board")),"normal"===g?h.push(chalk.bold.cyan("[wide]")+chalk.gray(t?" 宽屏":" widen")):("wide"===g?h.push(chalk.bold.cyan("[wider]")+chalk.gray(t?" 更宽":" wider")):"wider"===g?(h.push(chalk.bold.cyan("[widest]")+chalk.gray(t?" 最宽":" widest")),h.push(chalk.bold.cyan("[wide]")+chalk.gray(t?" 回宽屏":" back to wide"))):h.push(chalk.bold.cyan("[wider]")+chalk.gray(t?" 回 wider":" back to wider")),h.push(chalk.bold.cyan("[normal]")+chalk.gray(t?" 标准":" standard")));const p=s(j,z,o.number,t),m=p.startsWith("💬");if(h.push((m?chalk.bold.yellow("[r]"):chalk.gray("[r]"))+(m?chalk.bold.white(` ${p}`):chalk.gray(` ${p}`))),h.push(chalk.bold.yellow("[e]")+chalk.gray(t?" 提问或报告":" ask or report")),L){const e=L,o=`${e.done}/${e.total}`,n=e.completedAt?chalk.bold.green:chalk.bold.cyan;h.push(n("[task]")+chalk.gray(t?` 本周 ${o}`:` week ${o}`))}h.push(chalk.bold.cyan("[b]")+chalk.gray(t?" 上一张":" back")),h.push(chalk.bold.cyan("[card N]")+chalk.gray(t?" 跳转":" jump")),h.push(chalk.gray("[reload]")+(t?chalk.gray(" 刷新"):"")),h.push(chalk.gray("[quit]")+(t?chalk.gray(" 退出"):""));const b=e(l);console.log(chalk.gray(" "+l)),console.log(chalk.gray(" "+(t?`第 ${o.number} / ${n.totalCards} 张`:`Card ${o.number} / ${n.totalCards}`)));let f="",$=0;for(const o of h){const n=e(o);f&&$+2+n>b?(console.log(" "+f),f=o,$=n):(f=f?f+d+o:o,$=f===o?n:$+2+n)}f&&console.log(" "+f),console.log(" "+chalk.magenta("✍ ")+chalk.magenta("[/py]")+chalk.gray(t?" Python 草稿本":" Python scratchpad")+d+chalk.magenta("[/pylist]")+chalk.gray(t?" 我的草稿":" my files")),console.log(chalk.gray(" "+l));const w=[t?"e = 就这张卡提问,或报告问题":"e = ask about this card, or report a problem",t?"更多: bookmark / unbookmark · status · lang zh/en · link":"more: bookmark / unbookmark · status · lang zh/en · link"];for(const e of w)for(const o of wrapMixed(e,b))console.log(chalk.gray(" "+o));q(),console.log()}(t,r)}export function renderCheckFeedback(e,o,n,t=!1){const r=c().startsWith("zh");if(console.log(),n)console.log(chalk.green(" ✓ ")+chalk.white(r?"答对了。":"Correct."));else if(console.log(chalk.yellow(" ✗ ")+chalk.white(r?"记下了,继续。":"Noted — moving on.")),t){const o="y"===e.check?.answer?r?"是":"Yes":r?"否":"No";console.log(chalk.gray(" "+(r?"正确答案: ":"Answer: ")+o+". "+(r?"回看上面那段。":"Re-read the paragraph above.")))}const l=r?e._zh?.solution??e.solution:e.solution;if(l&&l.length>0){console.log(),console.log(chalk.cyan(" 📝 "+(r?"解答:":"Worked solution:")));for(const e of l){for(const o of wrapMixed(e,i()-4))console.log(chalk.white(" "+o));console.log()}}console.log()}function F(e){return[chalk.white(" "+(e?"编著:Charlie Zhu":"Created & edited by Charlie Zhu")),chalk.gray(" "+(e?"ICOA 2026 创始人 · 课程总架构师":"Founder & Chief Curriculum Architect · ICOA 2026"))]}export function renderPhaseComplete(e,o,n,t,l,a){const s=c().startsWith("zh"),[g,d]=n.cardRange,h=o.checkResults||{};let y=0,u=0;for(let e=g;e<=d;e++){const o=h[String(e)];o&&(y++,o.correct&&u++)}const p="-".repeat(48);console.log();for(const e of r(" "))console.log(e);console.log(),console.log(chalk.bold.yellow(" "+p)),console.log(chalk.bold.yellow(" "+(s?`阶段 ${n.number} 完成`:`Phase ${n.number} complete`))+chalk.gray(" · ")+chalk.white(n.name));const m=y>0&&u===y?chalk.bold.green:chalk.bold.white;console.log(chalk.gray(" "+(s?"理解检查得分: ":"comprehension score: "))+m(`${u}/${y}`)+chalk.gray(0===y?s?" (本阶段未作答 y/n)":" (no y/n answered)":""));const b=String(d).length;let f=!1,$=0,w=0,_=0,k=0;for(let o=g;o<=d;o++){const n=e.cards.find(e=>e.number===o);if(!n)continue;const t=n,r=t.title??t.badge??"",l=(s?t._zh?.title??t._zh?.badge??r:r)||"",a=null!=n.check,c=h[String(o)];let g;g=c?c.correct?chalk.green("✓"):chalk.red("✗"):a?chalk.gray("○"):chalk.gray("·");const d=D?D(o):null;d&&(f=!0);const y=d?(d.solved>=d.total?chalk.green:d.solved>0?chalk.yellow:chalk.gray)(` ⚔${d.solved}/${d.total}`):"";d&&($++,d.solved>=d.total&&w++,_+=d.solved,k+=d.total);const u=wrapMixed(l,i()-10-b-(d?6:0)),p=u[0]+(u.length>1?"…":"");console.log(chalk.gray(` ${String(o).padStart(b)} `)+g+y+chalk.white(" "+p))}if(console.log(chalk.gray(s?" ✓ 答对 · ✗ 答错 · ○ 未作答 · 无 y/n 的卡不计分":" ✓ correct · ✗ wrong · ○ unanswered · cards without a y/n are unscored")),f&&console.log(chalk.bold.cyan(" ⚔ "+(s?"卡片练习: ":"practice: "))+(w>=$?chalk.bold.green:chalk.bold.white)(`${w}/${$}`)+chalk.gray(s?` 卡全完成 · ${_}/${k} 题 AC · 行内 ⚔已过/共(绿 完成 · 黄 部分 · 灰 未碰)`:` cards complete · ${_}/${k} problems AC · ⚔solved/total per row (green done · yellow partial · gray untouched)`)),l){const e=e=>"green"===e?chalk.bold.green:"blue"===e?chalk.bold.cyan:"yellow"===e?chalk.bold.yellow:chalk.bold.red;console.log(chalk.bold.magenta(" ⭐ "+(s?"提问得分 (best): ":"Prompt scores (best): "))+(0===l.length?chalk.gray(s?"本阶段尚未提问 — 用 /ai 研究,再 /submit 评分":"none this phase — research with /ai, then /submit"):l.map(o=>chalk.gray((s?"卡":"#")+o.card+" ")+e(o.tier)(String(o.score))).join(chalk.gray(" · "))))}if(a&&!a.configured){const o=d-g+1>12,n="fill"===e.practiceMode;console.log(chalk.gray(o?s?" 🔒 本阶段通关标准制作中 — 很快更新(360 层第二阶段标准设计中)":" 🔒 Pass criteria for this phase are in production — coming soon (360-tier second-stage standard in design)":n?s?" 🔒 本阶段 3 场判分赛制作中 — 很快更新;赛场挂在卡 4 / 8 / 12,3 场全过解锁下一阶段(本轨无 research)":" 🔒 This phase’s 3 judged arenas are in production — coming soon; they hang on cards 4 / 8 / 12 and all 3 unlock the next phase (no research on this track)":s?" 🔒 本阶段通关标准制作中 — 很快更新(标准范式:3 场练习赛 + 3 卡研究)":" 🔒 Pass criteria for this phase are in production — coming soon (standard: 3 arenas + 3 research cards)"))}if(a?.configured&&a.contest){const e=a.contest;if(e.slots&&e.slots.length>0)for(const o of e.slots){const e=chalk.bold.cyan(` ⚔ ${s?"练习赛":"arena"} ${n.number}-${o.slot}: `);o.passed?console.log(e+chalk.bold.green(`${o.best_ac}/${o.n} AC ✅`)):0===o.attempts?console.log(e+chalk.white(s?`${o.n} 题 · 过 ${o.need} 题 — `:`${o.n} problems · AC ${o.need} — `)+chalk.bold.green(`contest ${o.slot}`)):console.log(e+chalk.yellow(s?`最好 ${o.best_ac}/${o.n}(需 ${o.need})· 已试 ${o.attempts} 次 — `:`best ${o.best_ac}/${o.n} (need ${o.need}) · ${o.attempts} attempt(s) — `)+chalk.bold.green(`contest ${o.slot}`))}else{const o=chalk.bold.cyan(" ⚖ "+(s?"判分赛: ":"Contest: "));e.passed?console.log(o+chalk.bold.green(`${e.best_ac}/${e.n} AC ✅ `+(s?"已过关":"passed"))):0===e.attempts?console.log(o+chalk.white(s?`${e.n} 题 · 过 ${e.need} 题解锁 — 输入 `:`${e.n} problems · AC ${e.need} to pass — type `)+chalk.bold.green("contest")+chalk.white(s?" 开始":" to start")):console.log(o+chalk.yellow(s?`最好 ${e.best_ac}/${e.n} AC(需 ${e.need})· 已试 ${e.attempts} 次 — 输入 `:`best ${e.best_ac}/${e.n} AC (need ${e.need}) · ${e.attempts} attempt(s) — type `)+chalk.bold.green("contest")+chalk.yellow(s?" 再战":" to retry"))}}t&&console.log(chalk.gray(" "+(s?"下一阶段: ":"next: "))+chalk.bold.cyan(s?`阶段 ${t.number}`:`Phase ${t.number}`)+chalk.gray(" · ")+chalk.white(t.name)),console.log(chalk.bold.yellow(" "+p));for(const e of F(s))console.log(e)}export function renderCurriculumComplete(e,o){const n=c().startsWith("zh"),t=o.checkResults||{},l="-".repeat(48);let a=0,s=0;console.log();for(const e of r(" "))console.log(e);console.log(),console.log(chalk.bold.green(" "+l)),console.log(chalk.bold.green(" 🏆 "+(n?`${e.name} — 全部完成!`:`${e.name} — complete!`))),console.log(chalk.bold.green(" "+l));for(const o of e.modules){const[e,r]=o.cardRange;let l=0,c=0;for(let o=e;o<=r;o++){const e=t[String(o)];e&&(l++,e.correct&&c++)}a+=l,s+=c;const g=l>0&&c===l?chalk.green:chalk.white;console.log(chalk.gray(" "+(n?`阶段 ${o.number}`:`Phase ${o.number}`).padEnd(8))+g(`${c}/${l}`.padEnd(7))+chalk.gray(o.name))}console.log(chalk.bold.green(" "+l)),console.log(chalk.bold.green(" "+(n?"总分 / overall: ":"Overall: "))+chalk.bold.white(`${s}/${a}`)),console.log(chalk.bold.green(" "+l));for(const e of F(n))console.log(e);console.log()}export function renderMCQCard(e,t){const r=c(),l=o(e,r);p(l,t),f(),b(chalk.bold.yellow("🎯 "+l.title)),b(chalk.gray("─".repeat(Math.min(l.title.length+4,i())))),f();for(const e of v(l.question,i()-4))b(" "+e);f();for(const e of["A","B","C","D"])b(chalk.cyan(` ${e}.`)+" "+chalk.white(l.options[e]));f(),m(),console.log(chalk.gray(" "+(r.startsWith("zh")?"输入 ":"Type "))+chalk.bold.green("A")+chalk.gray(" / ")+chalk.bold.green("B")+chalk.gray(" / ")+chalk.bold.green("C")+chalk.gray(" / ")+chalk.bold.green("D")+chalk.gray(" "+n("type_to_answer",r))),console.log(chalk.gray(" ")+chalk.bold.cyan("back")+chalk.gray(r.startsWith("zh")?" 上一张 · ":" previous card · ")+chalk.bold.cyan("card N")+chalk.gray(r.startsWith("zh")?" 跳转":" jump")),console.log()}export function renderMCQFeedback(e,t,r,l){const a=c(),s=o(e,a);console.log(),r?console.log(" "+chalk.bold.green(n("correct",a)+" ")+chalk.gray(`${n("one_point",a)} · ${t} = ${s.options[t]}`)):console.log(" "+chalk.bold.red(n("not_quite",a)+" ")+chalk.gray(`${n("you_chose",a)} ${t}; ${n("answer_is",a)} ${s.answer}.`)),console.log(),console.log(chalk.gray(" "+n("explanation",a)));for(const e of v(s.explanation,i()-4))console.log(chalk.gray(" "+e));const g=Object.values(l.mcqResults),d=g.filter(e=>e.correct).length;console.log(),console.log(chalk.gray(" "+n("mcq_accuracy_so_far",a)+" ")+chalk.white(`${d}/${g.length}`)),console.log(),r||(console.log(chalk.gray(" "+n("press_ok_continue",a)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",a))),console.log())}export function renderPracticalCard(e,t){const r=c(),l=o(e,r);p(l,t),f(),b(chalk.bold.yellow("🛠 "+l.title)),b(chalk.gray("─".repeat(Math.min(l.title.length+4,i())))),f();for(const e of v(l.task,i()-4))b(" "+e);if(l.starterCode){f(),b(chalk.gray(" "+n("starter_code",r))),f();for(const e of l.starterCode.split("\n"))b(" "+chalk.cyan(e))}f(),m(),console.log(chalk.gray(" "+n("try_in_sandbox",r)+" ")+chalk.bold.cyan("!python3")+chalk.gray(" "+n("drops_into_python",r))),console.log(chalk.gray(" "+n("when_done",r))),console.log(chalk.gray(" ")+chalk.bold.green("done")+chalk.gray(" "+n("done_desc",r))),console.log(chalk.gray(" ")+chalk.bold.yellow("skip")+chalk.gray(" "+n("skip_desc",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log()}export function renderPracticalSuccess(e){const t=c(),r=o(e,t);console.log(),console.log(" "+chalk.bold.green(n("practical_recorded",t))),console.log(),console.log(chalk.gray(" "+n("reference_answer",t)));for(const e of v(r.successHint,i()-4))console.log(chalk.gray(" "+e));console.log(),console.log(chalk.gray(" "+n("press_ok_continue",t)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",t))),console.log()}export function renderSimDemoCard(e,t){const r=c(),l=o(e,r);p(l,t),f(),b(chalk.bold.yellow("🎬 "+l.title)),f();for(const e of v(l.description,i()-4))b(" "+e);f(),b(chalk.gray(" "+n("sim_requires",r))),f(),m(),console.log(chalk.gray(" ")+chalk.bold.cyan("sim")+chalk.gray(" "+n("sim_launch_desc",r))),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",r))),console.log(chalk.gray(" bookmark "+n("bookmark_desc",r))),console.log(chalk.gray(" back "+n("back_desc",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",r))),console.log()}export function renderArenaTaskCard(e,n){const t=c(),r=t.startsWith("zh"),l=o(e,t);p(l,n),f(),b(chalk.bold.cyan("🏟 "+l.title)),b(chalk.gray(" "+l.origin+" · "+l.domain+" · "+l.metric)),f();for(const e of l.statement){for(const o of v(e,i()-4))b(" "+o);f()}b(chalk.bold.green(r?" 核心要点 — baseline → 解法的关键变化":" CORE DELTA — baseline → solution"));for(const e of l.core_delta)for(const o of v("• "+e,i()-6))b(" "+chalk.white(o));f(),b(chalk.gray((r?" 提交格式: ":" Submission: ")+l.submission_format)),l.hints&&b(chalk.gray(r?" 本题有 5 级提示 (a–e),进入 arena 后逐级解锁。":" 5 progressive hints (a–e) unlock inside the arena.")),f(),m(),console.log(chalk.gray(" ")+chalk.bold.cyan("arena "+l.task_id)+chalk.gray(r?" 动手做这道题(下载 / 提示 / 提交 / 榜单)":" open the arena (download / hints / submit / board)")),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续下一张":" continue to next")),console.log(chalk.gray(" back "+(r?"上一张":"previous"))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderComingSoonCard(e,n){const t=c(),r=t.startsWith("zh"),l=o(e,t);p(l,n),f(),b(chalk.bold.yellow("🔜 "+l.title)),f();const a=l.note||(r?"这道竞技场题目正在编写中,敬请期待。":"This arena task is coming soon.");for(const e of v(a,i()-4))b(" "+chalk.gray(e));f(),m(),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续":" continue")),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderMilestone(e,t){const r=c(),l=o(e,r),a=e.number===t.totalCards;console.log(),console.log(chalk.bold.yellow(" ╭"+d("═"))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+chalk.white(" "+n("milestone_header",r))),console.log(chalk.bold.yellow(" ║"));const s=` ${l.badge} ${l.emoji}`;console.log(chalk.bold.yellow(" ║ ")+chalk.bold.green(s)),console.log(chalk.bold.yellow(" ║ ")+chalk.gray(" ─".repeat(Math.max(1,Math.floor(l.badge.length/2+2))))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("in_wild_corresponds",r)));for(const e of v(l.realWorldLevel,i()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(e));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("whats_next",r)));for(const e of v(l.unlockedNext,i()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(e));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ╰"+d("═"))),console.log(),a?(console.log(chalk.gray(" "+n("demo_complete",r))),console.log(),console.log(chalk.gray(" "+n("unlock_full",r)+" ")+chalk.white(n("curriculum_name",r))+chalk.gray(",")),console.log(chalk.gray(" "+n("contact_team_leader",r)+" ")+chalk.bold.yellow("EA")+chalk.gray(" "+n("learn_token",r))),console.log(chalk.gray(" "+n("or_email",r)+" ")+chalk.cyan("australia@icoa2026.au")+chalk.gray(" "+n("for_partnership",r))),console.log(),console.log(chalk.gray(" "+n("type_quit",r)+" ")+chalk.bold.green("quit")+chalk.gray(" "+n("to_exit",r)+" ")+chalk.bold.green("status")+chalk.gray(" "+n("for_dashboard",r)))):(console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",r))),console.log(chalk.gray(" status "+n("status_full",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",r)))),console.log()}export function renderStatus(o,t,r={}){const l=c(),a=l.startsWith("zh"),s=t.cardsCompleted.length,g=o.totalCards,d=t.checkResults||{},p=r.gate??null,$=!!r.gated,w=r.focus??"current",_=r.posForSlot??(e=>4===e?10:4*e),k=t.currentCard,x=o.modules.find(e=>k>=e.cardRange[0]&&k<=e.cardRange[1]),C=(o,n)=>o+" ".repeat(Math.max(0,n-e((e=>e.replace(/\x1b\[[0-9;]*m/g,""))(o))));console.log();const v=`${o.name} — ${a?"状态":"Status"}`;console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(v)+" "+chalk.cyan("─".repeat(Math.max(4,i()-2-e(v))))),f(),b(" "+chalk.gray(n("total_progress",l)+" ")+y(s,g)+chalk.gray(` (${s}/${g})`)+chalk.gray(" "+n("streak",l)+" ")+u(t.streakDays));{let n=0,l=0,s=0,c=0,g=0,h=0,y=!1;for(const e of o.modules){for(let t=e.cardRange[0];t<=e.cardRange[1];t++){const e=D?D(t):null;e&&(n++,e.solved>=e.total&&l++);const r=o.cards.find(e=>e.number===t);null!=r?.check&&(s++,d[String(t)]?.correct&&c++)}const t=p?.phases.find(o=>o.phase===e.number);if(t?.configured)for(const e of t.contest?.slots??[])g++,e.passed&&h++;t?.research&&(y=!0)}const u=(e,o)=>(e>=o?chalk.green:chalk.white)(`${e}/${o}`),m=[];n&&m.push(chalk.gray(a?"⚔ 练习卡 ":"⚔ practice cards ")+u(l,n)),g&&m.push(chalk.gray(a?"赛场 ":"arena ")+u(h,g)),s&&m.push(chalk.gray(a?"✓ 自测 ":"✓ checks ")+u(c,s)),m.length&&b(" "+m.join(chalk.gray(" "))),r._anyResearch=y;{let n=0;const r=[];let l=0,c=0,y=0;for(const e of o.modules)for(let a=e.cardRange[0];a<=e.cardRange[1];a++){c++,t.cardsCompleted.includes(a)&&l++;const e=o.cards.find(e=>e.number===a);null!=e?.check&&d[String(a)]&&y++;const s=D?D(a):null;s&&s.solved<s.total&&(n+=s.total-s.solved,r.push(a))}const u=a?"▸ 通关还差 ":"▸ to finish ",p=[];if(l<c&&p.push(chalk.gray(a?"卡片 ":"cards ")+chalk.white(""+(c-l))+chalk.gray(a?" 张未读":" unread")),s&&y<s&&p.push(chalk.gray("✓ ")+chalk.white(""+(s-y))+chalk.gray(a?" 题自测未答":" checks unanswered")),n>0){const o=a?`练习还差 ${n} 题`:`${n} practice problem${n>1?"s":""}`,t=a?"(卡 ":" (cards ",l=")",s=" │ ⚔ ",c=i()-e(s)-e(u)-e(o)-e(t+l),g=e=>{const o=[];let n=0;for(const t of r){const r=String(t).length+(o.length?3:0);if(n+r>e)break;n+=r,o.push(t)}return o};let d=g(c);d.length<r.length&&(d=g(c-e(` +${r.length}`))),!d.length&&r.length&&(d=[r[0]]);const h=r.length-d.length,y=d.join(" · ")+(h>0?` +${h}`:"");p.push(chalk.gray("⚔ ")+chalk.white(o)+chalk.gray(t+y+l))}g&&h<g&&p.push(chalk.gray(a?"赛 ":"arena ")+chalk.white(""+(g-h))+chalk.gray(a?" 场未过":" to pass"));const m=l>0;m&&p.length?p.forEach((o,n)=>b(" "+(0===n?chalk.bold.yellow(u):" ".repeat(e(u)))+o)):m&&!p.length&&b(" "+chalk.bold.green(a?"✅ 通关条件已全部达成":"✅ every completion gate met"))}}f();const M=e=>a?`阶段 ${e}`:`Phase ${e}`,S=Math.max(10,Math.min(28,i()-54));for(const e of o.modules){const[n,r]=e.cardRange,l=r-n+1,s=t.cardsCompleted.filter(e=>e>=n&&e<=r).length,c=$&&!!p&&e.number>p.unlocked_through_phase,g=p?.phases.find(o=>o.phase===e.number);let y=0,u=0,m=0;const f=[],v=[];let A=0,W=0,j=0;const z=[];for(let e=n;e<=r;e++){const n=o.cards.find(o=>o.number===e);if(null!=n?.check){y++;const o=d[String(e)];o?(u++,o.correct?m++:v.push(e)):f.push(e)}const t=D?D(e):null;t&&(A++,j+=t.solved,t.solved>=t.total?W++:z.push(`${e}:${t.solved}/${t.total}`))}const L=g?.configured?g.contest?.slots??[]:[],R=e=>e.passed?chalk.green("✅"):e.attempts>0?chalk.yellow("❌"):chalk.gray("⬜"),P=s>=l&&(0===y||m===y)&&(0===A||W===A)&&(0===L.length||L.every(e=>e.passed))&&(!g?.research||g.research.passed),q=s>0||u>0||j>0||L.some(e=>e.attempts>0),E=c?chalk.gray("🔒"):P?chalk.green("✅"):e.number===x?.number?chalk.bold.cyan("▶ "):q?chalk.yellow("▶ "):chalk.gray("⬜"),N=h(e.name,S),T=[];if(T.push((s>=l?chalk.green:chalk.white)(`${s}/${l}`)+chalk.gray(a?"卡":"c")),y>0&&T.push(chalk.gray("✓")+(m===y?chalk.green:chalk.white)(`${m}/${y}`)),A>0&&T.push(chalk.gray("⚔")+(W===A?chalk.green:chalk.white)(`${W}/${A}`)+chalk.gray(a?"卡":"c")),L.length>0&&T.push(chalk.gray(a?"赛":"arena ")+L.map(R).join("")),g?.research&&T.push(chalk.gray("⭐")+(g.research.passed?chalk.green:chalk.white)(`${g.research.good_cards}/${g.research.need_cards}`)),b(" "+E+" "+chalk.white(C(M(e.number),a?5:8))+chalk.gray(C(N,S+1))+T.join(chalk.gray(" · "))),c||"all"!==w&&w!==e.number&&("current"!==w||e.number!==x?.number)){if(!c&&q&&!P){const o=[],t=L.filter(e=>!e.passed).map(o=>(o.attempts>0?chalk.yellow:chalk.gray)(`${e.number}-${o.slot}@${a?"卡":"card "}${n+_(o.slot)-1}`));t.length&&o.push(chalk.gray(a?"赛 ":"arena ")+t.join(chalk.gray(" · ")));const r=(e,o)=>e.slice(0,8).join(o)+(e.length>8?chalk.gray(" +"+(e.length-8)):"");z.length&&o.push(chalk.gray("⚔ ")+chalk.white(r(z," "))),v.length&&o.push(chalk.red("✗ ")+chalk.white(r(v.map(String),","))),f.length&&o.push(chalk.gray("○ ")+chalk.white(r(f.map(String),","))),g?.research&&!g.research.passed&&o.push(chalk.gray(`⭐ ${g.research.good_cards}/${g.research.need_cards}`)),o.forEach((e,o)=>b(chalk.gray(0===o?a?" 待办: ":" todo: ":" ")+e))}}else{const t=String(r).length;for(let s=n;s<=r;s++){const r=o.cards.find(e=>e.number===s);if(!r)continue;const c=r,g=c.title??c.badge??"",h=(a?c._zh?.title??c._zh?.badge??g:g)||"",y=null!=r.check,u=d[String(s)],p=u?u.correct?chalk.green("✓"):chalk.red("✗"):y?chalk.gray("○"):chalk.gray("·"),m=D?D(s):null,f=m?(m.solved>=m.total?chalk.green:m.solved>0?chalk.yellow:chalk.gray)(`⚔${m.solved}/${m.total}`):" ",$=s===k?chalk.bold.cyan("▶"):" ",w=wrapMixed(h,Math.max(16,i()-14-t)),x=w[0]+(w.length>1?"…":"");b(` ${$} `+chalk.gray(String(s).padStart(t))+" "+p+" "+C(f,5)+" "+chalk.white(x));const v=12===l?L.find(e=>n+_(e.slot)-1===s):void 0;if(v){const o=chalk.gray(` ${" ".repeat(t)} ⚔ ${a?"练习赛":"arena"} ${e.number}-${v.slot}: `);v.passed?b(o+chalk.bold.green(`${v.best_ac}/${v.n} AC ✅`)):0===v.attempts?b(o+chalk.gray("⬜ ")+chalk.white(a?`未开始 · ${v.n} 题 · 过 ${v.need} 题 → `:`not started · ${v.n} problems · AC ${v.need} → `)+chalk.bold.green(`contest ${v.slot}`)):b(o+chalk.yellow(a?`❌ 最好 ${v.best_ac}/${v.n}(需 ${v.need})· 已试 ${v.attempts} 次 → `:`❌ best ${v.best_ac}/${v.n} (need ${v.need}) · ${v.attempts} attempt(s) → `)+chalk.bold.green(`contest ${v.slot}`))}}if(12!==l)for(const o of L){const n=chalk.gray(` ⚔ ${a?"练习赛":"arena"} ${e.number}-${o.slot}: `);o.passed?b(n+chalk.bold.green(`${o.best_ac}/${o.n} AC ✅`)):0===o.attempts?b(n+chalk.gray("⬜ ")+chalk.white(a?`未开始 · ${o.n} 题 · 过 ${o.need} 题 → `:`not started · ${o.n} problems · AC ${o.need} → `)+chalk.bold.green(`contest ${o.slot}`)):b(n+chalk.yellow(a?`❌ 最好 ${o.best_ac}/${o.n}(需 ${o.need})· 已试 ${o.attempts} 次 → `:`❌ best ${o.best_ac}/${o.n} (need ${o.need}) · ${o.attempts} attempt(s) → `)+chalk.bold.green(`contest ${o.slot}`))}g?.research&&!g.research.passed&&b(chalk.gray(a?` ⭐ 研究: ${g.research.good_cards}/${g.research.need_cards} 卡达 ${g.research.min_score} 分 — /ai 研究后 /submit`:` ⭐ research: ${g.research.good_cards}/${g.research.need_cards} cards at ${g.research.min_score}+ — /ai then /submit`)),g&&!g.configured&&b(chalk.gray(a?" 🔒 本阶段通关标准制作中 — 很快更新":" 🔒 pass criteria for this phase in production — coming soon"))}}f(),b(chalk.gray(a?" ✓ 答对 ✗ 答错 ○ 未答 · ⚔ 练习 已过/共 · 赛 ✅ 过 ❌ 试过 ⬜ 未碰"+(r._anyResearch?" · ⭐ 研究":""):" ✓ right ✗ wrong ○ unanswered · ⚔ practice solved/total"+(r._anyResearch?" · ⭐ research":""))),b(chalk.gray(a?" 展开某阶段: ":" arena ✅ passed ❌ tried ⬜ untouched · expand: ")+chalk.bold.green("status all")+chalk.gray(" / ")+chalk.bold.green("status N")),t.achievements.length>0&&b(" "+chalk.gray(n("achievements",l)+" ")+t.achievements.map(e=>chalk.bold.yellow("★ ")+chalk.white(e)).join(chalk.gray(" · "))),f(),m()}function I(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}export function renderArenaIntro(){const e=c().startsWith("zh"),o=!!process.stdout.isTTY&&!/^(C|POSIX)$/i.test(process.env.LANG||"")&&!process.env.ICOA_TEST_BOOT_MODE,n=e?[chalk.bold.yellow(" ⚔ 你读完 4 张卡了 — 前面是第一个检查点。"),chalk.white(" ⚔ 每 4 张卡有一场判分赛:")+chalk.bold.yellow("卡 4 / 8 / 12")+chalk.white(",一个阶段共 3 场。"),chalk.white(" · 敲 ")+chalk.bold.green("contest 1")+chalk.white(" 开始 — 计时器同时开始,题目在赛场里读。"),chalk.white(" · 判分机会真的跑你的代码,不是对答案。"),chalk.white(" · 3 场全过 → 解锁下一阶段。"),chalk.gray(" ▸ 现在不想打?敲 ")+chalk.bold.green("next")+chalk.gray(" 继续读卡,赛场一直在那儿等你。")]:[chalk.bold.yellow(" ⚔ Four cards down — a checkpoint is waiting."),chalk.white(" ⚔ Every 4 cards there is a judged arena: ")+chalk.bold.yellow("cards 4 / 8 / 12")+chalk.white(", three per phase."),chalk.white(" · Type ")+chalk.bold.green("contest 1")+chalk.white(" to start — the clock starts with it; the problems are read inside."),chalk.white(" · The judge really runs your code. It is not an answer key."),chalk.white(" · Pass all three → the next phase unlocks."),chalk.gray(" ▸ Not now? Type ")+chalk.bold.green("next")+chalk.gray(" and keep reading — the arena waits for you.")];console.log();for(const e of n)console.log(e),o&&I(200);console.log()}
|