icoa-cli 2.19.222 → 2.19.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/ai4ctf.js +1 -1
- package/dist/commands/ctf4ai-demo.js +1 -1
- package/dist/commands/ctf4vla.js +1 -1
- package/dist/commands/exam.js +1 -1
- package/dist/commands/learn.js +1 -1
- package/dist/lib/hint-client.js +1 -1
- package/dist/lib/learn-curricula.d.ts +11 -0
- package/dist/lib/learn-input.d.ts +36 -0
- package/dist/lib/learn-input.js +1 -0
- package/dist/lib/learn-render.js +1 -1
- package/dist/lib/learn-state.d.ts +7 -0
- package/dist/lib/learn-state.js +1 -1
- package/dist/lib/render-card.d.ts +17 -0
- package/dist/lib/render-card.js +1 -0
- package/dist/repl.js +1 -1
- package/package.json +1 -1
package/dist/commands/learn.js
CHANGED
|
@@ -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 a}from"node:path";import{fileURLToPath as t}from"node:url";import{loadCurriculumById as c,validateEAToken as s,syncProgress as i}from"../lib/learn-curricula.js";import{getConfig as u}from"../lib/config.js";import{loadLearnState as d,saveLearnState as g,newLearnState as m,updateStreak as y,markCardComplete as f,recordMCQ as p,markPracticalComplete as h,addAchievement as b}from"../lib/learn-state.js";import{renderWelcome as w,renderKnowledgeCard as k,renderMCQCard as C,renderMCQFeedback as A,renderPracticalCard as v,renderPracticalSuccess as E,renderSimDemoCard as I,renderMilestone as O,renderStatus as _}from"../lib/learn-render.js";import{printError as S}from"../lib/ui.js";export function registerLearnCommand(T){T.command("learn [token]").description("Enter learn mode (free demo, or team-issued EA/AC/CA/IO/IA token for full curriculum)").action(async T=>{T&&T.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|AC|CA|IO|IA + 8 chars")+chalk.gray(" — token from your country team leader.")),console.log(),T="LEARNDEMO01");const $=T.trim().toUpperCase();let D=null;const j=/^(LEARNDEMO01|AI4CTFDEMO01|CTF4AIDEMO01)$/i.test($),M=/^(EA|AC|CA|IO|IA)[A-Z0-9]{8}$/i.test($);if(j)console.log(),console.log(chalk.gray(" Loading demo curriculum...")),D=await c($);else if(M){const e=u().ctfdUrl||"https://practice.icoa2026.au";console.log(),console.log(chalk.gray(" Validating token..."));const o=await s($,e);if(!o.ok)return S(`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}`)),D=await c(o.curriculumId||"LEARNDEMO01"),!D)return S(`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(!D)return S(`Unknown learn token: ${$}`),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|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 P=d(),L=!1;P&&P.token===$?y(P):(P=m($,D.id,D.totalCards),L=!0),g(P),w(D,P,L);const q=r(),x=null!==q,N=x?q.listeners("line").slice():[];x&&q.removeAllListeners("line");const F=x?q:e({input:process.stdin,output:process.stdout,terminal:!0}),U=()=>{F.setPrompt(chalk.bold.cyan("learn> ")),F.prompt()};U();let R=null,J=null,B=null,K=0;const G=[],Q=e=>D.cards.find(o=>o.number===e),V=()=>{const e=Q(P.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":k(e,D),e.check?(B=e.number,K=Date.now()):(f(P,e.number),g(P));break;case"mcq":C(e,D),R=e.number;break;case"practical":v(e,D),J=e.number;break;case"sim_demo":I(e,D),f(P,e.number),g(P);break;case"milestone":O(e,D),b(P,e.badge),f(P,e.number),g(P)}};F.on("line",async e=>{const r=e.trim().toLowerCase();if(r){if("menu"===r||"menu confirm"===r){G.length>0&&await Promise.race([Promise.allSettled(G),new Promise(e=>setTimeout(e,3e3))]);const{returnToMainMenu:e}=await import("../lib/menu-nav.js");return void e(F)}if("quit"!==r&&"exit"!==r&&"q"!==r){if("status"===r)return _(D,P),void U();if("sim"===r){const e=Q(P.currentCard);return e&&"sim_demo"===e.type?(function(e){const r=function(){const e=l(t(import.meta.url)),o=[a(e,"..","..","panda","mujoco-launcher.py"),a(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 U()):(console.log(chalk.gray(" (sim only available on simulation cards)")),void U())}if("bookmark"===r){const e=P.currentCard;return P.bookmarks.includes(e)||P.bookmarks.push(e),g(P),console.log(chalk.gray(` ✓ Card ${e} bookmarked.`)),void U()}if("back"===r)return P.currentCard>1&&(P.currentCard-=1),R=null,J=null,B=null,g(P),V(),void U();if(null!==B&&["y","yes","n","no"].includes(r)){const e=Q(B);if(e&&"knowledge"===e.type&&e.check){const o=r.startsWith("y")?"y":"n",n=o===e.check.answer,l=Date.now()-K;f(P,e.number),g(P);const{renderCheckFeedback:a}=await import("../lib/learn-render.js");a(e,o,n);const t=u();return G.push(i($,t.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(()=>{})),B=null,void(P.currentCard<D.totalCards?(P.currentCard+=1,g(P),V()):(console.log(chalk.gray(" Curriculum complete. Type ")+chalk.bold.green("status")+chalk.gray(" for dashboard.")),console.log(),U()))}}if(null!==R&&["a","b","c","d"].includes(r)){const e=Q(R);if(e&&"mcq"===e.type){const o=r.toUpperCase(),n=o===e.answer;p(P,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),f(P,e.number),g(P),A(e,o,n,P);const l=u();return G.push(i($,l.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"mcq_answered",mcq_answer:o,mcq_correct:n}).catch(()=>{})),R=null,void U()}}if(null!==J){if("done"===r){const e=Q(J);if(e&&"practical"===e.type)return h(P,e.number),f(P,e.number),g(P),E(e),J=null,void U()}if("skip"===r)return f(P,J),g(P),console.log(chalk.gray(" Skipped (counts as not completed).")),console.log(),J=null,void U()}if("ok"===r||"next"===r||"continue"===r||"n"===r)return null!==R?(console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void U()):null!==J?(console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void U()):null!==B?(console.log(chalk.yellow(" Please answer the check above (")+chalk.bold.green("y")+chalk.yellow(" or ")+chalk.bold.green("n")+chalk.yellow(").")),void U()):(P.currentCard+=1,g(P),P.currentCard>D.totalCards?(console.log(),console.log(chalk.bold.green(" 🎉 You've reached the end of the demo curriculum!")),console.log(chalk.gray(" Type ")+chalk.bold.green("status")+chalk.gray(" to see your full stats.")),console.log()):V(),void U());console.log(chalk.gray(" Unknown command. Try: ")+chalk.white("ok")+chalk.gray(" / ")+chalk.white("status")+chalk.gray(" / ")+chalk.white("quit")),U()}else if(G.length>0&&await Promise.race([Promise.allSettled(G),new Promise(e=>setTimeout(e,5e3))]),console.log(),console.log(chalk.gray(" Saved. See you next session.")),console.log(chalk.gray(" Streak: ")+chalk.yellow(`🔥 ${P.streakDays} day(s)`)),console.log(),x){F.removeAllListeners("line");for(const e of N)F.on("line",e);F.prompt()}else F.close()}else U()}),x||F.on("close",async()=>{G.length>0&&await Promise.race([Promise.allSettled(G),new Promise(e=>setTimeout(e,5e3))]),process.exit(0)}),V(),U()}),T.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(),a=await c(e),t=Date.now()-o;if(a){const e=a.cards,o=Array.isArray(e)?e.length:0,n=JSON.stringify(a).length;l+=n,console.log(chalk.green("✓ ")+chalk.gray(`${o.toString().padStart(3)} cards · ${(n/1024).toFixed(1).padStart(6)} KB · ${t.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 a}from"node:path";import{fileURLToPath as t}from"node:url";import{loadCurriculumById as c,validateEAToken as s,syncProgress as i}from"../lib/learn-curricula.js";import{getConfig as u}from"../lib/config.js";import{loadLearnState as d,saveLearnState as g,newLearnState as m,updateStreak as y,markCardComplete as p,recordMCQ as f,recordCheck as h,markPracticalComplete as b,addAchievement as w}from"../lib/learn-state.js";import{renderWelcome as k,renderKnowledgeCard as C,renderMCQCard as v,renderMCQFeedback as A,renderPracticalCard as $,renderPracticalSuccess as S,renderSimDemoCard as I,renderMilestone as E,renderStatus as O}from"../lib/learn-render.js";import{printError as _}from"../lib/ui.js";export function registerLearnCommand(T){T.command("learn [token]").description("Enter learn mode (free demo, or team-issued EA/AC/CA/IO/IA token for full curriculum)").action(async T=>{T&&T.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|AC|CA|IO|IA + 8 chars")+chalk.gray(" — token from your country team leader.")),console.log(),T="LEARNDEMO01");const D=T.trim().toUpperCase();let P=null;const j=/^(LEARNDEMO01|AI4CTFDEMO01|CTF4AIDEMO01)$/i.test(D),M=/^(EA|AC|CA|IO|IA)[A-Z0-9]{8}$/i.test(D);if(j)console.log(),console.log(chalk.gray(" Loading demo curriculum...")),P=await c(D);else if(M){const e=u().ctfdUrl||"https://practice.icoa2026.au";console.log(),console.log(chalk.gray(" Validating token..."));const o=await s(D,e);if(!o.ok)return _(`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}`)),P=await c(o.curriculumId||"LEARNDEMO01"),!P)return _(`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(!P)return _(`Unknown learn token: ${D}`),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|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 q=d(),L=!1;q&&q.token===D?y(q):(q=m(D,P.id,P.totalCards),L=!0),g(q),k(P,q,L);const N=r(),x=null!==N,R=x?N.listeners("line").slice():[];x&&N.removeAllListeners("line");const F=x?N:e({input:process.stdin,output:process.stdout,terminal:!0}),U=()=>{F.setPrompt(chalk.bold.cyan("learn> ")),F.prompt()};U();let J=null,B=null,K=null,Q=0;const W=[],G=e=>P.cards.find(o=>o.number===e),V=()=>{const e=G(q.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":C(e,P),e.check?(K=e.number,Q=Date.now()):(p(q,e.number),g(q));break;case"mcq":v(e,P),J=e.number;break;case"practical":$(e,P),B=e.number;break;case"sim_demo":I(e,P),p(q,e.number),g(q);break;case"milestone":E(e,P),w(q,e.badge),p(q,e.number),g(q)}};F.on("line",async e=>{const r=e.trim().toLowerCase();if(r){if("menu"===r||"menu confirm"===r){W.length>0&&await Promise.race([Promise.allSettled(W),new Promise(e=>setTimeout(e,3e3))]);const{returnToMainMenu:e}=await import("../lib/menu-nav.js");return void e(F)}if("quit"!==r&&"exit"!==r&&"q"!==r){if("status"===r)return O(P,q),void U();if("sim"===r){const e=G(q.currentCard);return e&&"sim_demo"===e.type?(function(e){const r=function(){const e=l(t(import.meta.url)),o=[a(e,"..","..","panda","mujoco-launcher.py"),a(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 U()):(console.log(chalk.gray(" (sim only available on simulation cards)")),void U())}if("bookmark"===r){const e=q.currentCard;return q.bookmarks.includes(e)||q.bookmarks.push(e),g(q),console.log(chalk.gray(` ✓ Card ${e} bookmarked.`)),void U()}if("back"===r)return q.currentCard>1&&(q.currentCard-=1),J=null,B=null,K=null,g(q),V(),void U();if(r.startsWith("card ")){const e=r.slice(5).trim();if("review"===e||"r"===e){const e=G(q.currentCard)||P.cards[0],o=P.modules.find(o=>e.number>=o.cardRange[0]&&e.number<=o.cardRange[1]);if(!o)return console.log(chalk.yellow(" Cannot locate current phase.")),void U();const[r,n]=o.cardRange,l=q.checkResults||{};console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(`Card review — Phase ${o.number}: ${o.name} (cards ${r}–${n})`)),console.log(chalk.cyan(" │"));let a=0,t=0;for(let e=r;e<=n;e++){const o=P.cards.find(o=>o.number===e);if(!o)continue;const r="knowledge"===o.type&&o.check,n=("title"in o?o.title:o.badge).slice(0,44);if(!r){const r="milestone"===o.type?"★":"mcq"===o.type?"Q":"practical"===o.type?"!":"sim_demo"===o.type?"▷":"·";console.log(chalk.cyan(" │ ")+chalk.gray(`${String(e).padStart(3)} [${r}] `)+chalk.gray(n));continue}const c=o,s=l[String(e)];if(s){a++,s.correct&&t++;const o=s.correct?chalk.green("✓"):chalk.red("✗"),r=chalk.white(s.answer),l=chalk.gray(c.check.answer);console.log(chalk.cyan(" │ ")+`${String(e).padStart(3)} [${o}] `+chalk.gray("you=")+r+chalk.gray(" truth=")+l+chalk.gray(" ")+chalk.gray(n))}else console.log(chalk.cyan(" │ ")+chalk.gray(`${String(e).padStart(3)} [—] `)+chalk.gray(`(unanswered) ${n}`))}return console.log(chalk.cyan(" │")),console.log(chalk.cyan(" │ ")+chalk.bold.white(`y/n score: ${t}/${a}`)+chalk.gray(0===a?" (no y/n cards answered in this phase yet)":"")),console.log(chalk.cyan(" ╰──────────────────────────────────────────────")),console.log(),void U()}const o=parseInt(e,10);return!Number.isInteger(o)||o<1||o>P.totalCards?(console.log(chalk.yellow(` Card number must be 1..${P.totalCards}. Try: `)+chalk.bold.green("card 1")+chalk.yellow(" / ")+chalk.bold.green("card review")),void U()):(q.currentCard=o,J=null,B=null,K=null,g(q),V(),void U())}if(null!==K&&["y","yes","n","no"].includes(r)){const e=G(K);if(e&&"knowledge"===e.type&&e.check){const o=r.startsWith("y")?"y":"n",n=o===e.check.answer,l=Date.now()-Q;p(q,e.number),h(q,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),g(q);const{renderCheckFeedback:a}=await import("../lib/learn-render.js");a(e,o,n);const t=u();return W.push(i(D,t.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(()=>{})),K=null,void(q.currentCard<P.totalCards?(q.currentCard+=1,g(q),V()):(console.log(chalk.gray(" Curriculum complete. Type ")+chalk.bold.green("status")+chalk.gray(" for dashboard.")),console.log(),U()))}}if(null!==J&&["a","b","c","d"].includes(r)){const e=G(J);if(e&&"mcq"===e.type){const o=r.toUpperCase(),n=o===e.answer;f(q,e.number,{answer:o,correct:n,submittedAt:(new Date).toISOString()}),p(q,e.number),g(q),A(e,o,n,q);const l=u();return W.push(i(D,l.ctfdUrl||"https://practice.icoa2026.au",{card_number:e.number,event_type:"mcq_answered",mcq_answer:o,mcq_correct:n}).catch(()=>{})),J=null,void U()}}if(null!==B){if("done"===r){const e=G(B);if(e&&"practical"===e.type)return b(q,e.number),p(q,e.number),g(q),S(e),B=null,void U()}if("skip"===r)return p(q,B),g(q),console.log(chalk.gray(" Skipped (counts as not completed).")),console.log(),B=null,void U()}if("ok"===r||"next"===r||"continue"===r||"n"===r)return null!==J?(console.log(chalk.yellow(" Please answer the MCQ first (A / B / C / D).")),void U()):null!==B?(console.log(chalk.yellow(" Please type ")+chalk.bold.green("done")+chalk.yellow(" or ")+chalk.bold.yellow("skip")+chalk.yellow(" for the practical.")),void U()):null!==K?(console.log(chalk.yellow(" Please answer the check above (")+chalk.bold.green("y")+chalk.yellow(" or ")+chalk.bold.green("n")+chalk.yellow(").")),void U()):(q.currentCard+=1,g(q),q.currentCard>P.totalCards?(console.log(),console.log(chalk.bold.green(" 🎉 You've reached the end of the demo curriculum!")),console.log(chalk.gray(" Type ")+chalk.bold.green("status")+chalk.gray(" to see your full stats.")),console.log()):V(),void U());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("card review")+chalk.gray(" / ")+chalk.white("quit")),U()}else if(W.length>0&&await Promise.race([Promise.allSettled(W),new Promise(e=>setTimeout(e,5e3))]),console.log(),console.log(chalk.gray(" Saved. See you next session.")),console.log(chalk.gray(" Streak: ")+chalk.yellow(`🔥 ${q.streakDays} day(s)`)),console.log(),x){F.removeAllListeners("line");for(const e of R)F.on("line",e);F.prompt()}else F.close()}else U()}),x||F.on("close",async()=>{W.length>0&&await Promise.race([Promise.allSettled(W),new Promise(e=>setTimeout(e,5e3))]),process.exit(0)}),V(),U()}),T.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(),a=await c(e),t=Date.now()-o;if(a){const e=a.cards,o=Array.isArray(e)?e.length:0,n=JSON.stringify(a).length;l+=n,console.log(chalk.green("✓ ")+chalk.gray(`${o.toString().padStart(3)} cards · ${(n/1024).toFixed(1).padStart(6)} KB · ${t.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()})}
|
package/dist/lib/hint-client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function a0a(){const x=['ndK2nJmYnKzPuvLKDW','zxHHBuLK','C3rYAw5NAwz5','C3rHDhvZ','BwvZC2fNzq','yxbWBgLJyxrPB24VANnVBG','mZK4nZiXweLSwvDx','BgfUz3vHz2u','mZuXnZiYnejWyunMzG','Ahr0Chm6lY9WCMfJDgLJzs5Py29HmJaYnI5HDq','l2HPBNq','oJKWotaVyxbPl2LJB2eVzxHHBxmV','y3rMzfvYBa','AgLUDcbYzxf1zxn0igzHAwXLzcaO','CxvLC3rPB24','mNrjDLfJAG','ANnVBG','mtC5nZa1uKLithvp','mtC1mdi0ofjzAM5zDG','DgLTzw91De1Z','zgf0yq','odC3mdC0CK5qA1zV','mZi4nduXmK1ruu9iqG','Dg9Rzw4','AwnVys1JBgK','DgLTzw91Da','BMv0D29YAYbLCNjVCG','nZjIs1P5y3y','l2fWAs9Py29Hl2v4yw1ZlW'];a0a=function(){return x;};return a0a();}(function(a,b){const v=a0b,c=a();while(!![]){try{const d=parseInt(v(0x125))/(-0x2194+-0x8d*0x36+0x3f53)*(-parseInt(v(0x111))/(-0x12e*0x16+0x7*-0x4c7+0x3b67))+parseInt(v(0x117))/(0x10cf+-0xd8a+-0x1*0x342)+-parseInt(v(0x114))/(0x167b+0x41d+-0x2*0xd4a)+-parseInt(v(0x113))/(0x54*0xd+-0x1*-0x19+-0x458*0x1)*(-parseInt(v(0x11d))/(0x86a+0xd*0x1ca+-0x1fa6))+parseInt(v(0x118))/(-0x1efa+-0x88d+0x278e)+-parseInt(v(0x127))/(-0x357+-0x1eb4+0x2213)+parseInt(v(0x11f))/(0x16*0x5+0x1013+-0x1078);if(d===b)break;else c['push'](c['shift']());}catch(e){c['push'](c['shift']());}}}(a0a,0x1*0x18151+0x1*0x48806+0x11db1));import{getConfig as a0c}from'./config.js';function a0b(a,b){a=a-(-0x1*-0x7b+0x1ee7+0x1*-0x1e57);const c=a0a();let d=c[a];if(a0b['sCUEqE']===undefined){var e=function(i){const j='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let l='',m='';for(let n=-0x157*-0x16+0x582+0x4*-0x8bf,o,p,q=0x1c10+-0x29a+0xcbb*-0x2;p=i['charAt'](q++);~p&&(o=n%(0x10bb*-0x1+-0x1*0x3ff+0x426*0x5)?o*(-0x2222+-0x30*-0x4+-0x69*-0x52)+p:p,n++%(-0x2a*0x2b+0x109d*-0x1+0x17af))?l+=String['fromCharCode'](0x23c+0x26e6+-0x807*0x5&o>>(-(-0x2325+0x25*-0xd6+0x4215)*n&-0x1*-0x24fb+-0x3*-0xb7d+-0x23b6*0x2)):0x655*-0x4+-0xc55+-0x1f*-0x137){p=j['indexOf'](p);}for(let r=0x1a6a+0x257b+-0x1*0x3fe5,s=l['length'];r<s;r++){m+='%'+('00'+l['charCodeAt'](r)['toString'](0x2c*0x95+0xd1d+-0x26a9*0x1))['slice'](-(0x1018+0x26ea+-0x3700));}return decodeURIComponent(m);};a0b['lTcrpU']=e,a0b['OtuCZl']={},a0b['sCUEqE']=!![];}const f=c[0x7f*0x26+0x1*0x196f+-0x3*0xec3],g=a+f,h=a0b['OtuCZl'][g];return!h?(d=a0b['lTcrpU'](d),a0b['OtuCZl'][g]=d):d=h,d;}export async function requestHint(d){const w=a0b,f=a0c(),g=f[w(0x10e)]||w(0x10b),h=d['lang']||f[w(0x126)]||'en',j=d[w(0x115)]??0x8d0+0x14c2+0xa*0x2b,k=[g+w(0x11e)+d['examId']+w(0x10c),g+w(0x10d)+d[w(0x120)]+w(0x10c)];let l=null;for(const p of k)try{const q=await fetch(p,{'method':'POST','headers':{'Content-Type':w(0x124),'User-Agent':w(0x11a)},'body':JSON[w(0x121)]({'token':d[w(0x119)],'question':d[w(0x110)],'level':d['level'],'lang':h}),'signal':AbortSignal[w(0x11b)](j)}),r=await q[w(0x112)]()['catch'](()=>({}));if(!q['ok']||!(0x1c10+-0x29a+0x85*-0x31)===r['success']){if(l={'status':q[w(0x122)],'message':r?.[w(0x123)]||w(0x10f)+q[w(0x122)]+')'},q[w(0x122)]>=0x10bb*-0x1+-0x1*0x3ff+0xb25*0x2&&q[w(0x122)]<-0x2222+-0x30*-0x4+-0x11ab*-0x2)throw l;continue;}return r[w(0x116)];}catch(u){if(u&&'object'==typeof u&&'status'in u)throw u;l={'status':0x0,'message':u?.[w(0x123)]||w(0x11c)};}const m={};m['status']=0x0,m[w(0x123)]='hint\x20API\x20unreachable';throw l||m;}
|
|
@@ -22,6 +22,7 @@ export type CardKnowledge = {
|
|
|
22
22
|
statement: string;
|
|
23
23
|
answer: 'y' | 'n';
|
|
24
24
|
};
|
|
25
|
+
chart_ids?: string[];
|
|
25
26
|
_zh?: {
|
|
26
27
|
title?: string;
|
|
27
28
|
body?: string[];
|
|
@@ -96,6 +97,15 @@ export type CardMilestone = {
|
|
|
96
97
|
};
|
|
97
98
|
};
|
|
98
99
|
export type Card = CardKnowledge | CardMCQ | CardPractical | CardSimDemo | CardMilestone;
|
|
100
|
+
export type ChartArt = {
|
|
101
|
+
art: string;
|
|
102
|
+
art_t0?: string;
|
|
103
|
+
width_cols?: number;
|
|
104
|
+
tier?: string;
|
|
105
|
+
tags?: string[];
|
|
106
|
+
embargo_ok?: boolean;
|
|
107
|
+
first_used?: string;
|
|
108
|
+
};
|
|
99
109
|
/** Returns a copy of `card` with locale-aware fields applied.
|
|
100
110
|
*
|
|
101
111
|
* As of v2.19.204, all curriculum content is fetched from the server
|
|
@@ -118,6 +128,7 @@ export type Curriculum = {
|
|
|
118
128
|
cardRange: [number, number];
|
|
119
129
|
}[];
|
|
120
130
|
cards: Card[];
|
|
131
|
+
charts?: Record<string, ChartArt>;
|
|
121
132
|
};
|
|
122
133
|
/**
|
|
123
134
|
* Resolves a curriculum by id. Order:
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fuzzy resolver for the 🧠 Learn token-input picker.
|
|
3
|
+
*
|
|
4
|
+
* Problem: a first-time newbie at the prompt:
|
|
5
|
+
*
|
|
6
|
+
* Learn token (or blank to go back): _
|
|
7
|
+
*
|
|
8
|
+
* naturally tries any of the following (none of which used to work):
|
|
9
|
+
*
|
|
10
|
+
* learn LEARNDEMO01 (echoes the command they expect to type)
|
|
11
|
+
* ctf4eai (the track-name they saw in the list)
|
|
12
|
+
* 3 (the third listed option)
|
|
13
|
+
* learndemo01 (lower-case the token they saw)
|
|
14
|
+
* demo (it said "Free 12-card demos:")
|
|
15
|
+
*
|
|
16
|
+
* Only the correct input — bare upper-case LEARNDEMO01 — used to work.
|
|
17
|
+
* That's a >20% bounce point on the new-user funnel. This resolver maps
|
|
18
|
+
* all the above to the correct token (or returns a friendly hint).
|
|
19
|
+
*
|
|
20
|
+
* See [[reference-newbie-path-invariant]] + CLAUDE.md "Newbie Path
|
|
21
|
+
* Invariant" rule. Gold standard for inline guidance + accept-many-
|
|
22
|
+
* variants is the pre-v2.19.180 national-selection demo flow.
|
|
23
|
+
*/
|
|
24
|
+
export type LearnInputResolution = {
|
|
25
|
+
kind: 'back';
|
|
26
|
+
} | {
|
|
27
|
+
kind: 'token';
|
|
28
|
+
token: string;
|
|
29
|
+
} | {
|
|
30
|
+
kind: 'ambiguous';
|
|
31
|
+
hint: string;
|
|
32
|
+
} | {
|
|
33
|
+
kind: 'unknown';
|
|
34
|
+
hint: string;
|
|
35
|
+
};
|
|
36
|
+
export declare function resolveLearnInput(raw: string): LearnInputResolution;
|
|
@@ -0,0 +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|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/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/IO/IA + 8 chars cohort token. Blank to go back.`}}
|
package/dist/lib/learn-render.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import chalk from"chalk";import{localized as o}from"./learn-curricula.js";import{t as e}from"./learn-i18n.js";import{getConfig as l}from"./config.js";function n(){return(l().language||"en").toLowerCase()}function r(o="─"){return o.repeat(66)}function t(o,e,l=20){const n=e>0?o/e:0,r=Math.floor(n*l),t=l-r;return`${chalk.green("█".repeat(r))+chalk.gray("░".repeat(t))} ${(100*n).toFixed(1)}%`}function c(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,l,a){const s=n(),g=l.cardsCompleted.length,y=o.totalCards,i=y-g,d=o.modules.find(o=>l.currentCard>=o.cardRange[0]&&l.currentCard<=o.cardRange[1]);if(console.log(),console.log(chalk.cyan(" ╭"+r("═"))),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ║ ")+chalk.bold.white(" "+e("academy_title",s))),console.log(chalk.cyan(" ║")),a)console.log(chalk.cyan(" ║ ")+chalk.white(" "+e("welcome_new_demo",s)));else{const o=new Date(l.lastSeenAt),n=Math.floor((Date.now()-o.getTime())/36e5),r=n<1?e("just_now",s):n<24?`${n}${e("ago_hours",s)}`:`${Math.floor(n/24)}${e("ago_days",s)}`;console.log(chalk.cyan(" ║ ")+chalk.white(` ${e("welcome_back",s)} ${r}`))}console.log(chalk.cyan(" ║"));const u=d?`${d.number}. ${d.name}`:"—";console.log(chalk.cyan(" ║ ")+" "+chalk.gray(e("module",s).padEnd(11))+chalk.white(u)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(e("progress",s).padEnd(11))+t(g,y)+chalk.gray(` (${g}/${y})`)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(e("streak",s).padEnd(11))+c(l.streakDays)),i>0&&l.currentCard<=y&&console.log(chalk.cyan(" ║ ")+" "+chalk.gray(e("next_card",s).padEnd(11))+chalk.white(`#${l.currentCard} ${e("of",s)} ${y}`)),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ╰"+r("═"))),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const h=0===g?e("continue_start",s):`${e("continue_resume",s)} ${l.currentCard}`;console.log(chalk.bold.green(" continue")+chalk.gray(" "+h)),console.log(chalk.yellow(" status")+chalk.gray(" "+e("status_full",s))),l.bookmarks.length>0&&console.log(chalk.yellow(" bookmarks")+chalk.gray(` ${l.bookmarks.length} ${e("bookmarks_desc",s)}`)),console.log(chalk.gray(" quit")+chalk.gray(" "+e("quit_desc",s))),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log()}function a(o,l){const r=n(),t=o.module,c=l.modules.find(o=>o.number===t),a=c?c.name:e("unknown_module",r),s=e("module",r).replace(":","").trim(),g=`${e("card",r)} ${o.number} / ${l.totalCards} · ${s} ${t} · ${a}`;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(g)+" "+chalk.cyan("─".repeat(Math.max(0,64-g.length-4))))}function s(){console.log(chalk.cyan(" ╰"+r())),console.log()}function g(o){console.log(chalk.cyan(" │ ")+chalk.white(o))}function y(){console.log(chalk.cyan(" │"))}function i(o,e){const l=[];for(const n of o.split("\n")){if(""===n){l.push("");continue}let o="";for(const r of n.split(" "))(o+" "+r).trim().length>e?(l.push(o.trim()),o=r):o=(o+" "+r).trim();o&&l.push(o)}return l}export function renderKnowledgeCard(l,r){const t=n(),c=o(l,t);a(c,r),y(),g(chalk.bold.yellow(c.title)),g(chalk.gray("─".repeat(Math.min(c.title.length,64)))),y();for(const o of c.body){for(const e of i(o,60))""===e?y():g(" "+e);y()}if(c.icoaConnection){g(chalk.magenta(" "+e("icoa_connection",t)+" 📌")),g(chalk.gray(" "+"─".repeat(20)));for(const o of i(c.icoaConnection,60))g(" "+chalk.magenta(o));y()}if(l.check){const o=t.startsWith("zh"),e=o?l._zh?.checkStatement??l.check.statement:l.check.statement;g(chalk.cyan(" 🤔 "+(o?"快速理解检查 (输 y 或 n):":"Quick comprehension check (type y or n):"))),g(chalk.gray(" "+"─".repeat(20)));for(const o of i(e,60))g(" "+chalk.white(o));y()}s(),l.check?console.log(chalk.gray(" ")+chalk.bold.green("y")+chalk.gray(" / ")+chalk.bold.green("n")+chalk.gray(" "+(t.startsWith("zh")?"回答上面问题":"answer the check above"))):console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+e("continue_to_next",t))),console.log(chalk.gray(" bookmark "+e("bookmark_desc",t))),console.log(chalk.gray(" back "+e("back_desc",t))),console.log(chalk.gray(" quit "+e("quit_desc",t))),console.log()}export function renderCheckFeedback(o,l,r){const t=n(),c=t.startsWith("zh");if(console.log(),r)console.log(chalk.green(" ✓ ")+chalk.white(c?"答对了。":"Correct."));else{const e="y"===o.check?.answer?c?"是":"Yes":c?"否":"No";console.log(chalk.yellow(" ✗ ")+chalk.white((c?"正确答案是 ":"Actually ")+e+". "+(c?"回去再看一遍上面那段。":"Re-read the paragraph above.")))}console.log(),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+e("continue_to_next",t))),console.log()}export function renderMCQCard(l,r){const t=n(),c=o(l,t);a(c,r),y(),g(chalk.bold.yellow("🎯 "+c.title)),g(chalk.gray("─".repeat(Math.min(c.title.length+4,64)))),y();for(const o of i(c.question,60))g(" "+o);y();for(const o of["A","B","C","D"])g(chalk.cyan(` ${o}.`)+" "+chalk.white(c.options[o]));y(),s(),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(" "+e("type_to_answer",t))),console.log()}export function renderMCQFeedback(l,r,t,c){const a=n(),s=o(l,a);console.log(),t?console.log(" "+chalk.bold.green(e("correct",a)+" ")+chalk.gray(`${e("one_point",a)} · ${r} = ${s.options[r]}`)):console.log(" "+chalk.bold.red(e("not_quite",a)+" ")+chalk.gray(`${e("you_chose",a)} ${r}; ${e("answer_is",a)} ${s.answer}.`)),console.log(),console.log(chalk.gray(" "+e("explanation",a)));for(const o of i(s.explanation,60))console.log(chalk.gray(" "+o));const g=Object.values(c.mcqResults),y=g.filter(o=>o.correct).length;console.log(),console.log(chalk.gray(" "+e("mcq_accuracy_so_far",a)+" ")+chalk.white(`${y}/${g.length}`)),console.log(),console.log(chalk.gray(" "+e("press_ok_continue",a)+" ")+chalk.bold.green("ok")+chalk.gray(" "+e("to_continue",a))),console.log()}export function renderPracticalCard(l,r){const t=n(),c=o(l,t);a(c,r),y(),g(chalk.bold.yellow("🛠 "+c.title)),g(chalk.gray("─".repeat(Math.min(c.title.length+4,64)))),y();for(const o of i(c.task,60))g(" "+o);if(c.starterCode){y(),g(chalk.gray(" "+e("starter_code",t))),y();for(const o of c.starterCode.split("\n"))g(" "+chalk.cyan(o))}y(),s(),console.log(chalk.gray(" "+e("try_in_sandbox",t)+" ")+chalk.bold.cyan("!python3")+chalk.gray(" "+e("drops_into_python",t))),console.log(chalk.gray(" "+e("when_done",t))),console.log(chalk.gray(" ")+chalk.bold.green("done")+chalk.gray(" "+e("done_desc",t))),console.log(chalk.gray(" ")+chalk.bold.yellow("skip")+chalk.gray(" "+e("skip_desc",t))),console.log()}export function renderPracticalSuccess(l){const r=n(),t=o(l,r);console.log(),console.log(" "+chalk.bold.green(e("practical_recorded",r))),console.log(),console.log(chalk.gray(" "+e("reference_answer",r)));for(const o of i(t.successHint,60))console.log(chalk.gray(" "+o));console.log(),console.log(chalk.gray(" "+e("press_ok_continue",r)+" ")+chalk.bold.green("ok")+chalk.gray(" "+e("to_continue",r))),console.log()}export function renderSimDemoCard(l,r){const t=n(),c=o(l,t);a(c,r),y(),g(chalk.bold.yellow("🎬 "+c.title)),y();for(const o of i(c.description,60))g(" "+o);y(),g(chalk.gray(" "+e("sim_requires",t))),y(),s(),console.log(chalk.gray(" ")+chalk.bold.cyan("sim")+chalk.gray(" "+e("sim_launch_desc",t))),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+e("continue_to_next",t))),console.log(chalk.gray(" bookmark "+e("bookmark_desc",t))),console.log(chalk.gray(" back "+e("back_desc",t))),console.log(chalk.gray(" quit "+e("quit_desc",t))),console.log()}export function renderMilestone(l,t){const c=n(),a=o(l,c),s=l.number===t.totalCards;console.log(),console.log(chalk.bold.yellow(" ╭"+r("═"))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+chalk.white(" "+e("milestone_header",c))),console.log(chalk.bold.yellow(" ║"));const g=` ${a.badge} ${a.emoji}`;console.log(chalk.bold.yellow(" ║ ")+chalk.bold.green(g)),console.log(chalk.bold.yellow(" ║ ")+chalk.gray(" ─".repeat(Math.max(1,Math.floor(a.badge.length/2+2))))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(e("in_wild_corresponds",c)));for(const o of i(a.realWorldLevel,60))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(e("whats_next",c)));for(const o of i(a.unlockedNext,60))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ╰"+r("═"))),console.log(),s?(console.log(chalk.gray(" "+e("demo_complete",c))),console.log(),console.log(chalk.gray(" "+e("unlock_full",c)+" ")+chalk.white(e("curriculum_name",c))+chalk.gray(",")),console.log(chalk.gray(" "+e("contact_team_leader",c)+" ")+chalk.bold.yellow("EA")+chalk.gray(" "+e("learn_token",c))),console.log(chalk.gray(" "+e("or_email",c)+" ")+chalk.cyan("asra@icoa2026.au")+chalk.gray(" "+e("for_partnership",c))),console.log(),console.log(chalk.gray(" "+e("type_quit",c)+" ")+chalk.bold.green("quit")+chalk.gray(" "+e("to_exit",c)+" ")+chalk.bold.green("status")+chalk.gray(" "+e("for_dashboard",c)))):(console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+e("continue_to_next",c))),console.log(chalk.gray(" status "+e("status_full",c))),console.log(chalk.gray(" quit "+e("quit_desc",c)))),console.log()}export function renderStatus(o,l){const r=n(),a=l.cardsCompleted.length,i=o.totalCards,d=Object.values(l.mcqResults),u=d.filter(o=>o.correct).length;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(e("status_title",r))+" "+chalk.cyan("─".repeat(25))),y(),g(" "+chalk.gray(e("total_progress",r)+" ")+t(a,i)+chalk.gray(` (${a}/${i})`)),g(" "+chalk.gray(e("streak",r)+" ")+c(l.streakDays)+chalk.gray(` (${e("longest",r)} ${l.longestStreak})`)),g(" "+chalk.gray(e("mcq_accuracy",r)+" ")+chalk.white(`${u}/${d.length}`)),g(" "+chalk.gray(e("practicals_done",r)+" ")+chalk.white(`${l.practicalsCompleted.length}`)),g(" "+chalk.gray(e("bookmarked",r)+" ")+chalk.white(`${l.bookmarks.length}`)),y();const h=e("module",r).replace(":","").trim();for(const e of o.modules){const[o,n]=e.cardRange,r=l.cardsCompleted.filter(e=>e>=o&&e<=n).length,t=n-o+1;g(" "+(r===t?chalk.green("✓"):r>0?chalk.yellow("▶"):chalk.gray("□"))+" "+chalk.gray(`${h} ${e.number}: `)+chalk.white(`${r}/${t}`)+chalk.gray(" "+e.name))}if(y(),l.achievements.length>0){g(" "+chalk.gray(e("achievements",r)));for(const o of l.achievements)g(" "+chalk.bold.yellow("★ ")+chalk.white(o))}else g(" "+chalk.gray(e("achievements_none",r)));y(),s()}
|
|
1
|
+
import chalk from"chalk";import{localized as o}from"./learn-curricula.js";import{t as e}from"./learn-i18n.js";import{getConfig as n}from"./config.js";import{renderCharts as l,detectCaps as r}from"./render-card.js";function t(){return(n().language||"en").toLowerCase()}function c(o="─"){return o.repeat(66)}function a(o,e,n=20){const l=e>0?o/e:0,r=Math.floor(l*n),t=n-r;return`${chalk.green("█".repeat(r))+chalk.gray("░".repeat(t))} ${(100*l).toFixed(1)}%`}function s(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,n,l){const r=t(),g=n.cardsCompleted.length,y=o.totalCards,d=y-g,i=o.modules.find(o=>n.currentCard>=o.cardRange[0]&&n.currentCard<=o.cardRange[1]);if(console.log(),console.log(chalk.cyan(" ╭"+c("═"))),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ║ ")+chalk.bold.white(" "+e("academy_title",r))),console.log(chalk.cyan(" ║")),l)console.log(chalk.cyan(" ║ ")+chalk.white(" "+e("welcome_new_demo",r)));else{const o=new Date(n.lastSeenAt),l=Math.floor((Date.now()-o.getTime())/36e5),t=l<1?e("just_now",r):l<24?`${l}${e("ago_hours",r)}`:`${Math.floor(l/24)}${e("ago_days",r)}`;console.log(chalk.cyan(" ║ ")+chalk.white(` ${e("welcome_back",r)} ${t}`))}console.log(chalk.cyan(" ║"));const u=i?`${i.number}. ${i.name}`:"—";console.log(chalk.cyan(" ║ ")+" "+chalk.gray(e("module",r).padEnd(11))+chalk.white(u)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(e("progress",r).padEnd(11))+a(g,y)+chalk.gray(` (${g}/${y})`)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(e("streak",r).padEnd(11))+s(n.streakDays)),d>0&&n.currentCard<=y&&console.log(chalk.cyan(" ║ ")+" "+chalk.gray(e("next_card",r).padEnd(11))+chalk.white(`#${n.currentCard} ${e("of",r)} ${y}`)),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ╰"+c("═"))),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const h=0===g?e("continue_start",r):`${e("continue_resume",r)} ${n.currentCard}`;console.log(chalk.bold.green(" continue")+chalk.gray(" "+h)),console.log(chalk.yellow(" status")+chalk.gray(" "+e("status_full",r))),n.bookmarks.length>0&&console.log(chalk.yellow(" bookmarks")+chalk.gray(` ${n.bookmarks.length} ${e("bookmarks_desc",r)}`)),console.log(chalk.gray(" quit")+chalk.gray(" "+e("quit_desc",r))),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log()}function g(o,n){const l=t(),r=o.module,c=n.modules.find(o=>o.number===r),a=c?c.name:e("unknown_module",l),s=e("module",l).replace(":","").trim(),g=`${e("card",l)} ${o.number} / ${n.totalCards} · ${s} ${r} · ${a}`;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(g)+" "+chalk.cyan("─".repeat(Math.max(0,64-g.length-4))))}function y(){console.log(chalk.cyan(" ╰"+c())),console.log()}function d(o){console.log(chalk.cyan(" │ ")+chalk.white(o))}function i(){console.log(chalk.cyan(" │"))}const u=/[┌┐└┘├┤┬┴┼─│╔╗╚╝═║╠╣╦╩╬▓▒░█]/;function h(o){return/^(?: {4}|\t)/.test(o)||u.test(o)||/ {3,}/.test(o)}function m(o,e){const n=[];for(const l of o.split("\n")){if(""===l){n.push("");continue}if(h(l)){n.push(l);continue}let o="";for(const r of l.split(" "))(o+" "+r).trim().length>e?(n.push(o.trim()),o=r):o=(o+" "+r).trim();o&&n.push(o)}return n}export function renderKnowledgeCard(n,c){const a=t(),s=o(n,a);g(s,c),i(),d(chalk.bold.yellow(s.title)),d(chalk.gray("─".repeat(Math.min(s.title.length,64)))),n.chart_ids&&n.chart_ids.length>0?l(n.chart_ids,c.charts,r()):i();for(const o of s.body){for(const e of m(o,60))""===e?i():d(" "+e);i()}if(s.icoaConnection){d(chalk.magenta(" "+e("icoa_connection",a)+" 📌")),d(chalk.gray(" "+"─".repeat(20)));for(const o of m(s.icoaConnection,60))d(" "+chalk.magenta(o));i()}if(n.check){const o=a.startsWith("zh"),e=o?n._zh?.checkStatement??n.check.statement:n.check.statement;d(chalk.cyan(" 🤔 "+(o?"快速理解检查 (输 y 或 n):":"Quick comprehension check (type y or n):"))),d(chalk.gray(" "+"─".repeat(20)));for(const o of m(e,60))d(" "+chalk.white(o));i()}y(),n.check?console.log(chalk.gray(" ")+chalk.bold.green("y")+chalk.gray(" / ")+chalk.bold.green("n")+chalk.gray(" "+(a.startsWith("zh")?"回答上面问题":"answer the check above"))):console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+e("continue_to_next",a))),console.log(chalk.gray(" bookmark "+e("bookmark_desc",a))),console.log(chalk.gray(" back "+e("back_desc",a))),console.log(chalk.gray(" card N / card review jump to card N / phase y/n recap")),console.log(chalk.gray(" quit "+e("quit_desc",a))),console.log()}export function renderCheckFeedback(o,n,l){const r=t(),c=r.startsWith("zh");if(console.log(),l)console.log(chalk.green(" ✓ ")+chalk.white(c?"答对了。":"Correct."));else{const e="y"===o.check?.answer?c?"是":"Yes":c?"否":"No";console.log(chalk.yellow(" ✗ ")+chalk.white((c?"正确答案是 ":"Actually ")+e+". "+(c?"回去再看一遍上面那段。":"Re-read the paragraph above.")))}console.log(),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+e("continue_to_next",r))),console.log()}export function renderMCQCard(n,l){const r=t(),c=o(n,r);g(c,l),i(),d(chalk.bold.yellow("🎯 "+c.title)),d(chalk.gray("─".repeat(Math.min(c.title.length+4,64)))),i();for(const o of m(c.question,60))d(" "+o);i();for(const o of["A","B","C","D"])d(chalk.cyan(` ${o}.`)+" "+chalk.white(c.options[o]));i(),y(),console.log(chalk.gray(" "+(r.startsWith("zh")?"输入 ":"Type "))+chalk.bold.green("A")+chalk.gray(" / ")+chalk.bold.green("B")+chalk.gray(" / ")+chalk.bold.green("C")+chalk.gray(" / ")+chalk.bold.green("D")+chalk.gray(" "+e("type_to_answer",r))),console.log()}export function renderMCQFeedback(n,l,r,c){const a=t(),s=o(n,a);console.log(),r?console.log(" "+chalk.bold.green(e("correct",a)+" ")+chalk.gray(`${e("one_point",a)} · ${l} = ${s.options[l]}`)):console.log(" "+chalk.bold.red(e("not_quite",a)+" ")+chalk.gray(`${e("you_chose",a)} ${l}; ${e("answer_is",a)} ${s.answer}.`)),console.log(),console.log(chalk.gray(" "+e("explanation",a)));for(const o of m(s.explanation,60))console.log(chalk.gray(" "+o));const g=Object.values(c.mcqResults),y=g.filter(o=>o.correct).length;console.log(),console.log(chalk.gray(" "+e("mcq_accuracy_so_far",a)+" ")+chalk.white(`${y}/${g.length}`)),console.log(),console.log(chalk.gray(" "+e("press_ok_continue",a)+" ")+chalk.bold.green("ok")+chalk.gray(" "+e("to_continue",a))),console.log()}export function renderPracticalCard(n,l){const r=t(),c=o(n,r);g(c,l),i(),d(chalk.bold.yellow("🛠 "+c.title)),d(chalk.gray("─".repeat(Math.min(c.title.length+4,64)))),i();for(const o of m(c.task,60))d(" "+o);if(c.starterCode){i(),d(chalk.gray(" "+e("starter_code",r))),i();for(const o of c.starterCode.split("\n"))d(" "+chalk.cyan(o))}i(),y(),console.log(chalk.gray(" "+e("try_in_sandbox",r)+" ")+chalk.bold.cyan("!python3")+chalk.gray(" "+e("drops_into_python",r))),console.log(chalk.gray(" "+e("when_done",r))),console.log(chalk.gray(" ")+chalk.bold.green("done")+chalk.gray(" "+e("done_desc",r))),console.log(chalk.gray(" ")+chalk.bold.yellow("skip")+chalk.gray(" "+e("skip_desc",r))),console.log(chalk.gray(" card N / card review jump to card N / phase y/n recap")),console.log()}export function renderPracticalSuccess(n){const l=t(),r=o(n,l);console.log(),console.log(" "+chalk.bold.green(e("practical_recorded",l))),console.log(),console.log(chalk.gray(" "+e("reference_answer",l)));for(const o of m(r.successHint,60))console.log(chalk.gray(" "+o));console.log(),console.log(chalk.gray(" "+e("press_ok_continue",l)+" ")+chalk.bold.green("ok")+chalk.gray(" "+e("to_continue",l))),console.log()}export function renderSimDemoCard(n,l){const r=t(),c=o(n,r);g(c,l),i(),d(chalk.bold.yellow("🎬 "+c.title)),i();for(const o of m(c.description,60))d(" "+o);i(),d(chalk.gray(" "+e("sim_requires",r))),i(),y(),console.log(chalk.gray(" ")+chalk.bold.cyan("sim")+chalk.gray(" "+e("sim_launch_desc",r))),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+e("continue_to_next",r))),console.log(chalk.gray(" bookmark "+e("bookmark_desc",r))),console.log(chalk.gray(" back "+e("back_desc",r))),console.log(chalk.gray(" card N / card review jump to card N / phase y/n recap")),console.log(chalk.gray(" quit "+e("quit_desc",r))),console.log()}export function renderMilestone(n,l){const r=t(),a=o(n,r),s=n.number===l.totalCards;console.log(),console.log(chalk.bold.yellow(" ╭"+c("═"))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+chalk.white(" "+e("milestone_header",r))),console.log(chalk.bold.yellow(" ║"));const g=` ${a.badge} ${a.emoji}`;console.log(chalk.bold.yellow(" ║ ")+chalk.bold.green(g)),console.log(chalk.bold.yellow(" ║ ")+chalk.gray(" ─".repeat(Math.max(1,Math.floor(a.badge.length/2+2))))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(e("in_wild_corresponds",r)));for(const o of m(a.realWorldLevel,60))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(e("whats_next",r)));for(const o of m(a.unlockedNext,60))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ╰"+c("═"))),console.log(),s?(console.log(chalk.gray(" "+e("demo_complete",r))),console.log(),console.log(chalk.gray(" "+e("unlock_full",r)+" ")+chalk.white(e("curriculum_name",r))+chalk.gray(",")),console.log(chalk.gray(" "+e("contact_team_leader",r)+" ")+chalk.bold.yellow("EA")+chalk.gray(" "+e("learn_token",r))),console.log(chalk.gray(" "+e("or_email",r)+" ")+chalk.cyan("asra@icoa2026.au")+chalk.gray(" "+e("for_partnership",r))),console.log(),console.log(chalk.gray(" "+e("type_quit",r)+" ")+chalk.bold.green("quit")+chalk.gray(" "+e("to_exit",r)+" ")+chalk.bold.green("status")+chalk.gray(" "+e("for_dashboard",r)))):(console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+e("continue_to_next",r))),console.log(chalk.gray(" status "+e("status_full",r))),console.log(chalk.gray(" card N / card review jump to card N / phase y/n recap")),console.log(chalk.gray(" quit "+e("quit_desc",r)))),console.log()}export function renderStatus(o,n){const l=t(),r=n.cardsCompleted.length,c=o.totalCards,g=Object.values(n.mcqResults),u=g.filter(o=>o.correct).length;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(e("status_title",l))+" "+chalk.cyan("─".repeat(25))),i(),d(" "+chalk.gray(e("total_progress",l)+" ")+a(r,c)+chalk.gray(` (${r}/${c})`)),d(" "+chalk.gray(e("streak",l)+" ")+s(n.streakDays)+chalk.gray(` (${e("longest",l)} ${n.longestStreak})`)),d(" "+chalk.gray(e("mcq_accuracy",l)+" ")+chalk.white(`${u}/${g.length}`)),d(" "+chalk.gray(e("practicals_done",l)+" ")+chalk.white(`${n.practicalsCompleted.length}`)),d(" "+chalk.gray(e("bookmarked",l)+" ")+chalk.white(`${n.bookmarks.length}`)),i();const h=e("module",l).replace(":","").trim();for(const e of o.modules){const[o,l]=e.cardRange,r=n.cardsCompleted.filter(e=>e>=o&&e<=l).length,t=l-o+1;d(" "+(r===t?chalk.green("✓"):r>0?chalk.yellow("▶"):chalk.gray("□"))+" "+chalk.gray(`${h} ${e.number}: `)+chalk.white(`${r}/${t}`)+chalk.gray(" "+e.name))}if(i(),n.achievements.length>0){d(" "+chalk.gray(e("achievements",l)));for(const o of n.achievements)d(" "+chalk.bold.yellow("★ ")+chalk.white(o))}else d(" "+chalk.gray(e("achievements_none",l)));i(),y()}
|
|
@@ -3,6 +3,11 @@ export type MCQResult = {
|
|
|
3
3
|
correct: boolean;
|
|
4
4
|
submittedAt: string;
|
|
5
5
|
};
|
|
6
|
+
export type CheckResult = {
|
|
7
|
+
answer: 'y' | 'n';
|
|
8
|
+
correct: boolean;
|
|
9
|
+
submittedAt: string;
|
|
10
|
+
};
|
|
6
11
|
export type LearnState = {
|
|
7
12
|
token: string;
|
|
8
13
|
curriculumId: string;
|
|
@@ -14,6 +19,7 @@ export type LearnState = {
|
|
|
14
19
|
longestStreak: number;
|
|
15
20
|
cardsCompleted: number[];
|
|
16
21
|
mcqResults: Record<string, MCQResult>;
|
|
22
|
+
checkResults?: Record<string, CheckResult>;
|
|
17
23
|
practicalsCompleted: number[];
|
|
18
24
|
bookmarks: number[];
|
|
19
25
|
achievements: string[];
|
|
@@ -32,6 +38,7 @@ export declare function newLearnState(token: string, curriculumId: string, total
|
|
|
32
38
|
export declare function updateStreak(state: LearnState): void;
|
|
33
39
|
export declare function markCardComplete(state: LearnState, cardNumber: number): void;
|
|
34
40
|
export declare function recordMCQ(state: LearnState, cardNumber: number, result: MCQResult): void;
|
|
41
|
+
export declare function recordCheck(state: LearnState, cardNumber: number, result: CheckResult): void;
|
|
35
42
|
export declare function markPracticalComplete(state: LearnState, cardNumber: number): void;
|
|
36
43
|
export declare function addAchievement(state: LearnState, badge: string): void;
|
|
37
44
|
export declare function getStateFilePath(): string;
|
package/dist/lib/learn-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as e,mkdirSync as t,readFileSync as r,writeFileSync as a}from"node:fs";import{homedir as n}from"node:os";import{join as o}from"node:path";const s=o(n(),".icoa"),c=o(s,"learn-state.json");export function loadLearnState(){if(!e(c))return null;try{return JSON.parse(r(c,"utf-8"))}catch{return null}}export function saveLearnState(r){e(s)||t(s,{recursive:!0}),r.lastSeenAt=(new Date).toISOString(),a(c,JSON.stringify(r,null,2))}export function clearLearnState(){if(e(c))try{a(c,"")}catch{}}export function newLearnState(e,t,r){const a=(new Date).toISOString();return{token:e,curriculumId:t,currentCard:1,totalCards:r,startedAt:a,lastSeenAt:a,streakDays:1,longestStreak:1,cardsCompleted:[],mcqResults:{},checkResults:{},practicalsCompleted:[],bookmarks:[],achievements:[],totalSecondsActive:0}}export function updateStreak(e){const t=new Date(e.lastSeenAt),r=new Date,a=Math.floor(t.getTime()/864e5),n=Math.floor(r.getTime()/864e5)-a;0!==n&&(1===n?(e.streakDays+=1,e.streakDays>e.longestStreak&&(e.longestStreak=e.streakDays)):e.streakDays=1)}export function markCardComplete(e,t){e.cardsCompleted.includes(t)||e.cardsCompleted.push(t)}export function recordMCQ(e,t,r){e.mcqResults[String(t)]=r}export function recordCheck(e,t,r){e.checkResults||(e.checkResults={}),e.checkResults[String(t)]=r}export function markPracticalComplete(e,t){e.practicalsCompleted.includes(t)||e.practicalsCompleted.push(t)}export function addAchievement(e,t){e.achievements.includes(t)||e.achievements.push(t)}export function getStateFilePath(){return c}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Curriculum } from './learn-curricula.js';
|
|
2
|
+
export type RenderCaps = {
|
|
3
|
+
tier: 'T0' | 'T1';
|
|
4
|
+
cols: number;
|
|
5
|
+
utf8: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function detectCaps(): RenderCaps;
|
|
8
|
+
/**
|
|
9
|
+
* Render chart art for a list of chart_ids. Each chart prints on its own
|
|
10
|
+
* "block" with a blank separator line above. Lines are left-padded with the
|
|
11
|
+
* three-sided-frame left bar to match learn-render body style.
|
|
12
|
+
*
|
|
13
|
+
* Pass `frameLeft = false` for standalone (non-card-frame) contexts.
|
|
14
|
+
*/
|
|
15
|
+
export declare function renderCharts(chartIds: string[] | undefined, charts: Curriculum['charts'], caps?: RenderCaps, opts?: {
|
|
16
|
+
frameLeft?: boolean;
|
|
17
|
+
}): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import chalk from"chalk";export function detectCaps(){const t=process.stdout.columns||80,o=process.env.LANG||process.env.LC_ALL||"",e=/utf-?8/i.test(o)||""===o||"C.UTF-8"===o;return"ascii"!==(process.env.ICOA_RENDER||"").toLowerCase()&&"C"!==o&&"POSIX"!==o&&e?{tier:"T1",cols:t,utf8:e}:{tier:"T0",cols:t,utf8:!1}}function t(t,o){return"T0"===o.tier&&t.art_t0||t.width_cols&&t.width_cols>o.cols-6&&t.art_t0?t.art_t0:t.art}export function renderCharts(o,e,r=detectCaps(),s={}){if(!o||0===o.length)return;if(!e)return;const n=!1!==s.frameLeft,c=n?chalk.cyan(" │ "):" ",i=n?chalk.cyan(" │"):"";let f=0;for(const s of o){const o=e[s];if(!o)continue;const n=t(o,r);console.log(i);for(const t of n.split("\n"))console.log(c+chalk.gray(t));f++}f>0&&console.log(i)}
|
package/dist/repl.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createInterface as o}from"node:readline";import{spawn as e,execSync as l}from"node:child_process";import chalk from"chalk";import{isConnected as n,getConfig as t,saveConfig as a}from"./lib/config.js";import{isActivated as s,activateToken as r,isFreeCommand as i,isDeviceMatch as c,recordExit as g,recordResume as y,isFirstRunOrUpgrade as m,markVersionSeen as d}from"./lib/access.js";import{setReplMode as p}from"./lib/ui.js";import{returnToMainMenu as u,printMenuHint as h,menuHintInline as w}from"./lib/menu-nav.js";import{setMainRl as f}from"./lib/main-rl.js";import{isChatActive as b,handleChatMessage as x}from"./commands/ai4ctf.js";import{isCtf4aiActive as v,handleCtf4aiMessage as C}from"./commands/ctf4ai-demo.js";import{isCtf4VlaActive as A,handleCtf4VlaMessage as I}from"./commands/ctf4vla.js";import{isDemo2Active as k}from"./commands/demo2.js";import{loadDemo2Progress as T}from"./lib/demo2-progress.js";import{hasAnySimHistory as S,lastArmAt as $,lastBundledAt as O,lastSimAt as E}from"./lib/sim-cooldown.js";import{getExamState as L,getRealExamState as D,getDemoState as P}from"./lib/exam-state.js";import{resetTerminalTheme as R}from"./lib/theme.js";import{ensureSandbox as j,runInSandbox as q,isDockerAvailable as F}from"./lib/sandbox.js";import{checkShellRisk as N,logShellAudit as M,getActiveCwd as B}from"./lib/exam-sandbox.js";import{logCommand as U}from"./lib/logger.js";import{startLogSync as Q,stopLogSync as _}from"./lib/log-sync.js";import{existsSync as W,mkdirSync as Y,writeFileSync as z}from"node:fs";import{join as V}from"node:path";import{homedir as G}from"node:os";function J(){return D()?chalk.cyan("exam> "):P()?chalk.yellow("demo> "):chalk.green("icoa> ")}const H=V(G(),"icoa-workspace"),K=new Set(["sudo","su","doas","pkexec","brew","apt","apt-get","yum","choco","npm","npx","pip","pip3","shutdown","reboot","halt","mkfs","fdisk","dd","iptables","ufw"]),Z="__REPL_NO_EXIT__",X="2.5.1";function oo(){console.log(),console.log(` ${chalk.cyan.bold("🎯 ICOA 2026 · National Selection")}`),console.log(),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("ACxxxxxxxx")+chalk.gray(" → ai4ctf-12 (AI as your CTF teammate)")),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("CAxxxxxxxx")+chalk.gray(" → ctf4ai-12 (red-team software AI)")),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("EAxxxxxxxx")+chalk.gray(" → ctf4eai-12 (red-team embodied AI)")),console.log(" "+chalk.bold.cyan("exam ")+chalk.white("<CC>xxxxxxxx")+chalk.gray(" → Paper A/B/C/D/E (country exam token)")),console.log(" "+chalk.bold.cyan("demo")+chalk.gray(" → free practice")),console.log(" "+chalk.bold.cyan("lang")+chalk.white(" es")+chalk.gray(" → switch language")),console.log(" "+chalk.gray("help · menu · quit")),console.log()}export async function startRepl(e,P){process.env.ICOA_INSIDE_REPL="1";const no=t(),to=n(),ao=process.exit.bind(process),so=s();if(no.demoCleanedForVersion!==X){try{const{existsSync:o,unlinkSync:e}=await import("node:fs"),{join:l}=await import("node:path"),{getIcoaDir:n}=await import("./lib/config.js"),t=l(n(),"demo-state.json");o(t)&&e(t)}catch{}a({demoCleanedForVersion:X})}const{select:ro,confirm:io}=await import("@inquirer/prompts"),co=no.mode||"",go=["instant","learn","selection","olympiad"].includes(co)?co:"selection",yo=[{name:` ${chalk.bold("⚡ Try ICOA in 30 seconds")} ${chalk.gray("—")} ${chalk.gray("watch · no token needed")}`,value:"instant"},{name:` ${chalk.bold("🧠 Learn")} ${chalk.gray("—")} ${chalk.gray("AC / CA / EA token · skill up")}`,value:"learn"},{name:` ${chalk.bold("🎯 National Selection")} ${chalk.gray("—")} ${chalk.gray("country exam token · aim for finals")}`,value:"selection"},{name:` ${chalk.bold("🏆 International Olympiad")} ${chalk.gray("—")} ${chalk.gray("finals stage · Sydney 2026 · full sandbox")}`,value:"olympiad"},{name:` ${chalk.gray("ℹ️ About ICOA")} ${chalk.gray("·")} ${chalk.gray("what this is · how to join")}`,value:"about"}];console.log(chalk.gray(" Use ")+chalk.yellow("↑")+chalk.gray(" / ")+chalk.yellow("↓")+chalk.gray(" to select, ")+chalk.yellow("Enter")+chalk.gray(" to confirm. Type ")+chalk.bold.cyan("menu")+chalk.gray(" anywhere to return here.")),console.log();let mo="";for(;!mo;){const o=await ro({message:"Mode",choices:yo,default:go||"selection"});"about"!==o?mo=o:(console.clear(),console.log(),console.log(chalk.cyan(" ═══════════════════════════════════════════════════")),console.log(chalk.bold.yellow(" ICOA")+chalk.white(" — AI-Native CLI OS for Cyber & AI Security")),console.log(chalk.gray(" Olympiad & Competition · K-12 to University")),console.log(chalk.cyan(" ───────────────────────────────────────────────────")),console.log(),console.log(chalk.bold.white(" What Makes ICOA Different")),console.log(chalk.gray(" · AI-native AI teammate, AI adversary, AI translation")),console.log(chalk.gray(" · CLI OS Complete competition environment in terminal")),console.log(chalk.gray(" · 110 tools pwntools, z3, gdb, nmap, sleuthkit... pre-configured")),console.log(chalk.gray(" · Global scale 15,000+ concurrent exams · 15 languages")),console.log(),console.log(chalk.bold.white(" Competition Format (2-day standard + 1-day Pioneer)")),console.log(` ${chalk.green.bold("AI4CTF")}${chalk.gray(" [Day 1] AI as teammate — speed track, dynamic decay + top-3 bonus")}`),console.log(` ${chalk.red.bold("CTF4AI")}${chalk.gray(" [Day 2] AI as target — knowledge track, static value per challenge")}`),console.log(` ${chalk.cyan.bold("CTF4EAI")}${chalk.gray(" [Pioneer / Practical Round] Embodied AI — VLA + world models + sim-to-real")}`),console.log(),console.log(chalk.bold.white(" Scoring (in brief)")),console.log(chalk.gray(" · Standard medals: AI4CTF + CTF4AI combined · 1/12 Gold · 2/12 Silver · 3/12 Bronze")),console.log(chalk.gray(" · HMA: top 50% on either day, total below bronze cutoff")),console.log(chalk.gray(" · CTF4EAI: separate 15-finalist pool, G/S/B + 12 Finalist Awards")),console.log(),console.log(chalk.white(" Sydney, Australia")+chalk.gray(" · Jun 27 - Jul 2, 2026")),console.log(),console.log(chalk.bold.white(" Organized by")+chalk.gray(" ASRA (Australia) · ICO Foundation Inc")),console.log(chalk.bold.white(" Contact ")+chalk.cyan(" australia@icoa2026.au · accreditation@icoa2026.au")),console.log(chalk.bold.white(" Website ")+chalk.cyan.underline(" https://icoa2026.au")),console.log(chalk.cyan(" ═══════════════════════════════════════════════════")),console.log(),console.log(chalk.gray(" Press ")+chalk.yellow("Enter")+chalk.gray(" to return...")),await new Promise(o=>{const e=l=>{process.stdin.removeListener("data",e),process.stdin.isTTY&&process.stdin.setRawMode&&process.stdin.setRawMode(!1),process.stdin.pause(),o()};process.stdin.isTTY&&process.stdin.setRawMode&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.once("data",e)}),console.clear())}if("olympiad"===mo&&"olympiad"!==go&&(console.log(),console.log(chalk.yellow(" This mode will download ~500MB of CTF tools and AI models.")),await io({message:"Continue?",default:!0})||(mo="selection",console.log(chalk.gray(" Switched to National Selection mode.")))),mo!==go&&a({mode:mo}),console.log(),"olympiad"===mo&&m(X)){d(X),console.log(chalk.gray(" Checking competition environment..."));const{execSync:o}=await import("node:child_process"),e=[{name:"pwntools",cmd:'python3 -c "import pwn"'},{name:"z3-solver",cmd:'python3 -c "import z3"'},{name:"numpy",cmd:'python3 -c "import numpy"'},{name:"requests",cmd:'python3 -c "import requests"'}];let l=0;for(const n of e)try{o(n.cmd,{stdio:"ignore"})}catch{l++}if(l>0){console.log(chalk.yellow(` ${l} core libraries missing.`));try{const{confirm:o}=await import("@inquirer/prompts");if(await o({message:" Install competition Python libraries now?",default:!0,theme:{prefix:"",style:{message:o=>chalk.green(o),defaultAnswer:o=>chalk.green(o)}}})){console.log();const{execSync:o}=await import("node:child_process");o("icoa env setup",{stdio:"inherit"})}}catch{console.log(chalk.gray(" Run ")+chalk.white("env setup")+chalk.gray(" later to install."))}console.log()}else console.log(chalk.green(" All core libraries ready.")),console.log()}if(P){const o=y();if(o){const e=Math.floor(o.awaySeconds/60),l=o.awaySeconds%60;console.log(chalk.yellow(` Session resumed. Away: ${e}m ${l}s | Total exits: ${o.exitCount}`)),console.log()}}if("selection"===mo)console.log(chalk.gray(" ─── exam hall · 90 min per paper once started · no pause ───")),console.log(),oo();else if("embodied"===mo)!function(){console.log(chalk.cyan.bold(" [🤖 ctf4eai — Embodied AI Security]")),console.log(),console.log(chalk.bold.cyan(" CTF4VLA")+chalk.gray(" — ICOA 2026's ")+chalk.bold.white("Pioneer Round")),console.log(chalk.gray(" an independent parallel track alongside the scored main events: ")+chalk.green("AI4CTF")+chalk.gray(" (Day 1) and ")+chalk.red("CTF4AI")+chalk.gray(" (Day 2)")),console.log(),console.log(chalk.white(" Embodied AI is at its ImageNet moment.")),console.log(chalk.gray(" VLA models, MuJoCo physics, real robot arms.")),console.log(chalk.gray(" Real models, real physics, real attack surfaces.")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const o=O()>0||E()>0,e=$()>0,l=S(),n=T(),t=null!==n&&"number"==typeof n.completedAt&&n.nextCardIndex>=n.totalCards,a=null!==n&&!t;if(t)console.log(chalk.bold.yellow(" Continue: ")+chalk.bold.cyan("④ learn LEARNDEMO01")+chalk.gray(" (demo2 ✓ · sim")+(e?chalk.gray(" ✓ · sim arm ✓)"):chalk.gray(")")));else if(a){const o=`${n.nextCardIndex} / ${n.totalCards}`;console.log(chalk.bold.yellow(" Continue: ")+chalk.bold.cyan("③ demo2")+chalk.gray(" (last left at card ")+chalk.bold.yellow(o)+chalk.gray(")"))}else o&&e?console.log(chalk.bold.yellow(" Next up: ")+chalk.bold.cyan("③ demo2")+chalk.gray(" → ")+chalk.bold.cyan("④ learn LEARNDEMO01")+chalk.gray(" (sim ✓ · sim arm ✓)")):l?console.log(chalk.bold.yellow(" Next up: ")+(e?chalk.bold.cyan("① sim")+chalk.gray(" → ")+chalk.bold.cyan("③ demo2"):chalk.bold.cyan("② sim arm")+chalk.gray(" → ")+chalk.bold.cyan("③ demo2"))+chalk.gray(" → ")+chalk.bold.cyan("④ learn LEARNDEMO01")):console.log(chalk.bold.yellow(" First time? Try in order: ")+chalk.bold.cyan("① sim")+chalk.gray(" → ")+chalk.bold.cyan("② sim arm")+chalk.gray(" → ")+chalk.bold.cyan("③ demo2")+chalk.gray(" → ")+chalk.bold.cyan("④ learn LEARNDEMO01"));console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.bold.green(" sim")+chalk.gray(" ")+chalk.bold.cyan("①")+chalk.gray(" ")+chalk.bold.yellow("★ INSTANT")+chalk.gray(" — 8-robot group dance, no wait, no setup")),console.log(chalk.bold.green(" sim arm")+chalk.gray(" ")+chalk.bold.cyan("②")+chalk.gray(" interactive 6-DOF arm sandbox — type joint values, watch")),console.log(chalk.bold.green(" demo2")+chalk.gray(" ")+chalk.bold.cyan("③")+chalk.gray(" ~8 min interactive intro + live MuJoCo sim")),console.log(chalk.bold.green(" learn LEARNDEMO01")+chalk.gray(" ")+chalk.bold.cyan("④")+chalk.gray(" free 11-card intro (paste this command as-is)")),console.log(chalk.bold.green(" learn ")+chalk.bold.yellow("EA")+chalk.gray(" + 8 chars full 96 / 360 curriculum (team-issued)")),console.log(chalk.bold.green(" exam ")+chalk.bold.yellow("PDxxxxxxxx")+chalk.gray(" Paper D (CTF4VLA) — national selection contestants")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(),console.log(chalk.gray(" Three open tiers: ")+chalk.green("free 11")+chalk.gray(" · ")+chalk.yellow("registered 100")+chalk.gray(" · ")+chalk.bold.magenta("national team 480")+chalk.gray(" (PhD-ready)")),console.log(chalk.gray(" Country team contact: ")+chalk.cyan("australia@icoa2026.au")),console.log(),h(),console.log()}();else{if("instant"===mo){console.log(chalk.cyan.bold(" [⚡ Try ICOA in 30 seconds — no token needed]")),console.log(),console.log(chalk.gray(" Pick what you want to see first:")),console.log();const o=[{name:` ${chalk.bold.green("★ demo ")} ${chalk.gray("Paper A/B/C taste — MCQ + ai4ctf + ctf4ai ")}`+chalk.bold.cyan("🎯 selection-style"),value:"demo"},{name:` ${chalk.bold.green("★ demo2 ")} ${chalk.gray("15-sec countdown render · bundled & offline ")}`+chalk.bold.yellow("⚡ visual wow"),value:"demo2"},{name:` ${chalk.gray("↩ back to main menu")}`,value:"menu"}];let l="menu";try{l=await ro({message:"Pick",choices:o,default:"demo"})}catch{}if("menu"!==l){console.log();const o="demo2"===l?"sim":l;try{await e.parseAsync(["node","icoa",o])}catch{}}return a({mode:"selection"}),void u()}if("learn"===mo){console.log(chalk.cyan.bold(" [🧠 Learn]")),console.log(),console.log(chalk.gray(" Three tracks · same difficulty curve · paste any token below.")),console.log(),console.log(chalk.white(" Free 12-card demos:")),console.log(chalk.bold(" 🤝 ai4ctf")+chalk.gray(" AI as your teammate ")+chalk.bold.green("AI4CTFDEMO01")),console.log(chalk.bold(" 🔓 ctf4ai")+chalk.gray(" AI as your target ")+chalk.bold.green("CTF4AIDEMO01")),console.log(chalk.bold(" 🤖 ctf4eai")+chalk.gray(" Embodied AI Security ")+chalk.bold.green("LEARNDEMO01")),console.log(),console.log(chalk.gray(" Got a learn token from your cohort? Paste it below.")),console.log(chalk.gray(" Format: ")+chalk.cyan("AC / CA / EA / IO / IA")+chalk.gray(" + 8 chars · unlocks 96 / 360 / future tiers.")),console.log();try{const{input:o}=await import("@inquirer/prompts"),l=(await o({message:" Learn token (or blank to go back):"})).trim();l&&(console.log(),console.log(chalk.gray(" Opening ")+chalk.bold.cyan("learn")+chalk.gray(`: ${l}`)),console.log(),a({mode:"selection"}),await e.parseAsync(["node","icoa","learn",l]))}catch{}return a({mode:"selection"}),void u()}"organizer"===mo?(console.log(chalk.yellow.bold(" [National/Regional Partner]")),console.log(),console.log(chalk.bold.white(" ██╗ ██████╗ ██████╗ █████╗")),console.log(chalk.bold.white(" ██║██╔════╝██╔═══██╗██╔══██╗")),console.log(chalk.bold.white(" ██║██║ ██║ ██║███████║")),console.log(chalk.bold.white(" ██║██║ ██║ ██║██╔══██║")),console.log(chalk.bold.white(" ██║╚██████╗╚██████╔╝██║ ██║")),console.log(chalk.bold.white(" ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝")),console.log(),console.log(chalk.yellow(" International Cyber Olympiad in AI 2026")),console.log(chalk.bold.magenta(" The World's First AI-Native CLI Operating System")),console.log(chalk.bold.magenta(" for Cybersecurity & AI Security Competition")),console.log(chalk.bold.magenta(" and Olympiad for K-12")),console.log(chalk.gray(" Sydney, Australia · Jun 27 - Jul 2, 2026")),console.log(),console.log(chalk.white(" Vision")),console.log(chalk.gray(" Building a global pipeline for youth cyber & AI")),console.log(chalk.gray(" security talent through education and competition.")),console.log(),console.log(chalk.white(" Capacity")),console.log(chalk.gray(" 15,000+ concurrent online examinations")),console.log(chalk.gray(" National selection, training, and education support")),console.log(),console.log(chalk.white(" Olympic Spirit")),console.log(chalk.gray(" Excellence · Friendship · Respect")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" New country accreditation & support:")),console.log(chalk.cyan(" australia@icoa2026.au")),console.log(chalk.cyan(" accreditation@icoa2026.au")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(),to?(console.log(chalk.green(` Logged in as ${no.userName}`)),console.log(chalk.white(" exam list")+chalk.gray(" Manage exams")),console.log(chalk.white(" logout")+chalk.gray(" Disconnect"))):console.log(chalk.white(" join <url>")+chalk.gray(" Connect to manage exams")),console.log(),h(),console.log()):(console.log(` ${chalk.cyan.bold("🏆 ICOA 2026 · International Olympiad")}`),console.log(),so&&!c()?(console.log(chalk.red(" Token was activated on a different device.")),console.log(chalk.gray(" Contact organizer for assistance.")),console.log()):to?(console.log(chalk.green.bold(` Welcome back, ${no.userName}!`)),console.log(chalk.gray(` Connected to ${no.ctfdUrl}`)),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" Ready to compete? Start here:")),console.log(),console.log(chalk.bold.cyan(" challenges")+chalk.gray(" Browse challenges by category")),console.log(chalk.white(" status")+chalk.gray(" Your score & hint budget")),console.log(chalk.white(" scoreboard")+chalk.gray(" Live rankings")),console.log(chalk.white(" help")+chalk.gray(" Full command list")),console.log(),console.log(chalk.gray(" Tool environment:")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("help")+chalk.gray(" · ")+w()+chalk.gray(" · ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses · ")+chalk.cyan("quit")+chalk.gray(" closes")),console.log()):so?(W(H)||Y(H,{recursive:!0}),console.log(chalk.green.bold(" Welcome, competitor!")),console.log(chalk.gray(` Workspace: ${H}`)),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" Get started:")),console.log(),console.log(chalk.white(" Step 1 ")+chalk.bold.cyan("join <url>")+chalk.gray(" Connect to competition server")),console.log(chalk.white(" Step 2 ")+chalk.bold.cyan("challenges")+chalk.gray(" Browse & solve challenges")),console.log(chalk.white(" Step 3 ")+chalk.bold.cyan("ai4ctf")+chalk.gray(" Ask AI when stuck")),console.log(),console.log(chalk.gray(" Before Step 1 — make sure your tools are ready:")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(),console.log(chalk.gray(" Also: ")+chalk.white("help")+chalk.gray(" all commands")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses · ")+w()+chalk.gray(" · ")+chalk.cyan("quit")+chalk.gray(" closes CLI")),console.log()):(console.log(chalk.bold.yellow(" 🏆 You reached the finals tier.")),console.log(chalk.gray(" Full sandbox · 110 CTF tools · Sydney 2026 · this is where finalists compete.")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" To begin, activate your competition token:")),console.log(),console.log(chalk.bold.cyan(" activate <token>")),console.log(),console.log(chalk.gray(" While waiting, explore:")),console.log(chalk.white(" ref linux")+chalk.gray(" Quick reference for Linux")),console.log(chalk.white(" ref web")+chalk.gray(" Quick reference for Web")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(chalk.white(" help")+chalk.gray(" All available commands")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses · ")+w()+chalk.gray(" · ")+chalk.cyan("quit")+chalk.gray(" closes CLI")),console.log()))}e.exitOverride(),e.configureOutput({writeErr:()=>{},writeOut:o=>{console.log(o)}});const po=o({input:process.stdin,output:process.stdout,prompt:J(),terminal:!0});f(po);let uo=!1;p(!0),Q();const ho=po.prompt.bind(po);po.prompt=o=>{b()||v()||A()||k()||po.setPrompt(J()),ho(o)},po.prompt(),po.on("line",async o=>{if(uo)return;const n=o.trim();if(!n)return po.setPrompt(b()?chalk.magenta("ai4ctf> "):J()),void po.prompt();if("menu"===n||"menu confirm"===n)return D()&&"menu confirm"!==n?(console.log(),console.log(chalk.yellow(" Real exam active. Progress is auto-saved.")),console.log(chalk.gray(" To return to main menu anyway, type ")+chalk.white("menu confirm")),console.log(),void po.prompt()):void u(po);if(b()){uo=!0;const o=await x(n);return uo=!1,"exit"===o&&po.setPrompt(J()),void po.prompt()}if(v()){uo=!0;const o=await C(n);return uo=!1,"exit"!==o&&"solved"!==o||po.setPrompt(J()),void po.prompt()}if(A()){uo=!0;const o=await I(n);return uo=!1,"exit"===o&&po.setPrompt(J()),po.setPrompt(A()?chalk.bold.cyan("ctf4vla> "):J()),void po.prompt()}if(U(n),"exit"===n)return L()?(console.log(),console.log(chalk.yellow(" ⚠ An exam is in progress.")),console.log(chalk.white(" To return to menu without losing progress, type: ")+chalk.bold.cyan("back")),console.log(chalk.white(" To fully close ICOA CLI, type: ")+chalk.bold.cyan("quit")),console.log(chalk.gray(" Your progress is auto-saved either way.")),console.log(),void po.prompt()):(console.log(),console.log(chalk.gray(" ")+chalk.white("exit")+chalk.gray(" returns to the main menu. To fully close ICOA CLI, type ")+chalk.bold.cyan("quit")+chalk.gray(".")),"selection"===mo&&oo(),void po.prompt());if("quit"===n||"q"===n||"quit confirm"===n){const o=L();return o&&"demo-free"!==o.session.examId&&"quit confirm"!==n?(console.log(),console.log(chalk.yellow(" ⚠ A real exam is in progress.")),console.log(chalk.gray(" Your answers are auto-saved on the server, but the exam timer keeps ticking")),console.log(chalk.gray(" on the server side even if you close the CLI.")),console.log(),console.log(chalk.white(" To leave the CLI but keep the exam alive, type: ")+chalk.bold.cyan("back")),console.log(chalk.gray(" (recommended — you can resume with ")+chalk.cyan("exam q 1")+chalk.gray(" after relaunching icoa)")),console.log(),console.log(chalk.white(" To really close ICOA CLI, type: ")+chalk.bold.cyan("quit confirm")),console.log(),void po.prompt()):(o&&"demo-free"===o.session.examId&&(console.log(),console.log(chalk.gray(" Demo paused. Resume with: ")+chalk.white("demo")+chalk.gray(" (fresh) or ")+chalk.white("exam q 1")+chalk.gray(" (continue)."))),_(),g(),console.log(chalk.gray(" Session saved. Use ")+chalk.white("icoa --resume")+chalk.gray(" to continue.")),R(),void ao(0))}if("back"===n){const o=L(),e=o&&"demo-free"!==o.session.examId,l=o&&"demo-free"===o.session.examId&&(()=>{const e=new Date(o.session.startedAt||0).getTime();return Date.now()-e<18e5})();if(e)console.log(),console.log(chalk.gray(" Exam paused. Your progress is saved.")),console.log(chalk.white(" Resume: exam q 1")+chalk.gray(" · ")+chalk.white("exam review")+chalk.gray(" · ")+chalk.white("exam submit")),console.log();else if(l){const e=Object.keys(o.answers).length,l=o.session.questionCount;console.log(),console.log(chalk.gray(` Demo paused (${e}/${l} answered). Resume with: `)+chalk.white("exam q 1")),console.log(chalk.gray(" Or type ")+chalk.white("demo")+chalk.gray(" to restart.")),console.log()}else{if(o&&"demo-free"===o.session.examId){const{clearExamState:o}=await import("./lib/exam-state.js");o("demo-free")}const e=t();fetch("https://practice.icoa2026.au/api/icoa/demo-stats",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"post-report-back",lang:e.language||"en",timestamp:(new Date).toISOString()}),signal:AbortSignal.timeout(5e3)}).catch(()=>{}),"selection"===mo?oo():console.log(chalk.gray(" Already at main menu."))}return void po.prompt()}if("help"===n||"?"===n){if(L()){uo=!0;try{await e.parseAsync(["node","icoa","exam","help"])}catch{}return uo=!1,void po.prompt()}return lo(s(),mo),void po.prompt()}if("man"===n||"manual"===n)return lo(s(),mo),void po.prompt();if("more help"===n.toLowerCase()&&L()){uo=!0;try{await e.parseAsync(["node","icoa","exam","more-help"])}catch{}return uo=!1,void po.prompt()}if("continue"===n.toLowerCase())return console.log(),console.log(chalk.green.bold(" ═══ AI4CTF — AI as Your Teammate ═══")),console.log(),console.log(chalk.white(" In AI4CTF, you solve cybersecurity challenges")),console.log(chalk.white(" with AI by your side.")),console.log(),console.log(chalk.white(" In competition, you get AI help at 3 levels:")),console.log(chalk.yellow(" hint a")+chalk.gray(" General guidance (50 uses)")),console.log(chalk.yellow(" hint b")+chalk.gray(" Deep analysis (10 uses)")),console.log(chalk.yellow(" hint c")+chalk.gray(" Critical assist (2 uses)")),console.log(),console.log(chalk.white(" Try it now! Type: ")+chalk.bold.green("ai4ctf")),console.log(chalk.gray(' Chat freely with your AI teammate. Type "exit" when done.')),console.log(),console.log(chalk.gray(" After ai4ctf, try: ")+chalk.bold.red("ctf4ai")+chalk.gray(' — trick the AI into saying "koala"')),console.log(),void po.prompt();if(/^ICOA-[A-Z]{2,3}-\d{1,6}$/i.test(n.trim())){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",n.trim()])}catch{}return uo=!1,void po.prompt()}if(/^[A-Z]{2}[0-9A-HJKMNP-TV-Z]{8}$/i.test(n.trim())){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",n.trim().toUpperCase()])}catch{}return uo=!1,void po.prompt()}const a=n.match(/^exam\s+([A-Z]{2}[0-9A-HJKMNP-TV-Z]{8})$/i);if(a){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",a[1].toUpperCase()])}catch{}return uo=!1,void po.prompt()}const y=n.match(/^exam\s+([A-Z]{2,3})$/i);if(y){uo=!0;try{await e.parseAsync(["node","icoa","exam","list",y[1]])}catch{}return uo=!1,void po.prompt()}if("clear"===n||"cls"===n)return console.clear(),void po.prompt();if(n.startsWith("activate ")){const o=n.slice(9).trim(),e=r(o);return"ok"===e?console.log(chalk.green(" Access granted! Token bound to this device.")):"already_bound"===e?(console.log(),console.log(chalk.red(" Token already activated on a different device.")),console.log(chalk.gray(" Each token binds to the first device that uses it. If you lost the device,")),console.log(chalk.gray(" contact your proctor to have the token re-issued for a new device."))):(console.log(),console.log(chalk.red(" Token not recognized.")),console.log(chalk.gray(" Possible reasons:")),console.log(chalk.white(" • ")+chalk.gray("Typo — tokens are case-insensitive, 10 chars, start with a 2-letter country code (e.g. ")+chalk.cyan("UAK7M2R9Q4")+chalk.gray(")")),console.log(chalk.white(" • ")+chalk.gray("Expired — ask your proctor or organizer for a fresh token")),console.log(chalk.white(" • ")+chalk.gray("Network — verify connection to ")+chalk.cyan("practice.icoa2026.au")),console.log(chalk.gray(" Still stuck? type ")+chalk.cyan("help")+chalk.gray(" or try ")+chalk.cyan("exam demo")+chalk.gray(" for a free practice round."))),console.log(),void po.prompt()}if("activate"===n)return console.log(chalk.gray(" Usage: ")+chalk.white("activate <token>")),console.log(),void po.prompt();const m=L();if(m){const o=n.toUpperCase().trim(),l=o=>{const e=m.questions.find(e=>e.number===o);return!!e&&("ai4ctf"===e.type||"ctf4ai"===e.type||e.options&&!e.options.A&&!e.options.B)},t=o=>{const e="demo-free"!==m.session.examId,l=e&&o>=39?"ctf4ai":e&&o>=31?"ai4ctf":null;console.log(),console.log(chalk.yellow(` Q${o} is a practical question — letters (A/B/C/D) don't apply here.`)),l?(console.log(chalk.white(" Enter the AI chat for this question: ")+chalk.bold.cyan(l)),console.log(chalk.gray(" Or submit a flag directly: ")+chalk.green(`exam answer ${o} ICOA{your_flag}`))):console.log(chalk.gray(" Submit a flag: ")+chalk.green(`exam answer ${o} ICOA{your_flag}`)),console.log()};if(/^[ABCD]$/.test(o)){const n=m._lastQ||1;if(l(n))return t(n),void po.prompt();uo=!0;try{await e.parseAsync(["node","icoa","exam","answer",String(n),o])}catch{}return uo=!1,void po.prompt()}const a=o.match(/^(\d+)\s+([ABCD])$/);if(a){const o=parseInt(a[1],10);if(l(o))return t(o),void po.prompt();uo=!0;try{await e.parseAsync(["node","icoa","exam","answer",a[1],a[2]])}catch{}return uo=!1,void po.prompt()}}const d=n.split(/\s+/)[0].toLowerCase(),p=/^python3?(\.\d+)?$/.test(d),h="ls"===d||"pwd"===d,w=n.startsWith("!")||d.startsWith("!")||p||h,f=new Set(["nano","vi","vim","emacs","pico","ed","code","cat","less","more","head","tail","ls","pwd","cd","base64","xxd","hexdump","od","openssl","md5sum","sha256sum","grep","find","awk","sed","strings","file","curl","wget","nc","ping","nmap","echo","bash","sh","zsh","pip","pip3","node","npm"]),k=()=>{console.log(chalk.gray(" Shell commands need ")+chalk.bold.cyan("!")+chalk.gray(" prefix. Try: ")+chalk.bold.cyan(`!${n}`)),console.log()};if("embodied"===mo&&!w&&!["demo2","learn","exam","ctf4vla","lang","ref","setup","env","sim"].includes(d))return f.has(d)?(k(),void po.prompt()):(console.log(chalk.gray(" Not available in Embodied AI Security mode.")),console.log(chalk.white(" Try ")+chalk.bold.cyan("demo2")+chalk.gray(" (intro) · ")+chalk.bold.cyan("learn")+chalk.gray(" (curriculum) · ")+chalk.bold.cyan("exam <PD-token>")+chalk.gray(" (Paper D)")),console.log(),void po.prompt());if("selection"===mo&&!w&&!["exam","demo","retry","nations","next","prev","continue","setup","lang","ref","ai4ctf","ctf4ai","mark","unmark","review","submit","env","sim"].includes(d)){if(f.has(d))return k(),void po.prompt();if(console.log(chalk.gray(" Not available in Selection mode.")),m){const o=m._lastQ||1;console.log(chalk.white(` Resume exam: exam q ${o}`)+chalk.gray(" · ")+chalk.white("A/B/C/D")+chalk.gray(" to answer"))}else console.log(chalk.gray(" Try: demo · setup to switch mode"));return console.log(),void po.prompt()}if("organizer"===mo&&!["join","exam","demo","retry","next","prev","logout","setup","lang","ref","ctf","mark","unmark","review","submit"].includes(d))return console.log(chalk.gray(" Not available in Organizer mode. Switch via: setup")),console.log(),void po.prompt();if(!("olympiad"!==mo||s()&&c()||i(d)))return console.log(chalk.yellow(" Restricted mode. ")+chalk.gray("Enter your access token:")),console.log(chalk.white(" activate <token>")),console.log(),console.log(chalk.gray(" Free commands: ")+chalk.white("ref [topic]")+chalk.gray(", ")+chalk.white("help")+chalk.gray(", ")+chalk.white("exit")),console.log(),void po.prompt();if(!["join","activate","challenges","ch","open","submit","flag","scoreboard","sb","status","time","ref","shell","files","connect","note","notes","logbook","log","man","manual","lang","setup","env","ai4ctf","model","ctf","exam","demo","retry","nations","next","prev","continue","logout","ctf4ai","mark","unmark","review","submit","learn","demo2","ctf4vla","theme","sim"].includes(d)){if(K.has(d))return console.log(chalk.yellow(` "${d}" is a shell command — the ICOA prompt isn't a shell.`)),console.log(chalk.gray(" In real-exam mode, prefix with ! to run inside the sandbox: ")+chalk.cyan(`!${n}`)),console.log(),void po.prompt();if(/(?:^|\s)(?:\/(?!home\/|Users\/|tmp\/)|\.\.\/|~\/)/.test(n)&&!n.startsWith("cd ")){const o=/(?:^|\s)\/(?!home\/\w+\/icoa-workspace|Users\/\w+\/icoa-workspace|tmp\/)/.test(n),e=/\.\./.test(n);if(o||e)return console.log(chalk.red(" Blocked: access outside workspace is not allowed.")),console.log(chalk.gray(` Workspace: ${H}`)),console.log(),void po.prompt()}let o=n.startsWith("!")?n.slice(1).trim():n;if("darwin"===process.platform){const e="/opt/homebrew/opt/python@3.12/bin/python3.12";o=o.replace(/^python3?\s/,`${e} `).replace(/^(python3|python)$/,e)}else if("win32"===process.platform){const e=(()=>{try{return l("py -3 --version",{stdio:["ignore","ignore","ignore"],timeout:1500}),"py -3"}catch{}return"python"})();o=o.replace(/^python3?(\.\d+)?\s/,`${e} `).replace(/^python3?(\.\d+)?$/,e)}else{const e=(()=>{try{return l("which python3.12",{stdio:"ignore"}),"python3.12"}catch{return"python3"}})();o=o.replace(/^python\s/,`${e} `).replace(/^python$/,e)}const e=B(),t=N(n);M({cwd:e,input:n,riskFlags:t}),t.length>0&&D()&&(console.log(chalk.yellow(` ⚠ Action flagged: ${t.join(", ")} — logged.`)),console.log()),/^(\S*python3?(\.\d+)?)\s*$/.test(o)&&(o=`PYTHONSTARTUP="${function(){const o=V(G(),".icoa");W(o)||Y(o,{recursive:!0});const e=V(o,"python-startup.py");return W(e)||z(e,"# ICOA exam interactive startup — auto-loaded by PYTHONSTARTUP\nimport base64, struct, hashlib, re, json, os, sys, binascii\ntry: import requests\nexcept ImportError: pass\ntry: from Crypto.Cipher import AES\nexcept ImportError: pass\ntry: from Crypto.Util.Padding import pad, unpad\nexcept ImportError: pass\ntry: from pwn import xor, p32, u32, p64, u64\nexcept ImportError: pass\ntry: import bs4\nexcept ImportError: pass\ntry: import numpy as np\nexcept ImportError: pass\n"),e}()}" ${o}`,console.log(),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log(chalk.bold.white(" Python ready — ICOA exam toolkit pre-loaded")),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log(),console.log(chalk.white(" Already imported: ")+chalk.gray("base64, struct, hashlib, re, json, binascii")),console.log(chalk.white(" Also available: ")+chalk.gray("requests, bs4, numpy, AES, pad/unpad, xor, p32/u32/p64/u64")),console.log(),console.log(chalk.yellow(" Quick examples:")),console.log(chalk.gray(' base64.b64decode("aGVsbG8=") ')+chalk.gray("# decode base64")),console.log(chalk.gray(' bytes.fromhex("48656c6c6f") ')+chalk.gray("# hex → bytes")),console.log(chalk.gray(' "ICOA{x}".encode() ')+chalk.gray("# str → bytes")),console.log(chalk.gray(" [chr(c) for c in [73,67,79,65]] ")+chalk.gray("# ASCII codes")),console.log(chalk.gray(' xor(bytes.fromhex("0a2b"), b"IC") ')+chalk.gray("# pwntools XOR")),console.log(),console.log(chalk.gray(" Exit: ")+chalk.white("exit()")+chalk.gray(" or Ctrl-D")),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log()),uo=!0;try{F()&&await j()?await q(o,po):await eo(o,po,e)}catch{console.log(chalk.yellow(` Command failed: ${d}`))}return uo=!1,console.log(),void po.prompt()}uo=!0;const T=n.trim(),S=T.toLowerCase();let $,O=null,E="";if(m)if("submit"===S)O="final";else if(S.startsWith("submit ")){let o=T.slice(7).trim();/^submit\s+/i.test(o)&&(o=o.replace(/^submit\s+/i,"").trim()),o=o.replace(/^["'`]+|["'`]+$/g,"").trim(),o&&/^ICOA\{[^}]*\}?$/i.test(o)&&(O="flag",E=o)}else/^ICOA\{[^}]+\}$/i.test(T)&&(O="flag",E=T);$="final"===O?["exam","submit"]:"flag"===O?["exam","answer",String(m?._lastQ||1),E]:function(o){const e=o.split(/\s+/),l=e[0].toLowerCase(),n=e.slice(1),t={demo:["exam","demo"],retry:["exam","demo-retry"],nations:["exam","nations"],next:["exam","next"],prev:["exam","prev"],mark:["exam","mark",...n],unmark:["exam","unmark",...n],review:["exam","review"],logout:["ctf","logout"],join:["ctf","join",...n],activate:["ctf","activate",...n],challenges:["ctf","challenges"],ch:["ctf","challenges"],open:["ctf","open",...n],submit:["ctf","submit",...n],flag:["ctf","submit",...n],scoreboard:["ctf","scoreboard",...n],sb:["ctf","scoreboard",...n],status:["ctf","status"],time:["ctf","time"]};return t[l]?t[l]:["ref","shell","files","connect","note","notes","logbook","log","man","manual","lang","setup","env","ai4ctf","model","ctf","exam","ctf4ai"].includes(l)?[l,...n]:e}(n);const P="ctf"===$[0]&&"join"===$[1];P&&po.pause(),process.exit=()=>{throw new Error(Z)};try{await e.parseAsync(["node","icoa",...$])}catch(o){const e=o instanceof Error?o.message:String(o);if(e===Z);else if(e.includes("commander.unknownCommand")){const{distance:o}=await import("fastest-levenshtein"),e=["ctf","ref","shell","files","connect","note","notes","logbook","log","manual","lang","setup","env","ai4ctf","exam","ctf4ai","theme","clear","cls","quit","exit","back","menu","help","continue","activate","demo","challenges","status","scoreboard","join","logout"],l=d.split(/\s+/)[0]||d;let n={word:"",dist:1/0};for(const t of e){const e=o(l.toLowerCase(),t);e<n.dist&&(n={word:t,dist:e})}console.log(chalk.yellow(` Unknown command: ${d}.`)),n.dist>0&&n.dist<=2&&console.log(chalk.gray(" Did you mean: ")+chalk.bold.cyan(n.word)+chalk.gray("?")),console.log(chalk.gray(" Type ")+chalk.cyan("help")+chalk.gray(" for the full command list."))}else e.includes("commander.")||(e.includes("fetch failed")||e.includes("ECONNREFUSED")||e.includes("ETIMEDOUT"))&&console.log(chalk.yellow(" Network error. Check your connection."))}finally{process.exit=ao,uo=!1,P&&po.resume()}b()?po.setPrompt(chalk.magenta("ai4ctf> ")):v()?po.setPrompt(chalk.red("ctf4ai> ")):A()&&po.setPrompt(chalk.bold.cyan("ctf4vla> ")),console.log(),po.prompt()}),po.on("SIGINT",()=>{if(console.log(),b()||v())console.log(chalk.yellow(" Ctrl+C did not close ICOA CLI — you are still in the AI chat.")),console.log(chalk.white(" Type ")+chalk.bold.cyan("exit")+chalk.white(" to leave the chat and return to the menu."));else if(L()){const o="demo-free"!==L().session.examId;console.log(chalk.yellow(" Ctrl+C did NOT close ICOA CLI.")),console.log(chalk.gray(` Your ${o?"exam":"demo"} is paused and every answer is auto-saved.`)),console.log(),console.log(chalk.white(" Resume: ")+chalk.cyan("exam q 1")+chalk.gray(" · Back to menu: ")+chalk.cyan("back")+chalk.gray(" · Close CLI: ")+chalk.cyan(o?"quit confirm":"quit"))}else console.log(chalk.yellow(" Ctrl+C did not close ICOA CLI — you are still at the ")+chalk.cyan("icoa>")+chalk.yellow(" prompt.")),console.log(chalk.gray(" Keep typing — ")+chalk.cyan("help")+chalk.gray(" lists commands. (Only ")+chalk.cyan("quit")+chalk.gray(" or Ctrl+D actually close the CLI.)"));console.log(),po.prompt()}),po.on("close",()=>{_(),g(),R(),ao(0)})}function eo(o,l,n){return new Promise(t=>{const a=process.stdin,s=!!a.isTTY&&!!a.isRaw;if(l.pause(),a.isTTY&&"function"==typeof a.setRawMode)try{a.setRawMode(!1)}catch{}const r=e(o,{shell:!0,stdio:"inherit",cwd:n||process.cwd()}),i=()=>{if(a.isTTY&&"function"==typeof a.setRawMode&&s)try{a.setRawMode(!0)}catch{}l.resume(),t()};r.on("close",i),r.on("error",i)})}function lo(o,e="olympiad"){return console.log(),"selection"===e||"organizer"===e?(console.log(chalk.bold.white(" Exam")),console.log(chalk.white(" join <url> ")+chalk.gray("Connect to exam server")),console.log(chalk.white(" exam list ")+chalk.gray("Available exams")),console.log(chalk.white(" exam start <id> ")+chalk.gray("Begin an exam")),console.log(chalk.white(" exam q [n] ")+chalk.gray("View questions")),console.log(chalk.white(" exam answer <n> <X> ")+chalk.gray("Answer question")),console.log(chalk.white(" exam review ")+chalk.gray("Review all answers")),console.log(chalk.white(" exam submit ")+chalk.gray("Submit for grading")),console.log(chalk.white(" exam result ")+chalk.gray("View your score")),console.log(),console.log(chalk.bold.white(" System")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference")),console.log(chalk.white(" setup ")+chalk.gray("Settings / switch mode")),console.log(chalk.white(" lang [code] ")+chalk.gray("Switch language")),console.log(chalk.white(" clear ")+chalk.gray("Clear screen")),console.log(chalk.white(" exit ")+chalk.gray("Quit")),void console.log()):o?(console.log(chalk.cyan(" ═══════════════════════════════════════════════")),console.log(chalk.bold.white(" How it works")),console.log(),console.log(chalk.gray(" 1. Browse ")+chalk.white("challenges")+chalk.gray(" and pick one")),console.log(chalk.gray(" 2. ")+chalk.white("open <id>")+chalk.gray(" to read the challenge")),console.log(chalk.gray(" 3. Use ")+chalk.white("ai4ctf")+chalk.gray(" to chat with AI when stuck")),console.log(chalk.gray(" 4. ")+chalk.white("submit <id> icoa{flag}")+chalk.gray(" to score points")),console.log(chalk.gray(" 5. Check ")+chalk.white("scoreboard")+chalk.gray(" to track your rank")),console.log(chalk.cyan(" ═══════════════════════════════════════════════")),console.log(),console.log(chalk.bold.white(" Competition")),console.log(chalk.white(" join <url> ")+chalk.gray("Connect to CTFd")),console.log(chalk.white(" challenges (ch) ")+chalk.gray("List challenges by category")),console.log(chalk.white(" open <id> ")+chalk.gray("Read challenge + get next steps")),console.log(chalk.white(" submit <id> <flag> ")+chalk.gray("Submit a flag")),console.log(chalk.white(" scoreboard (sb) ")+chalk.gray("Live rankings")),console.log(chalk.white(" status ")+chalk.gray("Your score, budget & timer")),console.log(chalk.white(" time ")+chalk.gray("Countdown timer")),console.log(),console.log(chalk.bold.white(" AI Teammate")+chalk.gray(" — 3 levels, use wisely")),console.log(chalk.white(' hint "question" ')+chalk.gray("Level A — General guidance (50 uses)")),console.log(chalk.white(' hint-b "question" ')+chalk.gray("Level B — Deep analysis (10 uses)")),console.log(chalk.white(' hint-c "question" ')+chalk.gray("Level C — Critical assist (2 uses)")),console.log(chalk.white(" hint budget ")+chalk.gray("Check remaining uses")),console.log(chalk.white(" ai4ctf ")+chalk.gray("Free-chat with AI (no limit)")),console.log(),console.log(chalk.bold.white(" Tools")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference (linux, web, crypto...)")),console.log(chalk.white(" shell ")+chalk.gray("Docker sandbox")),console.log(chalk.white(" files <id> ")+chalk.gray("Download challenge files")),console.log(chalk.white(" connect <id> ")+chalk.gray("Connect to remote target")),console.log(chalk.white(" note [text] ")+chalk.gray("Add a logbook entry (in-exam: tags current Q)")),console.log(chalk.white(" logbook [n] ")+chalk.gray("View your logbook (in-exam: filter by Q)")),console.log(chalk.white(" log ")+chalk.gray("Session history")),console.log(chalk.white(" man / manual ")+chalk.gray("Show this command list (works in exam too, does not burn elimination)")),console.log(),console.log(chalk.bold.white(" System")),console.log(chalk.white(" setup ")+chalk.gray("Configure settings")),console.log(chalk.white(" lang [code] ")+chalk.gray("Switch language (15 supported)")),console.log(chalk.white(" logout ")+chalk.gray("Disconnect")),console.log(chalk.white(" clear ")+chalk.gray("Clear screen")),console.log(chalk.white(" exit ")+chalk.gray("Quit (session saved)")),void console.log()):(console.log(chalk.bold.yellow(" Restricted Mode — activate with a token to unlock all commands")),console.log(),console.log(chalk.white(" activate <token> ")+chalk.gray("Unlock full access")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference")),console.log(chalk.white(" exit ")+chalk.gray("Quit")),void console.log())}
|
|
1
|
+
import{createInterface as o}from"node:readline";import{spawn as e,execSync as l}from"node:child_process";import chalk from"chalk";import{isConnected as n,getConfig as t,saveConfig as a}from"./lib/config.js";import{isActivated as s,activateToken as r,isFreeCommand as i,isDeviceMatch as c,recordExit as g,recordResume as y,isFirstRunOrUpgrade as m,markVersionSeen as d}from"./lib/access.js";import{setReplMode as p}from"./lib/ui.js";import{returnToMainMenu as u,printMenuHint as h,menuHintInline as w}from"./lib/menu-nav.js";import{setMainRl as f}from"./lib/main-rl.js";import{isChatActive as b,handleChatMessage as x}from"./commands/ai4ctf.js";import{isCtf4aiActive as v,handleCtf4aiMessage as C}from"./commands/ctf4ai-demo.js";import{isCtf4VlaActive as A,handleCtf4VlaMessage as I}from"./commands/ctf4vla.js";import{isDemo2Active as k}from"./commands/demo2.js";import{loadDemo2Progress as T}from"./lib/demo2-progress.js";import{hasAnySimHistory as S,lastArmAt as $,lastBundledAt as O,lastSimAt as E}from"./lib/sim-cooldown.js";import{getExamState as L,getRealExamState as D,getDemoState as P}from"./lib/exam-state.js";import{resetTerminalTheme as R}from"./lib/theme.js";import{ensureSandbox as j,runInSandbox as q,isDockerAvailable as F}from"./lib/sandbox.js";import{checkShellRisk as N,logShellAudit as M,getActiveCwd as B}from"./lib/exam-sandbox.js";import{logCommand as U}from"./lib/logger.js";import{startLogSync as Q,stopLogSync as _}from"./lib/log-sync.js";import{existsSync as W,mkdirSync as Y,writeFileSync as z}from"node:fs";import{join as V}from"node:path";import{homedir as G}from"node:os";function J(){return D()?chalk.cyan("exam> "):P()?chalk.yellow("demo> "):chalk.green("icoa> ")}const H=V(G(),"icoa-workspace"),K=new Set(["sudo","su","doas","pkexec","brew","apt","apt-get","yum","choco","npm","npx","pip","pip3","shutdown","reboot","halt","mkfs","fdisk","dd","iptables","ufw"]),Z="__REPL_NO_EXIT__",X="2.5.1";function oo(){console.log(),console.log(` ${chalk.cyan.bold("🎯 ICOA 2026 · National Selection")}`),console.log(),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("ACxxxxxxxx")+chalk.gray(" → ai4ctf-12 (AI as your CTF teammate)")),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("CAxxxxxxxx")+chalk.gray(" → ctf4ai-12 (red-team software AI)")),console.log(" "+chalk.bold.cyan("learn ")+chalk.white("EAxxxxxxxx")+chalk.gray(" → ctf4eai-12 (red-team embodied AI)")),console.log(" "+chalk.bold.cyan("exam ")+chalk.white("<CC>xxxxxxxx")+chalk.gray(" → Paper A/B/C/D/E (country exam token)")),console.log(" "+chalk.bold.cyan("demo")+chalk.gray(" → free practice")),console.log(" "+chalk.bold.cyan("lang")+chalk.white(" es")+chalk.gray(" → switch language")),console.log(" "+chalk.gray("help · menu · quit")),console.log()}export async function startRepl(e,P){process.env.ICOA_INSIDE_REPL="1";const no=t(),to=n(),ao=process.exit.bind(process),so=s();if(no.demoCleanedForVersion!==X){try{const{existsSync:o,unlinkSync:e}=await import("node:fs"),{join:l}=await import("node:path"),{getIcoaDir:n}=await import("./lib/config.js"),t=l(n(),"demo-state.json");o(t)&&e(t)}catch{}a({demoCleanedForVersion:X})}const{select:ro,confirm:io}=await import("@inquirer/prompts"),co=no.mode||"",go=["instant","learn","selection","olympiad"].includes(co)?co:"selection",yo=[{name:` ${chalk.bold("⚡ Try ICOA in 30 seconds")} ${chalk.gray("—")} ${chalk.gray("watch · no token needed")}`,value:"instant"},{name:` ${chalk.bold("🧠 Learn")} ${chalk.gray("—")} ${chalk.gray("AC / CA / EA token · skill up")}`,value:"learn"},{name:` ${chalk.bold("🎯 National Selection")} ${chalk.gray("—")} ${chalk.gray("country exam token · aim for finals")}`,value:"selection"},{name:` ${chalk.bold("🏆 International Olympiad")} ${chalk.gray("—")} ${chalk.gray("finals stage · Sydney 2026 · full sandbox")}`,value:"olympiad"},{name:` ${chalk.gray("ℹ️ About ICOA")} ${chalk.gray("·")} ${chalk.gray("what this is · how to join")}`,value:"about"}];console.log(chalk.gray(" Use ")+chalk.yellow("↑")+chalk.gray(" / ")+chalk.yellow("↓")+chalk.gray(" to select, ")+chalk.yellow("Enter")+chalk.gray(" to confirm. Type ")+chalk.bold.cyan("menu")+chalk.gray(" anywhere to return here.")),console.log();let mo="";for(;!mo;){const o=await ro({message:"Mode",choices:yo,default:go||"selection"});"about"!==o?mo=o:(console.clear(),console.log(),console.log(chalk.cyan(" ═══════════════════════════════════════════════════")),console.log(chalk.bold.yellow(" ICOA")+chalk.white(" — AI-Native CLI OS for Cyber & AI Security")),console.log(chalk.gray(" Olympiad & Competition · K-12 to University")),console.log(chalk.cyan(" ───────────────────────────────────────────────────")),console.log(),console.log(chalk.bold.white(" What Makes ICOA Different")),console.log(chalk.gray(" · AI-native AI teammate, AI adversary, AI translation")),console.log(chalk.gray(" · CLI OS Complete competition environment in terminal")),console.log(chalk.gray(" · 110 tools pwntools, z3, gdb, nmap, sleuthkit... pre-configured")),console.log(chalk.gray(" · Global scale 15,000+ concurrent exams · 15 languages")),console.log(),console.log(chalk.bold.white(" Competition Format (2-day standard + 1-day Pioneer)")),console.log(` ${chalk.green.bold("AI4CTF")}${chalk.gray(" [Day 1] AI as teammate — speed track, dynamic decay + top-3 bonus")}`),console.log(` ${chalk.red.bold("CTF4AI")}${chalk.gray(" [Day 2] AI as target — knowledge track, static value per challenge")}`),console.log(` ${chalk.cyan.bold("CTF4EAI")}${chalk.gray(" [Pioneer / Practical Round] Embodied AI — VLA + world models + sim-to-real")}`),console.log(),console.log(chalk.bold.white(" Scoring (in brief)")),console.log(chalk.gray(" · Standard medals: AI4CTF + CTF4AI combined · 1/12 Gold · 2/12 Silver · 3/12 Bronze")),console.log(chalk.gray(" · HMA: top 50% on either day, total below bronze cutoff")),console.log(chalk.gray(" · CTF4EAI: separate 15-finalist pool, G/S/B + 12 Finalist Awards")),console.log(),console.log(chalk.white(" Sydney, Australia")+chalk.gray(" · Jun 27 - Jul 2, 2026")),console.log(),console.log(chalk.bold.white(" Organized by")+chalk.gray(" ASRA (Australia) · ICO Foundation Inc")),console.log(chalk.bold.white(" Contact ")+chalk.cyan(" australia@icoa2026.au · accreditation@icoa2026.au")),console.log(chalk.bold.white(" Website ")+chalk.cyan.underline(" https://icoa2026.au")),console.log(chalk.cyan(" ═══════════════════════════════════════════════════")),console.log(),console.log(chalk.gray(" Press ")+chalk.yellow("Enter")+chalk.gray(" to return...")),await new Promise(o=>{const e=l=>{process.stdin.removeListener("data",e),process.stdin.isTTY&&process.stdin.setRawMode&&process.stdin.setRawMode(!1),process.stdin.pause(),o()};process.stdin.isTTY&&process.stdin.setRawMode&&process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.once("data",e)}),console.clear())}if("olympiad"===mo&&"olympiad"!==go&&(console.log(),console.log(chalk.yellow(" This mode will download ~500MB of CTF tools and AI models.")),await io({message:"Continue?",default:!0})||(mo="selection",console.log(chalk.gray(" Switched to National Selection mode.")))),mo!==go&&a({mode:mo}),console.log(),"olympiad"===mo&&m(X)){d(X),console.log(chalk.gray(" Checking competition environment..."));const{execSync:o}=await import("node:child_process"),e=[{name:"pwntools",cmd:'python3 -c "import pwn"'},{name:"z3-solver",cmd:'python3 -c "import z3"'},{name:"numpy",cmd:'python3 -c "import numpy"'},{name:"requests",cmd:'python3 -c "import requests"'}];let l=0;for(const n of e)try{o(n.cmd,{stdio:"ignore"})}catch{l++}if(l>0){console.log(chalk.yellow(` ${l} core libraries missing.`));try{const{confirm:o}=await import("@inquirer/prompts");if(await o({message:" Install competition Python libraries now?",default:!0,theme:{prefix:"",style:{message:o=>chalk.green(o),defaultAnswer:o=>chalk.green(o)}}})){console.log();const{execSync:o}=await import("node:child_process");o("icoa env setup",{stdio:"inherit"})}}catch{console.log(chalk.gray(" Run ")+chalk.white("env setup")+chalk.gray(" later to install."))}console.log()}else console.log(chalk.green(" All core libraries ready.")),console.log()}if(P){const o=y();if(o){const e=Math.floor(o.awaySeconds/60),l=o.awaySeconds%60;console.log(chalk.yellow(` Session resumed. Away: ${e}m ${l}s | Total exits: ${o.exitCount}`)),console.log()}}if("selection"===mo)console.log(chalk.gray(" ─── exam hall · 90 min per paper once started · no pause ───")),console.log(),oo();else if("embodied"===mo)!function(){console.log(chalk.cyan.bold(" [🤖 ctf4eai — Embodied AI Security]")),console.log(),console.log(chalk.bold.cyan(" CTF4VLA")+chalk.gray(" — ICOA 2026's ")+chalk.bold.white("Pioneer Round")),console.log(chalk.gray(" an independent parallel track alongside the scored main events: ")+chalk.green("AI4CTF")+chalk.gray(" (Day 1) and ")+chalk.red("CTF4AI")+chalk.gray(" (Day 2)")),console.log(),console.log(chalk.white(" Embodied AI is at its ImageNet moment.")),console.log(chalk.gray(" VLA models, MuJoCo physics, real robot arms.")),console.log(chalk.gray(" Real models, real physics, real attack surfaces.")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const o=O()>0||E()>0,e=$()>0,l=S(),n=T(),t=null!==n&&"number"==typeof n.completedAt&&n.nextCardIndex>=n.totalCards,a=null!==n&&!t;if(t)console.log(chalk.bold.yellow(" Continue: ")+chalk.bold.cyan("④ learn LEARNDEMO01")+chalk.gray(" (demo2 ✓ · sim")+(e?chalk.gray(" ✓ · sim arm ✓)"):chalk.gray(")")));else if(a){const o=`${n.nextCardIndex} / ${n.totalCards}`;console.log(chalk.bold.yellow(" Continue: ")+chalk.bold.cyan("③ demo2")+chalk.gray(" (last left at card ")+chalk.bold.yellow(o)+chalk.gray(")"))}else o&&e?console.log(chalk.bold.yellow(" Next up: ")+chalk.bold.cyan("③ demo2")+chalk.gray(" → ")+chalk.bold.cyan("④ learn LEARNDEMO01")+chalk.gray(" (sim ✓ · sim arm ✓)")):l?console.log(chalk.bold.yellow(" Next up: ")+(e?chalk.bold.cyan("① sim")+chalk.gray(" → ")+chalk.bold.cyan("③ demo2"):chalk.bold.cyan("② sim arm")+chalk.gray(" → ")+chalk.bold.cyan("③ demo2"))+chalk.gray(" → ")+chalk.bold.cyan("④ learn LEARNDEMO01")):console.log(chalk.bold.yellow(" First time? Try in order: ")+chalk.bold.cyan("① sim")+chalk.gray(" → ")+chalk.bold.cyan("② sim arm")+chalk.gray(" → ")+chalk.bold.cyan("③ demo2")+chalk.gray(" → ")+chalk.bold.cyan("④ learn LEARNDEMO01"));console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.bold.green(" sim")+chalk.gray(" ")+chalk.bold.cyan("①")+chalk.gray(" ")+chalk.bold.yellow("★ INSTANT")+chalk.gray(" — 8-robot group dance, no wait, no setup")),console.log(chalk.bold.green(" sim arm")+chalk.gray(" ")+chalk.bold.cyan("②")+chalk.gray(" interactive 6-DOF arm sandbox — type joint values, watch")),console.log(chalk.bold.green(" demo2")+chalk.gray(" ")+chalk.bold.cyan("③")+chalk.gray(" ~8 min interactive intro + live MuJoCo sim")),console.log(chalk.bold.green(" learn LEARNDEMO01")+chalk.gray(" ")+chalk.bold.cyan("④")+chalk.gray(" free 11-card intro (paste this command as-is)")),console.log(chalk.bold.green(" learn ")+chalk.bold.yellow("EA")+chalk.gray(" + 8 chars full 96 / 360 curriculum (team-issued)")),console.log(chalk.bold.green(" exam ")+chalk.bold.yellow("PDxxxxxxxx")+chalk.gray(" Paper D (CTF4VLA) — national selection contestants")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(),console.log(chalk.gray(" Three open tiers: ")+chalk.green("free 11")+chalk.gray(" · ")+chalk.yellow("registered 100")+chalk.gray(" · ")+chalk.bold.magenta("national team 480")+chalk.gray(" (PhD-ready)")),console.log(chalk.gray(" Country team contact: ")+chalk.cyan("australia@icoa2026.au")),console.log(),h(),console.log()}();else{if("instant"===mo){console.log(chalk.cyan.bold(" [⚡ Try ICOA in 30 seconds — no token needed]")),console.log(),console.log(chalk.gray(" Pick what you want to see first:")),console.log();const o=[{name:` ${chalk.bold.green("★ demo ")} ${chalk.gray("Paper A/B/C taste — MCQ + ai4ctf + ctf4ai ")}`+chalk.bold.cyan("🎯 selection-style"),value:"demo"},{name:` ${chalk.bold.green("★ demo2 ")} ${chalk.gray("15-sec countdown render · bundled & offline ")}`+chalk.bold.yellow("⚡ visual wow"),value:"demo2"},{name:` ${chalk.gray("↩ back to main menu")}`,value:"menu"}];let l="menu";try{l=await ro({message:"Pick",choices:o,default:"demo"})}catch{}if("menu"!==l){console.log();const o="demo2"===l?"sim":l;try{await e.parseAsync(["node","icoa",o])}catch{}}return a({mode:"selection"}),void u()}if("learn"===mo){console.log(chalk.cyan.bold(" [🧠 Learn]")),console.log(),console.log(chalk.gray(" Three tracks · same difficulty curve · paste any token below.")),console.log(),console.log(chalk.white(" Free 12-card demos:")),console.log(chalk.bold(" 🤝 ai4ctf")+chalk.gray(" AI as your teammate ")+chalk.bold.green("AI4CTFDEMO01")),console.log(chalk.bold(" 🔓 ctf4ai")+chalk.gray(" AI as your target ")+chalk.bold.green("CTF4AIDEMO01")),console.log(chalk.bold(" 🤖 ctf4eai")+chalk.gray(" Embodied AI Security ")+chalk.bold.green("LEARNDEMO01")),console.log(),console.log(chalk.gray(" Got a learn token from your cohort? Paste it below.")),console.log(chalk.gray(" Format: ")+chalk.cyan("AC / CA / EA / IO / IA")+chalk.gray(" + 8 chars · unlocks 96 / 360 / future tiers.")),console.log();try{const{input:o}=await import("@inquirer/prompts"),{resolveLearnInput:l}=await import("./lib/learn-input.js");let n=0;for(;n<3;){n++;const t=l(await o({message:" Learn token (or blank to go back):"}));if("back"===t.kind)break;if("token"===t.kind){console.log(),console.log(chalk.gray(" Opening ")+chalk.bold.cyan("learn")+chalk.gray(`: ${t.token}`)),console.log(),a({mode:"selection"}),await e.parseAsync(["node","icoa","learn",t.token]);break}console.log(),console.log(chalk.yellow(" "+t.hint)),console.log()}}catch{}return a({mode:"selection"}),void u()}"organizer"===mo?(console.log(chalk.yellow.bold(" [National/Regional Partner]")),console.log(),console.log(chalk.bold.white(" ██╗ ██████╗ ██████╗ █████╗")),console.log(chalk.bold.white(" ██║██╔════╝██╔═══██╗██╔══██╗")),console.log(chalk.bold.white(" ██║██║ ██║ ██║███████║")),console.log(chalk.bold.white(" ██║██║ ██║ ██║██╔══██║")),console.log(chalk.bold.white(" ██║╚██████╗╚██████╔╝██║ ██║")),console.log(chalk.bold.white(" ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝")),console.log(),console.log(chalk.yellow(" International Cyber Olympiad in AI 2026")),console.log(chalk.bold.magenta(" The World's First AI-Native CLI Operating System")),console.log(chalk.bold.magenta(" for Cybersecurity & AI Security Competition")),console.log(chalk.bold.magenta(" and Olympiad for K-12")),console.log(chalk.gray(" Sydney, Australia · Jun 27 - Jul 2, 2026")),console.log(),console.log(chalk.white(" Vision")),console.log(chalk.gray(" Building a global pipeline for youth cyber & AI")),console.log(chalk.gray(" security talent through education and competition.")),console.log(),console.log(chalk.white(" Capacity")),console.log(chalk.gray(" 15,000+ concurrent online examinations")),console.log(chalk.gray(" National selection, training, and education support")),console.log(),console.log(chalk.white(" Olympic Spirit")),console.log(chalk.gray(" Excellence · Friendship · Respect")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" New country accreditation & support:")),console.log(chalk.cyan(" australia@icoa2026.au")),console.log(chalk.cyan(" accreditation@icoa2026.au")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(),to?(console.log(chalk.green(` Logged in as ${no.userName}`)),console.log(chalk.white(" exam list")+chalk.gray(" Manage exams")),console.log(chalk.white(" logout")+chalk.gray(" Disconnect"))):console.log(chalk.white(" join <url>")+chalk.gray(" Connect to manage exams")),console.log(),h(),console.log()):(console.log(` ${chalk.cyan.bold("🏆 ICOA 2026 · International Olympiad")}`),console.log(),so&&!c()?(console.log(chalk.red(" Token was activated on a different device.")),console.log(chalk.gray(" Contact organizer for assistance.")),console.log()):to?(console.log(chalk.green.bold(` Welcome back, ${no.userName}!`)),console.log(chalk.gray(` Connected to ${no.ctfdUrl}`)),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" Ready to compete? Start here:")),console.log(),console.log(chalk.bold.cyan(" challenges")+chalk.gray(" Browse challenges by category")),console.log(chalk.white(" status")+chalk.gray(" Your score & hint budget")),console.log(chalk.white(" scoreboard")+chalk.gray(" Live rankings")),console.log(chalk.white(" help")+chalk.gray(" Full command list")),console.log(),console.log(chalk.gray(" Tool environment:")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("help")+chalk.gray(" · ")+w()+chalk.gray(" · ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses · ")+chalk.cyan("quit")+chalk.gray(" closes")),console.log()):so?(W(H)||Y(H,{recursive:!0}),console.log(chalk.green.bold(" Welcome, competitor!")),console.log(chalk.gray(` Workspace: ${H}`)),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" Get started:")),console.log(),console.log(chalk.white(" Step 1 ")+chalk.bold.cyan("join <url>")+chalk.gray(" Connect to competition server")),console.log(chalk.white(" Step 2 ")+chalk.bold.cyan("challenges")+chalk.gray(" Browse & solve challenges")),console.log(chalk.white(" Step 3 ")+chalk.bold.cyan("ai4ctf")+chalk.gray(" Ask AI when stuck")),console.log(),console.log(chalk.gray(" Before Step 1 — make sure your tools are ready:")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(),console.log(chalk.gray(" Also: ")+chalk.white("help")+chalk.gray(" all commands")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses · ")+w()+chalk.gray(" · ")+chalk.cyan("quit")+chalk.gray(" closes CLI")),console.log()):(console.log(chalk.bold.yellow(" 🏆 You reached the finals tier.")),console.log(chalk.gray(" Full sandbox · 110 CTF tools · Sydney 2026 · this is where finalists compete.")),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.white(" To begin, activate your competition token:")),console.log(),console.log(chalk.bold.cyan(" activate <token>")),console.log(),console.log(chalk.gray(" While waiting, explore:")),console.log(chalk.white(" ref linux")+chalk.gray(" Quick reference for Linux")),console.log(chalk.white(" ref web")+chalk.gray(" Quick reference for Web")),console.log(chalk.white(" env")+chalk.gray(" See which of the 110 CTF tools are installed")),console.log(chalk.white(" env setup")+chalk.gray(" Install anything missing (~5 min, one-time)")),console.log(chalk.white(" help")+chalk.gray(" All available commands")),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log(chalk.gray(" Tip: ")+chalk.cyan("Ctrl+C")+chalk.gray(" pauses · ")+w()+chalk.gray(" · ")+chalk.cyan("quit")+chalk.gray(" closes CLI")),console.log()))}e.exitOverride(),e.configureOutput({writeErr:()=>{},writeOut:o=>{console.log(o)}});const po=o({input:process.stdin,output:process.stdout,prompt:J(),terminal:!0});f(po);let uo=!1;p(!0),Q();const ho=po.prompt.bind(po);po.prompt=o=>{b()||v()||A()||k()||po.setPrompt(J()),ho(o)},po.prompt(),po.on("line",async o=>{if(uo)return;const n=o.trim();if(!n)return po.setPrompt(b()?chalk.magenta("ai4ctf> "):J()),void po.prompt();if("menu"===n||"menu confirm"===n)return D()&&"menu confirm"!==n?(console.log(),console.log(chalk.yellow(" Real exam active. Progress is auto-saved.")),console.log(chalk.gray(" To return to main menu anyway, type ")+chalk.white("menu confirm")),console.log(),void po.prompt()):void u(po);if(b()){uo=!0;const o=await x(n);return uo=!1,"exit"===o&&po.setPrompt(J()),void po.prompt()}if(v()){uo=!0;const o=await C(n);return uo=!1,"exit"!==o&&"solved"!==o||po.setPrompt(J()),void po.prompt()}if(A()){uo=!0;const o=await I(n);return uo=!1,"exit"===o&&po.setPrompt(J()),po.setPrompt(A()?chalk.bold.cyan("ctf4vla> "):J()),void po.prompt()}if(U(n),"exit"===n)return L()?(console.log(),console.log(chalk.yellow(" ⚠ An exam is in progress.")),console.log(chalk.white(" To return to menu without losing progress, type: ")+chalk.bold.cyan("back")),console.log(chalk.white(" To fully close ICOA CLI, type: ")+chalk.bold.cyan("quit")),console.log(chalk.gray(" Your progress is auto-saved either way.")),console.log(),void po.prompt()):(console.log(),console.log(chalk.gray(" ")+chalk.white("exit")+chalk.gray(" returns to the main menu. To fully close ICOA CLI, type ")+chalk.bold.cyan("quit")+chalk.gray(".")),"selection"===mo&&oo(),void po.prompt());if("quit"===n||"q"===n||"quit confirm"===n){const o=L();return o&&"demo-free"!==o.session.examId&&"quit confirm"!==n?(console.log(),console.log(chalk.yellow(" ⚠ A real exam is in progress.")),console.log(chalk.gray(" Your answers are auto-saved on the server, but the exam timer keeps ticking")),console.log(chalk.gray(" on the server side even if you close the CLI.")),console.log(),console.log(chalk.white(" To leave the CLI but keep the exam alive, type: ")+chalk.bold.cyan("back")),console.log(chalk.gray(" (recommended — you can resume with ")+chalk.cyan("exam q 1")+chalk.gray(" after relaunching icoa)")),console.log(),console.log(chalk.white(" To really close ICOA CLI, type: ")+chalk.bold.cyan("quit confirm")),console.log(),void po.prompt()):(o&&"demo-free"===o.session.examId&&(console.log(),console.log(chalk.gray(" Demo paused. Resume with: ")+chalk.white("demo")+chalk.gray(" (fresh) or ")+chalk.white("exam q 1")+chalk.gray(" (continue)."))),_(),g(),console.log(chalk.gray(" Session saved. Use ")+chalk.white("icoa --resume")+chalk.gray(" to continue.")),R(),void ao(0))}if("back"===n){const o=L(),e=o&&"demo-free"!==o.session.examId,l=o&&"demo-free"===o.session.examId&&(()=>{const e=new Date(o.session.startedAt||0).getTime();return Date.now()-e<18e5})();if(e)console.log(),console.log(chalk.gray(" Exam paused. Your progress is saved.")),console.log(chalk.white(" Resume: exam q 1")+chalk.gray(" · ")+chalk.white("exam review")+chalk.gray(" · ")+chalk.white("exam submit")),console.log();else if(l){const e=Object.keys(o.answers).length,l=o.session.questionCount;console.log(),console.log(chalk.gray(` Demo paused (${e}/${l} answered). Resume with: `)+chalk.white("exam q 1")),console.log(chalk.gray(" Or type ")+chalk.white("demo")+chalk.gray(" to restart.")),console.log()}else{if(o&&"demo-free"===o.session.examId){const{clearExamState:o}=await import("./lib/exam-state.js");o("demo-free")}const e=t();fetch("https://practice.icoa2026.au/api/icoa/demo-stats",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"post-report-back",lang:e.language||"en",timestamp:(new Date).toISOString()}),signal:AbortSignal.timeout(5e3)}).catch(()=>{}),"selection"===mo?oo():console.log(chalk.gray(" Already at main menu."))}return void po.prompt()}if("help"===n||"?"===n){if(L()){uo=!0;try{await e.parseAsync(["node","icoa","exam","help"])}catch{}return uo=!1,void po.prompt()}return lo(s(),mo),void po.prompt()}if("man"===n||"manual"===n)return lo(s(),mo),void po.prompt();if("more help"===n.toLowerCase()&&L()){uo=!0;try{await e.parseAsync(["node","icoa","exam","more-help"])}catch{}return uo=!1,void po.prompt()}if("continue"===n.toLowerCase())return console.log(),console.log(chalk.green.bold(" ═══ AI4CTF — AI as Your Teammate ═══")),console.log(),console.log(chalk.white(" In AI4CTF, you solve cybersecurity challenges")),console.log(chalk.white(" with AI by your side.")),console.log(),console.log(chalk.white(" In competition, you get AI help at 3 levels:")),console.log(chalk.yellow(" hint a")+chalk.gray(" General guidance (50 uses)")),console.log(chalk.yellow(" hint b")+chalk.gray(" Deep analysis (10 uses)")),console.log(chalk.yellow(" hint c")+chalk.gray(" Critical assist (2 uses)")),console.log(),console.log(chalk.white(" Try it now! Type: ")+chalk.bold.green("ai4ctf")),console.log(chalk.gray(' Chat freely with your AI teammate. Type "exit" when done.')),console.log(),console.log(chalk.gray(" After ai4ctf, try: ")+chalk.bold.red("ctf4ai")+chalk.gray(' — trick the AI into saying "koala"')),console.log(),void po.prompt();if(/^ICOA-[A-Z]{2,3}-\d{1,6}$/i.test(n.trim())){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",n.trim()])}catch{}return uo=!1,void po.prompt()}if(/^[A-Z]{2}[0-9A-HJKMNP-TV-Z]{8}$/i.test(n.trim())){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",n.trim().toUpperCase()])}catch{}return uo=!1,void po.prompt()}const a=n.match(/^exam\s+([A-Z]{2}[0-9A-HJKMNP-TV-Z]{8})$/i);if(a){uo=!0;try{await e.parseAsync(["node","icoa","exam","token",a[1].toUpperCase()])}catch{}return uo=!1,void po.prompt()}const y=n.match(/^exam\s+([A-Z]{2,3})$/i);if(y){uo=!0;try{await e.parseAsync(["node","icoa","exam","list",y[1]])}catch{}return uo=!1,void po.prompt()}if("clear"===n||"cls"===n)return console.clear(),void po.prompt();if(n.startsWith("activate ")){const o=n.slice(9).trim(),e=r(o);return"ok"===e?console.log(chalk.green(" Access granted! Token bound to this device.")):"already_bound"===e?(console.log(),console.log(chalk.red(" Token already activated on a different device.")),console.log(chalk.gray(" Each token binds to the first device that uses it. If you lost the device,")),console.log(chalk.gray(" contact your proctor to have the token re-issued for a new device."))):(console.log(),console.log(chalk.red(" Token not recognized.")),console.log(chalk.gray(" Possible reasons:")),console.log(chalk.white(" • ")+chalk.gray("Typo — tokens are case-insensitive, 10 chars, start with a 2-letter country code (e.g. ")+chalk.cyan("UAK7M2R9Q4")+chalk.gray(")")),console.log(chalk.white(" • ")+chalk.gray("Expired — ask your proctor or organizer for a fresh token")),console.log(chalk.white(" • ")+chalk.gray("Network — verify connection to ")+chalk.cyan("practice.icoa2026.au")),console.log(chalk.gray(" Still stuck? type ")+chalk.cyan("help")+chalk.gray(" or try ")+chalk.cyan("exam demo")+chalk.gray(" for a free practice round."))),console.log(),void po.prompt()}if("activate"===n)return console.log(chalk.gray(" Usage: ")+chalk.white("activate <token>")),console.log(),void po.prompt();const m=L();if(m){const o=n.toUpperCase().trim(),l=o=>{const e=m.questions.find(e=>e.number===o);return!!e&&("ai4ctf"===e.type||"ctf4ai"===e.type||e.options&&!e.options.A&&!e.options.B)},t=o=>{const e="demo-free"!==m.session.examId,l=e&&o>=39?"ctf4ai":e&&o>=31?"ai4ctf":null;console.log(),console.log(chalk.yellow(` Q${o} is a practical question — letters (A/B/C/D) don't apply here.`)),l?(console.log(chalk.white(" Enter the AI chat for this question: ")+chalk.bold.cyan(l)),console.log(chalk.gray(" Or submit a flag directly: ")+chalk.green(`exam answer ${o} ICOA{your_flag}`))):console.log(chalk.gray(" Submit a flag: ")+chalk.green(`exam answer ${o} ICOA{your_flag}`)),console.log()};if(/^[ABCD]$/.test(o)){const n=m._lastQ||1;if(l(n))return t(n),void po.prompt();uo=!0;try{await e.parseAsync(["node","icoa","exam","answer",String(n),o])}catch{}return uo=!1,void po.prompt()}const a=o.match(/^(\d+)\s+([ABCD])$/);if(a){const o=parseInt(a[1],10);if(l(o))return t(o),void po.prompt();uo=!0;try{await e.parseAsync(["node","icoa","exam","answer",a[1],a[2]])}catch{}return uo=!1,void po.prompt()}}const d=n.split(/\s+/)[0].toLowerCase(),p=/^python3?(\.\d+)?$/.test(d),h="ls"===d||"pwd"===d,w=n.startsWith("!")||d.startsWith("!")||p||h,f=new Set(["nano","vi","vim","emacs","pico","ed","code","cat","less","more","head","tail","ls","pwd","cd","base64","xxd","hexdump","od","openssl","md5sum","sha256sum","grep","find","awk","sed","strings","file","curl","wget","nc","ping","nmap","echo","bash","sh","zsh","pip","pip3","node","npm"]),k=()=>{console.log(chalk.gray(" Shell commands need ")+chalk.bold.cyan("!")+chalk.gray(" prefix. Try: ")+chalk.bold.cyan(`!${n}`)),console.log()};if("embodied"===mo&&!w&&!["demo2","learn","exam","ctf4vla","lang","ref","setup","env","sim"].includes(d))return f.has(d)?(k(),void po.prompt()):(console.log(chalk.gray(" Not available in Embodied AI Security mode.")),console.log(chalk.white(" Try ")+chalk.bold.cyan("demo2")+chalk.gray(" (intro) · ")+chalk.bold.cyan("learn")+chalk.gray(" (curriculum) · ")+chalk.bold.cyan("exam <PD-token>")+chalk.gray(" (Paper D)")),console.log(),void po.prompt());if("selection"===mo&&!w&&!["exam","demo","retry","nations","next","prev","continue","setup","lang","ref","ai4ctf","ctf4ai","mark","unmark","review","submit","env","sim"].includes(d)){if(f.has(d))return k(),void po.prompt();if(console.log(chalk.gray(" Not available in Selection mode.")),m){const o=m._lastQ||1;console.log(chalk.white(` Resume exam: exam q ${o}`)+chalk.gray(" · ")+chalk.white("A/B/C/D")+chalk.gray(" to answer"))}else console.log(chalk.gray(" Try: demo · setup to switch mode"));return console.log(),void po.prompt()}if("organizer"===mo&&!["join","exam","demo","retry","next","prev","logout","setup","lang","ref","ctf","mark","unmark","review","submit"].includes(d))return console.log(chalk.gray(" Not available in Organizer mode. Switch via: setup")),console.log(),void po.prompt();if(!("olympiad"!==mo||s()&&c()||i(d)))return console.log(chalk.yellow(" Restricted mode. ")+chalk.gray("Enter your access token:")),console.log(chalk.white(" activate <token>")),console.log(),console.log(chalk.gray(" Free commands: ")+chalk.white("ref [topic]")+chalk.gray(", ")+chalk.white("help")+chalk.gray(", ")+chalk.white("exit")),console.log(),void po.prompt();if(!["join","activate","challenges","ch","open","submit","flag","scoreboard","sb","status","time","ref","shell","files","connect","note","notes","logbook","log","man","manual","lang","setup","env","ai4ctf","model","ctf","exam","demo","retry","nations","next","prev","continue","logout","ctf4ai","mark","unmark","review","submit","learn","demo2","ctf4vla","theme","sim"].includes(d)){if(K.has(d))return console.log(chalk.yellow(` "${d}" is a shell command — the ICOA prompt isn't a shell.`)),console.log(chalk.gray(" In real-exam mode, prefix with ! to run inside the sandbox: ")+chalk.cyan(`!${n}`)),console.log(),void po.prompt();if(/(?:^|\s)(?:\/(?!home\/|Users\/|tmp\/)|\.\.\/|~\/)/.test(n)&&!n.startsWith("cd ")){const o=/(?:^|\s)\/(?!home\/\w+\/icoa-workspace|Users\/\w+\/icoa-workspace|tmp\/)/.test(n),e=/\.\./.test(n);if(o||e)return console.log(chalk.red(" Blocked: access outside workspace is not allowed.")),console.log(chalk.gray(` Workspace: ${H}`)),console.log(),void po.prompt()}let o=n.startsWith("!")?n.slice(1).trim():n;if("darwin"===process.platform){const e="/opt/homebrew/opt/python@3.12/bin/python3.12";o=o.replace(/^python3?\s/,`${e} `).replace(/^(python3|python)$/,e)}else if("win32"===process.platform){const e=(()=>{try{return l("py -3 --version",{stdio:["ignore","ignore","ignore"],timeout:1500}),"py -3"}catch{}return"python"})();o=o.replace(/^python3?(\.\d+)?\s/,`${e} `).replace(/^python3?(\.\d+)?$/,e)}else{const e=(()=>{try{return l("which python3.12",{stdio:"ignore"}),"python3.12"}catch{return"python3"}})();o=o.replace(/^python\s/,`${e} `).replace(/^python$/,e)}const e=B(),t=N(n);M({cwd:e,input:n,riskFlags:t}),t.length>0&&D()&&(console.log(chalk.yellow(` ⚠ Action flagged: ${t.join(", ")} — logged.`)),console.log()),/^(\S*python3?(\.\d+)?)\s*$/.test(o)&&(o=`PYTHONSTARTUP="${function(){const o=V(G(),".icoa");W(o)||Y(o,{recursive:!0});const e=V(o,"python-startup.py");return W(e)||z(e,"# ICOA exam interactive startup — auto-loaded by PYTHONSTARTUP\nimport base64, struct, hashlib, re, json, os, sys, binascii\ntry: import requests\nexcept ImportError: pass\ntry: from Crypto.Cipher import AES\nexcept ImportError: pass\ntry: from Crypto.Util.Padding import pad, unpad\nexcept ImportError: pass\ntry: from pwn import xor, p32, u32, p64, u64\nexcept ImportError: pass\ntry: import bs4\nexcept ImportError: pass\ntry: import numpy as np\nexcept ImportError: pass\n"),e}()}" ${o}`,console.log(),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log(chalk.bold.white(" Python ready — ICOA exam toolkit pre-loaded")),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log(),console.log(chalk.white(" Already imported: ")+chalk.gray("base64, struct, hashlib, re, json, binascii")),console.log(chalk.white(" Also available: ")+chalk.gray("requests, bs4, numpy, AES, pad/unpad, xor, p32/u32/p64/u64")),console.log(),console.log(chalk.yellow(" Quick examples:")),console.log(chalk.gray(' base64.b64decode("aGVsbG8=") ')+chalk.gray("# decode base64")),console.log(chalk.gray(' bytes.fromhex("48656c6c6f") ')+chalk.gray("# hex → bytes")),console.log(chalk.gray(' "ICOA{x}".encode() ')+chalk.gray("# str → bytes")),console.log(chalk.gray(" [chr(c) for c in [73,67,79,65]] ")+chalk.gray("# ASCII codes")),console.log(chalk.gray(' xor(bytes.fromhex("0a2b"), b"IC") ')+chalk.gray("# pwntools XOR")),console.log(),console.log(chalk.gray(" Exit: ")+chalk.white("exit()")+chalk.gray(" or Ctrl-D")),console.log(chalk.cyan(" ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━")),console.log()),uo=!0;try{F()&&await j()?await q(o,po):await eo(o,po,e)}catch{console.log(chalk.yellow(` Command failed: ${d}`))}return uo=!1,console.log(),void po.prompt()}uo=!0;const T=n.trim(),S=T.toLowerCase();let $,O=null,E="";if(m)if("submit"===S)O="final";else if(S.startsWith("submit ")){let o=T.slice(7).trim();/^submit\s+/i.test(o)&&(o=o.replace(/^submit\s+/i,"").trim()),o=o.replace(/^["'`]+|["'`]+$/g,"").trim(),o&&/^ICOA\{[^}]*\}?$/i.test(o)&&(O="flag",E=o)}else/^ICOA\{[^}]+\}$/i.test(T)&&(O="flag",E=T);$="final"===O?["exam","submit"]:"flag"===O?["exam","answer",String(m?._lastQ||1),E]:function(o){const e=o.split(/\s+/),l=e[0].toLowerCase(),n=e.slice(1),t={demo:["exam","demo"],retry:["exam","demo-retry"],nations:["exam","nations"],next:["exam","next"],prev:["exam","prev"],mark:["exam","mark",...n],unmark:["exam","unmark",...n],review:["exam","review"],logout:["ctf","logout"],join:["ctf","join",...n],activate:["ctf","activate",...n],challenges:["ctf","challenges"],ch:["ctf","challenges"],open:["ctf","open",...n],submit:["ctf","submit",...n],flag:["ctf","submit",...n],scoreboard:["ctf","scoreboard",...n],sb:["ctf","scoreboard",...n],status:["ctf","status"],time:["ctf","time"]};return t[l]?t[l]:["ref","shell","files","connect","note","notes","logbook","log","man","manual","lang","setup","env","ai4ctf","model","ctf","exam","ctf4ai"].includes(l)?[l,...n]:e}(n);const P="ctf"===$[0]&&"join"===$[1];P&&po.pause(),process.exit=()=>{throw new Error(Z)};try{await e.parseAsync(["node","icoa",...$])}catch(o){const e=o instanceof Error?o.message:String(o);if(e===Z);else if(e.includes("commander.unknownCommand")){const{distance:o}=await import("fastest-levenshtein"),e=["ctf","ref","shell","files","connect","note","notes","logbook","log","manual","lang","setup","env","ai4ctf","exam","ctf4ai","theme","clear","cls","quit","exit","back","menu","help","continue","activate","demo","challenges","status","scoreboard","join","logout"],l=d.split(/\s+/)[0]||d;let n={word:"",dist:1/0};for(const t of e){const e=o(l.toLowerCase(),t);e<n.dist&&(n={word:t,dist:e})}console.log(chalk.yellow(` Unknown command: ${d}.`)),n.dist>0&&n.dist<=2&&console.log(chalk.gray(" Did you mean: ")+chalk.bold.cyan(n.word)+chalk.gray("?")),console.log(chalk.gray(" Type ")+chalk.cyan("help")+chalk.gray(" for the full command list."))}else e.includes("commander.")||(e.includes("fetch failed")||e.includes("ECONNREFUSED")||e.includes("ETIMEDOUT"))&&console.log(chalk.yellow(" Network error. Check your connection."))}finally{process.exit=ao,uo=!1,P&&po.resume()}b()?po.setPrompt(chalk.magenta("ai4ctf> ")):v()?po.setPrompt(chalk.red("ctf4ai> ")):A()&&po.setPrompt(chalk.bold.cyan("ctf4vla> ")),console.log(),po.prompt()}),po.on("SIGINT",()=>{if(console.log(),b()||v())console.log(chalk.yellow(" Ctrl+C did not close ICOA CLI — you are still in the AI chat.")),console.log(chalk.white(" Type ")+chalk.bold.cyan("exit")+chalk.white(" to leave the chat and return to the menu."));else if(L()){const o="demo-free"!==L().session.examId;console.log(chalk.yellow(" Ctrl+C did NOT close ICOA CLI.")),console.log(chalk.gray(` Your ${o?"exam":"demo"} is paused and every answer is auto-saved.`)),console.log(),console.log(chalk.white(" Resume: ")+chalk.cyan("exam q 1")+chalk.gray(" · Back to menu: ")+chalk.cyan("back")+chalk.gray(" · Close CLI: ")+chalk.cyan(o?"quit confirm":"quit"))}else console.log(chalk.yellow(" Ctrl+C did not close ICOA CLI — you are still at the ")+chalk.cyan("icoa>")+chalk.yellow(" prompt.")),console.log(chalk.gray(" Keep typing — ")+chalk.cyan("help")+chalk.gray(" lists commands. (Only ")+chalk.cyan("quit")+chalk.gray(" or Ctrl+D actually close the CLI.)"));console.log(),po.prompt()}),po.on("close",()=>{_(),g(),R(),ao(0)})}function eo(o,l,n){return new Promise(t=>{const a=process.stdin,s=!!a.isTTY&&!!a.isRaw;if(l.pause(),a.isTTY&&"function"==typeof a.setRawMode)try{a.setRawMode(!1)}catch{}const r=e(o,{shell:!0,stdio:"inherit",cwd:n||process.cwd()}),i=()=>{if(a.isTTY&&"function"==typeof a.setRawMode&&s)try{a.setRawMode(!0)}catch{}l.resume(),t()};r.on("close",i),r.on("error",i)})}function lo(o,e="olympiad"){return console.log(),"selection"===e||"organizer"===e?(console.log(chalk.bold.white(" Exam")),console.log(chalk.white(" join <url> ")+chalk.gray("Connect to exam server")),console.log(chalk.white(" exam list ")+chalk.gray("Available exams")),console.log(chalk.white(" exam start <id> ")+chalk.gray("Begin an exam")),console.log(chalk.white(" exam q [n] ")+chalk.gray("View questions")),console.log(chalk.white(" exam answer <n> <X> ")+chalk.gray("Answer question")),console.log(chalk.white(" exam review ")+chalk.gray("Review all answers")),console.log(chalk.white(" exam submit ")+chalk.gray("Submit for grading")),console.log(chalk.white(" exam result ")+chalk.gray("View your score")),console.log(),console.log(chalk.bold.white(" System")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference")),console.log(chalk.white(" setup ")+chalk.gray("Settings / switch mode")),console.log(chalk.white(" lang [code] ")+chalk.gray("Switch language")),console.log(chalk.white(" clear ")+chalk.gray("Clear screen")),console.log(chalk.white(" exit ")+chalk.gray("Quit")),void console.log()):o?(console.log(chalk.cyan(" ═══════════════════════════════════════════════")),console.log(chalk.bold.white(" How it works")),console.log(),console.log(chalk.gray(" 1. Browse ")+chalk.white("challenges")+chalk.gray(" and pick one")),console.log(chalk.gray(" 2. ")+chalk.white("open <id>")+chalk.gray(" to read the challenge")),console.log(chalk.gray(" 3. Use ")+chalk.white("ai4ctf")+chalk.gray(" to chat with AI when stuck")),console.log(chalk.gray(" 4. ")+chalk.white("submit <id> icoa{flag}")+chalk.gray(" to score points")),console.log(chalk.gray(" 5. Check ")+chalk.white("scoreboard")+chalk.gray(" to track your rank")),console.log(chalk.cyan(" ═══════════════════════════════════════════════")),console.log(),console.log(chalk.bold.white(" Competition")),console.log(chalk.white(" join <url> ")+chalk.gray("Connect to CTFd")),console.log(chalk.white(" challenges (ch) ")+chalk.gray("List challenges by category")),console.log(chalk.white(" open <id> ")+chalk.gray("Read challenge + get next steps")),console.log(chalk.white(" submit <id> <flag> ")+chalk.gray("Submit a flag")),console.log(chalk.white(" scoreboard (sb) ")+chalk.gray("Live rankings")),console.log(chalk.white(" status ")+chalk.gray("Your score, budget & timer")),console.log(chalk.white(" time ")+chalk.gray("Countdown timer")),console.log(),console.log(chalk.bold.white(" AI Teammate")+chalk.gray(" — 3 levels, use wisely")),console.log(chalk.white(' hint "question" ')+chalk.gray("Level A — General guidance (50 uses)")),console.log(chalk.white(' hint-b "question" ')+chalk.gray("Level B — Deep analysis (10 uses)")),console.log(chalk.white(' hint-c "question" ')+chalk.gray("Level C — Critical assist (2 uses)")),console.log(chalk.white(" hint budget ")+chalk.gray("Check remaining uses")),console.log(chalk.white(" ai4ctf ")+chalk.gray("Free-chat with AI (no limit)")),console.log(),console.log(chalk.bold.white(" Tools")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference (linux, web, crypto...)")),console.log(chalk.white(" shell ")+chalk.gray("Docker sandbox")),console.log(chalk.white(" files <id> ")+chalk.gray("Download challenge files")),console.log(chalk.white(" connect <id> ")+chalk.gray("Connect to remote target")),console.log(chalk.white(" note [text] ")+chalk.gray("Add a logbook entry (in-exam: tags current Q)")),console.log(chalk.white(" logbook [n] ")+chalk.gray("View your logbook (in-exam: filter by Q)")),console.log(chalk.white(" log ")+chalk.gray("Session history")),console.log(chalk.white(" man / manual ")+chalk.gray("Show this command list (works in exam too, does not burn elimination)")),console.log(),console.log(chalk.bold.white(" System")),console.log(chalk.white(" setup ")+chalk.gray("Configure settings")),console.log(chalk.white(" lang [code] ")+chalk.gray("Switch language (15 supported)")),console.log(chalk.white(" logout ")+chalk.gray("Disconnect")),console.log(chalk.white(" clear ")+chalk.gray("Clear screen")),console.log(chalk.white(" exit ")+chalk.gray("Quit (session saved)")),void console.log()):(console.log(chalk.bold.yellow(" Restricted Mode — activate with a token to unlock all commands")),console.log(),console.log(chalk.white(" activate <token> ")+chalk.gray("Unlock full access")),console.log(chalk.white(" ref [topic] ")+chalk.gray("Quick reference")),console.log(chalk.white(" exit ")+chalk.gray("Quit")),void console.log())}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "icoa-cli",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.224",
|
|
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": {
|