icoa-cli 2.19.260 → 2.19.261

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{normalizeTokenBody as d}from"../lib/token-format.js";import{getConfig as g,saveConfig as m}from"../lib/config.js";import{loadLearnState as y,saveLearnState as f,newLearnState as h,updateStreak as p,markCardComplete as b,recordMCQ as w,recordCheck as k,markPracticalComplete as C,addAchievement as v}from"../lib/learn-state.js";import{renderWelcome as A,renderKnowledgeCard as E,renderMCQCard as _,renderMCQFeedback as I,renderPracticalCard as $,renderPracticalSuccess as D,renderSimDemoCard as O,renderMilestone as S,renderArenaTaskCard as M,renderComingSoonCard as P,renderStatus as L,renderPhaseComplete as T,renderCurriculumComplete as j}from"../lib/learn-render.js";import{printError as x}from"../lib/ui.js";export function registerLearnCommand(N){N.command("learn [token]").description("Enter learn mode (free demo, or team-issued EA/EI/AC/CA/IO/IA token for full curriculum)").action(async N=>{N&&N.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(),N="LEARNDEMO01");let q=N.trim().toUpperCase(),U=null;const F=/^(LEARNDEMO01|AI4CTFDEMO01|CTF4AIDEMO01)$/i.test(q),R=/^[A-Z]{2}[A-Z0-9]{8}$/i.test(q);if(F)console.log(),console.log(chalk.gray(" Loading demo curriculum...")),U=await c(q);else if(R){const e=g().ctfdUrl||"https://practice.icoa2026.au";console.log(),console.log(chalk.gray(" Validating token..."));let o=await s(q,e);if(!o.ok){const r=d(q);if(r!==q){const n=await s(r,e);n.ok&&(console.log(chalk.yellow(` Corrected look-alike characters: ${q} → ${r}`)),o=n,q=r)}}if(!o.ok)return x(`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 (check 0/O, 1/I/L, V/U)")),void console.log();if(console.log(chalk.green(` ✓ Token valid · curriculum: ${o.curriculumId} · status: ${o.status}`)),U=await c(o.curriculumId||"LEARNDEMO01"),!U)return x(`Could not open a learn curriculum for token '${q}'.`),console.log(),console.log(chalk.gray(" If this is an ")+chalk.bold.yellow("EXAM token")+chalk.gray(", start it with ")+chalk.bold.green(`exam ${q}`)+chalk.gray(" instead.")),console.log(chalk.gray(" Otherwise: the full curriculum is ~3 MB; on a slow link the download")),console.log(chalk.gray(" can take a while — stay on a stable connection and run ")+chalk.bold.yellow(`learn ${q}`)+chalk.gray(" again")),console.log(chalk.gray(" (it caches after the first load). If it keeps failing, check ")+chalk.cyan(e)+chalk.gray(" is reachable.")),void console.log()}if(!U)return x(`Unknown learn token: ${q}`),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 z=y(),B=!1;try{z&&z.token===q?p(z):(z=h(q,U.id,U.totalCards),B=!0),f(z),A(U,z,B)}catch{return x("Could not open this curriculum — it may be malformed or not a learn curriculum."),console.log(chalk.gray(" If this is an ")+chalk.bold.yellow("EXAM token")+chalk.gray(", start it with ")+chalk.bold.green(`exam ${q}`)+chalk.gray(".")),void console.log()}const J=r(),W=null!==J,K=W?J.listeners("line").slice():[];W&&J.removeAllListeners("line");const Q=W?J:e({input:process.stdin,output:process.stdout,terminal:!0}),V=()=>{Q.setPrompt(chalk.bold.cyan("icoa learn> ")),Q.prompt()};V();let X=null,Z=null,G=null,H=null,Y=!1,ee=0;const oe=(g().language||"en").toLowerCase().startsWith("zh"),re=[];let ne=null;const le=new Promise(e=>{ne=e}),te=()=>{const e=ne;ne=null,e?.()},ae="1"===process.env.ICOA_LEARN_EMBEDDED,ce=e=>U.cards.find(o=>o.number===e),se=e=>{const o=U.modules.find(o=>o.cardRange[1]===e);if(!o)return!1;const r=U.modules.find(e=>e.number===o.number+1);return T(U,z,o,r),!0},ie=()=>{Y=!0,console.log(chalk.gray(oe?" 按 Enter 进入下一阶段…":" Press Enter to continue to the next phase…"))},ue=()=>{const e=ce(z.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":E(e,U),e.check?(G=e.number,ee=Date.now()):(b(z,e.number),f(z));break;case"mcq":_(e,U),X=e.number;break;case"practical":$(e,U),Z=e.number;break;case"sim_demo":O(e,U),b(z,e.number),f(z);break;case"milestone":S(e,U),v(z,e.badge),b(z,e.number),f(z);break;case"arena_task":M(e,U),b(z,e.number),f(z);break;case"coming_soon":P(e,U),b(z,e.number),f(z)}};Q.on("line",async e=>{const r=e.trim().toLowerCase();if(null!==H){const o=e.trim(),r=H;if(H=null,""===o)console.log(chalk.gray(oe?" 已取消(未提交)。":" Cancelled (nothing submitted)."));else{const e=g(),n=ee>0?Date.now()-ee:void 0;re.push(u(q,e.ctfdUrl||"https://practice.icoa2026.au",{curriculum_id:U.id,card_number:r,feedback_text:o,time_on_card_ms:n}).catch(()=>{})),console.log(chalk.green(oe?" ✓ 已收到,谢谢帮助完善这张卡。":" ✓ Thanks — your report was recorded."))}return console.log(),void V()}if(Y)return Y=!1,ue(),void V();if(r)if("menu"!==r&&"menu confirm"!==r)if("quit"!==r&&"exit"!==r&&"q"!==r){if("status"===r)return L(U,z),void V();if("lang"===r||r.startsWith("lang ")){const e=r.slice(4).trim();if(!e)return console.log(chalk.gray(" 当前语言 / current: ")+chalk.white(g().language||"en")+chalk.gray(" · ")+chalk.bold.green("lang zh")+chalk.gray(" / ")+chalk.bold.green("lang en")),void V();const o=U.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 m({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,X=null,Z=null,H=null,Y=!1,ue(),void V()}if("sim"===r){const e=ce(z.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 V()):(console.log(chalk.gray(" (sim only available on simulation cards)")),void V())}if("bookmark"===r){const e=z.currentCard;return z.bookmarks.includes(e)||z.bookmarks.push(e),f(z),console.log(chalk.gray(` ✓ Card ${e} bookmarked.`)),void V()}if("e"===r)return H=z.currentCard,console.log(chalk.gray(oe?" 描述问题(回车提交 / 空行取消):":" Describe the issue (Enter to submit / blank to cancel):")),void V();if("back"===r||"b"===r)return z.currentCard>1&&(z.currentCard-=1),X=null,Z=null,G=null,f(z),ue(),void V();if(r.startsWith("card ")){const e=r.slice(5).trim(),o=parseInt(e,10);return!Number.isInteger(o)||o<1||o>U.totalCards?(console.log(chalk.yellow(` Card number must be 1..${U.totalCards}. Try: `)+chalk.bold.green("card 1")),void V()):(z.currentCard=o,X=null,Z=null,G=null,f(z),ue(),void V())}if(null!==G&&["y","yes","n","no"].includes(r)){const e=ce(G);if(e&&"knowledge"===e.type&&e.check){const o=r.startsWith("y")?"y":"n",n=o===e.check.answer,l=Date.now()-ee;b(z,e.number),k(z,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),f(z);const{renderCheckFeedback:t}=await import("../lib/learn-render.js");t(e,o,n,!1);const a=g();if(re.push(i(q,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,e.solution&&e.solution.length>0)return void V();if(z.currentCard<U.totalCards){const e=z.currentCard;z.currentCard+=1,f(z),se(e)?ie():ue(),V()}else j(U,z),V();return}}if(null!==X&&["a","b","c","d"].includes(r)){const e=ce(X);if(e&&"mcq"===e.type){const o=r.toUpperCase(),n=o===e.answer;w(z,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),b(z,e.number),f(z),I(e,o,n,z);const l=g();return re.push(i(q,l.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"mcq_answered",mcq_answer:o,mcq_correct:n}).catch(()=>{})),X=null,void(n?z.currentCard<U.totalCards?(z.currentCard+=1,f(z),ue()):(j(U,z),V()):V())}}if(null!==Z){if("done"===r){const e=ce(Z);if(e&&"practical"===e.type)return C(z,e.number),b(z,e.number),f(z),D(e),Z=null,void V()}if("skip"===r)return b(z,Z),f(z),console.log(chalk.gray(" Skipped (counts as not completed).")),console.log(),Z=null,void V()}if("ok"===r||"next"===r||"continue"===r||"n"===r){if(null!==X)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void V();if(null!==Z)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void V();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 V();const e=z.currentCard;return z.currentCard+=1,f(z),z.currentCard>U.totalCards?j(U,z):se(e)?ie():ue(),void V()}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 V();if(null!==X)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void V();if(null!==Z)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void V();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")),V()}else if(re.length>0&&await Promise.race([Promise.allSettled(re),new Promise(e=>setTimeout(e,5e3))]),console.log(),console.log(chalk.gray(" Saved. See you next session.")),console.log(chalk.gray(" Streak: ")+chalk.yellow(`🔥 ${z.streakDays} day(s)`)),console.log(),W){Q.removeAllListeners("line");for(const e of K)Q.on("line",e);Q.prompt(),te()}else Q.removeAllListeners("line"),Q.close();else if(re.length>0&&await Promise.race([Promise.allSettled(re),new Promise(e=>setTimeout(e,3e3))]),Q.removeAllListeners("line"),W||!ae){const{returnToMainMenu:e}=await import("../lib/menu-nav.js");e(W?Q:void 0),te()}else Q.close();else V()}),W||Q.on("close",async()=>{re.length>0&&await Promise.race([Promise.allSettled(re),new Promise(e=>setTimeout(e,5e3))]),ae?te():process.exit(0)}),ue(),V(),await le}),N.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{normalizeTokenBody as d}from"../lib/token-format.js";import{getConfig as g,saveConfig as m}from"../lib/config.js";import{loadLearnState as y,saveLearnState as f,newLearnState as h,updateStreak as p,markCardComplete as b,recordMCQ as w,recordCheck as k,markPracticalComplete as C,addAchievement as v}from"../lib/learn-state.js";import{renderWelcome as A,renderKnowledgeCard as E,renderMCQCard as _,renderMCQFeedback as I,renderPracticalCard as $,renderPracticalSuccess as D,renderSimDemoCard as O,renderMilestone as S,renderArenaTaskCard as P,renderComingSoonCard as L,renderStatus as M,renderPhaseComplete as T,renderCurriculumComplete as j}from"../lib/learn-render.js";import{printError as x}from"../lib/ui.js";export function registerLearnCommand(N){N.command("learn [token]").description("Enter learn mode (free demo, or team-issued EA/EI/AC/CA/IO/IA token for full curriculum)").action(async N=>{N&&N.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(),N="LEARNDEMO01");let q=N.trim().toUpperCase(),U=null;const F=/^(LEARNDEMO01|AI4CTFDEMO01|CTF4AIDEMO01)$/i.test(q),R=/^[A-Z]{2}[A-Z0-9]{8}$/i.test(q);if(F)console.log(),console.log(chalk.gray(" Loading demo curriculum...")),U=await c(q);else if(R){const e=g().ctfdUrl||"https://practice.icoa2026.au";console.log(),console.log(chalk.gray(" Validating token..."));let o=await s(q,e);if(!o.ok){const r=d(q);if(r!==q){const n=await s(r,e);n.ok&&(console.log(chalk.yellow(` Corrected look-alike characters: ${q} → ${r}`)),o=n,q=r)}}if(!o.ok)return x(`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 (check 0/O, 1/I/L, V/U)")),void console.log();if(console.log(chalk.green(` ✓ Token valid · curriculum: ${o.curriculumId} · status: ${o.status}`)),U=await c(o.curriculumId||"LEARNDEMO01"),!U)return x(`Could not open a learn curriculum for token '${q}'.`),console.log(),console.log(chalk.gray(" If this is an ")+chalk.bold.yellow("EXAM token")+chalk.gray(", start it with ")+chalk.bold.green(`exam ${q}`)+chalk.gray(" instead.")),console.log(chalk.gray(" Otherwise: the full curriculum is ~3 MB; on a slow link the download")),console.log(chalk.gray(" can take a while — stay on a stable connection and run ")+chalk.bold.yellow(`learn ${q}`)+chalk.gray(" again")),console.log(chalk.gray(" (it caches after the first load). If it keeps failing, check ")+chalk.cyan(e)+chalk.gray(" is reachable.")),void console.log()}if(!U)return x(`Unknown learn token: ${q}`),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 z=y(),B=!1;try{z&&z.token===q?p(z):(z=h(q,U.id,U.totalCards),B=!0),f(z),A(U,z,B)}catch{return x("Could not open this curriculum — it may be malformed or not a learn curriculum."),console.log(chalk.gray(" If this is an ")+chalk.bold.yellow("EXAM token")+chalk.gray(", start it with ")+chalk.bold.green(`exam ${q}`)+chalk.gray(".")),void console.log()}const J=r(),W=null!==J,K=W?J.listeners("line").slice():[];W&&J.removeAllListeners("line");const Q=W?J:e({input:process.stdin,output:process.stdout,terminal:!0}),V=()=>{Q.setPrompt(chalk.bold.cyan("icoa learn> ")),Q.prompt()};V();let X=null,Z=null,G=null,H=null,Y=!1,ee=0;const oe=(g().language||"en").toLowerCase().startsWith("zh"),re=[];let ne=null;const le=new Promise(e=>{ne=e}),te=()=>{const e=ne;ne=null,e?.()},ae="1"===process.env.ICOA_LEARN_EMBEDDED,ce=e=>U.cards.find(o=>o.number===e),se=e=>{const o=U.modules.find(o=>o.cardRange[1]===e);if(!o)return!1;const r=U.modules.find(e=>e.number===o.number+1);return T(U,z,o,r),!0},ie=()=>{Y=!0,console.log(chalk.gray(oe?" 按 Enter 进入下一阶段…":" Press Enter to continue to the next phase…"))},ue=()=>{const e=ce(z.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":E(e,U),e.check?(G=e.number,ee=Date.now()):(b(z,e.number),f(z));break;case"mcq":_(e,U),X=e.number;break;case"practical":$(e,U),Z=e.number;break;case"sim_demo":O(e,U),b(z,e.number),f(z);break;case"milestone":S(e,U),v(z,e.badge),b(z,e.number),f(z);break;case"arena_task":P(e,U),b(z,e.number),f(z);break;case"coming_soon":L(e,U),b(z,e.number),f(z)}};Q.on("line",e=>{(async e=>{const r=e.trim().toLowerCase();if(null!==H){const o=e.trim(),r=H;if(H=null,""===o)console.log(chalk.gray(oe?" 已取消(未提交)。":" Cancelled (nothing submitted)."));else{const e=g(),n=ee>0?Date.now()-ee:void 0;re.push(u(q,e.ctfdUrl||"https://practice.icoa2026.au",{curriculum_id:U.id,card_number:r,feedback_text:o,time_on_card_ms:n}).catch(()=>{})),console.log(chalk.green(oe?" ✓ 已收到,谢谢帮助完善这张卡。":" ✓ Thanks — your report was recorded."))}return console.log(),void V()}if(Y)return Y=!1,ue(),void V();if(r)if("menu"!==r&&"menu confirm"!==r)if("quit"!==r&&"exit"!==r&&"q"!==r){if("status"===r)return M(U,z),void V();if("lang"===r||r.startsWith("lang ")){const e=r.slice(4).trim();if(!e)return console.log(chalk.gray(" 当前语言 / current: ")+chalk.white(g().language||"en")+chalk.gray(" · ")+chalk.bold.green("lang zh")+chalk.gray(" / ")+chalk.bold.green("lang en")),void V();const o=U.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 m({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,X=null,Z=null,H=null,Y=!1,ue(),void V()}if("sim"===r){const e=ce(z.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 V()):(console.log(chalk.gray(" (sim only available on simulation cards)")),void V())}if("bookmark"===r){const e=z.currentCard;return z.bookmarks.includes(e)||z.bookmarks.push(e),f(z),console.log(chalk.gray(` ✓ Card ${e} bookmarked.`)),void V()}if("e"===r)return H=z.currentCard,console.log(chalk.gray(oe?" 描述问题(回车提交 / 空行取消):":" Describe the issue (Enter to submit / blank to cancel):")),void V();if("back"===r||"b"===r)return z.currentCard>1&&(z.currentCard-=1),X=null,Z=null,G=null,f(z),ue(),void V();if(r.startsWith("card ")){const e=r.slice(5).trim(),o=parseInt(e,10);return!Number.isInteger(o)||o<1||o>U.totalCards?(console.log(chalk.yellow(` Card number must be 1..${U.totalCards}. Try: `)+chalk.bold.green("card 1")),void V()):(z.currentCard=o,X=null,Z=null,G=null,f(z),ue(),void V())}if(null!==G&&["y","yes","n","no"].includes(r)){const e=ce(G);if(e&&"knowledge"===e.type&&e.check){const o=r.startsWith("y")?"y":"n",n=o===e.check.answer,l=Date.now()-ee;b(z,e.number),k(z,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),f(z);const{renderCheckFeedback:t}=await import("../lib/learn-render.js");t(e,o,n,!1);const a=g();if(re.push(i(q,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,e.solution&&e.solution.length>0)return void V();if(z.currentCard<U.totalCards){const e=z.currentCard;z.currentCard+=1,f(z),se(e)?ie():ue(),V()}else j(U,z),V();return}}if(null!==X&&["a","b","c","d"].includes(r)){const e=ce(X);if(e&&"mcq"===e.type){const o=r.toUpperCase(),n=o===e.answer;w(z,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),b(z,e.number),f(z),I(e,o,n,z);const l=g();return re.push(i(q,l.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"mcq_answered",mcq_answer:o,mcq_correct:n}).catch(()=>{})),X=null,void(n?z.currentCard<U.totalCards?(z.currentCard+=1,f(z),ue()):(j(U,z),V()):V())}}if(null!==Z){if("done"===r){const e=ce(Z);if(e&&"practical"===e.type)return C(z,e.number),b(z,e.number),f(z),D(e),Z=null,void V()}if("skip"===r)return b(z,Z),f(z),console.log(chalk.gray(" Skipped (counts as not completed).")),console.log(),Z=null,void V()}if("ok"===r||"next"===r||"continue"===r||"n"===r){if(null!==X)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void V();if(null!==Z)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void V();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 V();const e=z.currentCard;return z.currentCard+=1,f(z),z.currentCard>U.totalCards?j(U,z):se(e)?ie():ue(),void V()}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 V();if(null!==X)return console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void V();if(null!==Z)return console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void V();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")),V()}else if(re.length>0&&await Promise.race([Promise.allSettled(re),new Promise(e=>setTimeout(e,5e3))]),console.log(),console.log(chalk.gray(" Saved. See you next session.")),console.log(chalk.gray(" Streak: ")+chalk.yellow(`🔥 ${z.streakDays} day(s)`)),console.log(),W){Q.removeAllListeners("line");for(const e of K)Q.on("line",e);Q.prompt(),te()}else Q.removeAllListeners("line"),Q.close();else if(re.length>0&&await Promise.race([Promise.allSettled(re),new Promise(e=>setTimeout(e,3e3))]),Q.removeAllListeners("line"),W||!ae){const{returnToMainMenu:e}=await import("../lib/menu-nav.js");e(W?Q:void 0),te()}else Q.close();else V()})(e).catch(e=>{console.log(),console.log(chalk.red(" ⚠ Something went wrong handling that input.")),console.log(chalk.gray(` ${e instanceof Error?e.message:String(e)}`)),console.log(chalk.gray(" Progress is saved. Type ")+chalk.bold.green("ok")+chalk.gray(" to continue or ")+chalk.bold.green("quit")+chalk.gray(" to exit.")),V()})}),W||Q.on("close",async()=>{re.length>0&&await Promise.race([Promise.allSettled(re),new Promise(e=>setTimeout(e,5e3))]),ae?te():process.exit(0)});try{ue(),V()}catch{if(x("Could not render this card — the curriculum may be malformed."),W){Q.removeAllListeners("line");for(const e of K)Q.on("line",e);Q.prompt()}else Q.close();te()}await le}),N.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 a0a(){const x=['AgLUDcbbueKGDw5YzwfJAgfIBgu','oeHws2rira','nJa2mda2CLbOtfvz','yxbWBgLJyxrPB24VANnVBG','B2jQzwn0','ANnVBG','mta1mZe3ogP2ChPnDq','mJm3nZrusM9RDxe','l2fWAs9Py29Hl2v4yw1ZlW','DgLTzw91De1Z','C3vJy2vZCW','CxvLC3rPB24','Dg9Rzw4','m2DYv3fcuq','y3rMzfvYBa','Bgv2zwW','BgfUzW','DgLTzw91Da','zgf0yq','nw9NrxDgzW','C3rYAw5NAwz5','mJKXotG4s1Hus2TR','mJeZotiWweXrzuP2','ndyYmJe2meTZq2nqva','mJa3mJK3vwLIzhLI','C3rHDhvZ','AwnVys1JBgK','zxHHBuLK','BwvZC2fNzq','Ahr0Chm6lY9WCMfJDgLJzs5Py29HmJaYnI5HDq'];a0a=function(){return x;};return a0a();}(function(a,b){const v=a0b,c=a();while(!![]){try{const d=parseInt(v(0x86))/(-0x248+-0xe4d+0x1096)+-parseInt(v(0x95))/(-0xe6b+-0x23d6+0x1*0x3243)*(-parseInt(v(0x7d))/(0x8f6+-0x1*-0x20a4+-0x2997))+-parseInt(v(0x85))/(0xb03*0x3+-0xc4*-0x7+-0x5*0x7ad)*(-parseInt(v(0x83))/(0x23ce*0x1+0x1fd*0x1+-0x2*0x12e3))+parseInt(v(0x90))/(-0x2*0xa20+0x1*0x1fb2+0x44*-0x2b)+parseInt(v(0x94))/(0x146d+-0x183e+0x3d8)+parseInt(v(0x8f))/(-0x239*0x8+0x120c+-0x3c)*(parseInt(v(0x88))/(0x1*0x515+0x9*0x271+-0x1*0x1b05))+-parseInt(v(0x87))/(-0x4a2+-0x1*-0xa54+-0x2*0x2d4);if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a0a,-0x204d4+0x34f20+0x6798));import{getConfig as a0c}from'./config.js';function a0b(a,b){a=a-(0x8*0x191+0x216+-0xe23);const c=a0a();let d=c[a];if(a0b['TpAMii']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=-0x313+-0xe67+0x8bd*0x2,o,p,q=-0x1*0xdf4+-0x1*-0x12f+0xcc5;p=i['charAt'](q++);~p&&(o=n%(0x751*-0x1+-0x1cab+-0x240*-0x10)?o*(0x1*-0x656+-0x3*0x3e2+0x48f*0x4)+p:p,n++%(0x2*-0x130d+0x282*0xf+-0x80*-0x1))?l+=String['fromCharCode'](-0x119*-0x21+-0x214e+-0x1ec&o>>(-(0x145a+0x18*0x40+-0x8c8*0x3)*n&0x35*0x43+-0x62d+-0x7ac)):-0x7b5+-0xe35+-0x21*-0xaa){p=j['indexOf'](p);}for(let r=0x15f*0x2+0x1*0x1877+-0x1b35,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](-0x1794+-0x1*0x10a5+-0x2849*-0x1))['slice'](-(-0xc4f+0x3da*0x6+-0x133*0x9));}return decodeURIComponent(m);};a0b['sOVuWl']=e,a0b['nVNfnd']={},a0b['TpAMii']=!![];}const f=c[-0x665+-0xb*0x17c+0x793*0x3],g=a+f,h=a0b['nVNfnd'][g];return!h?(d=a0b['sOVuWl'](d),a0b['nVNfnd'][g]=d):d=h,d;}export async function requestHint(d){const w=a0b,f=a0c(),g=f[w(0x7e)]||w(0x8d),h=d[w(0x80)]||f['language']||'en',j=d[w(0x97)]??0x9fd*-0x3+-0x1cb8+0x82d*0xb,k=[g+w(0x96)+d[w(0x8b)]+'/hint',g+':9090/api/icoa/exams/'+d[w(0x8b)]+'/hint'];let l=null;for(const p of k)try{const q=await fetch(p,{'method':'POST','headers':{'Content-Type':w(0x91),'User-Agent':w(0x8a)},'body':JSON[w(0x84)]({'token':d[w(0x7c)],'question':d[w(0x7b)],'level':d[w(0x7f)],'lang':h}),'signal':AbortSignal[w(0x81)](j)}),r=await q[w(0x93)]()['catch'](()=>({}));if(!q['ok']||!(-0x90+0x2c2+-0x231)===r[w(0x98)]){if(l={'status':q['status'],'message':r?.[w(0x8c)]||'hint\x20request\x20failed\x20('+q['status']+')'},q[w(0x89)]>=-0x1*0x1cab+-0x11fb*-0x1+0xc40&&q[w(0x89)]<0x1f1*-0x6+0x955+0x445*0x1)throw l;continue;}return r[w(0x82)];}catch(u){if(u&&w(0x92)==typeof u&&w(0x89)in u)throw u;l={'status':0x0,'message':u?.['message']||'network\x20error'};}const m={};m[w(0x89)]=0x0,m[w(0x8c)]=w(0x8e);throw l||m;}
1
+ (function(a,b){const v=a0b,c=a();while(!![]){try{const d=parseInt(v(0x203))/(-0x1d2e+-0x173f*0x1+0x346e)+-parseInt(v(0x1e8))/(0x3*0x1af+-0xcd9*-0x1+-0x11e4)*(-parseInt(v(0x1e6))/(-0x2185+0x1a96+0x6f2))+-parseInt(v(0x1f2))/(-0xb6c+0x2d0+0x8a*0x10)+-parseInt(v(0x201))/(-0x1806+0x16e2+-0x63*-0x3)+parseInt(v(0x1f9))/(-0x1a7d+0x6*0x15f+-0x1*-0x1249)+-parseInt(v(0x202))/(-0x1*0x1246+-0x362*0x8+0x2d5d)+parseInt(v(0x1e9))/(-0x591+0x163c+-0x10a3)*(parseInt(v(0x1ea))/(-0x619+-0x8e2*-0x3+-0x2*0xa42));if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a0a,0x71*0xb5+0x1*-0x281f7+-0x2*-0x232ea));import{getConfig as a0c}from'./config.js';function a0b(a,b){a=a-(-0x84f+-0x6b1+0x10e6);const c=a0a();let d=c[a];if(a0b['cPeEXD']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=0x13*-0xc2+0x5*0x30+-0x2*-0x6bb,o,p,q=0x1dd8+0x5b*0xe+-0x1169*0x2;p=i['charAt'](q++);~p&&(o=n%(0x1*-0xb47+-0xe*-0x1bb+0x12d*-0xb)?o*(0x953*-0x4+-0x80*0x8+0x298c)+p:p,n++%(-0xb8*0x31+0xf8f+-0x17*-0xdb))?l+=String['fromCharCode'](-0xa96+0x2118+-0x1583&o>>(-(0x11b*-0x13+-0x1*0x1987+-0x25*-0x142)*n&-0x2429+0x26e9+-0x2ba)):-0x1a72+0x19e9+0x89){p=j['indexOf'](p);}for(let r=0x3a4*-0x8+0xd*-0x53+0x2157,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](0x6*0x257+-0x32*0x83+0xb9c))['slice'](-(0xf*0xe3+-0xf2*0x7+-0x6ad));}return decodeURIComponent(m);};a0b['erjDMj']=e,a0b['LgGSNx']={},a0b['cPeEXD']=!![];}const f=c[-0x1*0xc4d+0x1104*0x2+-0x1*0x15bb],g=a+f,h=a0b['LgGSNx'][g];return!h?(d=a0b['erjDMj'](d),a0b['LgGSNx'][g]=d):d=h,d;}function a0a(){const x=['nZjWze5bB04','Bgv2zwW','BgfUz3vHz2u','oJKWotaVyxbPl2LJB2eVzxHHBxmV','y2f0y2G','yxbWBgLJyxrPB24VANnVBG','AgLUDcbbueKGDw5YzwfJAgfIBgu','AgLUDcbYzxf1zxn0igzHAwXLzcaO','nJK5mtuYuKTLsMLe','DgLTzw91Da','C3vJy2vZCW','y3rMzfvYBa','zgf0yq','C3rHDhvZ','BwvZC2fNzq','nZuZmdq4uK1nz2rY','l2HPBNq','C3rYAw5NAwz5','BgfUzW','l2fWAs9Py29Hl2v4yw1ZlW','zxHHBuLK','BMv0D29YAYbLCNjVCG','ue9tva','nte3odmWtePUEuL2','nJi2nZCZv1f6qvLy','mte0otCXwNHmCwjA','DgLTzw91De1Z','otC0mZrOEMD4wLi','Ahr0Chm6lY9WCMfJDgLJzs5Py29HmJaYnI5HDq','mtz6BNvPuMS','mte5mtjWv3DnDNG'];a0a=function(){return x;};return a0a();}export async function requestHint(d){const w=a0b,f=a0c(),g=f[w(0x1f5)]||w(0x1e7),h=d[w(0x1fc)]||f[w(0x1ec)]||'en',j=d[w(0x204)]??0x3*0x787+0x17fa+0x1*-0xf4f,k=[g+w(0x1fd)+d['examId']+w(0x1fa),g+w(0x1ed)+d[w(0x1fe)]+w(0x1fa)];let l=null;for(const p of k)try{const q=await fetch(p,{'method':w(0x200),'headers':{'Content-Type':w(0x1ef),'User-Agent':'icoa-cli'},'body':JSON[w(0x1fb)]({'token':d['token'],'question':d['question'],'level':d[w(0x1eb)],'lang':h}),'signal':AbortSignal[w(0x1f3)](j)}),r=await q['json']()[w(0x1ee)](()=>({}));if(!q['ok']||!(0x1*-0x23ea+0x15b8+0xe33)===r[w(0x1f4)]){if(l={'status':q['status'],'message':r?.[w(0x1f8)]||w(0x1f1)+q[w(0x1f7)]+')'},q[w(0x1f7)]>=0x1bb*0xe+0x1b3f+0x10a3*-0x3&&q[w(0x1f7)]<0x953*-0x4+-0x80*0x8+0x2b40)throw l;continue;}return r[w(0x1f6)];}catch(u){if(u&&'object'==typeof u&&w(0x1f7)in u)throw u;l={'status':0x0,'message':u?.[w(0x1f8)]||w(0x1ff)};}const m={};m[w(0x1f7)]=0x0,m[w(0x1f8)]=w(0x1f0);throw l||m;}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.260",
3
+ "version": "2.19.261",
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": {