icoa-cli 2.19.243 → 2.19.244

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.
@@ -1 +1 @@
1
- import chalk from"chalk";import{createInterface as e}from"node:readline";import{spawn as o}from"node:child_process";import{getMainRl as r}from"../lib/main-rl.js";import{existsSync as n}from"node:fs";import{dirname as l,join as t}from"node:path";import{fileURLToPath as a}from"node:url";import{loadCurriculumById as c,validateEAToken as s,syncProgress as i,syncCardFeedback as u}from"../lib/learn-curricula.js";import{getConfig as d,saveConfig as g}from"../lib/config.js";import{loadLearnState as m,saveLearnState as y,newLearnState as f,updateStreak as p,markCardComplete as h,recordMCQ as b,recordCheck as w,markPracticalComplete as k,addAchievement as C}from"../lib/learn-state.js";import{renderWelcome as v,renderKnowledgeCard as A,renderMCQCard as E,renderMCQFeedback as I,renderPracticalCard as _,renderPracticalSuccess as D,renderSimDemoCard as O,renderMilestone as S,renderStatus as P,renderPhaseComplete as $,renderCurriculumComplete as T}from"../lib/learn-render.js";import{printError as L}from"../lib/ui.js";export function registerLearnCommand(M){M.command("learn [token]").description("Enter learn mode (free demo, or team-issued EA/EI/AC/CA/IO/IA token for full curriculum)").action(async M=>{M&&M.trim()||(console.log(),console.log(chalk.gray(" No token given — starting free 11-card demo (")+chalk.bold.green("LEARNDEMO01")+chalk.gray(").")),console.log(chalk.gray(" Full curriculum (96 / 360 cards): ")+chalk.bold.yellow("learn EA|EI|AC|CA|IO|IA + 8 chars")+chalk.gray(" — token from your country team leader.")),console.log(),M="LEARNDEMO01");const j=M.trim().toUpperCase();let x=null;const N=/^(LEARNDEMO01|AI4CTFDEMO01|CTF4AIDEMO01)$/i.test(j),q=/^(EA|EI|AC|CA|IO|IA)[A-Z0-9]{8}$/i.test(j);if(N)console.log(),console.log(chalk.gray(" Loading demo curriculum...")),x=await c(j);else if(q){const e=d().ctfdUrl||"https://practice.icoa2026.au";console.log(),console.log(chalk.gray(" Validating token..."));const o=await s(j,e);if(!o.ok)return L(`Token validation failed: ${o.message}`),console.log(),console.log(chalk.gray(" Possible causes:")),console.log(chalk.gray(" · Token expired or revoked")),console.log(chalk.gray(" · Network down (check connection)")),console.log(chalk.gray(" · Typo in token")),void console.log();if(console.log(chalk.green(` ✓ Token valid · curriculum: ${o.curriculumId} · status: ${o.status}`)),x=await c(o.curriculumId||"LEARNDEMO01"),!x)return L(`Failed to fetch curriculum '${o.curriculumId}' from server.`),console.log(chalk.gray(" This is usually a transient network issue. Try again in a minute.")),void console.log(chalk.gray(" If it persists, check ")+chalk.cyan(e)+chalk.gray(" is reachable."))}if(!x)return L(`Unknown learn token: ${j}`),console.log(),console.log(chalk.gray(" Available tokens:")),console.log(chalk.gray(" ")+chalk.bold.green("LEARNDEMO01")+chalk.gray(" free 11-card demo (anyone can use)")),console.log(chalk.gray(" ")+chalk.bold.yellow("EA|EI|AC|CA|IO|IA")+chalk.gray(" + 8 chars full 96 / 360-card curriculum (issued by team leader)")),console.log(),console.log(chalk.gray(" Tracks: ")+chalk.cyan("EA")+chalk.gray("=ctf4eai · ")+chalk.cyan("AC")+chalk.gray("=ai4ctf · ")+chalk.cyan("CA")+chalk.gray("=ctf4ai · ")+chalk.cyan("IO")+chalk.gray("=ioai · ")+chalk.cyan("IA")+chalk.gray("=iaio")),console.log(),console.log(chalk.gray(" To get a 360-card olympiad-prep curriculum, email ")),console.log(chalk.gray(" ")+chalk.cyan("asra@icoa2026.au")+chalk.gray(" or ask your country's team leader.")),void console.log();let F=m(),R=!1;F&&F.token===j?p(F):(F=f(j,x.id,x.totalCards),R=!0),y(F),v(x,F,R);const U=r(),z=null!==U,B=z?U.listeners("line").slice():[];z&&U.removeAllListeners("line");const J=z?U:e({input:process.stdin,output:process.stdout,terminal:!0}),W=()=>{J.setPrompt(chalk.bold.cyan("icoa learn> ")),J.prompt()};W();let K=null,Q=null,G=null,V=null,Z=!1,H=0;const X=(d().language||"en").toLowerCase().startsWith("zh"),Y=[];let ee=null;const oe=new Promise(e=>{ee=e}),re=()=>{const e=ee;ee=null,e?.()},ne="1"===process.env.ICOA_LEARN_EMBEDDED,le=e=>x.cards.find(o=>o.number===e),te=e=>{const o=x.modules.find(o=>o.cardRange[1]===e);if(!o)return!1;const r=x.modules.find(e=>e.number===o.number+1);return $(x,F,o,r),!0},ae=()=>{Z=!0,console.log(chalk.gray(X?" 按 Enter 进入下一阶段…":" Press Enter to continue to the next phase…"))},ce=()=>{const e=le(F.currentCard);if(!e)return console.log(),console.log(chalk.gray(" No more cards in this curriculum.")),console.log(chalk.gray(" Type ")+chalk.bold.green("status")+chalk.gray(" for the dashboard or ")+chalk.bold.green("quit")+chalk.gray(" to exit.")),void console.log();switch(e.type){case"knowledge":A(e,x),e.check?(G=e.number,H=Date.now()):(h(F,e.number),y(F));break;case"mcq":E(e,x),K=e.number;break;case"practical":_(e,x),Q=e.number;break;case"sim_demo":O(e,x),h(F,e.number),y(F);break;case"milestone":S(e,x),C(F,e.badge),h(F,e.number),y(F)}};J.on("line",async e=>{const r=e.trim().toLowerCase();if(null!==V){const o=e.trim(),r=V;if(V=null,""===o)console.log(chalk.gray(X?" 已取消(未提交)。":" Cancelled (nothing submitted)."));else{const e=d(),n=H>0?Date.now()-H:void 0;Y.push(u(j,e.ctfdUrl||"https://practice.icoa2026.au",{curriculum_id:x.id,card_number:r,feedback_text:o,time_on_card_ms:n}).catch(()=>{})),console.log(chalk.green(X?" ✓ 已收到,谢谢帮助完善这张卡。":" ✓ Thanks — your report was recorded."))}return console.log(),void W()}if(Z)return Z=!1,ce(),void W();if(r)if("menu"!==r&&"menu confirm"!==r)if("quit"!==r&&"exit"!==r&&"q"!==r){if("status"===r)return P(x,F),void W();if("lang"===r||r.startsWith("lang ")){const e=r.slice(4).trim();if(!e)return console.log(chalk.gray(" 当前语言 / current: ")+chalk.white(d().language||"en")+chalk.gray(" · ")+chalk.bold.green("lang zh")+chalk.gray(" / ")+chalk.bold.green("lang en")),void W();const o=x.cards.some(e=>null!=e._zh),n=e.toLowerCase().startsWith("zh")?"zh":e.toLowerCase(),l="en"===n||"zh"===n&&o,t=l?n:"en";return g({language:t}),l?console.log(chalk.green(" ✓ ")+chalk.gray("语言 / language → ")+chalk.white(t)):console.log(chalk.yellow(" ! ")+chalk.gray(`${e} 本课暂无翻译,已用英文 / not available — using English`)),G=null,K=null,Q=null,V=null,Z=!1,ce(),void W()}if("sim"===r){const e=le(F.currentCard);return e&&"sim_demo"===e.type?(function(e){const r=function(){const e=l(a(import.meta.url)),o=[t(e,"..","..","panda","mujoco-launcher.py"),t(e,"..","..","..","panda","mujoco-launcher.py")];for(const e of o)if(n(e))return e;return null}();if(!r)return console.log(chalk.yellow(" MuJoCo launcher not found.")),console.log(chalk.gray(" Get it from: https://github.com/newaipanda/ICOA_CLI/blob/main/panda/mujoco-launcher.py")),void console.log(chalk.gray(" Or use the sandbox-vla docker image (Phase 3)."));const c={baseline:"baseline",prompt_injected:"prompt_inj",patch_attacked:"patch",modality_confused:"confused"}[e]||"baseline";console.log(chalk.gray(` Launching MuJoCo viewer (scenario: ${c})...`)),console.log(chalk.gray(" Close the window or press ESC to return to learn mode.")),o("python3",[r,c,"--seconds","5"],{stdio:"inherit"}).on("exit",e=>{0!==e?console.log(chalk.yellow(` MuJoCo exited with code ${e} (install: pip install mujoco)`)):console.log(chalk.gray(" Returned from sim."))})}(e.simAction),void W()):(console.log(chalk.gray(" (sim only available on simulation cards)")),void W())}if("bookmark"===r){const e=F.currentCard;return F.bookmarks.includes(e)||F.bookmarks.push(e),y(F),console.log(chalk.gray(` ✓ Card ${e} bookmarked.`)),void W()}if("e"===r)return V=F.currentCard,console.log(chalk.gray(X?" 描述问题(回车提交 / 空行取消):":" Describe the issue (Enter to submit / blank to cancel):")),void W();if("back"===r||"b"===r)return F.currentCard>1&&(F.currentCard-=1),K=null,Q=null,G=null,y(F),ce(),void W();if(r.startsWith("card ")){const e=r.slice(5).trim(),o=parseInt(e,10);return!Number.isInteger(o)||o<1||o>x.totalCards?(console.log(chalk.yellow(` Card number must be 1..${x.totalCards}. Try: `)+chalk.bold.green("card 1")),void W()):(F.currentCard=o,K=null,Q=null,G=null,y(F),ce(),void W())}if(null!==G&&["y","yes","n","no"].includes(r)){const e=le(G);if(e&&"knowledge"===e.type&&e.check){const o=r.startsWith("y")?"y":"n",n=o===e.check.answer,l=Date.now()-H;h(F,e.number),w(F,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),y(F);const{renderCheckFeedback:t}=await import("../lib/learn-render.js");t(e,o,n,!1);const a=d();if(Y.push(i(j,a.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"check_answered",check_answer:o,check_correct:n,time_on_card_ms:l}).catch(()=>{})),G=null,F.currentCard<x.totalCards){const e=F.currentCard;F.currentCard+=1,y(F),te(e)?ae():ce(),W()}else T(x,F),W();return}}if(null!==K&&["a","b","c","d"].includes(r)){const e=le(K);if(e&&"mcq"===e.type){const o=r.toUpperCase(),n=o===e.answer;b(F,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),h(F,e.number),y(F),I(e,o,n,F);const l=d();return Y.push(i(j,l.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"mcq_answered",mcq_answer:o,mcq_correct:n}).catch(()=>{})),K=null,void(n?F.currentCard<x.totalCards?(F.currentCard+=1,y(F),ce()):(T(x,F),W()):W())}}if(null!==Q){if("done"===r){const e=le(Q);if(e&&"practical"===e.type)return k(F,e.number),h(F,e.number),y(F),D(e),Q=null,void W()}if("skip"===r)return h(F,Q),y(F),console.log(chalk.gray(" Skipped (counts as not completed).")),console.log(),Q=null,void W()}if("ok"===r||"next"===r||"continue"===r||"n"===r){if(null!==K)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void W();if(null!==Q)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void W();if(null!==G)return console.log(chalk.yellow(" Please answer the check above (")+chalk.bold.green("y")+chalk.yellow(" or ")+chalk.bold.green("n")+chalk.yellow(").")),void W();const e=F.currentCard;return F.currentCard+=1,y(F),F.currentCard>x.totalCards?T(x,F):te(e)?ae():ce(),void W()}if(null!==G)return console.log(chalk.yellow(" Please answer the check above (")+chalk.bold.green("y")+chalk.yellow(" or ")+chalk.bold.green("n")+chalk.yellow(").")),void W();if(null!==K)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void W();if(null!==Q)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void W();console.log(chalk.gray(" Unknown command. Try: ")+chalk.white("ok")+chalk.gray(" / ")+chalk.white("status")+chalk.gray(" / ")+chalk.white("card N")+chalk.gray(" / ")+chalk.white("quit")),W()}else if(Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,5e3))]),console.log(),console.log(chalk.gray(" Saved. See you next session.")),console.log(chalk.gray(" Streak: ")+chalk.yellow(`🔥 ${F.streakDays} day(s)`)),console.log(),z){J.removeAllListeners("line");for(const e of B)J.on("line",e);J.prompt(),re()}else J.removeAllListeners("line"),J.close();else if(Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,3e3))]),J.removeAllListeners("line"),z||!ne){const{returnToMainMenu:e}=await import("../lib/menu-nav.js");e(z?J:void 0),re()}else J.close();else W()}),z||J.on("close",async()=>{Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,5e3))]),ne?re():process.exit(0)}),ce(),W(),await oe}),M.command("learn-pull [id]").description("Pre-download learn curricula to ~/.icoa/learn-cache/ for offline use (default: all)").action(async e=>{const o=e?[e.trim()]:["LEARNDEMO01","AI4CTFDEMO01","CTF4AIDEMO01","ai4ctf-96","ai4ctf-360","ctf4ai-96","ctf4ai-360","ctf4eai-96","ctf4eai-360","embodied-ai-100","embodied-ai-480"];console.log(),console.log(chalk.bold.cyan(" ICOA learn-pull — fetching curricula for offline use")),console.log(chalk.gray(` Server: ${(()=>{try{return JSON.parse(require("node:fs").readFileSync(require("node:path").join(require("node:os").homedir(),".icoa","config.json"),"utf-8")).ctfdUrl||"https://practice.icoa2026.au"}catch{return"https://practice.icoa2026.au"}})()}`)),console.log();let r=0,n=0,l=0;for(const e of o){process.stdout.write(` ${e.padEnd(22)} `);const o=Date.now(),t=await c(e),a=Date.now()-o;if(t){const e=t.cards,o=Array.isArray(e)?e.length:0,n=JSON.stringify(t).length;l+=n,console.log(chalk.green("✓ ")+chalk.gray(`${o.toString().padStart(3)} cards · ${(n/1024).toFixed(1).padStart(6)} KB · ${a.toString().padStart(4)} ms`)),r++}else console.log(chalk.red("✗ failed (server unreachable or unknown id)")),n++}console.log(),console.log(chalk.gray(" Summary: ")+chalk.green.bold(`${r} cached`)+chalk.gray(` · ${n} failed · total ${(l/1024).toFixed(0)} KB`)),console.log(chalk.gray(" Cache: ")+chalk.cyan("~/.icoa/learn-cache/")),console.log()})}
1
+ import chalk from"chalk";import{createInterface as e}from"node:readline";import{spawn as o}from"node:child_process";import{getMainRl as r}from"../lib/main-rl.js";import{existsSync as n}from"node:fs";import{dirname as l,join as t}from"node:path";import{fileURLToPath as a}from"node:url";import{loadCurriculumById as c,validateEAToken as s,syncProgress as i,syncCardFeedback as u}from"../lib/learn-curricula.js";import{getConfig as d,saveConfig as g}from"../lib/config.js";import{loadLearnState as m,saveLearnState as y,newLearnState as f,updateStreak as p,markCardComplete as h,recordMCQ as b,recordCheck as w,markPracticalComplete as k,addAchievement as C}from"../lib/learn-state.js";import{renderWelcome as v,renderKnowledgeCard as A,renderMCQCard as E,renderMCQFeedback as _,renderPracticalCard as I,renderPracticalSuccess as D,renderSimDemoCard as O,renderMilestone as S,renderStatus as P,renderPhaseComplete as $,renderCurriculumComplete as T}from"../lib/learn-render.js";import{printError as L}from"../lib/ui.js";export function registerLearnCommand(M){M.command("learn [token]").description("Enter learn mode (free demo, or team-issued EA/EI/AC/CA/IO/IA token for full curriculum)").action(async M=>{M&&M.trim()||(console.log(),console.log(chalk.gray(" No token given — starting free 11-card demo (")+chalk.bold.green("LEARNDEMO01")+chalk.gray(").")),console.log(chalk.gray(" Full curriculum: ")+chalk.bold.yellow("learn EA|EI|AC|CA|IO|IA + 8 chars")+chalk.gray(" — token from your country team leader.")),console.log(),M="LEARNDEMO01");const j=M.trim().toUpperCase();let x=null;const N=/^(LEARNDEMO01|AI4CTFDEMO01|CTF4AIDEMO01)$/i.test(j),q=/^[A-Z]{2}[A-Z0-9]{8}$/i.test(j);if(N)console.log(),console.log(chalk.gray(" Loading demo curriculum...")),x=await c(j);else if(q){const e=d().ctfdUrl||"https://practice.icoa2026.au";console.log(),console.log(chalk.gray(" Validating token..."));const o=await s(j,e);if(!o.ok)return L(`Token validation failed: ${o.message}`),console.log(),console.log(chalk.gray(" Possible causes:")),console.log(chalk.gray(" · Token expired or revoked")),console.log(chalk.gray(" · Network down (check connection)")),console.log(chalk.gray(" · Typo in token")),void console.log();if(console.log(chalk.green(` ✓ Token valid · curriculum: ${o.curriculumId} · status: ${o.status}`)),x=await c(o.curriculumId||"LEARNDEMO01"),!x)return L(`Failed to fetch curriculum '${o.curriculumId}' from server.`),console.log(chalk.gray(" This is usually a transient network issue. Try again in a minute.")),void console.log(chalk.gray(" If it persists, check ")+chalk.cyan(e)+chalk.gray(" is reachable."))}if(!x)return L(`Unknown learn token: ${j}`),console.log(),console.log(chalk.gray(" Available tokens:")),console.log(chalk.gray(" ")+chalk.bold.green("LEARNDEMO01")+chalk.gray(" free 11-card demo (anyone can use)")),console.log(chalk.gray(" ")+chalk.bold.yellow("EA|EI|AC|CA|IO|IA")+chalk.gray(" + 8 chars full curriculum (issued by team leader)")),console.log(),console.log(chalk.gray(" Tracks: ")+chalk.cyan("EA")+chalk.gray("=ctf4eai · ")+chalk.cyan("AC")+chalk.gray("=ai4ctf · ")+chalk.cyan("CA")+chalk.gray("=ctf4ai · ")+chalk.cyan("IO")+chalk.gray("=ioai · ")+chalk.cyan("IA")+chalk.gray("=iaio")),console.log(),console.log(chalk.gray(" To get a full curriculum, email ")),console.log(chalk.gray(" ")+chalk.cyan("australia@icoa2026.au")+chalk.gray(" or ask your country's team leader.")),void console.log();let F=m(),R=!1;F&&F.token===j?p(F):(F=f(j,x.id,x.totalCards),R=!0),y(F),v(x,F,R);const U=r(),z=null!==U,B=z?U.listeners("line").slice():[];z&&U.removeAllListeners("line");const J=z?U:e({input:process.stdin,output:process.stdout,terminal:!0}),W=()=>{J.setPrompt(chalk.bold.cyan("icoa learn> ")),J.prompt()};W();let K=null,Q=null,Z=null,G=null,V=!1,H=0;const X=(d().language||"en").toLowerCase().startsWith("zh"),Y=[];let ee=null;const oe=new Promise(e=>{ee=e}),re=()=>{const e=ee;ee=null,e?.()},ne="1"===process.env.ICOA_LEARN_EMBEDDED,le=e=>x.cards.find(o=>o.number===e),te=e=>{const o=x.modules.find(o=>o.cardRange[1]===e);if(!o)return!1;const r=x.modules.find(e=>e.number===o.number+1);return $(x,F,o,r),!0},ae=()=>{V=!0,console.log(chalk.gray(X?" 按 Enter 进入下一阶段…":" Press Enter to continue to the next phase…"))},ce=()=>{const e=le(F.currentCard);if(!e)return console.log(),console.log(chalk.gray(" No more cards in this curriculum.")),console.log(chalk.gray(" Type ")+chalk.bold.green("status")+chalk.gray(" for the dashboard or ")+chalk.bold.green("quit")+chalk.gray(" to exit.")),void console.log();switch(e.type){case"knowledge":A(e,x),e.check?(Z=e.number,H=Date.now()):(h(F,e.number),y(F));break;case"mcq":E(e,x),K=e.number;break;case"practical":I(e,x),Q=e.number;break;case"sim_demo":O(e,x),h(F,e.number),y(F);break;case"milestone":S(e,x),C(F,e.badge),h(F,e.number),y(F)}};J.on("line",async e=>{const r=e.trim().toLowerCase();if(null!==G){const o=e.trim(),r=G;if(G=null,""===o)console.log(chalk.gray(X?" 已取消(未提交)。":" Cancelled (nothing submitted)."));else{const e=d(),n=H>0?Date.now()-H:void 0;Y.push(u(j,e.ctfdUrl||"https://practice.icoa2026.au",{curriculum_id:x.id,card_number:r,feedback_text:o,time_on_card_ms:n}).catch(()=>{})),console.log(chalk.green(X?" ✓ 已收到,谢谢帮助完善这张卡。":" ✓ Thanks — your report was recorded."))}return console.log(),void W()}if(V)return V=!1,ce(),void W();if(r)if("menu"!==r&&"menu confirm"!==r)if("quit"!==r&&"exit"!==r&&"q"!==r){if("status"===r)return P(x,F),void W();if("lang"===r||r.startsWith("lang ")){const e=r.slice(4).trim();if(!e)return console.log(chalk.gray(" 当前语言 / current: ")+chalk.white(d().language||"en")+chalk.gray(" · ")+chalk.bold.green("lang zh")+chalk.gray(" / ")+chalk.bold.green("lang en")),void W();const o=x.cards.some(e=>null!=e._zh),n=e.toLowerCase().startsWith("zh")?"zh":e.toLowerCase(),l="en"===n||"zh"===n&&o,t=l?n:"en";return g({language:t}),l?console.log(chalk.green(" ✓ ")+chalk.gray("语言 / language → ")+chalk.white(t)):console.log(chalk.yellow(" ! ")+chalk.gray(`${e} 本课暂无翻译,已用英文 / not available — using English`)),Z=null,K=null,Q=null,G=null,V=!1,ce(),void W()}if("sim"===r){const e=le(F.currentCard);return e&&"sim_demo"===e.type?(function(e){const r=function(){const e=l(a(import.meta.url)),o=[t(e,"..","..","panda","mujoco-launcher.py"),t(e,"..","..","..","panda","mujoco-launcher.py")];for(const e of o)if(n(e))return e;return null}();if(!r)return console.log(chalk.yellow(" MuJoCo launcher not found.")),console.log(chalk.gray(" Get it from: https://github.com/newaipanda/ICOA_CLI/blob/main/panda/mujoco-launcher.py")),void console.log(chalk.gray(" Or use the sandbox-vla docker image (Phase 3)."));const c={baseline:"baseline",prompt_injected:"prompt_inj",patch_attacked:"patch",modality_confused:"confused"}[e]||"baseline";console.log(chalk.gray(` Launching MuJoCo viewer (scenario: ${c})...`)),console.log(chalk.gray(" Close the window or press ESC to return to learn mode.")),o("python3",[r,c,"--seconds","5"],{stdio:"inherit"}).on("exit",e=>{0!==e?console.log(chalk.yellow(` MuJoCo exited with code ${e} (install: pip install mujoco)`)):console.log(chalk.gray(" Returned from sim."))})}(e.simAction),void W()):(console.log(chalk.gray(" (sim only available on simulation cards)")),void W())}if("bookmark"===r){const e=F.currentCard;return F.bookmarks.includes(e)||F.bookmarks.push(e),y(F),console.log(chalk.gray(` ✓ Card ${e} bookmarked.`)),void W()}if("e"===r)return G=F.currentCard,console.log(chalk.gray(X?" 描述问题(回车提交 / 空行取消):":" Describe the issue (Enter to submit / blank to cancel):")),void W();if("back"===r||"b"===r)return F.currentCard>1&&(F.currentCard-=1),K=null,Q=null,Z=null,y(F),ce(),void W();if(r.startsWith("card ")){const e=r.slice(5).trim(),o=parseInt(e,10);return!Number.isInteger(o)||o<1||o>x.totalCards?(console.log(chalk.yellow(` Card number must be 1..${x.totalCards}. Try: `)+chalk.bold.green("card 1")),void W()):(F.currentCard=o,K=null,Q=null,Z=null,y(F),ce(),void W())}if(null!==Z&&["y","yes","n","no"].includes(r)){const e=le(Z);if(e&&"knowledge"===e.type&&e.check){const o=r.startsWith("y")?"y":"n",n=o===e.check.answer,l=Date.now()-H;h(F,e.number),w(F,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),y(F);const{renderCheckFeedback:t}=await import("../lib/learn-render.js");t(e,o,n,!1);const a=d();if(Y.push(i(j,a.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"check_answered",check_answer:o,check_correct:n,time_on_card_ms:l}).catch(()=>{})),Z=null,e.solution&&e.solution.length>0)return void W();if(F.currentCard<x.totalCards){const e=F.currentCard;F.currentCard+=1,y(F),te(e)?ae():ce(),W()}else T(x,F),W();return}}if(null!==K&&["a","b","c","d"].includes(r)){const e=le(K);if(e&&"mcq"===e.type){const o=r.toUpperCase(),n=o===e.answer;b(F,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),h(F,e.number),y(F),_(e,o,n,F);const l=d();return Y.push(i(j,l.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"mcq_answered",mcq_answer:o,mcq_correct:n}).catch(()=>{})),K=null,void(n?F.currentCard<x.totalCards?(F.currentCard+=1,y(F),ce()):(T(x,F),W()):W())}}if(null!==Q){if("done"===r){const e=le(Q);if(e&&"practical"===e.type)return k(F,e.number),h(F,e.number),y(F),D(e),Q=null,void W()}if("skip"===r)return h(F,Q),y(F),console.log(chalk.gray(" Skipped (counts as not completed).")),console.log(),Q=null,void W()}if("ok"===r||"next"===r||"continue"===r||"n"===r){if(null!==K)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void W();if(null!==Q)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void W();if(null!==Z)return console.log(chalk.yellow(" Please answer the check above (")+chalk.bold.green("y")+chalk.yellow(" or ")+chalk.bold.green("n")+chalk.yellow(").")),void W();const e=F.currentCard;return F.currentCard+=1,y(F),F.currentCard>x.totalCards?T(x,F):te(e)?ae():ce(),void W()}if(null!==Z)return console.log(chalk.yellow(" Please answer the check above (")+chalk.bold.green("y")+chalk.yellow(" or ")+chalk.bold.green("n")+chalk.yellow(").")),void W();if(null!==K)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void W();if(null!==Q)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void W();console.log(chalk.gray(" Unknown command. Try: ")+chalk.white("ok")+chalk.gray(" / ")+chalk.white("status")+chalk.gray(" / ")+chalk.white("card N")+chalk.gray(" / ")+chalk.white("quit")),W()}else if(Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,5e3))]),console.log(),console.log(chalk.gray(" Saved. See you next session.")),console.log(chalk.gray(" Streak: ")+chalk.yellow(`🔥 ${F.streakDays} day(s)`)),console.log(),z){J.removeAllListeners("line");for(const e of B)J.on("line",e);J.prompt(),re()}else J.removeAllListeners("line"),J.close();else if(Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,3e3))]),J.removeAllListeners("line"),z||!ne){const{returnToMainMenu:e}=await import("../lib/menu-nav.js");e(z?J:void 0),re()}else J.close();else W()}),z||J.on("close",async()=>{Y.length>0&&await Promise.race([Promise.allSettled(Y),new Promise(e=>setTimeout(e,5e3))]),ne?re():process.exit(0)}),ce(),W(),await oe}),M.command("learn-pull [id]").description("Pre-download learn curricula to ~/.icoa/learn-cache/ for offline use (default: all)").action(async e=>{const o=e?[e.trim()]:["LEARNDEMO01","AI4CTFDEMO01","CTF4AIDEMO01","ai4ctf-96","ai4ctf-360","ctf4ai-96","ctf4ai-360","ctf4eai-96","ctf4eai-360","embodied-ai-100","embodied-ai-480"];console.log(),console.log(chalk.bold.cyan(" ICOA learn-pull — fetching curricula for offline use")),console.log(chalk.gray(` Server: ${(()=>{try{return JSON.parse(require("node:fs").readFileSync(require("node:path").join(require("node:os").homedir(),".icoa","config.json"),"utf-8")).ctfdUrl||"https://practice.icoa2026.au"}catch{return"https://practice.icoa2026.au"}})()}`)),console.log();let r=0,n=0,l=0;for(const e of o){process.stdout.write(` ${e.padEnd(22)} `);const o=Date.now(),t=await c(e),a=Date.now()-o;if(t){const e=t.cards,o=Array.isArray(e)?e.length:0,n=JSON.stringify(t).length;l+=n,console.log(chalk.green("✓ ")+chalk.gray(`${o.toString().padStart(3)} cards · ${(n/1024).toFixed(1).padStart(6)} KB · ${a.toString().padStart(4)} ms`)),r++}else console.log(chalk.red("✗ failed (server unreachable or unknown id)")),n++}console.log(),console.log(chalk.gray(" Summary: ")+chalk.green.bold(`${r} cached`)+chalk.gray(` · ${n} failed · total ${(l/1024).toFixed(0)} KB`)),console.log(chalk.gray(" Cache: ")+chalk.cyan("~/.icoa/learn-cache/")),console.log()})}
@@ -1 +1 @@
1
- function a0b(a,b){a=a-(-0x15e9+-0x1589+-0xf0c*-0x3);const c=a0a();let d=c[a];if(a0b['guVTHV']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=-0x41*-0x17+-0xd*-0x2f2+-0x1*0x2c21,o,p,q=0x11a1*-0x1+-0x3*-0x4b6+0x37f;p=i['charAt'](q++);~p&&(o=n%(0xd92+0x8*-0x2d2+-0x481*-0x2)?o*(0x15f5+-0x104e+-0x567)+p:p,n++%(-0xf*0x6b+0x902*-0x4+0x2a51))?l+=String['fromCharCode'](0xa33+0x1*0x1c91+0x25c5*-0x1&o>>(-(0x8d2*-0x4+-0x59*-0x52+-0x1c*-0x3e)*n&-0x1fd+0x13f4+0x3*-0x5fb)):-0x22fa+0xab*0x33+0xe9*0x1){p=j['indexOf'](p);}for(let r=-0xe91+-0xe5d*-0x1+-0x1a*-0x2,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](-0x15d5+-0x3*0xa87+-0x25*-0x172))['slice'](-(-0x11*-0x1f3+0x67e*0x6+-0x4815));}return decodeURIComponent(m);};a0b['GkIpxk']=e,a0b['CmNbrK']={},a0b['guVTHV']=!![];}const f=c[-0x6*0x5c+-0x1891+0x1ab9],g=a+f,h=a0b['CmNbrK'][g];return!h?(d=a0b['GkIpxk'](d),a0b['CmNbrK'][g]=d):d=h,d;}(function(a,b){const v=a0b,c=a();while(!![]){try{const d=parseInt(v(0x1d1))/(0x6e3+0x1a*0xd9+0x3*-0x9a4)*(-parseInt(v(0x1d0))/(-0x1598+0xffb+0x59f))+parseInt(v(0x1c6))/(0x217+0x49a*0x1+-0x6ae)+parseInt(v(0x1cd))/(-0x1cde+0x3eb+0x18f7)*(-parseInt(v(0x1bb))/(0x389+-0x349*-0x9+0x1*-0x2115))+parseInt(v(0x1d2))/(-0x2205+0x1*0x7c0+0x1a4b)*(parseInt(v(0x1b7))/(-0x12c5+0x335+0xf97*0x1))+parseInt(v(0x1cf))/(-0x231a*0x1+0x1*0x1682+0xca0)+parseInt(v(0x1c1))/(0x284*-0x1+-0x1*0x92b+0xbb8)*(-parseInt(v(0x1cc))/(0x21ef+0x9e0+-0x2bc5))+parseInt(v(0x1ba))/(0x49d*-0x2+0x1*0x1471+-0xb2c)*(parseInt(v(0x1c8))/(-0x1e5*-0x8+0x1e73+-0x2d8f));if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a0a,-0x784e2+-0xde6b9*0x1+0x1cb5f9));import{getConfig as a0c}from'./config.js';function a0a(){const x=['BgfUz3vHz2u','Bgv2zwW','oJKWotaVyxbPl2LJB2eVzxHHBxmV','AwnVys1JBgK','nJC1ou9jswHMCa','C3rHDhvZ','BwvZC2fNzq','C3rYAw5NAwz5','l2fWAs9Py29Hl2v4yw1ZlW','nty4mdu2qLbit3fk','BgfUzW','mJi4BhjZvuLH','BMv0D29YAYbLCNjVCG','y2f0y2G','DgLTzw91Da','mJGXmeLXr0nisW','nhvvALPOBa','zgf0yq','ntyWmJyXnMLeC1vuuG','mZrHru1Jv3q','nte4ndzTrxb5tMK','mZiYnZiXnfDArhnnvq','C3vJy2vZCW','ANnVBG','zxHHBuLK','Ahr0Chm6lY9WCMfJDgLJzs5Py29HmJaYnI5HDq','yxbWBgLJyxrPB24VANnVBG','AgLUDcbbueKGDw5YzwfJAgfIBgu','B2jQzwn0','n295ALzZAG','y3rMzfvYBa','CxvLC3rPB24','mZaWmdKXy2HwruTb','mtG3odqYmgvVthLgCq','l2HPBNq'];a0a=function(){return x;};return a0a();}export async function requestHint(d){const w=a0b,f=a0c(),g=f[w(0x1b8)]||w(0x1b3),h=d[w(0x1c7)]||f[w(0x1bd)]||'en',j=d['timeoutMs']??-0x14*-0x27d+-0x2*0xfe2+0xd40,k=[g+w(0x1c5)+d[w(0x1b2)]+w(0x1bc),g+w(0x1bf)+d[w(0x1b2)]+w(0x1bc)];let l=null;for(const p of k)try{const q=await fetch(p,{'method':'POST','headers':{'Content-Type':w(0x1b4),'User-Agent':w(0x1c0)},'body':JSON[w(0x1c4)]({'token':d['token'],'question':d[w(0x1b9)],'level':d[w(0x1be)],'lang':h}),'signal':AbortSignal[w(0x1cb)](j)}),r=await q[w(0x1d4)]()[w(0x1ca)](()=>({}));if(!q['ok']||!(0x1b*0x86+0x1c35+-0x2a56)===r[w(0x1d3)]){if(l={'status':q[w(0x1c2)],'message':r?.[w(0x1c3)]||'hint\x20request\x20failed\x20('+q[w(0x1c2)]+')'},q[w(0x1c2)]>=0xd92+0x8*-0x2d2+-0x182*-0x7&&q['status']<0x15f5+-0x104e+-0x3b3)throw l;continue;}return r[w(0x1ce)];}catch(u){if(u&&w(0x1b6)==typeof u&&w(0x1c2)in u)throw u;l={'status':0x0,'message':u?.[w(0x1c3)]||w(0x1c9)};}const m={};m[w(0x1c2)]=0x0,m[w(0x1c3)]=w(0x1b5);throw l||m;}
1
+ (function(a,b){const v=a0b,c=a();while(!![]){try{const d=parseInt(v(0x88))/(0x6*-0x2c9+0x2f*0xad+-0xf0c)*(-parseInt(v(0x8b))/(0x1*0xaaf+0x7fe+-0x12ab))+-parseInt(v(0xa2))/(0x2*-0x6c4+0x1628+-0x89d)*(-parseInt(v(0x94))/(-0xd*0x1a7+0x1*0x975+-0x1*-0xc0a))+parseInt(v(0x8e))/(0xfd0+0x116b+-0x6*0x589)*(parseInt(v(0x99))/(0x18cb+-0x1*0x6fb+0x45*-0x42))+-parseInt(v(0x90))/(-0xfc7+-0x1*0xc1+0x108f)*(-parseInt(v(0x91))/(-0x1b4c+-0x4*0x529+-0xa*-0x4cc))+-parseInt(v(0x8d))/(0x9c2+0x31*0x81+-0x226a)*(parseInt(v(0x93))/(0x29*0x4d+-0x13c9+-0x89*-0xe))+-parseInt(v(0xa7))/(0x2390+0x1a96*-0x1+-0x8ef)+-parseInt(v(0x89))/(0xb51*-0x3+-0x499+0x2698)*(-parseInt(v(0x8a))/(-0x2399+0xcc*0xc+0x1a16));if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a0a,-0x66022+-0x1*0x80271+0xb61f*0x1b));import{getConfig as a0c}from'./config.js';function a0b(a,b){a=a-(-0x74+-0x236+-0x1*-0x332);const c=a0a();let d=c[a];if(a0b['csRsYY']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=-0x3*-0x1a3+0x13df+-0x18c8,o,p,q=0x223+-0x2050+0x1e2d;p=i['charAt'](q++);~p&&(o=n%(0xef1+-0x1a57+-0xb6a*-0x1)?o*(-0x168d+-0x172a*0x1+-0x2df7*-0x1)+p:p,n++%(-0x2550+0x2*-0xa27+-0x1*-0x39a2))?l+=String['fromCharCode'](0x6*-0x2ba+0x1887+0x1b*-0x44&o>>(-(-0xdd*-0x24+-0x12a3+-0x425*0x3)*n&0x3d5*0x6+-0x6fc+0xba*-0x16)):-0x98c+-0x12c1*0x1+0x1c4d){p=j['indexOf'](p);}for(let r=0x186d*-0x1+0xb5f+0xd0e,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](-0x234c+0x24e5+-0x189))['slice'](-(0x5*0xbf+-0x1741+0x1388));}return decodeURIComponent(m);};a0b['yqZOpg']=e,a0b['vBjIaK']={},a0b['csRsYY']=!![];}const f=c[0x25da+0xf5b+-0x3535],g=a+f,h=a0b['vBjIaK'][g];return!h?(d=a0b['yqZOpg'](d),a0b['vBjIaK'][g]=d):d=h,d;}function a0a(){const x=['C3vJy2vZCW','nJy2mJnqDKHvBvC','mJKWmdaWngjRzfr5qq','mtnoALnSzvK','mLj0BNvtAW','Dg9Rzw4','mte5mJvMDLvQBuK','ndvdA1flANK','Bgv2zwW','mta5oxvlB2joDa','mtq0odHICg93z0O','ue9tva','ntuWALv1s2jr','ndu4ng5JwxfYCq','C3rHDhvZ','B2jQzwn0','BMv0D29YAYbLCNjVCG','zgf0yq','oduYmZzAs3rNB2q','AgLUDcbYzxf1zxn0igzHAwXLzcaO','BwvZC2fNzq','zxHHBuLK','y3rMzfvYBa','y2f0y2G','BgfUzW','l2HPBNq','AgLUDcbbueKGDw5YzwfJAgfIBgu','mtC0AgPiqLHT','oJKWotaVyxbPl2LJB2eVzxHHBxmV','CxvLC3rPB24','DgLTzw91De1Z','DgLTzw91Da','mJKXmJa5nNnqCvLAAa'];a0a=function(){return x;};return a0a();}export async function requestHint(d){const w=a0b,f=a0c(),g=f[w(0x9d)]||'https://practice.icoa2026.au',h=d[w(0x9f)]||f['language']||'en',j=d[w(0xa5)]??0xb6d+-0x128d+-0x998*-0x4,k=[g+'/api/icoa/exams/'+d['examId']+w(0xa0),g+w(0xa3)+d[w(0x9c)]+w(0xa0)];let l=null;for(const p of k)try{const q=await fetch(p,{'method':w(0x92),'headers':{'Content-Type':'application/json','User-Agent':'icoa-cli'},'body':JSON['stringify']({'token':d[w(0x8c)],'question':d[w(0xa4)],'level':d[w(0x8f)],'lang':h}),'signal':AbortSignal[w(0xa6)](j)}),r=await q['json']()[w(0x9e)](()=>({}));if(!q['ok']||!(-0xabb+-0xde*0x19+0x206a)===r[w(0xa8)]){if(l={'status':q[w(0x95)],'message':r?.['message']||w(0x9a)+q[w(0x95)]+')'},q['status']>=-0x12fe+0x8e6+0xba8&&q[w(0x95)]<-0x2417+-0x10fc*-0x1+0x150f)throw l;continue;}return r[w(0x98)];}catch(u){if(u&&w(0x96)==typeof u&&w(0x95)in u)throw u;l={'status':0x0,'message':u?.[w(0x9b)]||w(0x97)};}const m={};m[w(0x95)]=0x0,m['message']=w(0xa1);throw l||m;}
@@ -22,6 +22,7 @@ export type CardKnowledge = {
22
22
  statement: string;
23
23
  answer: 'y' | 'n';
24
24
  };
