icoa-cli 2.19.502 → 2.19.505
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/learn-curricula.js +1 -1
- package/dist/lib/learn-render.js +1 -1
- package/dist/lib/learn-state.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export function localized(r,
|
|
1
|
+
export function localized(r,e){if(!e.startsWith("zh")||!r._zh)return r;const t=r._zh,n={...r};for(const r of Object.keys(t))void 0!==t[r]&&(n[r]=t[r]);return n}export function isValidCurriculum(r){if(!r||"object"!=typeof r)return!1;const e=r;return"string"==typeof e.id&&"number"==typeof e.totalCards&&Array.isArray(e.cards)&&Array.isArray(e.modules)}import{readFileSync as r,writeFileSync as e,mkdirSync as t,existsSync as n,statSync as a,utimesSync as c}from"node:fs";import{join as i}from"node:path";import{homedir as o}from"node:os";import{getDeviceFingerprint as s}from"./access.js";import{getCliVersion as u}from"./version.js";import{httpFetch as l}from"./http.js";import{parseHometask as d}from"./learn-hometask.js";import{parseFaqs as p,parseReplies as m}from"./learn-replies.js";const f=i(o(),".icoa","learn-cache");export const LEARN_SERVER="https://practice.icoa2026.au";function g(r){const e=r.replace(/[^A-Za-z0-9_-]/g,"_");return i(f,`${e}.json`)}function _(r){const e=r.replace(/[^A-Za-z0-9_-]/g,"_");return i(f,`${e}.etag`)}let h=null;export function getLastCurriculumFailure(){return h}export async function loadCurriculumById(i,o,s=!1){"ctf4eai-12"===i&&(i="LEARNDEMO01");const l=function(e){const t=g(e);if(!n(t))return null;try{const e=a(t),n=Date.now()-e.mtimeMs;return{curriculum:JSON.parse(r(t,"utf-8")),ageMs:n}}catch{return null}}(i);if(!s&&l&&l.ageMs<6048e5&&isValidCurriculum(l.curriculum))return l.curriculum;h=null;const d=await async function(e,t){const a=LEARN_SERVER.replace(/\/$/,"")+"/api/icoa/learn/curriculum/"+encodeURIComponent(e),c={},i=function(e){const t=_(e);if(!n(t))return null;try{return r(t,"utf-8").trim()||null}catch{return null}}(e);i&&(c["If-None-Match"]=i),t&&(c["X-Learn-Token"]=t.toUpperCase()),c["X-ICOA-Client"]=u();try{const r=await fetch(a,{headers:c,signal:AbortSignal.timeout(6e4)});if(304===r.status)return{kind:"unchanged"};if(404===r.status)return{kind:"notfound"};if(!r.ok)return{kind:"error"};const e=await r.json();if(!e.success||!e.data)return{kind:"error"};if(!isValidCurriculum(e.data))return{kind:"error"};const t=r.headers.get("etag")||r.headers.get("ETag")||void 0;return{kind:"fresh",curriculum:e.data,etag:t||void 0}}catch{return{kind:"error"}}}(i,o);return"fresh"===d.kind?(function(r,n,a){try{t(f,{recursive:!0}),e(g(r),JSON.stringify(n)),a&&e(_(r),a)}catch{}}(i,d.curriculum,d.etag),d.curriculum):"unchanged"===d.kind&&l&&isValidCurriculum(l.curriculum)?(function(r){try{const e=g(r);if(n(e)){const r=Date.now()/1e3;c(e,r,r)}}catch{}}(i),l.curriculum):l&&isValidCurriculum(l.curriculum)?l.curriculum:(h="notfound"===d.kind?"notfound":"offline",null)}export function validateResultShape(r){return{curriculumId:String(r.curriculum_id??""),status:String(r.status??""),validUntil:String(r.valid_until??""),aiEnabled:1===r.ai_enabled||!0===r.ai_enabled,gated:1===r.gated||!0===r.gated,replies:m(r.replies),hometask:d(r.hometask)}}export async function validateEAToken(r){const e=LEARN_SERVER.replace(/\/$/,"")+"/api/icoa/learn/validate";try{const t=await l(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:r.toUpperCase(),device_fingerprint:s()}),signal:AbortSignal.timeout(8e3)});if(!t.ok){const r=await t.json().catch(()=>({}));return{ok:!1,message:r.message||`HTTP ${t.status}`,code:r.code}}const n=await t.json();return n.success&&n.data?{ok:!0,...validateResultShape(n.data)}:{ok:!1,message:n.message||"Validation failed"}}catch(r){return{ok:!1,message:`Network error: ${r instanceof Error?r.message:String(r)}`}}}export async function syncProgress(r,e,t){if("LEARNDEMO01"===r.toUpperCase())return;const n=LEARN_SERVER.replace(/\/$/,"")+"/api/icoa/learn/progress/"+r.toUpperCase();try{await l(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({card_number:e.card_number,event_type:e.event_type,mcq_answer:e.mcq_answer,mcq_correct:e.mcq_correct?1:0,check_answer:e.check_answer,check_correct:e.check_correct?1:0,time_on_card_ms:e.time_on_card_ms,device_fingerprint:s(),reply_ack:t&&t.length>0?t:void 0}),signal:AbortSignal.timeout(5e3)})}catch{}}export async function fetchServerProgress(r){if("LEARNDEMO01"===r.toUpperCase())return null;const e=LEARN_SERVER.replace(/\/$/,"")+"/api/icoa/learn/progress/"+r.toUpperCase();try{const r=await l(e,{signal:AbortSignal.timeout(5e3)});if(!r.ok)return null;const t=await r.json();return t?.success&&Array.isArray(t.data?.events)?t.data.events:null}catch{return null}}export async function fetchCardFaqs(r){const e=LEARN_SERVER.replace(/\/$/,"")+"/api/icoa/learn/faq/"+encodeURIComponent(r.toUpperCase());try{const r=await l(e,{signal:AbortSignal.timeout(5e3)});if(!r.ok)return[];const t=await r.json();return t.success&&t.data?p(t.data.faqs):[]}catch{return[]}}export async function syncCardFeedback(r,e){const t=LEARN_SERVER.replace(/\/$/,"")+"/api/icoa/learn/feedback/"+r.toUpperCase();try{return(await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({curriculum_id:e.curriculum_id,card_number:e.card_number,feedback_text:e.feedback_text,time_on_card_ms:e.time_on_card_ms}),signal:AbortSignal.timeout(5e3)})).ok}catch{return!1}}
|
package/dist/lib/learn-render.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import chalk from"chalk";import o from"string-width";import{localized as e}from"./learn-curricula.js";import{t as n}from"./learn-i18n.js";import{getConfig as t}from"./config.js";import{icoaBannerLines as r}from"./banner.js";import{renderCharts as l,detectCaps as a}from"./render-card.js";import{replyChipLabel as s}from"./learn-replies.js";function c(){return(t().language||"en").toLowerCase()}let g="normal";export function resolveLearnWidth(o){return"normal"===o.learnWidth||"wide"===o.learnWidth||"wider"===o.learnWidth?o.learnWidth:o.learnWide?"wide":"normal"}export function setLearnWidth(o){g=o}export function learnWidthCap(o=g){return"wider"===o?120:"wide"===o?96:64}export function learnW(){if("normal"===g)return 64;const o=process.stdout.columns||64;return Math.max(64,Math.min(o-6,learnWidthCap()))}const i=learnW;function d(o="─"){return o.repeat(i()+2)}function y(o,e,n=20){const t=e>0?o/e:0,r=Math.floor(t*n),l=n-r;return`${chalk.green("█".repeat(r))+chalk.gray("░".repeat(l))} ${(100*t).toFixed(1)}%`}function u(o){return o>=30?chalk.red("🔥🔥🔥 "+o+" days"):o>=7?chalk.yellow("🔥 "+o+" days"):o>=1?chalk.gray("· "+o+" day"+(o>1?"s":"")):chalk.gray("—")}export function renderWelcome(o,e,t){const r=c(),l=e.cardsCompleted.length,a=o.totalCards,s=a-l,g=o.modules.find(o=>e.currentCard>=o.cardRange[0]&&e.currentCard<=o.cardRange[1]),i=/demo/i.test(o.id);if(console.log(),console.log(chalk.cyan(" ╭"+d("═"))),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ║ ")+chalk.bold.white(" "+(o.name?.trim()||n("academy_title",r)))),console.log(chalk.cyan(" ║")),t)console.log(chalk.cyan(" ║ ")+chalk.white(" "+n(i?"welcome_new_demo":"welcome_new",r)));else{const o=new Date(e.lastSeenAt),t=Math.floor((Date.now()-o.getTime())/36e5),l=t<1?n("just_now",r):t<24?`${t}${n("ago_hours",r)}`:`${Math.floor(t/24)}${n("ago_days",r)}`;console.log(chalk.cyan(" ║ ")+chalk.white(` ${n("welcome_back",r)} ${l}`))}console.log(chalk.cyan(" ║"));const h=g?`${g.number}. ${g.name}`:"—";console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("module",r).padEnd(11))+chalk.white(h)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("progress",r).padEnd(11))+y(l,a)+chalk.gray(` (${l}/${a})`)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("streak",r).padEnd(11))+u(e.streakDays)),s>0&&e.currentCard<=a&&console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("next_card",r).padEnd(11))+chalk.white(`#${e.currentCard} ${n("of",r)} ${a}`)),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ╰"+d("═"))),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const m=0===l?n("continue_start",r):`${n("continue_resume",r)} ${e.currentCard}`;console.log(chalk.bold.green(" continue")+chalk.gray(" "+m)),console.log(chalk.yellow(" status")+chalk.gray(" "+n("status_full",r))),e.bookmarks.length>0&&console.log(chalk.yellow(" bookmarks")+chalk.gray(` ${e.bookmarks.length} ${n("bookmarks_desc",r)}`)),console.log(chalk.gray(" quit")+chalk.gray(" "+n("quit_desc",r))),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log()}function h(o,e){const t=c(),r=o.module,l=e.modules.find(o=>o.number===r),a=l?l.name:n("unknown_module",t),s=n("module",t).replace(":","").trim(),g=`${n("card",t)} ${o.number} / ${e.totalCards} · ${s} ${r} · ${a}`;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(g)+" "+chalk.cyan("─".repeat(Math.max(0,i()-g.length-4))))}function m(){console.log(chalk.cyan(" ╰"+d())),console.log()}function p(o){console.log(chalk.cyan(" │ ")+chalk.white(o))}function b(){console.log(chalk.cyan(" │"))}const f=/[┌┐└┘├┤┬┴┼─│╔╗╚╝═║╠╣╦╩╬▓▒░█]/;function $(o){return/^(?: {4}|\t)/.test(o)||f.test(o)||/ {3,}/.test(o)}export function wrapMixed(e,n){const t=[];let r="",l=0,a=!1;for(const s of function(e){const n=[],t=e=>{let t="";const r=()=>{t&&(n.push({t:"atom",s:t}),t="")};for(const l of e)" "===l?(r(),n.push({t:"space"})):2===o(l)?(r(),n.push({t:"wide",s:l})):t+=l;r()},r=/`[^`]*`/g;let l,a=0;for(;null!==(l=r.exec(e));)t(e.slice(a,l.index)),n.push({t:"code",s:l[0]}),a=l.index+l[0].length;return t(e.slice(a)),n}(e)){if("space"===s.t){""!==r&&(a=!0);continue}const e=s.s,c=o("code"===s.t?e.replace(/`/g,""):e),g=a?1:0,i="atom"===s.t&&e.length<=2&&/^[.,;:!?)\]}…'"]+$/.test(e);""!==r&&!i&&l+g+c>n?(t.push(r),r=e,l=c,a=!1):(a&&(r+=" ",l+=1,a=!1),r+=e,l+=c)}return r&&t.push(r),t}const w=/\b(?:Common bug|Common mistake|Common error|Pitfall|Gotcha|Footgun)\b[::]?|\b(?:Warning|Caution)\b[::]|(?:常见错误|常见陷阱|常见误区|陷阱|注意|警告|误区)[::]/gi;function _(o,e){const n=e?chalk.bold.white:chalk.white;let t,r="",l=0;for(w.lastIndex=0;null!==(t=w.exec(o));)t.index>l&&(r+=n(o.slice(l,t.index))),r+=chalk.bold.yellow(t[0]),l=t.index+t[0].length;return l<o.length&&(r+=n(o.slice(l))),r}function k(o,e=!1){let n="",t=0;const r=/`([^`]*)`/g;let l;for(;null!==(l=r.exec(o));)l.index>t&&(n+=_(o.slice(t,l.index),e)),n+=chalk.cyan(l[1]),t=l.index+l[0].length;return t<o.length&&(n+=_(o.slice(t),e)),n}function x(o,e=!1){let n=!1;for(const t of o.split("\n"))if(/^\s*```/.test(t))n=!n;else if(n)console.log(chalk.cyan(" │ ")+chalk.cyan(` ${t}`));else if(""!==t)if($(t))console.log(chalk.cyan(" │ ")+chalk.white(t));else for(const o of wrapMixed(t,i()-4))console.log(chalk.cyan(" │ ")+` ${k(o,e)}`);else b()}function C(o,e){const n=[];for(const t of o.split("\n")){if(""===t){n.push("");continue}if($(t)){n.push(t);continue}let o="";for(const r of t.split(" "))(o+" "+r).trim().length>e?(n.push(o.trim()),o=r):o=(o+" "+r).trim();o&&n.push(o)}return n}let M=!1;export function setLearnAiEnabled(o){M=o}let W=new Set;export function setLearnPqsViewCards(o){W=o}let v=new Map;export function setLearnHonorRanks(o){v=o}const z=["①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩"];let q=[];export function setLearnReplies(o){q=o}let j=[];export function setLearnFaqs(o){j=o}let S=null;export function setLearnHometask(o){S=o}export function renderHonorWall(o){const e=c().startsWith("zh"),{totals:n,chapters:t}=o,r=n.gold+n.silver+n.bronze,l=(o,e)=>e>0?chalk.bold.white(`${o}×${e}`):chalk.gray(`${o}×0`);if(console.log(chalk.gray(" ─────────────────────────────────────────")),console.log(chalk.bold.white(e?" 🏅 奖牌墙 ":" 🏅 Medal wall ")+l("🥇",n.gold)+chalk.gray(" · ")+l("🥈",n.silver)+chalk.gray(" · ")+l("🥉",n.bronze)+chalk.gray(e?" (永久 — 挂上墙就不会摘下)":" (permanent — once earned, never removed)")),0===r){const n=null!=o.floor?`${o.floor}+`:e?"高分":"a high score";return console.log(chalk.gray(e?` 还没有奖牌 — 单卡提问评分 ${n} 并进入该卡前三,即可永久挂墙 🥇🥈🥉`:` No medals yet — score ${n} on a card and hold its top-3 to hang one 🥇🥈🥉`)),void console.log(chalk.gray(" ─────────────────────────────────────────"))}const a=t.map(o=>{const e=`Ch${o.chapter}`,n=(o.gold>0?`🥇${o.gold}`:"")+(o.silver>0?`🥈${o.silver}`:"")+(o.bronze>0?`🥉${o.bronze}`:"");return n?chalk.white(`${e} ${n}`):chalk.gray(`${e} —`)}).join(chalk.gray(" "));console.log(" "+a);const s=t.flatMap(o=>o.cards.map(e=>({...e,chapter:o.chapter})));s.sort((o,e)=>o.rank-e.rank||o.chapter-e.chapter||o.card-e.card);for(const o of s.slice(0,24)){const n=(o.since||"").slice(0,10);console.log(chalk.white(` ${o.icon} `)+chalk.gray(`Ch${o.chapter} · `)+chalk.white(e?`第 ${o.card} 张`:`card ${o.card}`)+chalk.gray(` · ${o.score}`)+(n?chalk.gray(e?` · 始于 ${n}`:` · since ${n}`):""))}s.length>24&&console.log(chalk.gray(e?` …还有 ${s.length-24} 枚`:` …and ${s.length-24} more`)),console.log(chalk.gray(" ─────────────────────────────────────────"))}export function renderKnowledgeCard(t,r){const d=c(),y=e(t,d);h(y,r),b();const u=wrapMixed(y.title,i()-4);for(const o of u)p(chalk.bold.yellow(o));p(chalk.gray("─".repeat(Math.min(Math.max(...u.map(e=>o(e))),i()))));const f=!!(t.chart_ids&&t.chart_ids.length>0);if(f&&l(t.chart_ids.slice(0,1),r.charts,a()),y.key_point&&""!==y.key_point.trim()?(f||b(),function(o,e,n){const t=c().startsWith("zh"),r=a().cols,l="-".repeat(Math.min(i(),Math.max(24,r-6))),s=t?"要点":"KEY POINT",g=t?`第 ${e} / ${n} 张`:`Card ${e} / ${n}`;console.log(chalk.cyan(" │ ")+chalk.green(l)),console.log(chalk.cyan(" │ ")+chalk.green(`${s} · ${g}`));for(const e of wrapMixed(o,i()-4))console.log(chalk.cyan(" │ ")+chalk.bold.green(" "+e));console.log(chalk.cyan(" │ ")+chalk.green(l)),b()}(y.key_point,y.number,r.totalCards)):f||b(),y.body.filter(o=>null!=o&&""!==o.trim()).forEach((o,e)=>{const n=0===e?o.match(/^([\s\S]*?(?:[.!?](?=\s|$)|[。!?]))(\s[\s\S]*)?$/):null;if(n&&n[1].trim().length<=180){x(n[1],!0);const o=n[2]?.trimStart();o&&x(o,!1)}else x(o,!1);b()}),y.icoaConnection){p(chalk.magenta(" "+n("icoa_connection",d))),p(chalk.gray(" "+"─".repeat(20)));for(const o of wrapMixed(y.icoaConnection,i()-4))p(" "+chalk.magenta(o));b()}if(t.check){const o=d.startsWith("zh"),e=t._zh?.checkStatement??t._zh?.check?.statement,n=o?e??t.check.statement:t.check.statement;p(chalk.cyan(" 🤔 "+(o?"请回答 (输 y 或 n):":"Quick comprehension check (type y or n):"))),p(chalk.gray(" "+"─".repeat(20)));for(const o of wrapMixed(n,i()-4))p(" "+chalk.white(o));b()}m(),function(e,n){const t=c().startsWith("zh"),r=a().cols,l="-".repeat(Math.min(i(),Math.max(24,r-6))),d=chalk.gray(" "),y=[];e.check?(y.push(chalk.bold.green("[y]")+chalk.gray(t?" 是":" yes")),y.push(chalk.bold.green("[n]")+chalk.gray(t?" 否":" no"))):y.push(chalk.bold.green("[ok]")+chalk.gray(t?" 继续":" next")),M&&(y.push(chalk.bold.magenta("[/ai]")+chalk.gray(t?" 🐼 熊猫导师":" 🐼 Panda tutor")),y.push(chalk.bold.magenta("[/submit]")+chalk.gray(t?" 提问评分":" prompt score")));const u=v.get(e.number);var h;y.push(chalk.bold.magenta(u?`[/honors ${h=u,z[h-1]??`#${h}`}]`:"[/honors]")+chalk.gray(t?" 排行":" board")),"normal"===g?y.push(chalk.bold.cyan("[wide]")+chalk.gray(t?" 宽屏":" widen")):(y.push("wide"===g?chalk.bold.cyan("[wider]")+chalk.gray(t?" 更宽":" wider"):chalk.bold.cyan("[wide]")+chalk.gray(t?" 回宽屏":" back to wide")),y.push(chalk.bold.cyan("[normal]")+chalk.gray(t?" 64列":" 64-col")));const m=s(q,j,e.number,t),p=m.startsWith("💬");if(y.push((p?chalk.bold.yellow("[r]"):chalk.gray("[r]"))+(p?chalk.bold.white(` ${m}`):chalk.gray(` ${m}`))),y.push(chalk.bold.yellow("[e]")+chalk.gray(t?" 提问或报告":" ask or report")),S){const o=S,e=`${o.done}/${o.total}`,n=o.completedAt?chalk.bold.green:chalk.bold.cyan;y.push(n("[task]")+chalk.gray(t?` 本周 ${e}`:` week ${e}`))}y.push(chalk.bold.cyan("[b]")+chalk.gray(t?" 上一张":" back")),y.push(chalk.bold.cyan("[card N]")+chalk.gray(t?" 跳转":" jump")),y.push(chalk.gray("[reload]")+(t?chalk.gray(" 刷新"):"")),y.push(chalk.gray("[quit]")+(t?chalk.gray(" 退出"):""));const b=o(l);console.log(chalk.gray(" "+l)),console.log(chalk.gray(" "+(t?`第 ${e.number} / ${n.totalCards} 张`:`Card ${e.number} / ${n.totalCards}`)));let f="",$=0;for(const e of y){const n=o(e);f&&$+2+n>b?(console.log(" "+f),f=e,$=n):(f=f?f+d+e:e,$=f===e?n:$+2+n)}f&&console.log(" "+f),console.log(" "+chalk.magenta("✍ ")+chalk.magenta("[/py]")+chalk.gray(t?" Python 草稿本":" Python scratchpad")+d+chalk.magenta("[/pylist]")+chalk.gray(t?" 我的草稿":" my files")),console.log(chalk.gray(" "+l));const w=[t?"e = 就这张卡提问,或报告问题":"e = ask about this card, or report a problem",t?"更多: bookmark / unbookmark · status · lang zh/en · link":"more: bookmark / unbookmark · status · lang zh/en · link"];for(const o of w)for(const e of wrapMixed(o,b))console.log(chalk.gray(" "+e));console.log()}(t,r)}export function renderCheckFeedback(o,e,n,t=!1){const r=c().startsWith("zh");if(console.log(),n)console.log(chalk.green(" ✓ ")+chalk.white(r?"答对了。":"Correct."));else if(console.log(chalk.yellow(" ✗ ")+chalk.white(r?"记下了,继续。":"Noted — moving on.")),t){const e="y"===o.check?.answer?r?"是":"Yes":r?"否":"No";console.log(chalk.gray(" "+(r?"正确答案: ":"Answer: ")+e+". "+(r?"回看上面那段。":"Re-read the paragraph above.")))}const l=r?o._zh?.solution??o.solution:o.solution;if(l&&l.length>0){console.log(),console.log(chalk.cyan(" 📝 "+(r?"解答:":"Worked solution:")));for(const o of l){for(const e of wrapMixed(o,i()-4))console.log(chalk.white(" "+e));console.log()}}console.log()}function A(o){return[chalk.white(" "+(o?"编著:Charlie Zhu":"Created & edited by Charlie Zhu")),chalk.gray(" "+(o?"ICOA 2026 创始人 · 课程总架构师":"Founder & Chief Curriculum Architect · ICOA 2026"))]}export function renderPhaseComplete(o,e,n,t,l,a){const s=c().startsWith("zh"),[g,d]=n.cardRange,y=e.checkResults||{};let u=0,h=0;for(let o=g;o<=d;o++){const e=y[String(o)];e&&(u++,e.correct&&h++)}const m="-".repeat(48);console.log();for(const o of r(" "))console.log(o);console.log(),console.log(chalk.bold.yellow(" "+m)),console.log(chalk.bold.yellow(" "+(s?`阶段 ${n.number} 完成`:`Phase ${n.number} complete`))+chalk.gray(" · ")+chalk.white(n.name));const p=u>0&&h===u?chalk.bold.green:chalk.bold.white;console.log(chalk.gray(" "+(s?"理解检查得分: ":"comprehension score: "))+p(`${h}/${u}`)+chalk.gray(0===u?s?" (本阶段未作答 y/n)":" (no y/n answered)":""));const b=String(d).length;for(let e=g;e<=d;e++){const n=o.cards.find(o=>o.number===e);if(!n)continue;const t=n,r=t.title??t.badge??"",l=(s?t._zh?.title??t._zh?.badge??r:r)||"",a=null!=n.check,c=y[String(e)];let g;g=c?c.correct?chalk.green("✓"):chalk.red("✗"):a?chalk.gray("○"):chalk.gray("·");const d=wrapMixed(l,i()-10-b),u=d[0]+(d.length>1?"…":"");console.log(chalk.gray(` ${String(e).padStart(b)} `)+g+chalk.white(" "+u))}if(console.log(chalk.gray(s?" ✓ 答对 · ✗ 答错 · ○ 未作答 · 无 y/n 的卡不计分":" ✓ correct · ✗ wrong · ○ unanswered · cards without a y/n are unscored")),l){const o=o=>"green"===o?chalk.bold.green:"blue"===o?chalk.bold.cyan:"yellow"===o?chalk.bold.yellow:chalk.bold.red;console.log(chalk.bold.magenta(" ⭐ "+(s?"提问得分 (best): ":"Prompt scores (best): "))+(0===l.length?chalk.gray(s?"本阶段尚未提问 — 用 /ai 研究,再 /submit 评分":"none this phase — research with /ai, then /submit"):l.map(e=>chalk.gray((s?"卡":"#")+e.card+" ")+o(e.tier)(String(e.score))).join(chalk.gray(" · "))))}if(a&&!a.configured){const o=d-g+1>12;console.log(chalk.gray(o?s?" 🔒 本阶段通关标准制作中 — 很快更新(360 层第二阶段标准设计中)":" 🔒 Pass criteria for this phase are in production — coming soon (360-tier second-stage standard in design)":s?" 🔒 本阶段通关标准制作中 — 很快更新(标准范式:3 场练习赛 + 3 卡研究)":" 🔒 Pass criteria for this phase are in production — coming soon (standard: 3 arenas + 3 research cards)"))}if(a?.configured&&a.contest){const o=a.contest;if(o.slots&&o.slots.length>0)for(const e of o.slots){const o=chalk.bold.cyan(` ⚔ ${s?"练习赛":"arena"} ${n.number}-${e.slot}: `);e.passed?console.log(o+chalk.bold.green(`${e.best_ac}/${e.n} AC ✅`)):0===e.attempts?console.log(o+chalk.white(s?`${e.n} 题 · 过 ${e.need} 题 — `:`${e.n} problems · AC ${e.need} — `)+chalk.bold.green(`contest ${e.slot}`)):console.log(o+chalk.yellow(s?`最好 ${e.best_ac}/${e.n}(需 ${e.need})· 已试 ${e.attempts} 次 — `:`best ${e.best_ac}/${e.n} (need ${e.need}) · ${e.attempts} attempt(s) — `)+chalk.bold.green(`contest ${e.slot}`))}else{const e=chalk.bold.cyan(" ⚖ "+(s?"判分赛: ":"Contest: "));o.passed?console.log(e+chalk.bold.green(`${o.best_ac}/${o.n} AC ✅ `+(s?"已过关":"passed"))):0===o.attempts?console.log(e+chalk.white(s?`${o.n} 题 · 过 ${o.need} 题解锁 — 输入 `:`${o.n} problems · AC ${o.need} to pass — type `)+chalk.bold.green("contest")+chalk.white(s?" 开始":" to start")):console.log(e+chalk.yellow(s?`最好 ${o.best_ac}/${o.n} AC(需 ${o.need})· 已试 ${o.attempts} 次 — 输入 `:`best ${o.best_ac}/${o.n} AC (need ${o.need}) · ${o.attempts} attempt(s) — type `)+chalk.bold.green("contest")+chalk.yellow(s?" 再战":" to retry"))}}t&&console.log(chalk.gray(" "+(s?"下一阶段: ":"next: "))+chalk.bold.cyan(s?`阶段 ${t.number}`:`Phase ${t.number}`)+chalk.gray(" · ")+chalk.white(t.name)),console.log(chalk.bold.yellow(" "+m));for(const o of A(s))console.log(o)}export function renderCurriculumComplete(o,e){const n=c().startsWith("zh"),t=e.checkResults||{},l="-".repeat(48);let a=0,s=0;console.log();for(const o of r(" "))console.log(o);console.log(),console.log(chalk.bold.green(" "+l)),console.log(chalk.bold.green(" 🏆 "+(n?`${o.name} — 全部完成!`:`${o.name} — complete!`))),console.log(chalk.bold.green(" "+l));for(const e of o.modules){const[o,r]=e.cardRange;let l=0,c=0;for(let e=o;e<=r;e++){const o=t[String(e)];o&&(l++,o.correct&&c++)}a+=l,s+=c;const g=l>0&&c===l?chalk.green:chalk.white;console.log(chalk.gray(" "+(n?`阶段 ${e.number}`:`Phase ${e.number}`).padEnd(8))+g(`${c}/${l}`.padEnd(7))+chalk.gray(e.name))}console.log(chalk.bold.green(" "+l)),console.log(chalk.bold.green(" "+(n?"总分 / overall: ":"Overall: "))+chalk.bold.white(`${s}/${a}`)),console.log(chalk.bold.green(" "+l));for(const o of A(n))console.log(o);console.log()}export function renderMCQCard(o,t){const r=c(),l=e(o,r);h(l,t),b(),p(chalk.bold.yellow("🎯 "+l.title)),p(chalk.gray("─".repeat(Math.min(l.title.length+4,i())))),b();for(const o of C(l.question,i()-4))p(" "+o);b();for(const o of["A","B","C","D"])p(chalk.cyan(` ${o}.`)+" "+chalk.white(l.options[o]));b(),m(),console.log(chalk.gray(" "+(r.startsWith("zh")?"输入 ":"Type "))+chalk.bold.green("A")+chalk.gray(" / ")+chalk.bold.green("B")+chalk.gray(" / ")+chalk.bold.green("C")+chalk.gray(" / ")+chalk.bold.green("D")+chalk.gray(" "+n("type_to_answer",r))),console.log(chalk.gray(" ")+chalk.bold.cyan("back")+chalk.gray(r.startsWith("zh")?" 上一张 · ":" previous card · ")+chalk.bold.cyan("card N")+chalk.gray(r.startsWith("zh")?" 跳转":" jump")),console.log()}export function renderMCQFeedback(o,t,r,l){const a=c(),s=e(o,a);console.log(),r?console.log(" "+chalk.bold.green(n("correct",a)+" ")+chalk.gray(`${n("one_point",a)} · ${t} = ${s.options[t]}`)):console.log(" "+chalk.bold.red(n("not_quite",a)+" ")+chalk.gray(`${n("you_chose",a)} ${t}; ${n("answer_is",a)} ${s.answer}.`)),console.log(),console.log(chalk.gray(" "+n("explanation",a)));for(const o of C(s.explanation,i()-4))console.log(chalk.gray(" "+o));const g=Object.values(l.mcqResults),d=g.filter(o=>o.correct).length;console.log(),console.log(chalk.gray(" "+n("mcq_accuracy_so_far",a)+" ")+chalk.white(`${d}/${g.length}`)),console.log(),r||(console.log(chalk.gray(" "+n("press_ok_continue",a)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",a))),console.log())}export function renderPracticalCard(o,t){const r=c(),l=e(o,r);h(l,t),b(),p(chalk.bold.yellow("🛠 "+l.title)),p(chalk.gray("─".repeat(Math.min(l.title.length+4,i())))),b();for(const o of C(l.task,i()-4))p(" "+o);if(l.starterCode){b(),p(chalk.gray(" "+n("starter_code",r))),b();for(const o of l.starterCode.split("\n"))p(" "+chalk.cyan(o))}b(),m(),console.log(chalk.gray(" "+n("try_in_sandbox",r)+" ")+chalk.bold.cyan("!python3")+chalk.gray(" "+n("drops_into_python",r))),console.log(chalk.gray(" "+n("when_done",r))),console.log(chalk.gray(" ")+chalk.bold.green("done")+chalk.gray(" "+n("done_desc",r))),console.log(chalk.gray(" ")+chalk.bold.yellow("skip")+chalk.gray(" "+n("skip_desc",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log()}export function renderPracticalSuccess(o){const t=c(),r=e(o,t);console.log(),console.log(" "+chalk.bold.green(n("practical_recorded",t))),console.log(),console.log(chalk.gray(" "+n("reference_answer",t)));for(const o of C(r.successHint,i()-4))console.log(chalk.gray(" "+o));console.log(),console.log(chalk.gray(" "+n("press_ok_continue",t)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",t))),console.log()}export function renderSimDemoCard(o,t){const r=c(),l=e(o,r);h(l,t),b(),p(chalk.bold.yellow("🎬 "+l.title)),b();for(const o of C(l.description,i()-4))p(" "+o);b(),p(chalk.gray(" "+n("sim_requires",r))),b(),m(),console.log(chalk.gray(" ")+chalk.bold.cyan("sim")+chalk.gray(" "+n("sim_launch_desc",r))),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",r))),console.log(chalk.gray(" bookmark "+n("bookmark_desc",r))),console.log(chalk.gray(" back "+n("back_desc",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",r))),console.log()}export function renderArenaTaskCard(o,n){const t=c(),r=t.startsWith("zh"),l=e(o,t);h(l,n),b(),p(chalk.bold.cyan("🏟 "+l.title)),p(chalk.gray(" "+l.origin+" · "+l.domain+" · "+l.metric)),b();for(const o of l.statement){for(const e of C(o,i()-4))p(" "+e);b()}p(chalk.bold.green(r?" 核心要点 — baseline → 解法的关键变化":" CORE DELTA — baseline → solution"));for(const o of l.core_delta)for(const e of C("• "+o,i()-6))p(" "+chalk.white(e));b(),p(chalk.gray((r?" 提交格式: ":" Submission: ")+l.submission_format)),l.hints&&p(chalk.gray(r?" 本题有 5 级提示 (a–e),进入 arena 后逐级解锁。":" 5 progressive hints (a–e) unlock inside the arena.")),b(),m(),console.log(chalk.gray(" ")+chalk.bold.cyan("arena "+l.task_id)+chalk.gray(r?" 动手做这道题(下载 / 提示 / 提交 / 榜单)":" open the arena (download / hints / submit / board)")),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续下一张":" continue to next")),console.log(chalk.gray(" back "+(r?"上一张":"previous"))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderComingSoonCard(o,n){const t=c(),r=t.startsWith("zh"),l=e(o,t);h(l,n),b(),p(chalk.bold.yellow("🔜 "+l.title)),b();const a=l.note||(r?"这道竞技场题目正在编写中,敬请期待。":"This arena task is coming soon.");for(const o of C(a,i()-4))p(" "+chalk.gray(o));b(),m(),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续":" continue")),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderMilestone(o,t){const r=c(),l=e(o,r),a=o.number===t.totalCards;console.log(),console.log(chalk.bold.yellow(" ╭"+d("═"))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+chalk.white(" "+n("milestone_header",r))),console.log(chalk.bold.yellow(" ║"));const s=` ${l.badge} ${l.emoji}`;console.log(chalk.bold.yellow(" ║ ")+chalk.bold.green(s)),console.log(chalk.bold.yellow(" ║ ")+chalk.gray(" ─".repeat(Math.max(1,Math.floor(l.badge.length/2+2))))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("in_wild_corresponds",r)));for(const o of C(l.realWorldLevel,i()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("whats_next",r)));for(const o of C(l.unlockedNext,i()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ╰"+d("═"))),console.log(),a?(console.log(chalk.gray(" "+n("demo_complete",r))),console.log(),console.log(chalk.gray(" "+n("unlock_full",r)+" ")+chalk.white(n("curriculum_name",r))+chalk.gray(",")),console.log(chalk.gray(" "+n("contact_team_leader",r)+" ")+chalk.bold.yellow("EA")+chalk.gray(" "+n("learn_token",r))),console.log(chalk.gray(" "+n("or_email",r)+" ")+chalk.cyan("australia@icoa2026.au")+chalk.gray(" "+n("for_partnership",r))),console.log(),console.log(chalk.gray(" "+n("type_quit",r)+" ")+chalk.bold.green("quit")+chalk.gray(" "+n("to_exit",r)+" ")+chalk.bold.green("status")+chalk.gray(" "+n("for_dashboard",r)))):(console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",r))),console.log(chalk.gray(" status "+n("status_full",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",r)))),console.log()}export function renderStatus(o,e){const t=c(),r=e.cardsCompleted.length,l=o.totalCards,a=Object.values(e.mcqResults),s=a.filter(o=>o.correct).length;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(n("status_title",t))+" "+chalk.cyan("─".repeat(25))),b(),p(" "+chalk.gray(n("total_progress",t)+" ")+y(r,l)+chalk.gray(` (${r}/${l})`)),p(" "+chalk.gray(n("streak",t)+" ")+u(e.streakDays)+chalk.gray(` (${n("longest",t)} ${e.longestStreak})`)),p(" "+chalk.gray(n("mcq_accuracy",t)+" ")+chalk.white(`${s}/${a.length}`)),p(" "+chalk.gray(n("practicals_done",t)+" ")+chalk.white(`${e.practicalsCompleted.length}`)),p(" "+chalk.gray(n("bookmarked",t)+" ")+chalk.white(`${e.bookmarks.length}`)),b();const g=n("module",t).replace(":","").trim();for(const n of o.modules){const[o,t]=n.cardRange,r=e.cardsCompleted.filter(e=>e>=o&&e<=t).length,l=t-o+1;p(" "+(r===l?chalk.green("✓"):r>0?chalk.yellow("▶"):chalk.gray("□"))+" "+chalk.gray(`${g} ${n.number}: `)+chalk.white(`${r}/${l}`)+chalk.gray(" "+n.name))}if(b(),e.achievements.length>0){p(" "+chalk.gray(n("achievements",t)));for(const o of e.achievements)p(" "+chalk.bold.yellow("★ ")+chalk.white(o))}else p(" "+chalk.gray(n("achievements_none",t)));b(),m()}
|
|
1
|
+
import chalk from"chalk";import o from"string-width";import{localized as e}from"./learn-curricula.js";import{t as n}from"./learn-i18n.js";import{getConfig as t}from"./config.js";import{icoaBannerLines as r}from"./banner.js";import{renderCharts as l,detectCaps as a}from"./render-card.js";import{replyChipLabel as s}from"./learn-replies.js";function c(){return(t().language||"en").toLowerCase()}let g="normal";export function resolveLearnWidth(o){return"normal"===o.learnWidth||"wide"===o.learnWidth||"wider"===o.learnWidth?o.learnWidth:o.learnWide?"wide":"normal"}export function setLearnWidth(o){g=o}export function learnWidthCap(o=g){return"wider"===o?120:"wide"===o?96:64}export function learnW(){if("normal"===g)return 64;const o=process.stdout.columns||64;return Math.max(64,Math.min(o-6,learnWidthCap()))}const i=learnW;function d(o="─"){return o.repeat(i()+2)}function y(o,e,n=20){const t=e>0?o/e:0,r=Math.floor(t*n),l=n-r;return`${chalk.green("█".repeat(r))+chalk.gray("░".repeat(l))} ${(100*t).toFixed(1)}%`}function u(o){return o>=30?chalk.red("🔥🔥🔥 "+o+" days"):o>=7?chalk.yellow("🔥 "+o+" days"):o>=1?chalk.gray("· "+o+" day"+(o>1?"s":"")):chalk.gray("—")}export function renderWelcome(o,e,t){const r=c(),l=e.cardsCompleted.length,a=o.totalCards,s=a-l,g=o.modules.find(o=>e.currentCard>=o.cardRange[0]&&e.currentCard<=o.cardRange[1]),i=/demo/i.test(o.id);if(console.log(),console.log(chalk.cyan(" ╭"+d("═"))),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ║ ")+chalk.bold.white(" "+(o.name?.trim()||n("academy_title",r)))),console.log(chalk.cyan(" ║")),t)console.log(chalk.cyan(" ║ ")+chalk.white(" "+n(i?"welcome_new_demo":"welcome_new",r)));else{const o=new Date(e.lastSeenAt),t=Math.floor((Date.now()-o.getTime())/36e5),l=t<1?n("just_now",r):t<24?`${t}${n("ago_hours",r)}`:`${Math.floor(t/24)}${n("ago_days",r)}`;console.log(chalk.cyan(" ║ ")+chalk.white(` ${n("welcome_back",r)} ${l}`))}console.log(chalk.cyan(" ║"));const h=g?`${g.number}. ${g.name}`:"—";console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("module",r).padEnd(11))+chalk.white(h)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("progress",r).padEnd(11))+y(l,a)+chalk.gray(` (${l}/${a})`)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("streak",r).padEnd(11))+u(e.streakDays)),s>0&&e.currentCard<=a&&console.log(chalk.cyan(" ║ ")+" "+chalk.gray(n("next_card",r).padEnd(11))+chalk.white(`#${e.currentCard} ${n("of",r)} ${a}`)),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ╰"+d("═"))),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const p=0===l?n("continue_start",r):`${n("continue_resume",r)} ${e.currentCard}`;console.log(chalk.bold.green(" continue")+chalk.gray(" "+p)),console.log(chalk.yellow(" status")+chalk.gray(" "+n("status_full",r))),e.bookmarks.length>0&&console.log(chalk.yellow(" bookmarks")+chalk.gray(` ${e.bookmarks.length} ${n("bookmarks_desc",r)}`)),console.log(chalk.gray(" quit")+chalk.gray(" "+n("quit_desc",r))),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log()}function h(o,e){const t=c(),r=o.module,l=e.modules.find(o=>o.number===r),a=l?l.name:n("unknown_module",t),s=n("module",t).replace(":","").trim(),g=`${n("card",t)} ${o.number} / ${e.totalCards} · ${s} ${r} · ${a}`;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(g)+" "+chalk.cyan("─".repeat(Math.max(0,i()-g.length-4))))}function p(){console.log(chalk.cyan(" ╰"+d())),console.log()}function b(o){console.log(chalk.cyan(" │ ")+chalk.white(o))}function m(){console.log(chalk.cyan(" │"))}const f=/[┌┐└┘├┤┬┴┼─│╔╗╚╝═║╠╣╦╩╬▓▒░█]/;function $(o){return/^(?: {4}|\t)/.test(o)||f.test(o)||/ {3,}/.test(o)}export function wrapMixed(e,n){const t=[];let r="",l=0,a=!1;for(const s of function(e){const n=[],t=e=>{let t="";const r=()=>{t&&(n.push({t:"atom",s:t}),t="")};for(const l of e)" "===l?(r(),n.push({t:"space"})):2===o(l)?(r(),n.push({t:"wide",s:l})):t+=l;r()},r=/`[^`]*`/g;let l,a=0;for(;null!==(l=r.exec(e));)t(e.slice(a,l.index)),n.push({t:"code",s:l[0]}),a=l.index+l[0].length;return t(e.slice(a)),n}(e)){if("space"===s.t){""!==r&&(a=!0);continue}const e=s.s,c=o("code"===s.t?e.replace(/`/g,""):e),g=a?1:0,i="atom"===s.t&&e.length<=2&&/^[.,;:!?)\]}…'"]+$/.test(e);""!==r&&!i&&l+g+c>n?(t.push(r),r=e,l=c,a=!1):(a&&(r+=" ",l+=1,a=!1),r+=e,l+=c)}return r&&t.push(r),t}const w=/\b(?:Common bug|Common mistake|Common error|Pitfall|Gotcha|Footgun)\b[::]?|\b(?:Warning|Caution)\b[::]|(?:常见错误|常见陷阱|常见误区|陷阱|注意|警告|误区)[::]/gi;function k(o,e){const n=e?chalk.bold.white:chalk.white;let t,r="",l=0;for(w.lastIndex=0;null!==(t=w.exec(o));)t.index>l&&(r+=n(o.slice(l,t.index))),r+=chalk.bold.yellow(t[0]),l=t.index+t[0].length;return l<o.length&&(r+=n(o.slice(l))),r}function _(o,e=!1){let n="",t=0;const r=/`([^`]*)`/g;let l;for(;null!==(l=r.exec(o));)l.index>t&&(n+=k(o.slice(t,l.index),e)),n+=chalk.cyan(l[1]),t=l.index+l[0].length;return t<o.length&&(n+=k(o.slice(t),e)),n}function x(o,e=!1){let n=!1;for(const t of o.split("\n"))if(/^\s*```/.test(t))n=!n;else if(n)console.log(chalk.cyan(" │ ")+chalk.cyan(` ${t}`));else if(""!==t)if($(t))console.log(chalk.cyan(" │ ")+chalk.white(t));else for(const o of wrapMixed(t,i()-4))console.log(chalk.cyan(" │ ")+` ${_(o,e)}`);else m()}function C(o,e){const n=[];for(const t of o.split("\n")){if(""===t){n.push("");continue}if($(t)){n.push(t);continue}let o="";for(const r of t.split(" "))(o+" "+r).trim().length>e?(n.push(o.trim()),o=r):o=(o+" "+r).trim();o&&n.push(o)}return n}let M=!1;export function setLearnAiEnabled(o){M=o}let v=new Set;export function setLearnPqsViewCards(o){v=o}let W=new Map;export function setLearnHonorRanks(o){W=o}const z=["①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩"];let q=[];export function setLearnReplies(o){q=o}let j=[];export function setLearnFaqs(o){j=o}let S=null;export function setLearnHometask(o){S=o}let A="full";export function setLearnFooterProfile(o){A=o}let P=null;export function setLearnPracticeChips(o){P=o}export function renderHonorWall(o){const e=c().startsWith("zh"),{totals:n,chapters:t}=o,r=n.gold+n.silver+n.bronze,l=(o,e)=>e>0?chalk.bold.white(`${o}×${e}`):chalk.gray(`${o}×0`);if(console.log(chalk.gray(" ─────────────────────────────────────────")),console.log(chalk.bold.white(e?" 🏅 奖牌墙 ":" 🏅 Medal wall ")+l("🥇",n.gold)+chalk.gray(" · ")+l("🥈",n.silver)+chalk.gray(" · ")+l("🥉",n.bronze)+chalk.gray(e?" (永久 — 挂上墙就不会摘下)":" (permanent — once earned, never removed)")),0===r){const n=null!=o.floor?`${o.floor}+`:e?"高分":"a high score";return console.log(chalk.gray(e?` 还没有奖牌 — 单卡提问评分 ${n} 并进入该卡前三,即可永久挂墙 🥇🥈🥉`:` No medals yet — score ${n} on a card and hold its top-3 to hang one 🥇🥈🥉`)),void console.log(chalk.gray(" ─────────────────────────────────────────"))}const a=t.map(o=>{const e=`Ch${o.chapter}`,n=(o.gold>0?`🥇${o.gold}`:"")+(o.silver>0?`🥈${o.silver}`:"")+(o.bronze>0?`🥉${o.bronze}`:"");return n?chalk.white(`${e} ${n}`):chalk.gray(`${e} —`)}).join(chalk.gray(" "));console.log(" "+a);const s=t.flatMap(o=>o.cards.map(e=>({...e,chapter:o.chapter})));s.sort((o,e)=>o.rank-e.rank||o.chapter-e.chapter||o.card-e.card);for(const o of s.slice(0,24)){const n=(o.since||"").slice(0,10);console.log(chalk.white(` ${o.icon} `)+chalk.gray(`Ch${o.chapter} · `)+chalk.white(e?`第 ${o.card} 张`:`card ${o.card}`)+chalk.gray(` · ${o.score}`)+(n?chalk.gray(e?` · 始于 ${n}`:` · since ${n}`):""))}s.length>24&&console.log(chalk.gray(e?` …还有 ${s.length-24} 枚`:` …and ${s.length-24} more`)),console.log(chalk.gray(" ─────────────────────────────────────────"))}export function renderKnowledgeCard(t,r){const d=c(),y=e(t,d);h(y,r),m();const u=wrapMixed(y.title,i()-4);for(const o of u)b(chalk.bold.yellow(o));b(chalk.gray("─".repeat(Math.min(Math.max(...u.map(e=>o(e))),i()))));const f=!!(t.chart_ids&&t.chart_ids.length>0);if(f&&l(t.chart_ids.slice(0,1),r.charts,a()),y.key_point&&""!==y.key_point.trim()?(f||m(),function(o,e,n){const t=c().startsWith("zh"),r=a().cols,l="-".repeat(Math.min(i(),Math.max(24,r-6))),s=t?"要点":"KEY POINT",g=t?`第 ${e} / ${n} 张`:`Card ${e} / ${n}`;console.log(chalk.cyan(" │ ")+chalk.green(l)),console.log(chalk.cyan(" │ ")+chalk.green(`${s} · ${g}`));for(const e of wrapMixed(o,i()-4))console.log(chalk.cyan(" │ ")+chalk.bold.green(" "+e));console.log(chalk.cyan(" │ ")+chalk.green(l)),m()}(y.key_point,y.number,r.totalCards)):f||m(),y.body.filter(o=>null!=o&&""!==o.trim()).forEach((o,e)=>{const n=0===e?o.match(/^([\s\S]*?(?:[.!?](?=\s|$)|[。!?]))(\s[\s\S]*)?$/):null;if(n&&n[1].trim().length<=180){x(n[1],!0);const o=n[2]?.trimStart();o&&x(o,!1)}else x(o,!1);m()}),y.icoaConnection){b(chalk.magenta(" "+n("icoa_connection",d))),b(chalk.gray(" "+"─".repeat(20)));for(const o of wrapMixed(y.icoaConnection,i()-4))b(" "+chalk.magenta(o));m()}if(t.check){const o=d.startsWith("zh"),e=t._zh?.checkStatement??t._zh?.check?.statement,n=o?e??t.check.statement:t.check.statement;b(chalk.cyan(" 🤔 "+(o?"请回答 (输 y 或 n):":"Quick comprehension check (type y or n):"))),b(chalk.gray(" "+"─".repeat(20)));for(const o of wrapMixed(n,i()-4))b(" "+chalk.white(o));m()}p(),function(e,n){const t=c().startsWith("zh"),r=a().cols,l="-".repeat(Math.min(i(),Math.max(24,r-6))),d=chalk.gray(" ");if("minimal"===A){const o=P?P(e.number):null;console.log(chalk.gray(" "+l)),console.log(chalk.gray(" "+(t?`第 ${e.number} / ${n.totalCards} 张`:`Card ${e.number} / ${n.totalCards}`))+(o?chalk.gray(t?" · 本卡练习 ":" · practice ")+o:""));const r=[];return e.check?(r.push(chalk.bold.green("[y]")+chalk.gray(t?" 是":" yes")),r.push(chalk.bold.green("[n]")+chalk.gray(t?" 否":" no"))):r.push(chalk.bold.green("[ok]")+chalk.gray(t?" 下一张":" next")),o&&r.push(chalk.bold.cyan("[1][2]")+chalk.gray(t?" 练习":" practice")),r.push(chalk.bold.cyan("[b]")+chalk.gray(t?" 上一张":" back")),r.push(chalk.bold.yellow("[e]")+chalk.gray(t?" 求助":" help")),r.push(chalk.gray("[quit]")+(t?chalk.gray(" 退出"):"")),console.log(" "+r.join(d)),void console.log()}const y=[];e.check?(y.push(chalk.bold.green("[y]")+chalk.gray(t?" 是":" yes")),y.push(chalk.bold.green("[n]")+chalk.gray(t?" 否":" no"))):y.push(chalk.bold.green("[ok]")+chalk.gray(t?" 继续":" next")),M&&(y.push(chalk.bold.magenta("[/ai]")+chalk.gray(t?" 🐼 熊猫导师":" 🐼 Panda tutor")),y.push(chalk.bold.magenta("[/submit]")+chalk.gray(t?" 提问评分":" prompt score")));const u=W.get(e.number);var h;y.push(chalk.bold.magenta(u?`[/honors ${h=u,z[h-1]??`#${h}`}]`:"[/honors]")+chalk.gray(t?" 排行":" board")),"normal"===g?y.push(chalk.bold.cyan("[wide]")+chalk.gray(t?" 宽屏":" widen")):(y.push("wide"===g?chalk.bold.cyan("[wider]")+chalk.gray(t?" 更宽":" wider"):chalk.bold.cyan("[wide]")+chalk.gray(t?" 回宽屏":" back to wide")),y.push(chalk.bold.cyan("[normal]")+chalk.gray(t?" 64列":" 64-col")));const p=s(q,j,e.number,t),b=p.startsWith("💬");if(y.push((b?chalk.bold.yellow("[r]"):chalk.gray("[r]"))+(b?chalk.bold.white(` ${p}`):chalk.gray(` ${p}`))),y.push(chalk.bold.yellow("[e]")+chalk.gray(t?" 提问或报告":" ask or report")),S){const o=S,e=`${o.done}/${o.total}`,n=o.completedAt?chalk.bold.green:chalk.bold.cyan;y.push(n("[task]")+chalk.gray(t?` 本周 ${e}`:` week ${e}`))}y.push(chalk.bold.cyan("[b]")+chalk.gray(t?" 上一张":" back")),y.push(chalk.bold.cyan("[card N]")+chalk.gray(t?" 跳转":" jump")),y.push(chalk.gray("[reload]")+(t?chalk.gray(" 刷新"):"")),y.push(chalk.gray("[quit]")+(t?chalk.gray(" 退出"):""));const m=o(l);console.log(chalk.gray(" "+l)),console.log(chalk.gray(" "+(t?`第 ${e.number} / ${n.totalCards} 张`:`Card ${e.number} / ${n.totalCards}`)));let f="",$=0;for(const e of y){const n=o(e);f&&$+2+n>m?(console.log(" "+f),f=e,$=n):(f=f?f+d+e:e,$=f===e?n:$+2+n)}f&&console.log(" "+f),console.log(" "+chalk.magenta("✍ ")+chalk.magenta("[/py]")+chalk.gray(t?" Python 草稿本":" Python scratchpad")+d+chalk.magenta("[/pylist]")+chalk.gray(t?" 我的草稿":" my files")),console.log(chalk.gray(" "+l));const w=[t?"e = 就这张卡提问,或报告问题":"e = ask about this card, or report a problem",t?"更多: bookmark / unbookmark · status · lang zh/en · link":"more: bookmark / unbookmark · status · lang zh/en · link"];for(const o of w)for(const e of wrapMixed(o,m))console.log(chalk.gray(" "+e));console.log()}(t,r)}export function renderCheckFeedback(o,e,n,t=!1){const r=c().startsWith("zh");if(console.log(),n)console.log(chalk.green(" ✓ ")+chalk.white(r?"答对了。":"Correct."));else if(console.log(chalk.yellow(" ✗ ")+chalk.white(r?"记下了,继续。":"Noted — moving on.")),t){const e="y"===o.check?.answer?r?"是":"Yes":r?"否":"No";console.log(chalk.gray(" "+(r?"正确答案: ":"Answer: ")+e+". "+(r?"回看上面那段。":"Re-read the paragraph above.")))}const l=r?o._zh?.solution??o.solution:o.solution;if(l&&l.length>0){console.log(),console.log(chalk.cyan(" 📝 "+(r?"解答:":"Worked solution:")));for(const o of l){for(const e of wrapMixed(o,i()-4))console.log(chalk.white(" "+e));console.log()}}console.log()}function L(o){return[chalk.white(" "+(o?"编著:Charlie Zhu":"Created & edited by Charlie Zhu")),chalk.gray(" "+(o?"ICOA 2026 创始人 · 课程总架构师":"Founder & Chief Curriculum Architect · ICOA 2026"))]}export function renderPhaseComplete(o,e,n,t,l,a){const s=c().startsWith("zh"),[g,d]=n.cardRange,y=e.checkResults||{};let u=0,h=0;for(let o=g;o<=d;o++){const e=y[String(o)];e&&(u++,e.correct&&h++)}const p="-".repeat(48);console.log();for(const o of r(" "))console.log(o);console.log(),console.log(chalk.bold.yellow(" "+p)),console.log(chalk.bold.yellow(" "+(s?`阶段 ${n.number} 完成`:`Phase ${n.number} complete`))+chalk.gray(" · ")+chalk.white(n.name));const b=u>0&&h===u?chalk.bold.green:chalk.bold.white;console.log(chalk.gray(" "+(s?"理解检查得分: ":"comprehension score: "))+b(`${h}/${u}`)+chalk.gray(0===u?s?" (本阶段未作答 y/n)":" (no y/n answered)":""));const m=String(d).length;for(let e=g;e<=d;e++){const n=o.cards.find(o=>o.number===e);if(!n)continue;const t=n,r=t.title??t.badge??"",l=(s?t._zh?.title??t._zh?.badge??r:r)||"",a=null!=n.check,c=y[String(e)];let g;g=c?c.correct?chalk.green("✓"):chalk.red("✗"):a?chalk.gray("○"):chalk.gray("·");const d=wrapMixed(l,i()-10-m),u=d[0]+(d.length>1?"…":"");console.log(chalk.gray(` ${String(e).padStart(m)} `)+g+chalk.white(" "+u))}if(console.log(chalk.gray(s?" ✓ 答对 · ✗ 答错 · ○ 未作答 · 无 y/n 的卡不计分":" ✓ correct · ✗ wrong · ○ unanswered · cards without a y/n are unscored")),l){const o=o=>"green"===o?chalk.bold.green:"blue"===o?chalk.bold.cyan:"yellow"===o?chalk.bold.yellow:chalk.bold.red;console.log(chalk.bold.magenta(" ⭐ "+(s?"提问得分 (best): ":"Prompt scores (best): "))+(0===l.length?chalk.gray(s?"本阶段尚未提问 — 用 /ai 研究,再 /submit 评分":"none this phase — research with /ai, then /submit"):l.map(e=>chalk.gray((s?"卡":"#")+e.card+" ")+o(e.tier)(String(e.score))).join(chalk.gray(" · "))))}if(a&&!a.configured){const o=d-g+1>12;console.log(chalk.gray(o?s?" 🔒 本阶段通关标准制作中 — 很快更新(360 层第二阶段标准设计中)":" 🔒 Pass criteria for this phase are in production — coming soon (360-tier second-stage standard in design)":s?" 🔒 本阶段通关标准制作中 — 很快更新(标准范式:3 场练习赛 + 3 卡研究)":" 🔒 Pass criteria for this phase are in production — coming soon (standard: 3 arenas + 3 research cards)"))}if(a?.configured&&a.contest){const o=a.contest;if(o.slots&&o.slots.length>0)for(const e of o.slots){const o=chalk.bold.cyan(` ⚔ ${s?"练习赛":"arena"} ${n.number}-${e.slot}: `);e.passed?console.log(o+chalk.bold.green(`${e.best_ac}/${e.n} AC ✅`)):0===e.attempts?console.log(o+chalk.white(s?`${e.n} 题 · 过 ${e.need} 题 — `:`${e.n} problems · AC ${e.need} — `)+chalk.bold.green(`contest ${e.slot}`)):console.log(o+chalk.yellow(s?`最好 ${e.best_ac}/${e.n}(需 ${e.need})· 已试 ${e.attempts} 次 — `:`best ${e.best_ac}/${e.n} (need ${e.need}) · ${e.attempts} attempt(s) — `)+chalk.bold.green(`contest ${e.slot}`))}else{const e=chalk.bold.cyan(" ⚖ "+(s?"判分赛: ":"Contest: "));o.passed?console.log(e+chalk.bold.green(`${o.best_ac}/${o.n} AC ✅ `+(s?"已过关":"passed"))):0===o.attempts?console.log(e+chalk.white(s?`${o.n} 题 · 过 ${o.need} 题解锁 — 输入 `:`${o.n} problems · AC ${o.need} to pass — type `)+chalk.bold.green("contest")+chalk.white(s?" 开始":" to start")):console.log(e+chalk.yellow(s?`最好 ${o.best_ac}/${o.n} AC(需 ${o.need})· 已试 ${o.attempts} 次 — 输入 `:`best ${o.best_ac}/${o.n} AC (need ${o.need}) · ${o.attempts} attempt(s) — type `)+chalk.bold.green("contest")+chalk.yellow(s?" 再战":" to retry"))}}t&&console.log(chalk.gray(" "+(s?"下一阶段: ":"next: "))+chalk.bold.cyan(s?`阶段 ${t.number}`:`Phase ${t.number}`)+chalk.gray(" · ")+chalk.white(t.name)),console.log(chalk.bold.yellow(" "+p));for(const o of L(s))console.log(o)}export function renderCurriculumComplete(o,e){const n=c().startsWith("zh"),t=e.checkResults||{},l="-".repeat(48);let a=0,s=0;console.log();for(const o of r(" "))console.log(o);console.log(),console.log(chalk.bold.green(" "+l)),console.log(chalk.bold.green(" 🏆 "+(n?`${o.name} — 全部完成!`:`${o.name} — complete!`))),console.log(chalk.bold.green(" "+l));for(const e of o.modules){const[o,r]=e.cardRange;let l=0,c=0;for(let e=o;e<=r;e++){const o=t[String(e)];o&&(l++,o.correct&&c++)}a+=l,s+=c;const g=l>0&&c===l?chalk.green:chalk.white;console.log(chalk.gray(" "+(n?`阶段 ${e.number}`:`Phase ${e.number}`).padEnd(8))+g(`${c}/${l}`.padEnd(7))+chalk.gray(e.name))}console.log(chalk.bold.green(" "+l)),console.log(chalk.bold.green(" "+(n?"总分 / overall: ":"Overall: "))+chalk.bold.white(`${s}/${a}`)),console.log(chalk.bold.green(" "+l));for(const o of L(n))console.log(o);console.log()}export function renderMCQCard(o,t){const r=c(),l=e(o,r);h(l,t),m(),b(chalk.bold.yellow("🎯 "+l.title)),b(chalk.gray("─".repeat(Math.min(l.title.length+4,i())))),m();for(const o of C(l.question,i()-4))b(" "+o);m();for(const o of["A","B","C","D"])b(chalk.cyan(` ${o}.`)+" "+chalk.white(l.options[o]));m(),p(),console.log(chalk.gray(" "+(r.startsWith("zh")?"输入 ":"Type "))+chalk.bold.green("A")+chalk.gray(" / ")+chalk.bold.green("B")+chalk.gray(" / ")+chalk.bold.green("C")+chalk.gray(" / ")+chalk.bold.green("D")+chalk.gray(" "+n("type_to_answer",r))),console.log(chalk.gray(" ")+chalk.bold.cyan("back")+chalk.gray(r.startsWith("zh")?" 上一张 · ":" previous card · ")+chalk.bold.cyan("card N")+chalk.gray(r.startsWith("zh")?" 跳转":" jump")),console.log()}export function renderMCQFeedback(o,t,r,l){const a=c(),s=e(o,a);console.log(),r?console.log(" "+chalk.bold.green(n("correct",a)+" ")+chalk.gray(`${n("one_point",a)} · ${t} = ${s.options[t]}`)):console.log(" "+chalk.bold.red(n("not_quite",a)+" ")+chalk.gray(`${n("you_chose",a)} ${t}; ${n("answer_is",a)} ${s.answer}.`)),console.log(),console.log(chalk.gray(" "+n("explanation",a)));for(const o of C(s.explanation,i()-4))console.log(chalk.gray(" "+o));const g=Object.values(l.mcqResults),d=g.filter(o=>o.correct).length;console.log(),console.log(chalk.gray(" "+n("mcq_accuracy_so_far",a)+" ")+chalk.white(`${d}/${g.length}`)),console.log(),r||(console.log(chalk.gray(" "+n("press_ok_continue",a)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",a))),console.log())}export function renderPracticalCard(o,t){const r=c(),l=e(o,r);h(l,t),m(),b(chalk.bold.yellow("🛠 "+l.title)),b(chalk.gray("─".repeat(Math.min(l.title.length+4,i())))),m();for(const o of C(l.task,i()-4))b(" "+o);if(l.starterCode){m(),b(chalk.gray(" "+n("starter_code",r))),m();for(const o of l.starterCode.split("\n"))b(" "+chalk.cyan(o))}m(),p(),console.log(chalk.gray(" "+n("try_in_sandbox",r)+" ")+chalk.bold.cyan("!python3")+chalk.gray(" "+n("drops_into_python",r))),console.log(chalk.gray(" "+n("when_done",r))),console.log(chalk.gray(" ")+chalk.bold.green("done")+chalk.gray(" "+n("done_desc",r))),console.log(chalk.gray(" ")+chalk.bold.yellow("skip")+chalk.gray(" "+n("skip_desc",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log()}export function renderPracticalSuccess(o){const t=c(),r=e(o,t);console.log(),console.log(" "+chalk.bold.green(n("practical_recorded",t))),console.log(),console.log(chalk.gray(" "+n("reference_answer",t)));for(const o of C(r.successHint,i()-4))console.log(chalk.gray(" "+o));console.log(),console.log(chalk.gray(" "+n("press_ok_continue",t)+" ")+chalk.bold.green("ok")+chalk.gray(" "+n("to_continue",t))),console.log()}export function renderSimDemoCard(o,t){const r=c(),l=e(o,r);h(l,t),m(),b(chalk.bold.yellow("🎬 "+l.title)),m();for(const o of C(l.description,i()-4))b(" "+o);m(),b(chalk.gray(" "+n("sim_requires",r))),m(),p(),console.log(chalk.gray(" ")+chalk.bold.cyan("sim")+chalk.gray(" "+n("sim_launch_desc",r))),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",r))),console.log(chalk.gray(" bookmark "+n("bookmark_desc",r))),console.log(chalk.gray(" back "+n("back_desc",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",r))),console.log()}export function renderArenaTaskCard(o,n){const t=c(),r=t.startsWith("zh"),l=e(o,t);h(l,n),m(),b(chalk.bold.cyan("🏟 "+l.title)),b(chalk.gray(" "+l.origin+" · "+l.domain+" · "+l.metric)),m();for(const o of l.statement){for(const e of C(o,i()-4))b(" "+e);m()}b(chalk.bold.green(r?" 核心要点 — baseline → 解法的关键变化":" CORE DELTA — baseline → solution"));for(const o of l.core_delta)for(const e of C("• "+o,i()-6))b(" "+chalk.white(e));m(),b(chalk.gray((r?" 提交格式: ":" Submission: ")+l.submission_format)),l.hints&&b(chalk.gray(r?" 本题有 5 级提示 (a–e),进入 arena 后逐级解锁。":" 5 progressive hints (a–e) unlock inside the arena.")),m(),p(),console.log(chalk.gray(" ")+chalk.bold.cyan("arena "+l.task_id)+chalk.gray(r?" 动手做这道题(下载 / 提示 / 提交 / 榜单)":" open the arena (download / hints / submit / board)")),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续下一张":" continue to next")),console.log(chalk.gray(" back "+(r?"上一张":"previous"))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderComingSoonCard(o,n){const t=c(),r=t.startsWith("zh"),l=e(o,t);h(l,n),m(),b(chalk.bold.yellow("🔜 "+l.title)),m();const a=l.note||(r?"这道竞技场题目正在编写中,敬请期待。":"This arena task is coming soon.");for(const o of C(a,i()-4))b(" "+chalk.gray(o));m(),p(),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续":" continue")),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderMilestone(o,t){const r=c(),l=e(o,r),a=o.number===t.totalCards;console.log(),console.log(chalk.bold.yellow(" ╭"+d("═"))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+chalk.white(" "+n("milestone_header",r))),console.log(chalk.bold.yellow(" ║"));const s=` ${l.badge} ${l.emoji}`;console.log(chalk.bold.yellow(" ║ ")+chalk.bold.green(s)),console.log(chalk.bold.yellow(" ║ ")+chalk.gray(" ─".repeat(Math.max(1,Math.floor(l.badge.length/2+2))))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("in_wild_corresponds",r)));for(const o of C(l.realWorldLevel,i()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(n("whats_next",r)));for(const o of C(l.unlockedNext,i()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(o));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ╰"+d("═"))),console.log(),a?(console.log(chalk.gray(" "+n("demo_complete",r))),console.log(),console.log(chalk.gray(" "+n("unlock_full",r)+" ")+chalk.white(n("curriculum_name",r))+chalk.gray(",")),console.log(chalk.gray(" "+n("contact_team_leader",r)+" ")+chalk.bold.yellow("EA")+chalk.gray(" "+n("learn_token",r))),console.log(chalk.gray(" "+n("or_email",r)+" ")+chalk.cyan("australia@icoa2026.au")+chalk.gray(" "+n("for_partnership",r))),console.log(),console.log(chalk.gray(" "+n("type_quit",r)+" ")+chalk.bold.green("quit")+chalk.gray(" "+n("to_exit",r)+" ")+chalk.bold.green("status")+chalk.gray(" "+n("for_dashboard",r)))):(console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+n("continue_to_next",r))),console.log(chalk.gray(" status "+n("status_full",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+n("quit_desc",r)))),console.log()}export function renderStatus(o,e){const t=c(),r=e.cardsCompleted.length,l=o.totalCards,a=Object.values(e.mcqResults),s=a.filter(o=>o.correct).length;console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(n("status_title",t))+" "+chalk.cyan("─".repeat(25))),m(),b(" "+chalk.gray(n("total_progress",t)+" ")+y(r,l)+chalk.gray(` (${r}/${l})`)),b(" "+chalk.gray(n("streak",t)+" ")+u(e.streakDays)+chalk.gray(` (${n("longest",t)} ${e.longestStreak})`)),b(" "+chalk.gray(n("mcq_accuracy",t)+" ")+chalk.white(`${s}/${a.length}`)),b(" "+chalk.gray(n("practicals_done",t)+" ")+chalk.white(`${e.practicalsCompleted.length}`)),b(" "+chalk.gray(n("bookmarked",t)+" ")+chalk.white(`${e.bookmarks.length}`)),m();const g=n("module",t).replace(":","").trim();for(const n of o.modules){const[o,t]=n.cardRange,r=e.cardsCompleted.filter(e=>e>=o&&e<=t).length,l=t-o+1;b(" "+(r===l?chalk.green("✓"):r>0?chalk.yellow("▶"):chalk.gray("□"))+" "+chalk.gray(`${g} ${n.number}: `)+chalk.white(`${r}/${l}`)+chalk.gray(" "+n.name))}if(m(),e.achievements.length>0){b(" "+chalk.gray(n("achievements",t)));for(const o of e.achievements)b(" "+chalk.bold.yellow("★ ")+chalk.white(o))}else b(" "+chalk.gray(n("achievements_none",t)));m(),p()}
|
package/dist/lib/learn-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as
|
|
1
|
+
import{join as e}from"node:path";import{getIcoaDir as t,getInstallSalt as n}from"./config.js";import{deriveFileKey as r,readSignedFile as s,writeSignedFile as o,recordVerdict as c}from"./secure-store.js";const a="learn-state";function i(){return e(t(),"learn-state.json")}function u(){return r(n(),a)}const l="learn-sessions";export const CONTINUE_LIST_MAX=5;function m(){return e(t(),"learn-sessions.json")}function d(){return r(n(),l)}function p(){const{data:e,verdict:t}=s(m(),d());if(c(l,t),!e||"object"!=typeof e)return{};const n={};for(const[t,r]of Object.entries(e))r&&"object"==typeof r&&"string"==typeof r.token&&"string"==typeof r.curriculumId&&(n[t]=r);return n}export function listLearnSessions(){const e=loadLearnState(),t=[];e?.token&&e.curriculumId&&t.push(e);for(const[n,r]of Object.entries(p()))n!==e?.token&&t.push(r);return t.sort((e,t)=>(t.lastSeenAt??"").localeCompare(e.lastSeenAt??""))}export function activateSession(e){const t=loadLearnState(),n=p();t?.token&&t.curriculumId&&t.token!==e&&(n[t.token]=t);const r=n[e]??null;return function(e){const t=Object.keys(e);if(t.length>20){const n=t.sort((t,n)=>(e[t].lastSeenAt??"").localeCompare(e[n].lastSeenAt??"")).slice(0,t.length-20);for(const t of n)delete e[t]}o(m(),e,d())}(n),r}export function loadLearnState(){const{data:e,verdict:t}=s(i(),u());return c(a,t),e}export function saveLearnState(e){e.lastSeenAt=(new Date).toISOString(),o(i(),e,u())}export function newLearnState(e,t,n){const r=(new Date).toISOString();return{token:e,curriculumId:t,currentCard:1,totalCards:n,startedAt:r,lastSeenAt:r,streakDays:1,longestStreak:1,cardsCompleted:[],mcqResults:{},checkResults:{},practicalsCompleted:[],bookmarks:[],achievements:[],totalSecondsActive:0}}export function stateFromServerEvents(e,t,n,r){const s=newLearnState(e,t,n),o=new Set;let c="";for(const e of r){const t=Number(e.card_number);!Number.isInteger(t)||t<1||t>n||("check_answered"!==e.event_type||"y"!==e.check_answer&&"n"!==e.check_answer?"mcq_answered"===e.event_type&&e.mcq_answer&&/^[ABCD]$/.test(e.mcq_answer)?(s.mcqResults[String(t)]={answer:e.mcq_answer,correct:!!e.mcq_correct,submittedAt:e.timestamp},o.add(t)):"viewed"===e.event_type?o.add(t):"practical_done"===e.event_type?(s.practicalsCompleted.push(t),o.add(t)):"bookmarked"===e.event_type&&s.bookmarks.push(t):(s.checkResults[String(t)]={answer:e.check_answer,correct:!!e.check_correct,submittedAt:e.timestamp},o.add(t)),e.timestamp&&(!c||e.timestamp<c)&&(c=e.timestamp))}return 0===o.size?null:(s.cardsCompleted=[...o].sort((e,t)=>e-t),s.currentCard=Math.min(n,Math.max(...o)+1),c&&(s.startedAt=c),s)}export function updateStreak(e){const t=new Date(e.lastSeenAt),n=new Date,r=Math.floor(t.getTime()/864e5),s=Math.floor(n.getTime()/864e5)-r;0!==s&&(1===s?(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,n){e.mcqResults[String(t)]=n}export function recordCheck(e,t,n){e.checkResults||(e.checkResults={}),e.checkResults[String(t)]=n}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)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "icoa-cli",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.505",
|
|
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": {
|