25
+ solution?: string[];
25
26
  key_point?: string;
26
27
  chart_ids?: string[];
27
28
  _zh?: {
@@ -30,6 +31,7 @@ export type CardKnowledge = {
30
31
  icoaConnection?: string;
31
32
  checkStatement?: string;
32
33
  key_point?: string;
34
+ solution?: string[];
33
35
  };
34
36
  };
35
37
  export type CardMCQ = {
@@ -1 +1 @@
1
- const t={ai4ctf:"AI4CTFDEMO01",ctf4ai:"CTF4AIDEMO01",ctf4eai:"LEARNDEMO01","ai4ctf-12":"AI4CTFDEMO01","ctf4ai-12":"CTF4AIDEMO01","ctf4eai-12":"LEARNDEMO01",ctf4vla:"LEARNDEMO01",vla:"LEARNDEMO01",embodied:"LEARNDEMO01",ai4ctfdemo:"AI4CTFDEMO01",ctf4aidemo:"CTF4AIDEMO01",learndemo:"LEARNDEMO01"},e={1:"AI4CTFDEMO01",2:"CTF4AIDEMO01",3:"LEARNDEMO01"},o=/^(AC|CA|EA|EI|IO|IA)[A-Z0-9]{6,}$/,n=/^(AI4CTFDEMO\d+|CTF4AIDEMO\d+|LEARNDEMO\d+)$/;export function resolveLearnInput(i){const r=i.trim();if(!r)return{kind:"back"};let a=r.replace(/^\s*(?:[/>])?\s*(?:icoa\s+)?learn\s+/i,"").trim();if(!a)return{kind:"ambiguous",hint:"Type just the token (e.g. LEARNDEMO01) or one of: ai4ctf / ctf4ai / ctf4eai"};if(e[a])return{kind:"token",token:e[a]};const c=a.toLowerCase();if(t[c])return{kind:"token",token:t[c]};if("demo"===c||"demos"===c)return{kind:"ambiguous",hint:"Which demo? Type: 1 (ai4ctf) / 2 (ctf4ai) / 3 (ctf4eai)"};if(/\s/.test(a))return{kind:"unknown",hint:`Don't recognize "${r}". Try one of: ai4ctf / ctf4ai / ctf4eai (for the free demos), 1/2/3, or paste your AC/CA/EA/EI/IO/IA + 8 chars cohort token. Blank to go back.`};const f=a.toUpperCase();return n.test(f)||o.test(f)||/^[A-Z0-9]{8,}$/.test(f)?{kind:"token",token:f}:{kind:"unknown",hint:`Don't recognize "${r}". Try one of: ai4ctf / ctf4ai / ctf4eai (for the free demos), 1/2/3, or paste your AC/CA/EA/EI/IO/IA + 8 chars cohort token. Blank to go back.`}}
1
+ const t={ai4ctf:"AI4CTFDEMO01",ctf4ai:"CTF4AIDEMO01",ctf4eai:"LEARNDEMO01","ai4ctf-12":"AI4CTFDEMO01","ctf4ai-12":"CTF4AIDEMO01","ctf4eai-12":"LEARNDEMO01",ctf4vla:"LEARNDEMO01",vla:"LEARNDEMO01",embodied:"LEARNDEMO01",ai4ctfdemo:"AI4CTFDEMO01",ctf4aidemo:"CTF4AIDEMO01",learndemo:"LEARNDEMO01"},e={1:"AI4CTFDEMO01",2:"CTF4AIDEMO01",3:"LEARNDEMO01"},o=/^[A-Z]{2}[A-Z0-9]{6,}$/,n=/^(AI4CTFDEMO\d+|CTF4AIDEMO\d+|LEARNDEMO\d+)$/;export function resolveLearnInput(i){const r=i.trim();if(!r)return{kind:"back"};let a=r.replace(/^\s*(?:[/>])?\s*(?:icoa\s+)?learn\s+/i,"").trim();if(!a)return{kind:"ambiguous",hint:"Type just the token (e.g. LEARNDEMO01) or one of: ai4ctf / ctf4ai / ctf4eai"};if(e[a])return{kind:"token",token:e[a]};const c=a.toLowerCase();if(t[c])return{kind:"token",token:t[c]};if("demo"===c||"demos"===c)return{kind:"ambiguous",hint:"Which demo? Type: 1 (ai4ctf) / 2 (ctf4ai) / 3 (ctf4eai)"};if(/\s/.test(a))return{kind:"unknown",hint:`Don't recognize "${r}". Try one of: ai4ctf / ctf4ai / ctf4eai (for the free demos), 1/2/3, or paste your AC/CA/EA/EI/IO/IA + 8 chars cohort token. Blank to go back.`};const f=a.toUpperCase();return n.test(f)||o.test(f)||/^[A-Z0-9]{8,}$/.test(f)?{kind:"token",token:f}:{kind:"unknown",hint:`Don't recognize "${r}". Try one of: ai4ctf / ctf4ai / ctf4eai (for the free demos), 1/2/3, or paste your AC/CA/EA/EI/IO/IA + 8 chars cohort token. Blank to go back.`}}
@@ -1 +1 @@
1
- import chalk from"chalk";import o from"string-width";import{localized as e}from"./learn-curricula.js";import{t as n}from"./learn-i18n.js";import{getConfig as l}from"./config.js";import{icoaBannerLines as t}from"./banner.js";import{renderCharts as r,detectCaps as c}from"./render-card.js";function s(){return(l().language||"en").toLowerCase()}const a=64;function g(o="─"){return o.repeat(66)}function i(o,e,n=20){const l=e>0?o/e:0,t=Math.floor(l*n),r=n-t;return`${chalk.green("█".repeat(t))+chalk.gray("░".repeat(r))} ${(100*l).toFixed(1)}%`}function d(o){return o>=30?chalk.red("🔥🔥🔥 "+o+" days"):o>=7?chalk.yellow("🔥 "+o+" days"):o>=1?chalk.gray("· "+o+" day"+(o>1?"s":"")):chalk.gray("—")}export function renderWelcome(o,e,l){const t=s(),r=e.cardsCompleted.length,c=o.totalCards,a=c-r,y=o.modules.find(o=>e.currentCard>=o.cardRange[0]&&e.currentCard<=o.cardRange[1]);if(console.log(),console.log(chalk.cyan(" ╭"+g("═"))),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ║ ")+chalk.bold.white(" "+n("academy_title",t))),console.log(chalk.cyan(" ║")),l)console.log(chalk.cyan(" ║ ")+chalk.white(" "+n("welcome_new_demo",t)));else{const o=new Date(e.lastSeenAt),l=Math.floor((Date.now()-o.getTime())/36e5),r=l<1?n("just_now",t):l<24?`${l}${n("ago_hours",t)}`:`${Math.floor(l/24)}${n("ago_days",t)}`;console.log(chalk.cyan(" ║ ")+chalk.white(` ${n("welcome_back",t)} ${r}`))}console.log(chalk.cyan(" ║"));const u=y?`${y.number}. ${y.name}`:"—";console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("module",t).padEnd(11))+chalk.white(u)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("progress",t).padEnd(11))+i(r,c)+chalk.gray(` (${r}/${c})`)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("streak",t).padEnd(11))+d(e.streakDays)),a>0&&e.currentCard<=c&&console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("next_card",t).padEnd(11))+chalk.white(`#${e.currentCard} ${n("of",t)} ${c}`)),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ╰"+g("═"))),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const h=0===r?n("continue_start",t):`${n("continue_resume",t)} ${e.currentCard}`;console.log(chalk.bold.green(" continue")+chalk.gray(" "+h)),console.log(chalk.yellow(" status")+chalk.gray(" "+n("status_full",t))),e.bookmarks.length>0&&console.log(chalk.yellow(" bookmarks")+chalk.gray(` ${e.bookmarks.length} ${n("bookmarks_desc",t)}`)),console.log(chalk.gray(" quit")+chalk.gray(" "+n("quit_desc",t))),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log()}function y(o,e){const l=s(),t=o.module,r=e.modules.find(o=>o.number===t),c=r?r.name:n("unknown_module",l),g=n("module",l).replace(":","").trim(),i=`${n("card",l)} ${o.number} / ${e.totalCards} · ${g} ${t} · ${c}`;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(i)+" "+chalk.cyan("─".repeat(Math.max(0,a-i.length-4))))}function u(){console.log(chalk.cyan(" ╰"+g())),console.log()}function h(o){console.log(chalk.cyan(" │ ")+chalk.white(o))}function m(){console.log(chalk.cyan(" │"))}const f=/[┌┐└┘├┤┬┴┼─│╔╗╚╝═║╠╣╦╩╬▓▒░█]/;function b(o){return/^(?: {4}|\t)/.test(o)||f.test(o)||/ {3,}/.test(o)}function p(e,n){const l=[];let t="",r=0,c=!1;for(const s of function(e){const n=[],l=e=>{let l="";const t=()=>{l&&(n.push({t:"atom",s:l}),l="")};for(const r of e)" "===r?(t(),n.push({t:"space"})):2===o(r)?(t(),n.push({t:"wide",s:r})):l+=r;t()},t=/`[^`]*`/g;let r,c=0;for(;null!==(r=t.exec(e));)l(e.slice(c,r.index)),n.push({t:"code",s:r[0]}),c=r.index+r[0].length;return l(e.slice(c)),n}(e)){if("space"===s.t){""!==t&&(c=!0);continue}const e=s.s,a=o("code"===s.t?e.replace(/`/g,""):e),g=c?1:0,i="atom"===s.t&&e.length<=2&&/^[.,;:!?)\]}…'"]+$/.test(e);""!==t&&!i&&r+g+a>n?(l.push(t),t=e,r=a,c=!1):(c&&(t+=" ",r+=1,c=!1),t+=e,r+=a)}return t&&l.push(t),l}const w=/\b(?:Common bug|Common mistake|Common error|Pitfall|Gotcha|Footgun)\b[::]?|\b(?:Warning|Caution)\b[::]|(?:常见错误|常见陷阱|常见误区|陷阱|注意|警告|误区)[::]/gi;function _(o,e){const n=e?chalk.bold.white:chalk.white;let l,t="",r=0;for(w.lastIndex=0;null!==(l=w.exec(o));)l.index>r&&(t+=n(o.slice(r,l.index))),t+=chalk.bold.yellow(l[0]),r=l.index+l[0].length;return r<o.length&&(t+=n(o.slice(r))),t}function $(o,e=!1){let n="",l=0;const t=/`([^`]*)`/g;let r;for(;null!==(r=t.exec(o));)r.index>l&&(n+=_(o.slice(l,r.index),e)),n+=chalk.cyan(r[1]),l=r.index+r[0].length;return l<o.length&&(n+=_(o.slice(l),e)),n}function k(o,e=!1){let n=!1;for(const l of o.split("\n"))if(/^\s*```/.test(l))n=!n;else if(n)console.log(chalk.cyan(" │ ")+chalk.cyan(` ${l}`));else if(""!==l)if(b(l))console.log(chalk.cyan(" │ ")+chalk.white(l));else for(const o of p(l,60))console.log(chalk.cyan(" │ ")+` ${$(o,e)}`);else m()}function C(o,e){const n=[];for(const l of o.split("\n")){if(""===l){n.push("");continue}if(b(l)){n.push(l);continue}let o="";for(const t of l.split(" "))(o+" "+t).trim().length>e?(n.push(o.trim()),o=t):o=(o+" "+t).trim();o&&n.push(o)}return n}export function renderKnowledgeCard(l,t){const g=s(),i=e(l,g);y(i,t),m();const d=p(i.title,60);for(const o of d)h(chalk.bold.yellow(o));h(chalk.gray("─".repeat(Math.min(Math.max(...d.map(e=>o(e))),a))));const f=!!(l.chart_ids&&l.chart_ids.length>0);if(f&&r(l.chart_ids.slice(0,1),t.charts,c()),i.key_point&&""!==i.key_point.trim()?(f||m(),function(o,e,n){const l=s().startsWith("zh"),t=c().cols,r="-".repeat(Math.min(a,Math.max(24,t-6))),g=l?"要点":"KEY POINT",i=l?`第 ${e} / ${n} 张`:`Card ${e} / ${n}`;console.log(chalk.cyan(" │ ")+chalk.green(r)),console.log(chalk.cyan(" │ ")+chalk.green(`${g} · ${i}`));for(const e of p(o,60))console.log(chalk.cyan(" │ ")+chalk.bold.green(" "+e));console.log(chalk.cyan(" │ ")+chalk.green(r)),m()}(i.key_point,i.number,t.totalCards)):f||m(),i.body.filter(o=>null!=o&&""!==o.trim()).forEach((o,e)=>{const n=0===e?o.match(/^([\s\S]*?(?:[.!?](?=\s|$)|[。!?]))(\s[\s\S]*)?$/):null;if(n&&n[1].trim().length<=180){k(n[1],!0);const o=n[2]?.trimStart();o&&k(o,!1)}else k(o,!1);m()}),i.icoaConnection){h(chalk.magenta(" "+n("icoa_connection",g))),h(chalk.gray(" "+"─".repeat(20)));for(const o of p(i.icoaConnection,60))h(" "+chalk.magenta(o));m()}if(l.check){const o=g.startsWith("zh"),e=l._zh?.checkStatement??l._zh?.check?.statement,n=o?e??l.check.statement:l.check.statement;h(chalk.cyan(" 🤔 "+(o?"请回答 (输 y 或 n):":"Quick comprehension check (type y or n):"))),h(chalk.gray(" "+"─".repeat(20)));for(const o of p(n,60))h(" "+chalk.white(o));m()}u(),function(o,e){const n=s().startsWith("zh"),l=c().cols,t="-".repeat(Math.min(a,Math.max(24,l-6))),r=chalk.gray(" "),g=[];o.check?(g.push(chalk.bold.green("[y]")+chalk.gray(n?" 是":" yes")),g.push(chalk.bold.green("[n]")+chalk.gray(n?" 否":" no"))):g.push(chalk.bold.green("[ok]")+chalk.gray(n?" 继续":" next")),g.push(chalk.bold.yellow("[e]")+chalk.gray(n?" 报告问题":" report")),g.push(chalk.bold.cyan("[b]")+chalk.gray(n?" 上一张":" back")),g.push(chalk.bold.cyan("[card N]")+chalk.gray(n?" 跳转":" jump")),g.push(chalk.gray("[quit]")+chalk.gray(n?" 退出":" quit")),console.log(chalk.gray(" "+t)),console.log(chalk.gray(" "+(n?`第 ${o.number} / ${e.totalCards} 张`:`Card ${o.number} / ${e.totalCards}`))),console.log(" "+g.join(r)),console.log(chalk.gray(" "+t)),console.log(chalk.gray(" "+(n?"e = 报告本卡错误,不算作答;提交后回到本题继续":"e = report a problem with this card (not an answer); you return here after"))),console.log(chalk.gray(" "+(n?"更多: bookmark · status · lang zh/en":"more: bookmark · status · lang zh/en"))),console.log()}(l,t)}export function renderCheckFeedback(o,e,n,l=!1){const t=s().startsWith("zh");if(console.log(),n)console.log(chalk.green(" ✓ ")+chalk.white(t?"答对了。":"Correct."));else if(console.log(chalk.yellow(" ✗ ")+chalk.white(t?"记下了,继续。":"Noted — moving on.")),l){const e="y"===o.check?.answer?t?"是":"Yes":t?"否":"No";console.log(chalk.gray(" "+(t?"正确答案: ":"Answer: ")+e+". "+(t?"回看上面那段。":"Re-read the paragraph above.")))}console.log()}function x(o){return[chalk.white(" "+(o?"编著:Charlie Zhu":"Created & edited by Charlie Zhu")),chalk.gray(" "+(o?"ICOA 2026 创始人 · 课程总架构师":"Founder & Chief Curriculum Architect · ICOA 2026"))]}export function renderPhaseComplete(o,e,n,l){const r=s().startsWith("zh"),[c,a]=n.cardRange,g=e.checkResults||{};let i=0,d=0;for(let o=c;o<=a;o++){const e=g[String(o)];e&&(i++,e.correct&&d++)}const y="-".repeat(48);console.log();for(const o of t(" "))console.log(o);console.log(),console.log(chalk.bold.yellow(" "+y)),console.log(chalk.bold.yellow(" "+(r?`阶段 ${n.number} 完成`:`Phase ${n.number} complete`))+chalk.gray(" · ")+chalk.white(n.name));const u=i>0&&d===i?chalk.bold.green:chalk.bold.white;console.log(chalk.gray(" "+(r?"理解检查得分: ":"comprehension score: "))+u(`${d}/${i}`)+chalk.gray(0===i?r?" (本阶段未作答 y/n)":" (no y/n answered)":"")),l&&console.log(chalk.gray(" "+(r?"下一阶段: ":"next: "))+chalk.bold.cyan(r?`阶段 ${l.number}`:`Phase ${l.number}`)+chalk.gray(" · ")+chalk.white(l.name)),console.log(chalk.bold.yellow(" "+y));for(const o of x(r))console.log(o)}export function renderCurriculumComplete(o,e){const n=s().startsWith("zh"),l=e.checkResults||{},r="-".repeat(48);let c=0,a=0;console.log();for(const o of t(" "))console.log(o);console.log(),console.log(chalk.bold.green(" "+r)),console.log(chalk.bold.green(" 🏆 "+(n?`${o.name} — 全部完成!`:`${o.name} — complete!`))),console.log(chalk.bold.green(" "+r));for(const e of o.modules){const[o,t]=e.cardRange;let r=0,s=0;for(let e=o;e<=t;e++){const o=l[String(e)];o&&(r++,o.correct&&s++)}c+=r,a+=s;const g=r>0&&s===r?chalk.green:chalk.white;console.log(chalk.gray(" "+(n?`阶段 ${e.number}`:`Phase ${e.number}`).padEnd(8))+g(`${s}/${r}`.padEnd(7))+chalk.gray(e.name))}console.log(chalk.bold.green(" "+r)),console.log(chalk.bold.green(" "+(n?"总分 / overall: ":"Overall: "))+chalk.bold.white(`${a}/${c}`)),console.log(chalk.bold.green(" "+r));for(const o of x(n))console.log(o);console.log()}export function renderMCQCard(o,l){const t=s(),r=e(o,t);y(r,l),m(),h(chalk.bold.yellow("🎯 "+r.title)),h(chalk.gray("─".repeat(Math.min(r.title.length+4,a)))),m();for(const o of C(r.question,60))h(" "+o);m();for(const o of["A","B","C","D"])h(chalk.cyan(` ${o}.`)+" "+chalk.white(r.options[o]));m(),u(),console.log(chalk.gray(" "+(t.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",t))),console.log()}export function renderMCQFeedback(o,l,t,r){const c=s(),a=e(o,c);console.log(),t?console.log(" "+chalk.bold.green(n("correct",c)+" ")+chalk.gray(`${n("one_point",c)} · ${l} = ${a.options[l]}`)):console.log(" "+chalk.bold.red(n("not_quite",c)+" ")+chalk.gray(`${n("you_chose",c)} ${l}; ${n("answer_is",c)} ${a.answer}.`)),console.log(),console.log(chalk.gray(" "+n("explanation",c)));for(const o of C(a.explanation,60))console.log(chalk.gray(" "+o));const g=Object.values(r.mcqResults),i=g.filter(o=>o.correct).length;console.log(),console.log(chalk.gray(" "+n("mcq_accuracy_so_far",c)+" ")+chalk.white(`${i}/${g.length}`)),console.log(),t||(console.log(chalk.gray(" "+n("press_ok_continue",c)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",c))),console.log())}export function renderPracticalCard(o,l){const t=s(),r=e(o,t);y(r,l),m(),h(chalk.bold.yellow("🛠 "+r.title)),h(chalk.gray("─".repeat(Math.min(r.title.length+4,a)))),m();for(const o of C(r.task,60))h(" "+o);if(r.starterCode){m(),h(chalk.gray(" "+n("starter_code",t))),m();for(const o of r.starterCode.split("\n"))h(" "+chalk.cyan(o))}m(),u(),console.log(chalk.gray(" "+n("try_in_sandbox",t)+" ")+chalk.bold.cyan("!python3")+chalk.gray(" "+n("drops_into_python",t))),console.log(chalk.gray(" "+n("when_done",t))),console.log(chalk.gray(" ")+chalk.bold.green("done")+chalk.gray(" "+n("done_desc",t))),console.log(chalk.gray(" ")+chalk.bold.yellow("skip")+chalk.gray(" "+n("skip_desc",t))),console.log(chalk.gray(" card N jump to a card by number")),console.log()}export function renderPracticalSuccess(o){const l=s(),t=e(o,l);console.log(),console.log(" "+chalk.bold.green(n("practical_recorded",l))),console.log(),console.log(chalk.gray(" "+n("reference_answer",l)));for(const o of C(t.successHint,60))console.log(chalk.gray(" "+o));console.log(),console.log(chalk.gray(" "+n("press_ok_continue",l)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",l))),console.log()}export function renderSimDemoCard(o,l){const t=s(),r=e(o,t);y(r,l),m(),h(chalk.bold.yellow("🎬 "+r.title)),m();for(const o of C(r.description,60))h(" "+o);m(),h(chalk.gray(" "+n("sim_requires",t))),m(),u(),console.log(chalk.gray(" ")+chalk.bold.cyan("sim")+chalk.gray(" "+n("sim_launch_desc",t))),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",t))),console.log(chalk.gray(" bookmark "+n("bookmark_desc",t))),console.log(chalk.gray(" back "+n("back_desc",t))),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",t))),console.log()}export function renderMilestone(o,l){const t=s(),r=e(o,t),c=o.number===l.totalCards;console.log(),console.log(chalk.bold.yellow(" ╭"+g("═"))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+chalk.white(" "+n("milestone_header",t))),console.log(chalk.bold.yellow(" ║"));const a=` ${r.badge} ${r.emoji}`;console.log(chalk.bold.yellow(" ║ ")+chalk.bold.green(a)),console.log(chalk.bold.yellow(" ║ ")+chalk.gray(" ─".repeat(Math.max(1,Math.floor(r.badge.length/2+2))))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("in_wild_corresponds",t)));for(const o of C(r.realWorldLevel,60))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("whats_next",t)));for(const o of C(r.unlockedNext,60))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ╰"+g("═"))),console.log(),c?(console.log(chalk.gray(" "+n("demo_complete",t))),console.log(),console.log(chalk.gray(" "+n("unlock_full",t)+" ")+chalk.white(n("curriculum_name",t))+chalk.gray(",")),console.log(chalk.gray(" "+n("contact_team_leader",t)+" ")+chalk.bold.yellow("EA")+chalk.gray(" "+n("learn_token",t))),console.log(chalk.gray(" "+n("or_email",t)+" ")+chalk.cyan("asra@icoa2026.au")+chalk.gray(" "+n("for_partnership",t))),console.log(),console.log(chalk.gray(" "+n("type_quit",t)+" ")+chalk.bold.green("quit")+chalk.gray(" "+n("to_exit",t)+" ")+chalk.bold.green("status")+chalk.gray(" "+n("for_dashboard",t)))):(console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",t))),console.log(chalk.gray(" status "+n("status_full",t))),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",t)))),console.log()}export function renderStatus(o,e){const l=s(),t=e.cardsCompleted.length,r=o.totalCards,c=Object.values(e.mcqResults),a=c.filter(o=>o.correct).length;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(n("status_title",l))+" "+chalk.cyan("─".repeat(25))),m(),h(" "+chalk.gray(n("total_progress",l)+" ")+i(t,r)+chalk.gray(` (${t}/${r})`)),h(" "+chalk.gray(n("streak",l)+" ")+d(e.streakDays)+chalk.gray(` (${n("longest",l)} ${e.longestStreak})`)),h(" "+chalk.gray(n("mcq_accuracy",l)+" ")+chalk.white(`${a}/${c.length}`)),h(" "+chalk.gray(n("practicals_done",l)+" ")+chalk.white(`${e.practicalsCompleted.length}`)),h(" "+chalk.gray(n("bookmarked",l)+" ")+chalk.white(`${e.bookmarks.length}`)),m();const g=n("module",l).replace(":","").trim();for(const n of o.modules){const[o,l]=n.cardRange,t=e.cardsCompleted.filter(e=>e>=o&&e<=l).length,r=l-o+1;h(" "+(t===r?chalk.green("✓"):t>0?chalk.yellow("▶"):chalk.gray("□"))+" "+chalk.gray(`${g} ${n.number}: `)+chalk.white(`${t}/${r}`)+chalk.gray(" "+n.name))}if(m(),e.achievements.length>0){h(" "+chalk.gray(n("achievements",l)));for(const o of e.achievements)h(" "+chalk.bold.yellow("★ ")+chalk.white(o))}else h(" "+chalk.gray(n("achievements_none",l)));m(),u()}
1
+ import chalk from"chalk";import o from"string-width";import{localized as e}from"./learn-curricula.js";import{t as n}from"./learn-i18n.js";import{getConfig as l}from"./config.js";import{icoaBannerLines as t}from"./banner.js";import{renderCharts as r,detectCaps as c}from"./render-card.js";function s(){return(l().language||"en").toLowerCase()}const a=64;function g(o="─"){return o.repeat(66)}function i(o,e,n=20){const l=e>0?o/e:0,t=Math.floor(l*n),r=n-t;return`${chalk.green("█".repeat(t))+chalk.gray("░".repeat(r))} ${(100*l).toFixed(1)}%`}function d(o){return o>=30?chalk.red("🔥🔥🔥 "+o+" days"):o>=7?chalk.yellow("🔥 "+o+" days"):o>=1?chalk.gray("· "+o+" day"+(o>1?"s":"")):chalk.gray("—")}export function renderWelcome(o,e,l){const t=s(),r=e.cardsCompleted.length,c=o.totalCards,a=c-r,y=o.modules.find(o=>e.currentCard>=o.cardRange[0]&&e.currentCard<=o.cardRange[1]);if(console.log(),console.log(chalk.cyan(" ╭"+g("═"))),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ║ ")+chalk.bold.white(" "+n("academy_title",t))),console.log(chalk.cyan(" ║")),l)console.log(chalk.cyan(" ║ ")+chalk.white(" "+n("welcome_new_demo",t)));else{const o=new Date(e.lastSeenAt),l=Math.floor((Date.now()-o.getTime())/36e5),r=l<1?n("just_now",t):l<24?`${l}${n("ago_hours",t)}`:`${Math.floor(l/24)}${n("ago_days",t)}`;console.log(chalk.cyan(" ║ ")+chalk.white(` ${n("welcome_back",t)} ${r}`))}console.log(chalk.cyan(" ║"));const u=y?`${y.number}. ${y.name}`:"—";console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("module",t).padEnd(11))+chalk.white(u)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("progress",t).padEnd(11))+i(r,c)+chalk.gray(` (${r}/${c})`)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("streak",t).padEnd(11))+d(e.streakDays)),a>0&&e.currentCard<=c&&console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("next_card",t).padEnd(11))+chalk.white(`#${e.currentCard} ${n("of",t)} ${c}`)),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ╰"+g("═"))),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const h=0===r?n("continue_start",t):`${n("continue_resume",t)} ${e.currentCard}`;console.log(chalk.bold.green(" continue")+chalk.gray(" "+h)),console.log(chalk.yellow(" status")+chalk.gray(" "+n("status_full",t))),e.bookmarks.length>0&&console.log(chalk.yellow(" bookmarks")+chalk.gray(` ${e.bookmarks.length} ${n("bookmarks_desc",t)}`)),console.log(chalk.gray(" quit")+chalk.gray(" "+n("quit_desc",t))),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log()}function y(o,e){const l=s(),t=o.module,r=e.modules.find(o=>o.number===t),c=r?r.name:n("unknown_module",l),g=n("module",l).replace(":","").trim(),i=`${n("card",l)} ${o.number} / ${e.totalCards} · ${g} ${t} · ${c}`;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(i)+" "+chalk.cyan("─".repeat(Math.max(0,a-i.length-4))))}function u(){console.log(chalk.cyan(" ╰"+g())),console.log()}function h(o){console.log(chalk.cyan(" │ ")+chalk.white(o))}function m(){console.log(chalk.cyan(" │"))}const f=/[┌┐└┘├┤┬┴┼─│╔╗╚╝═║╠╣╦╩╬▓▒░█]/;function b(o){return/^(?: {4}|\t)/.test(o)||f.test(o)||/ {3,}/.test(o)}function p(e,n){const l=[];let t="",r=0,c=!1;for(const s of function(e){const n=[],l=e=>{let l="";const t=()=>{l&&(n.push({t:"atom",s:l}),l="")};for(const r of e)" "===r?(t(),n.push({t:"space"})):2===o(r)?(t(),n.push({t:"wide",s:r})):l+=r;t()},t=/`[^`]*`/g;let r,c=0;for(;null!==(r=t.exec(e));)l(e.slice(c,r.index)),n.push({t:"code",s:r[0]}),c=r.index+r[0].length;return l(e.slice(c)),n}(e)){if("space"===s.t){""!==t&&(c=!0);continue}const e=s.s,a=o("code"===s.t?e.replace(/`/g,""):e),g=c?1:0,i="atom"===s.t&&e.length<=2&&/^[.,;:!?)\]}…'"]+$/.test(e);""!==t&&!i&&r+g+a>n?(l.push(t),t=e,r=a,c=!1):(c&&(t+=" ",r+=1,c=!1),t+=e,r+=a)}return t&&l.push(t),l}const w=/\b(?:Common bug|Common mistake|Common error|Pitfall|Gotcha|Footgun)\b[::]?|\b(?:Warning|Caution)\b[::]|(?:常见错误|常见陷阱|常见误区|陷阱|注意|警告|误区)[::]/gi;function _(o,e){const n=e?chalk.bold.white:chalk.white;let l,t="",r=0;for(w.lastIndex=0;null!==(l=w.exec(o));)l.index>r&&(t+=n(o.slice(r,l.index))),t+=chalk.bold.yellow(l[0]),r=l.index+l[0].length;return r<o.length&&(t+=n(o.slice(r))),t}function $(o,e=!1){let n="",l=0;const t=/`([^`]*)`/g;let r;for(;null!==(r=t.exec(o));)r.index>l&&(n+=_(o.slice(l,r.index),e)),n+=chalk.cyan(r[1]),l=r.index+r[0].length;return l<o.length&&(n+=_(o.slice(l),e)),n}function k(o,e=!1){let n=!1;for(const l of o.split("\n"))if(/^\s*```/.test(l))n=!n;else if(n)console.log(chalk.cyan(" │ ")+chalk.cyan(` ${l}`));else if(""!==l)if(b(l))console.log(chalk.cyan(" │ ")+chalk.white(l));else for(const o of p(l,60))console.log(chalk.cyan(" │ ")+` ${$(o,e)}`);else m()}function C(o,e){const n=[];for(const l of o.split("\n")){if(""===l){n.push("");continue}if(b(l)){n.push(l);continue}let o="";for(const t of l.split(" "))(o+" "+t).trim().length>e?(n.push(o.trim()),o=t):o=(o+" "+t).trim();o&&n.push(o)}return n}export function renderKnowledgeCard(l,t){const g=s(),i=e(l,g);y(i,t),m();const d=p(i.title,60);for(const o of d)h(chalk.bold.yellow(o));h(chalk.gray("─".repeat(Math.min(Math.max(...d.map(e=>o(e))),a))));const f=!!(l.chart_ids&&l.chart_ids.length>0);if(f&&r(l.chart_ids.slice(0,1),t.charts,c()),i.key_point&&""!==i.key_point.trim()?(f||m(),function(o,e,n){const l=s().startsWith("zh"),t=c().cols,r="-".repeat(Math.min(a,Math.max(24,t-6))),g=l?"要点":"KEY POINT",i=l?`第 ${e} / ${n} 张`:`Card ${e} / ${n}`;console.log(chalk.cyan(" │ ")+chalk.green(r)),console.log(chalk.cyan(" │ ")+chalk.green(`${g} · ${i}`));for(const e of p(o,60))console.log(chalk.cyan(" │ ")+chalk.bold.green(" "+e));console.log(chalk.cyan(" │ ")+chalk.green(r)),m()}(i.key_point,i.number,t.totalCards)):f||m(),i.body.filter(o=>null!=o&&""!==o.trim()).forEach((o,e)=>{const n=0===e?o.match(/^([\s\S]*?(?:[.!?](?=\s|$)|[。!?]))(\s[\s\S]*)?$/):null;if(n&&n[1].trim().length<=180){k(n[1],!0);const o=n[2]?.trimStart();o&&k(o,!1)}else k(o,!1);m()}),i.icoaConnection){h(chalk.magenta(" "+n("icoa_connection",g))),h(chalk.gray(" "+"─".repeat(20)));for(const o of p(i.icoaConnection,60))h(" "+chalk.magenta(o));m()}if(l.check){const o=g.startsWith("zh"),e=l._zh?.checkStatement??l._zh?.check?.statement,n=o?e??l.check.statement:l.check.statement;h(chalk.cyan(" 🤔 "+(o?"请回答 (输 y 或 n):":"Quick comprehension check (type y or n):"))),h(chalk.gray(" "+"─".repeat(20)));for(const o of p(n,60))h(" "+chalk.white(o));m()}u(),function(o,e){const n=s().startsWith("zh"),l=c().cols,t="-".repeat(Math.min(a,Math.max(24,l-6))),r=chalk.gray(" "),g=[];o.check?(g.push(chalk.bold.green("[y]")+chalk.gray(n?" 是":" yes")),g.push(chalk.bold.green("[n]")+chalk.gray(n?" 否":" no"))):g.push(chalk.bold.green("[ok]")+chalk.gray(n?" 继续":" next")),g.push(chalk.bold.yellow("[e]")+chalk.gray(n?" 报告问题":" report")),g.push(chalk.bold.cyan("[b]")+chalk.gray(n?" 上一张":" back")),g.push(chalk.bold.cyan("[card N]")+chalk.gray(n?" 跳转":" jump")),g.push(chalk.gray("[quit]")+chalk.gray(n?" 退出":" quit")),console.log(chalk.gray(" "+t)),console.log(chalk.gray(" "+(n?`第 ${o.number} / ${e.totalCards} 张`:`Card ${o.number} / ${e.totalCards}`))),console.log(" "+g.join(r)),console.log(chalk.gray(" "+t)),console.log(chalk.gray(" "+(n?"e = 报告本卡错误,不算作答;提交后回到本题继续":"e = report a problem with this card (not an answer); you return here after"))),console.log(chalk.gray(" "+(n?"更多: bookmark · status · lang zh/en":"more: bookmark · status · lang zh/en"))),console.log()}(l,t)}export function renderCheckFeedback(o,e,n,l=!1){const t=s().startsWith("zh");if(console.log(),n)console.log(chalk.green(" ✓ ")+chalk.white(t?"答对了。":"Correct."));else if(console.log(chalk.yellow(" ✗ ")+chalk.white(t?"记下了,继续。":"Noted — moving on.")),l){const e="y"===o.check?.answer?t?"是":"Yes":t?"否":"No";console.log(chalk.gray(" "+(t?"正确答案: ":"Answer: ")+e+". "+(t?"回看上面那段。":"Re-read the paragraph above.")))}const r=t?o._zh?.solution??o.solution:o.solution;if(r&&r.length>0){console.log(),console.log(chalk.cyan(" 📝 "+(t?"解答:":"Worked solution:")));for(const o of r){for(const e of p(o,60))console.log(chalk.white(" "+e));console.log()}}console.log()}function x(o){return[chalk.white(" "+(o?"编著:Charlie Zhu":"Created & edited by Charlie Zhu")),chalk.gray(" "+(o?"ICOA 2026 创始人 · 课程总架构师":"Founder & Chief Curriculum Architect · ICOA 2026"))]}export function renderPhaseComplete(o,e,n,l){const r=s().startsWith("zh"),[c,a]=n.cardRange,g=e.checkResults||{};let i=0,d=0;for(let o=c;o<=a;o++){const e=g[String(o)];e&&(i++,e.correct&&d++)}const y="-".repeat(48);console.log();for(const o of t(" "))console.log(o);console.log(),console.log(chalk.bold.yellow(" "+y)),console.log(chalk.bold.yellow(" "+(r?`阶段 ${n.number} 完成`:`Phase ${n.number} complete`))+chalk.gray(" · ")+chalk.white(n.name));const u=i>0&&d===i?chalk.bold.green:chalk.bold.white;console.log(chalk.gray(" "+(r?"理解检查得分: ":"comprehension score: "))+u(`${d}/${i}`)+chalk.gray(0===i?r?" (本阶段未作答 y/n)":" (no y/n answered)":"")),l&&console.log(chalk.gray(" "+(r?"下一阶段: ":"next: "))+chalk.bold.cyan(r?`阶段 ${l.number}`:`Phase ${l.number}`)+chalk.gray(" · ")+chalk.white(l.name)),console.log(chalk.bold.yellow(" "+y));for(const o of x(r))console.log(o)}export function renderCurriculumComplete(o,e){const n=s().startsWith("zh"),l=e.checkResults||{},r="-".repeat(48);let c=0,a=0;console.log();for(const o of t(" "))console.log(o);console.log(),console.log(chalk.bold.green(" "+r)),console.log(chalk.bold.green(" 🏆 "+(n?`${o.name} — 全部完成!`:`${o.name} — complete!`))),console.log(chalk.bold.green(" "+r));for(const e of o.modules){const[o,t]=e.cardRange;let r=0,s=0;for(let e=o;e<=t;e++){const o=l[String(e)];o&&(r++,o.correct&&s++)}c+=r,a+=s;const g=r>0&&s===r?chalk.green:chalk.white;console.log(chalk.gray(" "+(n?`阶段 ${e.number}`:`Phase ${e.number}`).padEnd(8))+g(`${s}/${r}`.padEnd(7))+chalk.gray(e.name))}console.log(chalk.bold.green(" "+r)),console.log(chalk.bold.green(" "+(n?"总分 / overall: ":"Overall: "))+chalk.bold.white(`${a}/${c}`)),console.log(chalk.bold.green(" "+r));for(const o of x(n))console.log(o);console.log()}export function renderMCQCard(o,l){const t=s(),r=e(o,t);y(r,l),m(),h(chalk.bold.yellow("🎯 "+r.title)),h(chalk.gray("─".repeat(Math.min(r.title.length+4,a)))),m();for(const o of C(r.question,60))h(" "+o);m();for(const o of["A","B","C","D"])h(chalk.cyan(` ${o}.`)+" "+chalk.white(r.options[o]));m(),u(),console.log(chalk.gray(" "+(t.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",t))),console.log()}export function renderMCQFeedback(o,l,t,r){const c=s(),a=e(o,c);console.log(),t?console.log(" "+chalk.bold.green(n("correct",c)+" ")+chalk.gray(`${n("one_point",c)} · ${l} = ${a.options[l]}`)):console.log(" "+chalk.bold.red(n("not_quite",c)+" ")+chalk.gray(`${n("you_chose",c)} ${l}; ${n("answer_is",c)} ${a.answer}.`)),console.log(),console.log(chalk.gray(" "+n("explanation",c)));for(const o of C(a.explanation,60))console.log(chalk.gray(" "+o));const g=Object.values(r.mcqResults),i=g.filter(o=>o.correct).length;console.log(),console.log(chalk.gray(" "+n("mcq_accuracy_so_far",c)+" ")+chalk.white(`${i}/${g.length}`)),console.log(),t||(console.log(chalk.gray(" "+n("press_ok_continue",c)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",c))),console.log())}export function renderPracticalCard(o,l){const t=s(),r=e(o,t);y(r,l),m(),h(chalk.bold.yellow("🛠 "+r.title)),h(chalk.gray("─".repeat(Math.min(r.title.length+4,a)))),m();for(const o of C(r.task,60))h(" "+o);if(r.starterCode){m(),h(chalk.gray(" "+n("starter_code",t))),m();for(const o of r.starterCode.split("\n"))h(" "+chalk.cyan(o))}m(),u(),console.log(chalk.gray(" "+n("try_in_sandbox",t)+" ")+chalk.bold.cyan("!python3")+chalk.gray(" "+n("drops_into_python",t))),console.log(chalk.gray(" "+n("when_done",t))),console.log(chalk.gray(" ")+chalk.bold.green("done")+chalk.gray(" "+n("done_desc",t))),console.log(chalk.gray(" ")+chalk.bold.yellow("skip")+chalk.gray(" "+n("skip_desc",t))),console.log(chalk.gray(" card N jump to a card by number")),console.log()}export function renderPracticalSuccess(o){const l=s(),t=e(o,l);console.log(),console.log(" "+chalk.bold.green(n("practical_recorded",l))),console.log(),console.log(chalk.gray(" "+n("reference_answer",l)));for(const o of C(t.successHint,60))console.log(chalk.gray(" "+o));console.log(),console.log(chalk.gray(" "+n("press_ok_continue",l)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",l))),console.log()}export function renderSimDemoCard(o,l){const t=s(),r=e(o,t);y(r,l),m(),h(chalk.bold.yellow("🎬 "+r.title)),m();for(const o of C(r.description,60))h(" "+o);m(),h(chalk.gray(" "+n("sim_requires",t))),m(),u(),console.log(chalk.gray(" ")+chalk.bold.cyan("sim")+chalk.gray(" "+n("sim_launch_desc",t))),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",t))),console.log(chalk.gray(" bookmark "+n("bookmark_desc",t))),console.log(chalk.gray(" back "+n("back_desc",t))),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",t))),console.log()}export function renderMilestone(o,l){const t=s(),r=e(o,t),c=o.number===l.totalCards;console.log(),console.log(chalk.bold.yellow(" ╭"+g("═"))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+chalk.white(" "+n("milestone_header",t))),console.log(chalk.bold.yellow(" ║"));const a=` ${r.badge} ${r.emoji}`;console.log(chalk.bold.yellow(" ║ ")+chalk.bold.green(a)),console.log(chalk.bold.yellow(" ║ ")+chalk.gray(" ─".repeat(Math.max(1,Math.floor(r.badge.length/2+2))))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("in_wild_corresponds",t)));for(const o of C(r.realWorldLevel,60))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("whats_next",t)));for(const o of C(r.unlockedNext,60))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ╰"+g("═"))),console.log(),c?(console.log(chalk.gray(" "+n("demo_complete",t))),console.log(),console.log(chalk.gray(" "+n("unlock_full",t)+" ")+chalk.white(n("curriculum_name",t))+chalk.gray(",")),console.log(chalk.gray(" "+n("contact_team_leader",t)+" ")+chalk.bold.yellow("EA")+chalk.gray(" "+n("learn_token",t))),console.log(chalk.gray(" "+n("or_email",t)+" ")+chalk.cyan("australia@icoa2026.au")+chalk.gray(" "+n("for_partnership",t))),console.log(),console.log(chalk.gray(" "+n("type_quit",t)+" ")+chalk.bold.green("quit")+chalk.gray(" "+n("to_exit",t)+" ")+chalk.bold.green("status")+chalk.gray(" "+n("for_dashboard",t)))):(console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",t))),console.log(chalk.gray(" status "+n("status_full",t))),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",t)))),console.log()}export function renderStatus(o,e){const l=s(),t=e.cardsCompleted.length,r=o.totalCards,c=Object.values(e.mcqResults),a=c.filter(o=>o.correct).length;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(n("status_title",l))+" "+chalk.cyan("─".repeat(25))),m(),h(" "+chalk.gray(n("total_progress",l)+" ")+i(t,r)+chalk.gray(` (${t}/${r})`)),h(" "+chalk.gray(n("streak",l)+" ")+d(e.streakDays)+chalk.gray(` (${n("longest",l)} ${e.longestStreak})`)),h(" "+chalk.gray(n("mcq_accuracy",l)+" ")+chalk.white(`${a}/${c.length}`)),h(" "+chalk.gray(n("practicals_done",l)+" ")+chalk.white(`${e.practicalsCompleted.length}`)),h(" "+chalk.gray(n("bookmarked",l)+" ")+chalk.white(`${e.bookmarks.length}`)),m();const g=n("module",l).replace(":","").trim();for(const n of o.modules){const[o,l]=n.cardRange,t=e.cardsCompleted.filter(e=>e>=o&&e<=l).length,r=l-o+1;h(" "+(t===r?chalk.green("✓"):t>0?chalk.yellow("▶"):chalk.gray("□"))+" "+chalk.gray(`${g} ${n.number}: `)+chalk.white(`${t}/${r}`)+chalk.gray(" "+n.name))}if(m(),e.achievements.length>0){h(" "+chalk.gray(n("achievements",l)));for(const o of e.achievements)h(" "+chalk.bold.yellow("★ ")+chalk.white(o))}else h(" "+chalk.gray(n("achievements_none",l)));m(),u()}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.243",
3
+ "version": "2.19.244",
4
4
  "description": "ICOA CLI — The world's first CLI-native cyber & AI security olympiad terminal: AI4CTF (Day 1), CTF4AI (Day 2), VLA4CTF (Pioneer Round — embodied AI)",
5
5
  "type": "module",
6
6
  "bin": {