icoa-cli 2.19.703 → 2.19.705

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/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{Command as o}from"commander";import chalk from"chalk";import{registerCtfCommands as e}from"./commands/ctf.js";import{registerRefCommand as n}from"./commands/ref.js";import{registerShellCommand as s}from"./commands/shell.js";import{registerFilesCommand as r}from"./commands/files.js";import{registerViewCommand as t}from"./commands/view.js";import{registerConnectCommand as i}from"./commands/connect.js";import{registerChallengeCommand as l}from"./commands/challenge.js";import{registerDoctorCommand as a}from"./commands/doctor.js";import{registerUpgradeCommand as m}from"./commands/upgrade.js";import{registerNoteCommand as c}from"./commands/note.js";import{registerLogCommand as g}from"./commands/log.js";import{registerLangCommand as d}from"./commands/lang.js";import{registerSetupCommand as p}from"./commands/setup.js";import{registerEnvCommand as h}from"./commands/env.js";import{registerAienvCommand as f}from"./commands/aienv.js";import{registerPythonCommands as y}from"./commands/python.js";import{registerMujocoCommands as u}from"./commands/mujoco.js";import{registerDuckCommand as w}from"./commands/duck.js";import{registerIpynbCommand as j}from"./commands/ipynb.js";import{registerAi4ctfCommand as b}from"./commands/ai4ctf.js";import{registerExamCommand as v}from"./commands/exam.js";import{registerCtf4aiDemoCommand as T}from"./commands/ctf4ai-demo.js";import{registerThemeCommand as $}from"./commands/theme.js";import{registerLearnCommand as E}from"./commands/learn.js";import{registerCtf4VlaCommand as A}from"./commands/ctf4vla.js";import{registerDemo2Command as x}from"./commands/demo2.js";import{registerDemo3Command as _}from"./commands/demo3.js";import{registerDemo4Command as I}from"./commands/demo4.js";import{registerDemo5Command as k}from"./commands/demo5.js";import{registerGfssmCommand as C}from"./commands/gfssm.js";import{registerGpuForTaskCommand as S}from"./commands/gpufortask.js";import{registerSimCommand as L}from"./commands/sim.js";import{registerArenaCommand as R}from"./commands/arena.js";import{registerKaggleCommand as O}from"./commands/kaggle.js";import{registerSprintCommand as N}from"./commands/sprint.js";import{registerTeleloadCommand as U}from"./commands/teleload.js";import{registerBoardCommand as F}from"./commands/board.js";import{registerTypeCommand as P}from"./commands/type.js";import{registerBattleCommand as M}from"./commands/battle.js";import{registerWmCommand as G}from"./commands/wm.js";import{getConfig as H,saveConfig as W}from"./lib/config.js";import{registerMicroduckCommand as D}from"./commands/microduck.js";import{startRepl as Y}from"./repl.js";import{RELAUNCH_CODE as V}from"./lib/menu-nav.js";import{setTerminalTheme as J}from"./lib/theme.js";import{cleanupTerminal as X}from"./lib/terminal-cleanup.js";import{checkForUpdates as q,runUpgrade as z,bootUpgradeEligible as K,startBootCheck as B,printUpdateHint as Q}from"./lib/update-check.js";import{detectIcoaInstalls as Z,isWindowsBuildInWslShell as oo}from"./lib/platform.js";import{ICOA_BIG as eo}from"./lib/banner.js";import{readFileSync as no}from"node:fs";import{fileURLToPath as so}from"node:url";import{dirname as ro,join as to}from"node:path";import{setDefaultResultOrder as io}from"node:dns";import{setDefaultAutoSelectFamilyAttemptTimeout as lo}from"node:net";io("ipv4first"),lo(4e3);const ao=ro(so(import.meta.url)),mo=JSON.parse(no(to(ao,"..","package.json"),"utf-8")).version,co=chalk.cyan(" ─────────────────────────────────────────────────────"),go=`\n${co}\n\n${eo.map(o=>` ${chalk.bold.white(o)}`).join("\n")}\n\n ${chalk.bold.magenta("The World's First AI-Native CLI Operating System")}\n ${chalk.bold.magenta("for K-12 AI & Cyber Olympiads and International AI Hackathons")}\n\n ${chalk.bold.white("ICOA 2026:")} ${chalk.white("Sydney, Australia")}\n ${chalk.bold.white("ICOA 2027:")} ${chalk.white("July 2027")} ${chalk.gray("· host city to be announced")}\n ${chalk.cyan.underline("https://icoa2026.au")}\n\n ${chalk.gray(`CLI-Native Competition Terminal v${mo}`)}\n\n${co}\n`;process.on("uncaughtException",o=>{"__REPL_NO_EXIT__"!==o.message&&(console.error(chalk.red("Error:"),o.message),process.exit(1))}),process.on("unhandledRejection",o=>{const e=o instanceof Error?o.message:String(o);"__REPL_NO_EXIT__"!==e&&(console.error(chalk.red("Error:"),e),process.exit(1))});{const o=process.argv.slice(2).some(o=>["-V","--version","-h","--help"].includes(o));if(!0===process.stdin.isTTY&&"1"!==process.env.ICOA_SUPERVISED&&!o){const{spawnSync:o}=await import("node:child_process");process.on("SIGINT",()=>{}),process.on("SIGTERM",()=>{});let e=0,n=!1;do{const s=n?process.argv.slice(1,2):process.argv.slice(1),r=o(process.execPath,s,{stdio:"inherit",env:{...process.env,ICOA_SUPERVISED:"1",...n?{ICOA_RELAUNCH:"1"}:{}}});if(r.signal){const{appendExitLog:o}=await import("./lib/exit-log.js");o("worker-signal",`signal=${r.signal}`),console.log(),console.log(chalk.yellow(` ⚠ icoa was stopped by signal ${r.signal}`)+chalk.gray(" — another process killed it (not a crash). Run icoa --resume to continue.")),e=0;break}if(e=r.status,0!==e&&e!==V){const{appendExitLog:o}=await import("./lib/exit-log.js");o("worker-exit",`code=${e}`);const n=null!==e&&e>128?e-128:0;console.log(),console.log(n?chalk.yellow(` ⚠ icoa was stopped by signal ${n}`)+chalk.gray(" — another process killed it (not a crash). Run icoa --resume to continue."):chalk.yellow(` ⚠ icoa exited unexpectedly (code ${e})`)+chalk.gray(" — see ~/.icoa/exit.log · run icoa --resume to continue."))}n=!0}while(e===V);X(),process.exit(e??0)}}const po=new o;if(po.name("icoa").version(mo).description("ICOA CLI — CLI-Native CTF Competition Terminal").option("--resume","Resume previous session").option("--continue","Continue where you left off — jump straight to your last learn card / exam").action(async o=>{const e=H();J("high-contrast"===e.themeVariant?"high-contrast":"dark");const n=!!o.resume||!!o.continue,s=K(n)&&process.argv.length<=2;s?B():q(),function(){const o=Z();if(o.length<=1)return;const e=o[0];if([...o.map(o=>o.version||"0.0.0")].sort((o,e)=>function(o,e){const n=o.split(".").map(o=>parseInt(o,10)||0),s=e.split(".").map(o=>parseInt(o,10)||0);for(let o=0;o<3;o++)if((n[o]||0)!==(s[o]||0))return(n[o]||0)-(s[o]||0);return 0}(e,o))[0]!==e.version){console.log(),console.log(chalk.yellow.bold(" ⚠ Multiple icoa installations detected on PATH:"));for(let e=0;e<o.length;e++){const n=o[e],s=n.version?`v${n.version}`:"(version unreadable)",r=0===e?chalk.yellow("→"):" ",t=0===e?chalk.gray(" ← currently running (older — shadowing newer install)"):chalk.gray(" ← shadowed");console.log(` ${r} ${chalk.cyan(n.path.padEnd(28))} ${chalk.white(s)}${t}`)}console.log(),console.log(chalk.yellow(" The first install on PATH wins. To use the newer one, remove the older:")),console.log(),e.pkgDir?console.log(` ${chalk.bold.cyan(`sudo rm -rf ${e.pkgDir} ${e.path}`)}`):console.log(` ${chalk.bold.cyan(`sudo rm -rf ${e.path} # also delete its node_modules dir`)}`),console.log(),console.log(chalk.gray(" Then re-run icoa to confirm version banner shows the newer release.")),console.log()}}();const r=process.env.LANG||process.env.LC_ALL||process.env.LC_CTYPE||"";if(!/UTF-?8/i.test(r))if("win32"===process.platform){let o="";try{const{execFileSync:e}=await import("node:child_process");o=e("chcp.com",[],{encoding:"utf-8",timeout:1500,stdio:["ignore","pipe","ignore"]}).trim()}catch{}o.includes("65001")||(console.log(chalk.yellow(`⚠ Windows terminal is not using UTF-8 (current: ${o||"unknown"}).`)),console.log(chalk.gray(' Non-English text (Ukrainian, Chinese, Japanese, etc.) may show as "?" or garbled glyphs.')),console.log(chalk.gray(" Fix (run before ")+chalk.cyan("icoa")+chalk.gray("): ")+chalk.cyan("chcp 65001")),console.log(chalk.gray(" Or stay in English inside the CLI: ")+chalk.cyan("lang en")),console.log())}else console.log(chalk.yellow(`⚠ Your terminal locale is not UTF-8 (LANG=${r||"(unset)"}).`)),console.log(chalk.gray(' Non-English text and box characters may display as "?" or garbled glyphs.')),console.log(chalk.gray(" Fix: ")+chalk.cyan("export LANG=en_US.UTF-8")+chalk.gray(" (or your locale, e.g. ")+chalk.cyan("zh_CN.UTF-8")+chalk.gray(", ")+chalk.cyan("uk_UA.UTF-8")+chalk.gray(")")),console.log();if(console.log(go),s?"upgraded"===await z({ask:!0})&&(console.log(chalk.gray(" restarting icoa …")),process.exit(V)):Q(),process.argv.length<=2||n)return o.continue&&(process.env.ICOA_AUTO_RESUME="1"),n||"1"===process.env.ICOA_RELAUNCH||await async function(){const o=process.stdin;if(o.isTTY&&"function"==typeof o.setRawMode)return new Promise(e=>{let n=!1;const s=()=>{if(!n){n=!0,o.removeListener("data",r);try{o.setRawMode(!1)}catch{}o.pause(),e()}},r=()=>s();o.setRawMode(!0),o.resume(),o.once("data",r),console.log(chalk.gray(" (press any key to continue...)")),setTimeout(s,3e3)});await new Promise(o=>setTimeout(o,3e3))}(),void Y(po,n)}),e(po),n(po),s(po),r(po),t(po),i(po),l(po),a(po),m(po),c(po),g(po),d(po),p(po),h(po),f(po),y(po),u(po),w(po),j(po),b(po),v(po),T(po),$(po),E(po),A(po),x(po),_(po),I(po),k(po),C(po),S(po),L(po),R(po),O(po),U(po),N(po),F(po),G(po),P(po),M(po),D(po),po.command("model",{hidden:!0}).argument("[name]","model name to switch to").action(o=>{const e=H().geminiModel||"gemini-2.5-flash-lite";o?(W({geminiModel:o}),console.log(),console.log(chalk.green(" Model switched: ")+chalk.gray(e)+chalk.white(" -> ")+chalk.bold.white(o)),console.log()):(console.log(),console.log(chalk.gray(" Current model: ")+chalk.white(e)),console.log(),console.log(chalk.gray(" Available models:")),console.log(chalk.bold.white(" Gemini 3.x (Latest)")),console.log(chalk.white(" model gemini-3.5-flash ")+chalk.gray("Newest stable, paid Tier 1+")),console.log(chalk.white(" model gemini-3-flash-preview ")+chalk.gray("Preview")),console.log(chalk.bold.white(" Gemini 2.5 (Stable)")),console.log(chalk.white(" model gemini-2.5-flash-lite ")+chalk.gray("Fastest, default, free tier")),console.log(chalk.white(" model gemini-2.5-flash ")+chalk.gray("Heavier, thinking enabled")),console.log(chalk.white(" model gemini-2.5-pro ")+chalk.gray("Strong reasoning, paid")),console.log(chalk.bold.white(" Open Source")),console.log(chalk.white(" model gemma-4-31b-it ")+chalk.gray("Free, open-source")),console.log(chalk.white(" model <any-model-id> ")+chalk.gray("Custom model")),console.log(),console.log(chalk.gray(" Translation uses gemini-3.5-flash for best quality.")),console.log())}),"1"===process.env.ICOA_RESET_STATE)try{const{clearExamState:o}=await import("./lib/exam-state.js");o(),console.log(chalk.yellow("⚠ ICOA_RESET_STATE=1 — local exam state wiped.")),console.log(chalk.gray(" (Token NOT revoked server-side. Re-enter a fresh token with `exam <token>`.)")),console.log()}catch(o){console.log(chalk.red("⚠ ICOA_RESET_STATE: could not clear state — ")+chalk.gray(String(o)))}po.hook("preAction",()=>{!function(){if(!oo())return;const o="─".repeat(Math.max(24,Math.min(52,(process.stdout.columns||80)-4)));console.log(),console.log(chalk.yellow(` ${o}`)),console.log(chalk.yellow.bold(" ⚠ You ARE inside Ubuntu — but this icoa")),console.log(chalk.yellow.bold(" is the WINDOWS build.")),console.log(),console.log(chalk.gray(" WSL appends the Windows PATH, so ")+chalk.cyan("icoa")),console.log(chalk.gray(" found the Windows copy first. Almost")),console.log(chalk.gray(" nothing will work: no vi, no python3,")),console.log(chalk.gray(" env setup cannot install.")),console.log(),console.log(chalk.gray(" Running: ")+chalk.white(process.execPath)),console.log(),console.log(chalk.white(" Fix — inside Ubuntu, check npm is Linux FIRST:")),console.log(` ${chalk.bold.cyan("which npm")}${chalk.gray(" → must not be /mnt/c/...")}`),console.log(` ${chalk.bold.cyan("sudo npm install -g icoa-cli")}`),console.log(` ${chalk.bold.cyan("hash -r")}${chalk.gray(" → bash caches the old path")}`),console.log(chalk.gray(" Then restart icoa and check ")+chalk.bold.cyan("which icoa")),console.log(chalk.yellow(` ${o}`)),console.log()}()}),po.parse();
2
+ import{Command as o}from"commander";import chalk from"chalk";import{registerCtfCommands as e}from"./commands/ctf.js";import{registerRefCommand as n}from"./commands/ref.js";import{registerShellCommand as s}from"./commands/shell.js";import{registerFilesCommand as r}from"./commands/files.js";import{registerViewCommand as t}from"./commands/view.js";import{registerConnectCommand as i}from"./commands/connect.js";import{registerChallengeCommand as l}from"./commands/challenge.js";import{registerDoctorCommand as a}from"./commands/doctor.js";import{registerUpgradeCommand as m}from"./commands/upgrade.js";import{registerNoteCommand as c}from"./commands/note.js";import{registerLogCommand as g}from"./commands/log.js";import{registerLangCommand as d}from"./commands/lang.js";import{registerSetupCommand as p}from"./commands/setup.js";import{registerEnvCommand as h}from"./commands/env.js";import{registerAienvCommand as f}from"./commands/aienv.js";import{registerPythonCommands as u}from"./commands/python.js";import{registerMujocoCommands as y}from"./commands/mujoco.js";import{registerDuckCommand as w}from"./commands/duck.js";import{registerIpynbCommand as j}from"./commands/ipynb.js";import{registerAi4ctfCommand as b}from"./commands/ai4ctf.js";import{registerExamCommand as v}from"./commands/exam.js";import{registerCtf4aiDemoCommand as T}from"./commands/ctf4ai-demo.js";import{registerThemeCommand as $}from"./commands/theme.js";import{registerLearnCommand as E}from"./commands/learn.js";import{registerCtf4VlaCommand as A}from"./commands/ctf4vla.js";import{registerDemo2Command as x}from"./commands/demo2.js";import{registerDemo3Command as _}from"./commands/demo3.js";import{registerDemo4Command as I}from"./commands/demo4.js";import{registerDemo5Command as k}from"./commands/demo5.js";import{registerGfssmCommand as C}from"./commands/gfssm.js";import{registerAi4StartupCommand as S}from"./commands/ai4startup.js";import{registerGpuForTaskCommand as L}from"./commands/gpufortask.js";import{registerSimCommand as R}from"./commands/sim.js";import{registerArenaCommand as O}from"./commands/arena.js";import{registerKaggleCommand as N}from"./commands/kaggle.js";import{registerSprintCommand as U}from"./commands/sprint.js";import{registerTeleloadCommand as F}from"./commands/teleload.js";import{registerBoardCommand as P}from"./commands/board.js";import{registerTypeCommand as M}from"./commands/type.js";import{registerBattleCommand as G}from"./commands/battle.js";import{registerWmCommand as H}from"./commands/wm.js";import{getConfig as W,saveConfig as D}from"./lib/config.js";import{registerMicroduckCommand as Y}from"./commands/microduck.js";import{startRepl as V}from"./repl.js";import{RELAUNCH_CODE as J}from"./lib/menu-nav.js";import{setTerminalTheme as X}from"./lib/theme.js";import{cleanupTerminal as q}from"./lib/terminal-cleanup.js";import{checkForUpdates as z,runUpgrade as K,bootUpgradeEligible as B,startBootCheck as Q,printUpdateHint as Z}from"./lib/update-check.js";import{detectIcoaInstalls as oo,isWindowsBuildInWslShell as eo}from"./lib/platform.js";import{ICOA_BIG as no}from"./lib/banner.js";import{readFileSync as so}from"node:fs";import{fileURLToPath as ro}from"node:url";import{dirname as to,join as io}from"node:path";import{setDefaultResultOrder as lo}from"node:dns";import{setDefaultAutoSelectFamilyAttemptTimeout as ao}from"node:net";lo("ipv4first"),ao(4e3);const mo=to(ro(import.meta.url)),co=JSON.parse(so(io(mo,"..","package.json"),"utf-8")).version,go=chalk.cyan(" ─────────────────────────────────────────────────────"),po=`\n${go}\n\n${no.map(o=>` ${chalk.bold.white(o)}`).join("\n")}\n\n ${chalk.bold.magenta("The World's First AI-Native CLI Operating System")}\n ${chalk.bold.magenta("for K-12 AI & Cyber Olympiads and International AI Hackathons")}\n\n ${chalk.bold.white("ICOA 2026:")} ${chalk.white("Sydney, Australia")}\n ${chalk.bold.white("ICOA 2027:")} ${chalk.white("July 2027")} ${chalk.gray("· host city to be announced")}\n ${chalk.cyan.underline("https://icoa2026.au")}\n\n ${chalk.gray(`CLI-Native Competition Terminal v${co}`)}\n\n${go}\n`;process.on("uncaughtException",o=>{"__REPL_NO_EXIT__"!==o.message&&(console.error(chalk.red("Error:"),o.message),process.exit(1))}),process.on("unhandledRejection",o=>{const e=o instanceof Error?o.message:String(o);"__REPL_NO_EXIT__"!==e&&(console.error(chalk.red("Error:"),e),process.exit(1))});{const o=process.argv.slice(2).some(o=>["-V","--version","-h","--help"].includes(o));if(!0===process.stdin.isTTY&&"1"!==process.env.ICOA_SUPERVISED&&!o){const{spawnSync:o}=await import("node:child_process");process.on("SIGINT",()=>{}),process.on("SIGTERM",()=>{});let e=0,n=!1;do{const s=n?process.argv.slice(1,2):process.argv.slice(1),r=o(process.execPath,s,{stdio:"inherit",env:{...process.env,ICOA_SUPERVISED:"1",...n?{ICOA_RELAUNCH:"1"}:{}}});if(r.signal){const{appendExitLog:o}=await import("./lib/exit-log.js");o("worker-signal",`signal=${r.signal}`),console.log(),console.log(chalk.yellow(` ⚠ icoa was stopped by signal ${r.signal}`)+chalk.gray(" — another process killed it (not a crash). Run icoa --resume to continue.")),e=0;break}if(e=r.status,0!==e&&e!==J){const{appendExitLog:o}=await import("./lib/exit-log.js");o("worker-exit",`code=${e}`);const n=null!==e&&e>128?e-128:0;console.log(),console.log(n?chalk.yellow(` ⚠ icoa was stopped by signal ${n}`)+chalk.gray(" — another process killed it (not a crash). Run icoa --resume to continue."):chalk.yellow(` ⚠ icoa exited unexpectedly (code ${e})`)+chalk.gray(" — see ~/.icoa/exit.log · run icoa --resume to continue."))}n=!0}while(e===J);q(),process.exit(e??0)}}const ho=new o;if(ho.name("icoa").version(co).description("ICOA CLI — CLI-Native CTF Competition Terminal").option("--resume","Resume previous session").option("--continue","Continue where you left off — jump straight to your last learn card / exam").action(async o=>{const e=W();X("high-contrast"===e.themeVariant?"high-contrast":"dark");const n=!!o.resume||!!o.continue,s=B(n)&&process.argv.length<=2;s?Q():z(),function(){const o=oo();if(o.length<=1)return;const e=o[0];if([...o.map(o=>o.version||"0.0.0")].sort((o,e)=>function(o,e){const n=o.split(".").map(o=>parseInt(o,10)||0),s=e.split(".").map(o=>parseInt(o,10)||0);for(let o=0;o<3;o++)if((n[o]||0)!==(s[o]||0))return(n[o]||0)-(s[o]||0);return 0}(e,o))[0]!==e.version){console.log(),console.log(chalk.yellow.bold(" ⚠ Multiple icoa installations detected on PATH:"));for(let e=0;e<o.length;e++){const n=o[e],s=n.version?`v${n.version}`:"(version unreadable)",r=0===e?chalk.yellow("→"):" ",t=0===e?chalk.gray(" ← currently running (older — shadowing newer install)"):chalk.gray(" ← shadowed");console.log(` ${r} ${chalk.cyan(n.path.padEnd(28))} ${chalk.white(s)}${t}`)}console.log(),console.log(chalk.yellow(" The first install on PATH wins. To use the newer one, remove the older:")),console.log(),e.pkgDir?console.log(` ${chalk.bold.cyan(`sudo rm -rf ${e.pkgDir} ${e.path}`)}`):console.log(` ${chalk.bold.cyan(`sudo rm -rf ${e.path} # also delete its node_modules dir`)}`),console.log(),console.log(chalk.gray(" Then re-run icoa to confirm version banner shows the newer release.")),console.log()}}();const r=process.env.LANG||process.env.LC_ALL||process.env.LC_CTYPE||"";if(!/UTF-?8/i.test(r))if("win32"===process.platform){let o="";try{const{execFileSync:e}=await import("node:child_process");o=e("chcp.com",[],{encoding:"utf-8",timeout:1500,stdio:["ignore","pipe","ignore"]}).trim()}catch{}o.includes("65001")||(console.log(chalk.yellow(`⚠ Windows terminal is not using UTF-8 (current: ${o||"unknown"}).`)),console.log(chalk.gray(' Non-English text (Ukrainian, Chinese, Japanese, etc.) may show as "?" or garbled glyphs.')),console.log(chalk.gray(" Fix (run before ")+chalk.cyan("icoa")+chalk.gray("): ")+chalk.cyan("chcp 65001")),console.log(chalk.gray(" Or stay in English inside the CLI: ")+chalk.cyan("lang en")),console.log())}else console.log(chalk.yellow(`⚠ Your terminal locale is not UTF-8 (LANG=${r||"(unset)"}).`)),console.log(chalk.gray(' Non-English text and box characters may display as "?" or garbled glyphs.')),console.log(chalk.gray(" Fix: ")+chalk.cyan("export LANG=en_US.UTF-8")+chalk.gray(" (or your locale, e.g. ")+chalk.cyan("zh_CN.UTF-8")+chalk.gray(", ")+chalk.cyan("uk_UA.UTF-8")+chalk.gray(")")),console.log();if(console.log(po),s?"upgraded"===await K({ask:!0})&&(console.log(chalk.gray(" restarting icoa …")),process.exit(J)):Z(),process.argv.length<=2||n)return o.continue&&(process.env.ICOA_AUTO_RESUME="1"),n||"1"===process.env.ICOA_RELAUNCH||await async function(){const o=process.stdin;if(o.isTTY&&"function"==typeof o.setRawMode)return new Promise(e=>{let n=!1;const s=()=>{if(!n){n=!0,o.removeListener("data",r);try{o.setRawMode(!1)}catch{}o.pause(),e()}},r=()=>s();o.setRawMode(!0),o.resume(),o.once("data",r),console.log(chalk.gray(" (press any key to continue...)")),setTimeout(s,3e3)});await new Promise(o=>setTimeout(o,3e3))}(),void V(ho,n)}),e(ho),n(ho),s(ho),r(ho),t(ho),i(ho),l(ho),a(ho),m(ho),c(ho),g(ho),d(ho),p(ho),h(ho),f(ho),u(ho),y(ho),w(ho),j(ho),b(ho),v(ho),T(ho),$(ho),E(ho),A(ho),x(ho),_(ho),I(ho),k(ho),C(ho),S(ho),L(ho),R(ho),O(ho),N(ho),F(ho),U(ho),P(ho),H(ho),M(ho),G(ho),Y(ho),ho.command("model",{hidden:!0}).argument("[name]","model name to switch to").action(o=>{const e=W().geminiModel||"gemini-2.5-flash-lite";o?(D({geminiModel:o}),console.log(),console.log(chalk.green(" Model switched: ")+chalk.gray(e)+chalk.white(" -> ")+chalk.bold.white(o)),console.log()):(console.log(),console.log(chalk.gray(" Current model: ")+chalk.white(e)),console.log(),console.log(chalk.gray(" Available models:")),console.log(chalk.bold.white(" Gemini 3.x (Latest)")),console.log(chalk.white(" model gemini-3.5-flash ")+chalk.gray("Newest stable, paid Tier 1+")),console.log(chalk.white(" model gemini-3-flash-preview ")+chalk.gray("Preview")),console.log(chalk.bold.white(" Gemini 2.5 (Stable)")),console.log(chalk.white(" model gemini-2.5-flash-lite ")+chalk.gray("Fastest, default, free tier")),console.log(chalk.white(" model gemini-2.5-flash ")+chalk.gray("Heavier, thinking enabled")),console.log(chalk.white(" model gemini-2.5-pro ")+chalk.gray("Strong reasoning, paid")),console.log(chalk.bold.white(" Open Source")),console.log(chalk.white(" model gemma-4-31b-it ")+chalk.gray("Free, open-source")),console.log(chalk.white(" model <any-model-id> ")+chalk.gray("Custom model")),console.log(),console.log(chalk.gray(" Translation uses gemini-3.5-flash for best quality.")),console.log())}),"1"===process.env.ICOA_RESET_STATE)try{const{clearExamState:o}=await import("./lib/exam-state.js");o(),console.log(chalk.yellow("⚠ ICOA_RESET_STATE=1 — local exam state wiped.")),console.log(chalk.gray(" (Token NOT revoked server-side. Re-enter a fresh token with `exam <token>`.)")),console.log()}catch(o){console.log(chalk.red("⚠ ICOA_RESET_STATE: could not clear state — ")+chalk.gray(String(o)))}ho.hook("preAction",()=>{!function(){if(!eo())return;const o="─".repeat(Math.max(24,Math.min(52,(process.stdout.columns||80)-4)));console.log(),console.log(chalk.yellow(` ${o}`)),console.log(chalk.yellow.bold(" ⚠ You ARE inside Ubuntu — but this icoa")),console.log(chalk.yellow.bold(" is the WINDOWS build.")),console.log(),console.log(chalk.gray(" WSL appends the Windows PATH, so ")+chalk.cyan("icoa")),console.log(chalk.gray(" found the Windows copy first. Almost")),console.log(chalk.gray(" nothing will work: no vi, no python3,")),console.log(chalk.gray(" env setup cannot install.")),console.log(),console.log(chalk.gray(" Running: ")+chalk.white(process.execPath)),console.log(),console.log(chalk.white(" Fix — inside Ubuntu, check npm is Linux FIRST:")),console.log(` ${chalk.bold.cyan("which npm")}${chalk.gray(" → must not be /mnt/c/...")}`),console.log(` ${chalk.bold.cyan("sudo npm install -g icoa-cli")}`),console.log(` ${chalk.bold.cyan("hash -r")}${chalk.gray(" → bash caches the old path")}`),console.log(chalk.gray(" Then restart icoa and check ")+chalk.bold.cyan("which icoa")),console.log(chalk.yellow(` ${o}`)),console.log()}()}),ho.parse();
@@ -1 +1 @@
1
- export const REGISTRY=[{name:"join",mapsTo:["ctf","join"],rest:!0,help:{order:0,section:"Competition",label:"join <url>",text:"Connect to CTFd"}},{name:"activate",mapsTo:["ctf","activate"],rest:!0},{name:"challenges",mapsTo:["ctf","challenges"],help:{order:1,section:"Competition",label:"challenges (ch)",text:"List challenges by category"}},{name:"ch",mapsTo:["ctf","challenges"]},{name:"open",mapsTo:["ctf","open"],rest:!0,help:{order:2,section:"Competition",label:"open <id>",text:"Read challenge + get next steps"}},{name:"submit",mapsTo:["ctf","submit"],rest:!0,help:{order:3,section:"Competition",label:"submit <id> <flag>",text:"Submit a flag"}},{name:"flag",mapsTo:["ctf","submit"],rest:!0},{name:"scoreboard",mapsTo:["ctf","scoreboard"],rest:!0,help:{order:4,section:"Competition",label:"scoreboard (sb)",text:"Live rankings"}},{name:"sb",mapsTo:["ctf","scoreboard"],rest:!0},{name:"status",mapsTo:["ctf","status"],help:{order:5,section:"Competition",label:"status",text:"Your score & timer"}},{name:"time",mapsTo:["ctf","time"],help:{order:6,section:"Competition",label:"time",text:"Countdown timer"}},{name:"ref",help:{order:8,section:"Tools",label:"ref [topic]",text:"Quick reference (linux, web, crypto...)"}},{name:"shell",help:{order:9,section:"Tools",label:"shell",text:"Interactive CTF shell (sandbox if present, else host)"}},{name:"files",help:{order:10,section:"Tools",label:"files <id>",text:"Download challenge files"}},{name:"view"},{name:"connect",help:{order:11,section:"Tools",label:"connect <id>",text:"Connect to remote target"}},{name:"challenge",subs:["start","stop","status"]},{name:"note",help:{order:12,section:"Tools",label:"note [text]",text:"Add a logbook entry (in-exam: tags current Q)"}},{name:"notes"},{name:"logbook",help:{order:13,section:"Tools",label:"logbook [n]",text:"View your logbook (in-exam: filter by Q)"}},{name:"log",help:{order:14,section:"Tools",label:"log",text:"Session history"}},{name:"man"},{name:"manual"},{name:"lang",help:{order:21,section:"System",label:"lang [code]",text:"Switch language (15 supported)"}},{name:"setup"},{name:"env"},{name:"aienv"},{name:"python",subs:["setup","status"]},{name:"mujoco",subs:["setup","status"]},{name:"mojoco",mapsTo:["mujoco"],rest:!0},{name:"ipynb"},{name:"kaggle"},{name:"teleload"},{name:"pandahelpme31"},{name:"gpufortask"},{name:"guide"},{name:"ai4ctf",help:{order:7,section:"AI Teammate",label:"ai4ctf",text:"Free-chat with your AI teammate"}},{name:"model"},{name:"ctf",subs:["challenges","open","submit","scoreboard","status","join","logout","time"]},{name:"exam",subs:["list","start","q","answer","submit","review","result","next","prev","mark","unmark","help"]},{name:"demo",mapsTo:["exam","demo"]},{name:"retry",mapsTo:["exam","demo-retry"]},{name:"nations",mapsTo:["exam","nations"]},{name:"next",mapsTo:["exam","next"]},{name:"prev",mapsTo:["exam","prev"]},{name:"continue"},{name:"logout",mapsTo:["ctf","logout"],help:{order:22,section:"System",label:"logout",text:"Disconnect"}},{name:"ctf4ai"},{name:"mark",mapsTo:["exam","mark"],rest:!0},{name:"unmark",mapsTo:["exam","unmark"],rest:!0},{name:"review",mapsTo:["exam","review"]},{name:"learn",subs:["start","continue"]},{name:"demo2"},{name:"demo3"},{name:"demo4"},{name:"demo5"},{name:"gfssm"},{name:"ctf4eai"},{name:"ctf4vla"},{name:"theme"},{name:"sim"},{name:"arena",subs:["eai"]},{name:"eai"},{name:"wm"},{name:"microduck"},{name:"battle",subs:["edit","syntax","play","replay","submit","status","bots"]},{name:"duck",subs:["edit","syntax","run","replay","submit","board","scenarios","status"]},{name:"type",subs:["15","30","60","words","python","shell","history"],help:{order:15,section:"Tools",label:"type [30]",text:"Typing speed trainer — WPM, live colours, no token"}},{name:"board"},{name:"learn-pull"},{name:"doctor",help:{order:19,section:"System",label:"doctor",text:"Self-check: version, Python, network/firewall, server"}},{name:"upgrade",help:{order:20,section:"System",label:"upgrade",text:"Install the newest icoa and restart into it"}},{name:"update"},{name:"bg",nav:!0,help:{order:17,section:"System",label:"bg <command>",text:"Run a shell command in the background"}},{name:"tasks",nav:!0,help:{order:18,section:"System",label:"tasks [id]",text:"Background task panel / view output"}},{name:"drafts",nav:!0,help:{order:16,section:"System",label:"drafts",text:"Review staged draft answers"}},{name:"help",nav:!0},{name:"menu",nav:!0},{name:"quit",nav:!0},{name:"q",nav:!0},{name:"exit",nav:!0,help:{order:24,section:"System",label:"exit",text:"Quit (session saved)"}},{name:"back",nav:!0},{name:"resume",nav:!0,help:{order:15,section:"System",label:"resume",text:"Continue your last learn card / exam"}},{name:"clear",nav:!0,help:{order:23,section:"System",label:"clear",text:"Clear screen"}},{name:"cls",nav:!0}];export const surface=()=>REGISTRY.map(e=>e.name);export const dispatchable=()=>REGISTRY.filter(e=>!e.nav).map(e=>e.name);export function shortcutFor(e,t){const a=REGISTRY.find(t=>t.name===e&&t.mapsTo);return a?.mapsTo?a.rest?[...a.mapsTo,...t]:[...a.mapsTo]:null}export const subcommandsOf=e=>REGISTRY.find(t=>t.name===e)?.subs;export const helpRows=e=>REGISTRY.filter(t=>t.help?.section===e).sort((e,t)=>e.help.order-t.help.order).map(e=>({label:e.help.label,text:e.help.text}));
1
+ export const REGISTRY=[{name:"join",mapsTo:["ctf","join"],rest:!0,help:{order:0,section:"Competition",label:"join <url>",text:"Connect to CTFd"}},{name:"activate",mapsTo:["ctf","activate"],rest:!0},{name:"challenges",mapsTo:["ctf","challenges"],help:{order:1,section:"Competition",label:"challenges (ch)",text:"List challenges by category"}},{name:"ch",mapsTo:["ctf","challenges"]},{name:"open",mapsTo:["ctf","open"],rest:!0,help:{order:2,section:"Competition",label:"open <id>",text:"Read challenge + get next steps"}},{name:"submit",mapsTo:["ctf","submit"],rest:!0,help:{order:3,section:"Competition",label:"submit <id> <flag>",text:"Submit a flag"}},{name:"flag",mapsTo:["ctf","submit"],rest:!0},{name:"scoreboard",mapsTo:["ctf","scoreboard"],rest:!0,help:{order:4,section:"Competition",label:"scoreboard (sb)",text:"Live rankings"}},{name:"sb",mapsTo:["ctf","scoreboard"],rest:!0},{name:"status",mapsTo:["ctf","status"],help:{order:5,section:"Competition",label:"status",text:"Your score & timer"}},{name:"time",mapsTo:["ctf","time"],help:{order:6,section:"Competition",label:"time",text:"Countdown timer"}},{name:"ref",help:{order:8,section:"Tools",label:"ref [topic]",text:"Quick reference (linux, web, crypto...)"}},{name:"shell",help:{order:9,section:"Tools",label:"shell",text:"Interactive CTF shell (sandbox if present, else host)"}},{name:"files",help:{order:10,section:"Tools",label:"files <id>",text:"Download challenge files"}},{name:"view"},{name:"connect",help:{order:11,section:"Tools",label:"connect <id>",text:"Connect to remote target"}},{name:"challenge",subs:["start","stop","status"]},{name:"note",help:{order:12,section:"Tools",label:"note [text]",text:"Add a logbook entry (in-exam: tags current Q)"}},{name:"notes"},{name:"logbook",help:{order:13,section:"Tools",label:"logbook [n]",text:"View your logbook (in-exam: filter by Q)"}},{name:"log",help:{order:14,section:"Tools",label:"log",text:"Session history"}},{name:"man"},{name:"manual"},{name:"lang",help:{order:21,section:"System",label:"lang [code]",text:"Switch language (15 supported)"}},{name:"setup"},{name:"env"},{name:"aienv"},{name:"python",subs:["setup","status"]},{name:"mujoco",subs:["setup","status"]},{name:"mojoco",mapsTo:["mujoco"],rest:!0},{name:"ipynb"},{name:"kaggle"},{name:"teleload"},{name:"pandahelpme31"},{name:"gpufortask"},{name:"guide"},{name:"ai4ctf",help:{order:7,section:"AI Teammate",label:"ai4ctf",text:"Free-chat with your AI teammate"}},{name:"model"},{name:"ctf",subs:["challenges","open","submit","scoreboard","status","join","logout","time"]},{name:"exam",subs:["list","start","q","answer","submit","review","result","next","prev","mark","unmark","help"]},{name:"demo",mapsTo:["exam","demo"]},{name:"retry",mapsTo:["exam","demo-retry"]},{name:"nations",mapsTo:["exam","nations"]},{name:"next",mapsTo:["exam","next"]},{name:"prev",mapsTo:["exam","prev"]},{name:"continue"},{name:"logout",mapsTo:["ctf","logout"],help:{order:22,section:"System",label:"logout",text:"Disconnect"}},{name:"ctf4ai"},{name:"mark",mapsTo:["exam","mark"],rest:!0},{name:"unmark",mapsTo:["exam","unmark"],rest:!0},{name:"review",mapsTo:["exam","review"]},{name:"learn",subs:["start","continue"]},{name:"demo2"},{name:"demo3"},{name:"demo4"},{name:"demo5"},{name:"gfssm"},{name:"ai4startup"},{name:"ctf4eai"},{name:"ctf4vla"},{name:"theme"},{name:"sim"},{name:"arena",subs:["eai"]},{name:"eai"},{name:"wm"},{name:"microduck"},{name:"battle",subs:["edit","syntax","play","replay","submit","status","bots"]},{name:"duck",subs:["edit","syntax","run","replay","submit","board","scenarios","status"]},{name:"type",subs:["15","30","60","words","python","shell","history"],help:{order:15,section:"Tools",label:"type [30]",text:"Typing speed trainer — WPM, live colours, no token"}},{name:"board"},{name:"learn-pull"},{name:"doctor",help:{order:19,section:"System",label:"doctor",text:"Self-check: version, Python, network/firewall, server"}},{name:"upgrade",help:{order:20,section:"System",label:"upgrade",text:"Install the newest icoa and restart into it"}},{name:"update"},{name:"bg",nav:!0,help:{order:17,section:"System",label:"bg <command>",text:"Run a shell command in the background"}},{name:"tasks",nav:!0,help:{order:18,section:"System",label:"tasks [id]",text:"Background task panel / view output"}},{name:"drafts",nav:!0,help:{order:16,section:"System",label:"drafts",text:"Review staged draft answers"}},{name:"help",nav:!0},{name:"menu",nav:!0},{name:"quit",nav:!0},{name:"q",nav:!0},{name:"exit",nav:!0,help:{order:24,section:"System",label:"exit",text:"Quit (session saved)"}},{name:"back",nav:!0},{name:"resume",nav:!0,help:{order:15,section:"System",label:"resume",text:"Continue your last learn card / exam"}},{name:"clear",nav:!0,help:{order:23,section:"System",label:"clear",text:"Clear screen"}},{name:"cls",nav:!0}];export const surface=()=>REGISTRY.map(e=>e.name);export const dispatchable=()=>REGISTRY.filter(e=>!e.nav).map(e=>e.name);export function shortcutFor(e,t){const a=REGISTRY.find(t=>t.name===e&&t.mapsTo);return a?.mapsTo?a.rest?[...a.mapsTo,...t]:[...a.mapsTo]:null}export const subcommandsOf=e=>REGISTRY.find(t=>t.name===e)?.subs;export const helpRows=e=>REGISTRY.filter(t=>t.help?.section===e).sort((e,t)=>e.help.order-t.help.order).map(e=>({label:e.help.label,text:e.help.text}));
@@ -0,0 +1 @@
1
+ import{marketCalc as e,SEG_N as t}from"./venture.js";export const CHARTS={segments:{en:`your user groups and their shares (box ${t})`,zh:`你的用户分类和占比(第 ${t} 格)`,slide:"user"},survey:{en:"last survey: would-buy in A and B",zh:"最近一次调研:A、B 两国会买比例",slide:"survey"},trend:{en:"would-buy across your surveys (needs 2+)",zh:"历次调研会买比例的变化(至少 2 次)",slide:"evidence"}};export const chartOn=(e,t)=>!1!==e.charts?.[t];export const TEMPLATES={problem:{en:"Problem first",zh:"先讲问题",order:["title","problem","user","alternatives","solution","why_now","value","evidence","survey","price","numbers","moat","risk","next","ask"]},story:{en:"Story first",zh:"先讲故事",order:["title","user","problem","solution","why_now","evidence","survey","alternatives","value","moat","price","numbers","risk","next","ask"]},evidence:{en:"Evidence first",zh:"先讲证据",order:["title","evidence","survey","problem","user","solution","why_now","value","alternatives","moat","price","numbers","risk","next","ask"]}};export const STYLES={night:{en:"Night (dark)",zh:"夜色(深色)"},paper:{en:"Paper (light)",zh:"纸张(浅色)"},bold:{en:"Bold (navy + yellow)",zh:"醒目(藏青 + 黄)"}};const n={title:{en:"",zh:""},problem:{en:"The problem",zh:"问题"},user:{en:"Who has it",zh:"谁有这个问题"},alternatives:{en:"What people do today",zh:"大家现在怎么凑合"},solution:{en:"Our solution",zh:"我们的方案"},value:{en:"Why it is better",zh:"为什么更好"},evidence:{en:"What we heard",zh:"我们听到了什么"},survey:{en:"Simulated survey",zh:"模拟调研"},price:{en:"Who pays, and how much",zh:"谁付钱、付多少"},risk:{en:"When the AI gets it wrong",zh:"AI 出错时"},next:{en:"Our next two weeks",zh:"接下来两周"},ask:{en:"Our ask",zh:"我们需要什么"},why_now:{en:"Why AI, why now",zh:"为什么是 AI、为什么是现在"},numbers:{en:"The numbers",zh:"算账"},moat:{en:"What they cannot copy",zh:"别人抄不走的"}},i={user:{en:"Meet the person",zh:"认识一下这个人"},problem:{en:"What goes wrong",zh:"哪里出了问题"}},r={problem:"problem",user:"user",alternatives:"alternatives",solution:"solution",value:"value",evidence:"evidence",price:"price",risk:"risk",next:"first_step",why_now:"ai_edge",numbers:"ai_cost",moat:"moat"};export const KIND_LABEL=n;const a={price:{en:"price",zh:"价格"},not_needed:{en:"don't need it",zh:"不需要"},already_have:{en:"already use something",zh:"已经有替代"},trust:{en:"trust",zh:"不信任"},privacy:{en:"privacy",zh:"隐私"},effort:{en:"too much effort",zh:"太麻烦"},quality:{en:"doubt it works",zh:"怀疑效果"},other:{en:"other",zh:"其他"}};export function newDeck(e="problem",t="night"){return{template:e,style:t,slides:TEMPLATES[e].order.map(e=>({kind:e,edits:0,own_chars:0,ai_chars:0})),created:(new Date).toISOString()}}export function retemplate(e,t){const n=new Map(e.slides.map(e=>[e.kind,e]));return{...e,template:t,slides:TEMPLATES[t].order.map(e=>n.get(e)??{kind:e,edits:0,own_chars:0,ai_chars:0})}}export function sentences(e,t=4){const n=(e??"").replace(/\s+/g," ").trim();return n?n.split(/(?<=[.!?。!?;;])(?!\d)\s*/).map(e=>e.trim()).filter(Boolean).slice(0,t).map(e=>e.length>180?`${e.slice(0,177)}…`:e):[]}export function renderSlide(t,s,o,l,c,d=[]){const p=s.slides[o];let u,h,m=("story"===s.template&&i[p.kind]||n[p.kind])[l],g=[];const f=r[p.kind];if("title"===p.kind)m=t.name||("zh"===l?"(给项目起个名字:name <名字>)":"(name your venture: name <name>)"),g=sentences(t.boxes.solution,1);else if(f){if(g=sentences(t.boxes[f]),"numbers"===p.kind){const n=e(t.market),i=t.market??{},r=e=>e.toLocaleString("en-US");null!==n.year&&g.push("zh"===l?`市场:${r(i.people)} 人 × ${i.price}/月 × 12 = 每年 ${r(n.year)}${i.source?`(${i.source})`:""}`:`Market: ${r(i.people)} people × ${i.price}/month × 12 = ${r(n.year)} a year${i.source?` (${i.source})`:""}`),null!==n.firstYear&&null!==n.firstYearUsers&&g.push("zh"===l?`第一年现实目标:${r(n.firstYearUsers)} 个用户(会买 ${i.buy}% × 能触达 ${i.reach}%)≈ ${r(n.firstYear)}`:`Realistic first year: ${r(n.firstYearUsers)} users (${i.buy}% would buy × ${i.reach}% reached) ≈ ${r(n.firstYear)}`),null!==n.margin&&g.push("zh"===l?`AI 成本每用户每月 ${i.cost},毛利约 ${n.margin}%`:`AI cost ${i.cost} per user a month — gross margin about ${n.margin}%`)}if("user"===p.kind&&t.segments.length)if(chartOn(s,"segments"))h={title:"zh"===l?"我们的用户分类(占比)":"Our user groups (share)",rows:t.segments.slice(0,6).map(e=>({label:e.source?`${e.name} (${e.source})`:e.name,value:e.share}))};else for(const e of t.segments.slice(0,4))g.push(`${e.name} — ${e.share}%${e.source?` (${e.source})`:""}`);if("evidence"===p.kind&&chartOn(s,"trend")&&d.length>=2){const e=d.slice(-5),t=d.length-e.length;h={title:"zh"===l?"历次模拟调研:目标人群会买比例":"Simulated surveys: target groups would buy",legend:"zh"===l?["A 国","B 国"]:["Country A","Country B"],rows:e.map((e,n)=>({label:"zh"===l?`第 ${t+n+1} 次`:`Survey ${t+n+1}`,value:e.buy_au,value2:e.buy_cn}))}}}else if("survey"===p.kind&&c){u=[];for(const[e,t]of[["AU","A"],["CN","B"]]){const n=c.countries[e];if(!n)continue;chartOn(s,"survey")&&u.push({label:"zh"===l?`${t} 国`:`Country ${t}`,target:n.buy_target,general:n.buy_general,control:n.control_buy,n:n.n});const i=n.ladder;i&&null!==i.stated&&g.push("zh"===l?`${t} 国会买:半价 ${i.half??"–"}% · 原价 ${i.stated}% · 两倍价 ${i.double??"–"}%`:`Country ${t} would buy: half price ${i.half??"–"}% · your price ${i.stated}% · double ${i.double??"–"}%`);const r=n.concerns[0];r&&g.push("zh"===l?`${t} 国不买的头号理由:${a[r.type]?.zh??r.type}(${r.pct}%)`:`Country ${t}: top reason for no — ${a[r.type]?.en??r.type} (${r.pct}%)`)}g.push("zh"===l?"模拟调研:合成受访者,不是真实顾客;每国约 100 人,±10 个百分点。":"Simulated survey: synthetic respondents, not real customers; ~100 per country, ±10 points.")}const v=void 0===p.title&&void 0===p.lines;void 0!==p.title&&(m=p.title),void 0!==p.lines&&(g=p.lines);const b=v?g.length||u?.length||h?"auto":"empty":"edited";return{kind:p.kind,title:m,lines:g,state:b,chart:u,bars:h,image:p.image}}export function emptyHint(e,t){if("survey"===e)return"zh"===t?"敲 survey 跑一次模拟调研,这页会自动填上。":"Run survey and this slide fills itself.";if("numbers"===e)return"zh"===t?"填卡片的「每个用户的 AI 成本」格,或者敲 market 算市场大小和毛利。":'Fill the "AI cost per user" box, or type market to work out market size and margin.';if("ask"===e)return"zh"===t?"写下你想要听众做什么(试用、介绍老师、给反馈……)。":"Write what you want from the audience (try it, introduce a teacher, give feedback…).";const n=r[e];return"zh"===t?`这页跟着你的卡片走 —— 先把卡片里对应的格子填上${n?`(${n})`:""},或者直接在这页打字。`:`This slide follows your card — fill in the matching box${n?` (${n})`:""}, or type on this slide directly.`}const s=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),o={night:"--bg:#070b16;--deck:#0c1222;--panel:#121b32;--line:#25335a;--ink:#e8edfb;--muted:#93a0c4;--accent:#5cc8ff;--accent2:#f5c451;",paper:"--bg:#e9e6df;--deck:#fbfaf7;--panel:#f1eee7;--line:#d6d0c4;--ink:#1d2433;--muted:#5d6577;--accent:#1f6feb;--accent2:#c2410c;",bold:"--bg:#04102b;--deck:#0a1f4d;--panel:#11307a;--line:#2a4a9a;--ink:#ffffff;--muted:#b9c6ea;--accent:#ffd400;--accent2:#ff7a59;"};export function deckHtml(e,t,n,i,r=[],a=()=>null){const l=t.slides.map((a,s)=>renderSlide(e,t,s,n,i,r)),c=e.name||("zh"===n?"未命名项目":"Untitled venture"),d=(e,t,n)=>`<div class="row"><span class="lab">${s(e)}</span><span class="track"><span class="fill ${n}" style="width:${(e=>null===e?0:Math.max(0,Math.min(100,e)))(t)}%"></span></span><span class="val">${null===t?"–":`${t}%`}</span></div>`,p=l.map((e,t)=>{const i=`${t+1} / ${l.length}`;if("title"===e.kind)return`<section class="slide title"><div class="big">${s(e.title)}</div>${e.lines.map(e=>`<div class="sub">${s(e)}</div>`).join("")}<div class="foot">${s("zh"===n?"AI4Startup · 创业实验室":"AI4Startup · Venture Lab")}</div></section>`;const r=e.chart?.length?`<div class="chart">${e.chart.map(e=>`<div class="cty"><div class="cname">${s(e.label)} <small>n=${e.n}</small></div>${d("zh"===n?"目标人群会买":"Target groups would buy",e.target,"a")}${d("zh"===n?"普通人会买":"General public would buy",e.general,"b")}${d("zh"===n?"对照产品(几乎没人买)":"Known-flop product",e.control,"c")}</div>`).join("")}</div>`:"",o=e.bars?`<div class="bars"><div class="btitle">${s(e.bars.title)}${e.bars.legend?` <span class="lg"><i class="a"></i>${s(e.bars.legend[0])} <i class="c"></i>${s(e.bars.legend[1])}</span>`:""}</div>${e.bars.rows.map(e=>void 0===e.value2?d(e.label,e.value,"a"):`<div class="pair"><span class="lab">${s(e.label)}</span><span class="two">${d("",e.value,"a")}${d("",e.value2,"c")}</span></div>`).join("")}</div>`:"",p=e.lines.length?`<ul>${e.lines.map(e=>`<li>${s(e)}</li>`).join("")}</ul>`:r||o?"":`<p class="empty">${s(emptyHint(e.kind,n))}</p>`,u=e.image?a(e.image):null;return u?`<section class="slide img"><div class="kicker">${i}</div><div class="cols"><div class="txt"><h1>${s(e.title)}</h1>${r}${o}${p}</div><figure><img src="${s(u)}" alt=""><figcaption>${s("zh"===n?"AI 生成的插图":"AI-generated illustration")}</figcaption></figure></div><div class="foot">${s(c)}</div></section>`:`<section class="slide"><div class="kicker">${i}</div><h1>${s(e.title)}</h1>${r}${o}${p}<div class="foot">${s(c)}</div></section>`}).join("\n");return`<!doctype html>\n<html lang="${"zh"===n?"zh-CN":"en"}"><head><meta charset="utf-8">\n<meta name="viewport" content="width=device-width,initial-scale=1">\n<title>${s(c)} · pitch deck</title>\n<style>\n:root{${o[t.style]}}\n*{box-sizing:border-box}html,body{margin:0;height:100%;background:var(--bg);color:var(--ink);\nfont-family:-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei","Noto Sans CJK SC",sans-serif}\n#stage{position:fixed;inset:0;display:flex;align-items:center;justify-content:center}\n#canvas{width:1600px;height:900px;position:relative;transform-origin:center center}\n.slide{position:absolute;inset:0;background:var(--deck);border:1px solid var(--line);border-radius:18px;padding:90px 110px;display:none;overflow:hidden}\n.slide.on{display:block}\n.kicker{font:600 22px ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--accent);letter-spacing:.08em}\nh1{font-size:68px;line-height:1.1;margin:18px 0 40px;font-weight:750}\nul{margin:0;padding-left:1.1em;font-size:38px;line-height:1.45}li{margin:0 0 18px}li::marker{color:var(--accent)}\n.empty{font-size:30px;color:var(--muted);font-style:italic}\n.title{display:none;flex-direction:column;justify-content:center}.title.on{display:flex}\n.big{font-size:104px;font-weight:800;line-height:1.05;color:var(--ink)}.sub{font-size:40px;color:var(--muted);margin-top:28px;max-width:1250px}\n.foot{position:absolute;left:110px;right:110px;bottom:46px;font-size:20px;color:var(--muted);border-top:1px solid var(--line);padding-top:14px}\n.chart{display:flex;gap:60px;margin:-10px 0 34px}.cty{flex:1;background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:22px 26px}\n.cname{font-size:30px;font-weight:700;margin-bottom:12px}.cname small{font-weight:400;color:var(--muted);font-size:20px}\n.row{display:flex;align-items:center;gap:14px;margin:10px 0;font-size:22px}.lab{width:300px;color:var(--muted)}\n.track{flex:1;height:22px;background:var(--line);border-radius:11px;overflow:hidden}.fill{display:block;height:100%}\n.cols{display:flex;gap:56px;align-items:flex-start}.cols .txt{flex:1;min-width:0}.cols ul{font-size:34px}\nfigure{margin:18px 0 0;width:560px;flex:none}figure img{width:560px;height:420px;object-fit:cover;border-radius:14px;border:1px solid var(--line);display:block}\nfigcaption{font-size:16px;color:var(--muted);margin-top:8px;text-align:right}\n.bars{background:var(--panel);border:1px solid var(--line);border-radius:14px;padding:18px 26px;margin:-10px 0 30px}\n.btitle{font-size:26px;font-weight:700;margin-bottom:6px}.lg{font-weight:400;font-size:20px;color:var(--muted);margin-left:18px}\n.lg i{display:inline-block;width:14px;height:14px;border-radius:3px;margin:0 6px 0 12px}.lg i.a{background:var(--accent)}.lg i.c{background:var(--accent2)}\n.pair{display:flex;align-items:center;gap:14px}.pair .two{flex:1}.pair .two .row{margin:4px 0}.pair .two .lab{display:none}\n.fill.a{background:var(--accent)}.fill.b{background:var(--muted)}.fill.c{background:var(--accent2)}.val{width:80px;text-align:right;font-family:ui-monospace,Menlo,monospace}\n#hud{position:fixed;right:18px;bottom:12px;font:13px ui-monospace,Menlo,monospace;color:var(--muted);opacity:.75}\n@media print{@page{size:1600px 900px;margin:0}html,body{background:#fff}#stage{position:static;display:block}\n#canvas{transform:none!important;width:auto;height:auto}.slide,.title{position:relative;display:block!important;width:1600px;height:900px;\npage-break-after:always;break-after:page;border-radius:0}.title{display:flex!important}#hud{display:none}}\n</style></head><body>\n<div id="stage"><div id="canvas">\n${p}\n</div></div>\n<div id="hud">← → / space · F ${"zh"===n?"全屏":"full screen"}</div>\n<script>\n(function(){var S=[].slice.call(document.querySelectorAll('.slide')),i=0,c=document.getElementById('canvas');\nfunction fit(){var k=Math.min(innerWidth/1600,innerHeight/900)*0.98;c.style.transform='scale('+k+')';}\nfunction show(n){i=Math.max(0,Math.min(S.length-1,n));S.forEach(function(s,j){s.classList.toggle('on',j===i);});location.hash=String(i+1);}\naddEventListener('resize',fit);\naddEventListener('keydown',function(e){var k=e.key;\nif(k==='ArrowRight'||k==='ArrowDown'||k===' '||k==='PageDown'||k==='Enter'){e.preventDefault();show(i+1);}\nelse if(k==='ArrowLeft'||k==='ArrowUp'||k==='PageUp'||k==='Backspace'){e.preventDefault();show(i-1);}\nelse if(k==='Home'){show(0);}else if(k==='End'){show(S.length-1);}\nelse if(k==='f'||k==='F'){if(!document.fullscreenElement)document.documentElement.requestFullscreen&&document.documentElement.requestFullscreen();else document.exitFullscreen();}});\naddEventListener('click',function(e){show(e.clientX>innerWidth/2?i+1:i-1);});\nfit();show((parseInt(location.hash.slice(1),10)||1)-1);})();\n<\/script></body></html>\n`}export function deckStats(e,t){const n=t.slides.map((n,i)=>renderSlide(e,t,i,"en",null));return{slides:t.slides.length,edited:n.filter(e=>"edited"===e.state).length,empty:n.filter(e=>"empty"===e.state&&"survey"!==e.kind).length,ownChars:t.slides.reduce((e,t)=>e+t.own_chars,0),aiChars:t.slides.reduce((e,t)=>e+t.ai_chars,0)}}
@@ -1,8 +1,10 @@
1
- import{spawnSync as e}from"node:child_process";import{existsSync as s,mkdirSync as t,readFileSync as r,writeFileSync as o}from"node:fs";import{homedir as n}from"node:os";import{join as i,resolve as a}from"node:path";const l=String.raw`import io, json, math, os, sys, time, traceback
1
+ import{spawnSync as e}from"node:child_process";import{existsSync as s,mkdirSync as t,readFileSync as r,writeFileSync as o}from"node:fs";import{homedir as i}from"node:os";import{join as n,resolve as a}from"node:path";const l=String.raw`import io, json, math, os, sys, time, traceback
2
2
  engine = sys.argv[sys.argv.index('--engine') + 1]
3
3
  path = sys.argv[sys.argv.index('--file') + 1]
4
4
  sid = sys.argv[sys.argv.index('--scenario') + 1]
5
5
  seed = int(sys.argv[sys.argv.index('--seed') + 1]) if '--seed' in sys.argv else None
6
+ policy = sys.argv[sys.argv.index('--policy') + 1] if '--policy' in sys.argv else None
7
+ backlash = '--backlash' in sys.argv
6
8
  sys.path.insert(0, engine)
7
9
  os.environ.setdefault('OMP_NUM_THREADS', '1')
8
10
  os.environ.setdefault('MUJOCO_GL', 'disable')
@@ -25,10 +27,17 @@ try:
25
27
  sc = Scenario.load(sid)
26
28
  if seed is not None:
27
29
  sc.seed = seed # another course: same map, different wobble (like the judge's hidden ones)
30
+ if policy: # 96-tier lab: a trained policy file (snap:N / variant:X / mine) walks instead
31
+ from duckkit import resolve_policy
32
+ sc.policies = dict(sc.policies, walk=resolve_policy(policy))
33
+ if backlash:
34
+ sc.backlash = True
28
35
  log = run_file(path, sc)
29
36
  res = score(sc, log)
30
37
  except ControlError as e:
31
38
  sys.stdout = real; emit({'ok': False, 'error': 'control', 'message': str(e)}); sys.exit()
39
+ except FileNotFoundError as e:
40
+ sys.stdout = real; emit({'ok': False, 'error': 'policy', 'message': str(e)}); sys.exit()
32
41
  except Exception as e:
33
42
  sys.stdout = real
34
43
  tb = traceback.extract_tb(sys.exc_info()[2])
@@ -51,4 +60,4 @@ emit({'ok': True, 'pass': bool(res['pass']), 'value': res['value'], 'detail': re
51
60
  'trace': {'samples': pts, 'seconds': sc.seconds, 'fallen_at': log.fallen_at,
52
61
  'walls': [{'pos': list(w['pos'][:2]), 'size': list(w['size'][:2])} for w in sc.walls],
53
62
  'markers': [list(m['pos'][:2]) for m in sc.markers], 'goal': dict(sc.goal)}})
54
- `,d=i(n(),".icoa","duck","trace_run.py");export function runWithTrace(c,m,g,p,f=18e4,u){t(i(n(),".icoa","duck"),{recursive:!0}),s(d)&&r(d,"utf-8")===l||o(d,l);const y=e(c,[d,"--engine",m,"--file",a(g),"--scenario",p,...null!=u?["--seed",String(u)]:[]],{encoding:"utf-8",timeout:f,cwd:m,env:{...process.env,PYTHONDONTWRITEBYTECODE:"1",OMP_NUM_THREADS:"1",MUJOCO_GL:"disable"}}),x=String(y.stdout??"").trim().split("\n").pop()||"";try{return JSON.parse(x)}catch{return{ok:!1,error:"engine",message:String(y.stderr??"").trim().split("\n").slice(-3).join(" ")||`exit ${y.status}`}}}
63
+ `,c=n(i(),".icoa","duck","trace_run.py");export function runWithTrace(d,p,m,g,y=18e4,f,u={}){t(n(i(),".icoa","duck"),{recursive:!0}),s(c)&&r(c,"utf-8")===l||o(c,l);const x=e(d,[c,"--engine",p,"--file",a(m),"--scenario",g,...null!=f?["--seed",String(f)]:[],...u.policy?["--policy",u.policy]:[],...u.backlash?["--backlash"]:[]],{encoding:"utf-8",timeout:y,cwd:p,env:{...process.env,PYTHONDONTWRITEBYTECODE:"1",OMP_NUM_THREADS:"1",MUJOCO_GL:"disable",...u.dir?{ICOA_DUCK_LAB:u.dir}:{}}}),k=String(x.stdout??"").trim().split("\n").pop()||"";try{return JSON.parse(k)}catch{return{ok:!1,error:"engine",message:String(x.stderr??"").trim().split("\n").slice(-3).join(" ")||`exit ${x.status}`}}}
@@ -1 +1 @@
1
- import{existsSync as e,mkdirSync as t,readFileSync as n,writeFileSync as r}from"node:fs";import{homedir as o}from"node:os";import{dirname as s,join as c}from"node:path";import chalk from"chalk";import{getConfig as i}from"./config.js";export function uiLang(){const e=(i().language||"en").toLowerCase();return e.startsWith("zh")?"zh":e.startsWith("th")?"th":"en"}export function tx(e,t=uiLang()){return"string"==typeof e?e:("zh"===t?e.zh:"th"===t?e.th:void 0)??e.en}export function asciiOnly(){if("1"===process.env.ICOA_ASCII)return!0;const e=process.env.LC_ALL||process.env.LC_CTYPE||process.env.LANG||"";return""!==e&&!/utf-?8/i.test(e)}export function dw(e){let t=0;for(const n of e.replace(u,"")){const e=n.codePointAt(0)??0;3633===e||e>=3636&&e<=3642||e>=3655&&e<=3662||(t+=e>65535||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255?2:1)}return t}function a(e,t){const n=dw(e);return n>=t?`${e} `:e+" ".repeat(t-n)}export function wrapText(e,t){const n=[];for(const r of e.split("\n")){const e=r.match(/[⺀-꓏가-힣豈-﫿]|\S+\s*|\s+/g)??[];let o="";for(const r of e){const e=/^[,.;:!?)\]}、。,;:!?)】」』…]/.test(r);o&&!e&&dw(o)+dw(r.trimEnd())>t&&(n.push(o.trimEnd()),o=""),o+=r}n.push(o.trimEnd())}return n}const u=new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`,"g");function l(){return process.env.ICOA_SEEN_FILE||c(o(),".icoa","seen-surfaces.json")}function p(){try{const e=JSON.parse(n(l(),"utf8"));return e&&"object"==typeof e?e:{}}catch{return{}}}export function seenBefore(e){return"1"!==process.env.ICOA_FRESH&&e in p()}export function markSeen(n){if("1"!==process.env.ICOA_FRESH)try{const o=l(),c=p();if(c[n])return;c[n]=(new Date).toISOString(),e(s(o))||t(s(o),{recursive:!0}),r(o,`${JSON.stringify(c,null,1)}\n`)}catch{}}const f={readMe:{en:"read me first",zh:"先读这个",th:"อ่านก่อน"},next:{en:"next, type:",zh:"下一步敲:",th:"ขั้นต่อไป พิมพ์:"},help:{en:"help = these steps",zh:"help = 这些步骤",th:"help = ขั้นตอนนี้"},guide:{en:"guide = full sheet",zh:"guide = 完整说明",th:"guide = คู่มือเต็ม"},leave:{en:"leave",zh:"离开",th:"ออก"},done:{en:"all steps done — explore, or",zh:"步骤都做完了 —— 自由探索,或",th:"ทำครบแล้ว — ลองเล่น หรือ"},optional:{en:"optional",zh:"可选",th:"ไม่บังคับ"}};export function currentNext(e){if(e.next)return e.next();for(const t of e.steps)if(!(t.optional||t.done&&t.done()))return t.verb;return null}export function renderPanel(e,t,n){const r=n?.lang??uiLang(),o=n?.ascii??asciiOnly(),s=e=>tx(e,r),c=o?"":"📖 ",i=o?"":"🧭 ",u=o?">":"▸",l=o?"<-":"↩",p=currentNext(e),h=e.helpWord??"help",$=e.leave??{verb:"back",what:f.leave},d=`${c}${s(e.title)}`;if("compact"===t){const t=p?`${chalk.gray(` ${u} ${s(f.next)} `)}${chalk.bold.green(p)}`:`${chalk.gray(` ${u} ${s(f.done)} `)}${chalk.cyan($.verb)}`,n=s(f.help).replace(/^help/,h),r=` ${chalk.bold.white(d)}${t}${chalk.gray(` · ${i}${n}${e.guide?` · ${s(f.guide)}`:""}`)}`;if(dw(r)<=80)return[r];const o=` ${chalk.bold.white(d)}${t}${chalk.gray(` · ${i}${n}`)}`;return[dw(o)<=80?o:` ${chalk.bold.white(d)}${t}${chalk.gray(` · ${i}${h}`)}`]}const g=[];g.push(` ${chalk.bold.white(d)}${chalk.gray(` — ${s(f.readMe)}`)}`);for(const t of wrapText(s(e.what),76))g.push(chalk.gray(` ${t}`));const x=Math.min(18,Math.max(6,...e.steps.map(e=>dw(e.verb))))+2;e.steps.forEach((e,t)=>{const n=null!==p&&e.verb===p,r=!n&&!0===e.done?.(),c=n?chalk.bold.green(o?"> ":"▸ "):r?chalk.green(o?"[x]":"✅"):e.optional?chalk.gray(o?" - ":" ·"):chalk.gray(o?"[ ]":"○ "),i=n?chalk.bold.green(a(e.verb,x)):chalk.cyan(a(e.verb,x)),u=wrapText(s(e.what)+(e.optional?chalk.gray(` (${s(f.optional)})`):""),68-x);g.push(` ${chalk.white(String(t+1).padStart(2))} ${c} ${i}${chalk.gray(u[0]??"")}`);for(const e of u.slice(1))g.push(`${" ".repeat(10+x)}${chalk.gray(e)}`)});for(const t of e.notes??[])for(const e of wrapText(s(t),74))g.push(chalk.gray(` ${e}`));const y=p?` ${chalk.bold.green(`${u} ${s(f.next)} ${p}`)}`:` ${chalk.gray(`${u} ${s(f.done)} `)}${chalk.cyan($.verb)}`;return g.push(`${y}${chalk.gray(` ${l} ${$.verb} · ${i}${h}${e.guide?" · guide":""}`)}`),g}export function footerLine(e,t){const n=t?.lang??uiLang(),r=t?.ascii??asciiOnly(),o=e=>tx(e,n),s=r?">":"▸",c=r?"<-":"↩",i=r?"":"🧭 ",a=currentNext(e),u=e.leave??{verb:"back",what:f.leave};return` ${a?chalk.bold.green(`${s} ${o(f.next)} ${a}`):`${chalk.gray(`${s} ${o(f.done)} `)}${chalk.cyan(u.verb)}`}${chalk.gray(` ${c} ${u.verb} · ${i}${e.helpWord??"help"}`)}`}const h=[];export function currentSurface(){return h.length?h[h.length-1]:null}export function enterPanel(e,t){const n=currentSurface();n&&n.id===e.id&&h.pop(),h.push(e);const r=t?.mode??(seenBefore(e.id)?"compact":"full");if(!t?.quiet){console.log();for(const t of renderPanel(e,r))console.log(t);console.log()}return markSeen(e.id),r}export function leavePanel(e){if(!e)return void h.pop();const t=h.map(e=>e.id).lastIndexOf(e);t>=0&&h.splice(t,1)}export function printHelp(){const e=currentSurface();if(!e)return!1;console.log();for(const t of renderPanel(e,"full"))console.log(t);return console.log(),!0}export function printGuide(){const e=currentSurface();return!!e&&(e.guide?(console.log(),e.guide(),console.log(),!0):printHelp())}const $=new Set(["help","/help","?","/?","h","帮助","帮助我","ช่วย"]),d=new Set(["guide","/guide","howto","how","说明","怎么玩","คู่มือ"]);export function isHelpWord(e){return $.has(e.trim().toLowerCase())}export function isGuideWord(e){return d.has(e.trim().toLowerCase())}
1
+ import{existsSync as e,mkdirSync as t,readFileSync as n,writeFileSync as r}from"node:fs";import{homedir as o}from"node:os";import{dirname as s,join as c}from"node:path";import chalk from"chalk";import{getConfig as i}from"./config.js";export function uiLang(){const e=(i().language||"en").toLowerCase();return e.startsWith("zh")?"zh":e.startsWith("th")?"th":"en"}export function tx(e,t=uiLang()){return"string"==typeof e?e:("zh"===t?e.zh:"th"===t?e.th:void 0)??e.en}export function asciiOnly(){if("1"===process.env.ICOA_ASCII)return!0;const e=process.env.LC_ALL||process.env.LC_CTYPE||process.env.LANG||"";return""!==e&&!/utf-?8/i.test(e)}export function dw(e){let t=0;for(const n of e.replace(u,"")){const e=n.codePointAt(0)??0;3633===e||e>=3636&&e<=3642||e>=3655&&e<=3662||(t+=e>65535||e>=11904&&e<=42191||e>=44032&&e<=55203||e>=63744&&e<=64255?2:1)}return t}function a(e,t){const n=dw(e);return n>=t?`${e} `:e+" ".repeat(t-n)}export function wrapText(e,t){const n=[];for(const r of e.split("\n")){const e=r.match(/[⺀-꓏가-힣豈-﫿]|[^\s⺀-꓏가-힣豈-﫿]+\s*|\s+/g)??[];let o="";for(const r of e){const e=/^[,.;:!?)\]}、。,;:!?)】」』…]/.test(r);o&&!e&&dw(o)+dw(r.trimEnd())>t&&(n.push(o.trimEnd()),o=""),o+=r}n.push(o.trimEnd())}return n}const u=new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`,"g");function l(){return process.env.ICOA_SEEN_FILE||c(o(),".icoa","seen-surfaces.json")}function p(){try{const e=JSON.parse(n(l(),"utf8"));return e&&"object"==typeof e?e:{}}catch{return{}}}export function seenBefore(e){return"1"!==process.env.ICOA_FRESH&&e in p()}export function markSeen(n){if("1"!==process.env.ICOA_FRESH)try{const o=l(),c=p();if(c[n])return;c[n]=(new Date).toISOString(),e(s(o))||t(s(o),{recursive:!0}),r(o,`${JSON.stringify(c,null,1)}\n`)}catch{}}const f={readMe:{en:"read me first",zh:"先读这个",th:"อ่านก่อน"},next:{en:"next, type:",zh:"下一步敲:",th:"ขั้นต่อไป พิมพ์:"},help:{en:"help = these steps",zh:"help = 这些步骤",th:"help = ขั้นตอนนี้"},guide:{en:"guide = full sheet",zh:"guide = 完整说明",th:"guide = คู่มือเต็ม"},leave:{en:"leave",zh:"离开",th:"ออก"},done:{en:"all steps done — explore, or",zh:"步骤都做完了 —— 自由探索,或",th:"ทำครบแล้ว — ลองเล่น หรือ"},optional:{en:"optional",zh:"可选",th:"ไม่บังคับ"}};export function currentNext(e){if(e.next)return e.next();for(const t of e.steps)if(!(t.optional||t.done&&t.done()))return t.verb;return null}export function renderPanel(e,t,n){const r=n?.lang??uiLang(),o=n?.ascii??asciiOnly(),s=e=>tx(e,r),c=o?"":"📖 ",i=o?"":"🧭 ",u=o?">":"▸",l=o?"<-":"↩",p=currentNext(e),h=e.helpWord??"help",$=e.leave??{verb:"back",what:f.leave},d=`${c}${s(e.title)}`;if("compact"===t){const t=p?`${chalk.gray(` ${u} ${s(f.next)} `)}${chalk.bold.green(p)}`:`${chalk.gray(` ${u} ${s(f.done)} `)}${chalk.cyan($.verb)}`,n=s(f.help).replace(/^help/,h),r=` ${chalk.bold.white(d)}${t}${chalk.gray(` · ${i}${n}${e.guide?` · ${s(f.guide)}`:""}`)}`;if(dw(r)<=80)return[r];const o=` ${chalk.bold.white(d)}${t}${chalk.gray(` · ${i}${n}`)}`;return[dw(o)<=80?o:` ${chalk.bold.white(d)}${t}${chalk.gray(` · ${i}${h}`)}`]}const g=[];g.push(` ${chalk.bold.white(d)}${chalk.gray(` — ${s(f.readMe)}`)}`);for(const t of wrapText(s(e.what),76))g.push(chalk.gray(` ${t}`));const x=Math.min(18,Math.max(6,...e.steps.map(e=>dw(e.verb))))+2;e.steps.forEach((e,t)=>{const n=null!==p&&e.verb===p,r=!n&&!0===e.done?.(),c=n?chalk.bold.green(o?"> ":"▸ "):r?chalk.green(o?"[x]":"✅"):e.optional?chalk.gray(o?" - ":" ·"):chalk.gray(o?"[ ]":"○ "),i=n?chalk.bold.green(a(e.verb,x)):chalk.cyan(a(e.verb,x)),u=wrapText(s(e.what)+(e.optional?chalk.gray(` (${s(f.optional)})`):""),68-x);g.push(` ${chalk.white(String(t+1).padStart(2))} ${c} ${i}${chalk.gray(u[0]??"")}`);for(const e of u.slice(1))g.push(`${" ".repeat(10+x)}${chalk.gray(e)}`)});for(const t of e.notes??[])for(const e of wrapText(s(t),74))g.push(chalk.gray(` ${e}`));const y=p?` ${chalk.bold.green(`${u} ${s(f.next)} ${p}`)}`:` ${chalk.gray(`${u} ${s(f.done)} `)}${chalk.cyan($.verb)}`;return g.push(`${y}${chalk.gray(` ${l} ${$.verb} · ${i}${h}${e.guide?" · guide":""}`)}`),g}export function footerLine(e,t){const n=t?.lang??uiLang(),r=t?.ascii??asciiOnly(),o=e=>tx(e,n),s=r?">":"▸",c=r?"<-":"↩",i=r?"":"🧭 ",a=currentNext(e),u=e.leave??{verb:"back",what:f.leave};return` ${a?chalk.bold.green(`${s} ${o(f.next)} ${a}`):`${chalk.gray(`${s} ${o(f.done)} `)}${chalk.cyan(u.verb)}`}${chalk.gray(` ${c} ${u.verb} · ${i}${e.helpWord??"help"}`)}`}const h=[];export function currentSurface(){return h.length?h[h.length-1]:null}export function enterPanel(e,t){const n=currentSurface();n&&n.id===e.id&&h.pop(),h.push(e);const r=t?.mode??(seenBefore(e.id)?"compact":"full");if(!t?.quiet){console.log();for(const t of renderPanel(e,r))console.log(t);console.log()}return markSeen(e.id),r}export function leavePanel(e){if(!e)return void h.pop();const t=h.map(e=>e.id).lastIndexOf(e);t>=0&&h.splice(t,1)}export function printHelp(){const e=currentSurface();if(!e)return!1;console.log();for(const t of renderPanel(e,"full"))console.log(t);return console.log(),!0}export function printGuide(){const e=currentSurface();return!!e&&(e.guide?(console.log(),e.guide(),console.log(),!0):printHelp())}const $=new Set(["help","/help","?","/?","h","帮助","帮助我","ช่วย"]),d=new Set(["guide","/guide","howto","how","说明","怎么玩","คู่มือ"]);export function isHelpWord(e){return $.has(e.trim().toLowerCase())}export function isGuideWord(e){return d.has(e.trim().toLowerCase())}
@@ -0,0 +1 @@
1
+ import{spawnSync as o}from"node:child_process";import{existsSync as r,mkdtempSync as e,readFileSync as t,rmSync as n,statSync as s}from"node:fs";import{tmpdir as i}from"node:os";import{join as c}from"node:path";import{pathToFileURL as f}from"node:url";const a=["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome","/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge","/Applications/Chromium.app/Contents/MacOS/Chromium","/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"],p=["google-chrome","google-chrome-stable","chromium","chromium-browser","microsoft-edge","brave-browser"];export function findBrowser(){if(process.env.ICOA_NO_PDF)return null;if("darwin"===process.platform)return a.find(o=>r(o))??null;if("linux"===process.platform||function(){try{return/microsoft/i.test(t("/proc/version","utf8"))}catch{return!1}}())for(const r of p){const e=o("sh",["-c",`command -v ${r}`],{encoding:"utf8"}),t=(e.stdout||"").trim();if(0===e.status&&t)return t}return null}export function htmlToPdf(t,a,p=9e4){const m=findBrowser();if(!m)return{ok:!1,reason:"no-browser"};const u=e(c(i(),"icoa-pdf-"));try{n(a,{force:!0}),o(m,["--headless=new","--disable-gpu","--no-first-run","--no-default-browser-check","--no-pdf-header-footer",`--user-data-dir=${u}`,`--print-to-pdf=${a}`,f(t).href],{timeout:p,stdio:"ignore"});const e=r(a)&&s(a).size>1e4;return e?{ok:e,browser:m}:{ok:!1,browser:m,reason:"failed"}}catch{return{ok:!1,browser:m,reason:"failed"}}finally{try{n(u,{recursive:!0,force:!0})}catch{}}}
@@ -1 +1 @@
1
- import chalk from"chalk";import e from"string-width";import{localized as o}from"./learn-curricula.js";import{completedCount as n}from"./learn-state.js";import{t}from"./learn-i18n.js";import{arenaCadence as r}from"./learn-contest.js";import{getConfig as a}from"./config.js";import{icoaBannerLines as l}from"./banner.js";import{renderCharts as s,detectCaps as c}from"./render-card.js";import{replyChipLabel as g}from"./learn-replies.js";function i(){return(a().language||"en").toLowerCase()}function d(e,o,n){const t=i();return t.startsWith("zh")?o:t.startsWith("th")?n:e}let h="normal";export function resolveLearnWidth(e){return"normal"===e.learnWidth||"wide"===e.learnWidth||"wider"===e.learnWidth||"widest"===e.learnWidth?e.learnWidth:e.learnWide?"wide":"normal"}export function setLearnWidth(e){h=e}export function learnWidthCap(e=h){return"widest"===e?160:"wider"===e?120:"wide"===e?96:64}export function learnW(){const e=process.stdout.columns||69,o=Math.max(40,Math.min(64,e-5));return"normal"===h?o:Math.max(o,Math.min(e-6,learnWidthCap()))}const y=learnW;function u(e="─"){return e.repeat(y()+2)}function p(o,n){if(e(o)<=n)return o;let t=o;for(;t.length>0&&e(t)>Math.max(1,n-1);)t=t.slice(0,-1);return t.trimEnd()+"…"}function b(e,o,n=20){const t=o>0?e/o:0,r=Math.floor(t*n),a=n-r;return`${chalk.green("█".repeat(r))+chalk.gray("░".repeat(a))} ${(100*t).toFixed(1)}%`}function m(e){return e>=30?chalk.red("🔥🔥🔥 "+e+" days"):e>=7?chalk.yellow("🔥 "+e+" days"):e>=1?chalk.gray("· "+e+" day"+(e>1?"s":"")):chalk.gray("—")}export function renderWelcome(e,o,r){const a=i(),l=e.totalCards,s=n(o,l),c=l-s,g=e.modules.find(e=>o.currentCard>=e.cardRange[0]&&o.currentCard<=e.cardRange[1]),d=/demo/i.test(e.id);if(console.log(),console.log(chalk.cyan(" ╭"+u("═"))),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ║ ")+chalk.bold.white(" "+(e.name?.trim()||t("academy_title",a)))),console.log(chalk.cyan(" ║")),r)console.log(chalk.cyan(" ║ ")+chalk.white(" "+t(d?"welcome_new_demo":"welcome_new",a)));else{const e=new Date(o.lastSeenAt),n=Math.floor((Date.now()-e.getTime())/36e5),r=n<1?t("just_now",a):n<24?`${n}${t("ago_hours",a)}`:`${Math.floor(n/24)}${t("ago_days",a)}`;console.log(chalk.cyan(" ║ ")+chalk.white(` ${t("welcome_back",a)} ${r}`))}console.log(chalk.cyan(" ║"));const h=p(g?`${g.number}. ${g.name}`:"—",y()-14);console.log(chalk.cyan(" ║ ")+" "+chalk.gray(t("module",a).padEnd(11))+chalk.white(h)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(t("progress",a).padEnd(11))+b(s,l,Math.max(6,Math.min(20,y()-26-`${s}/${l}`.length)))+chalk.gray(` (${s}/${l})`)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(t("streak",a).padEnd(11))+m(o.streakDays)),c>0&&o.currentCard<=l&&console.log(chalk.cyan(" ║ ")+" "+chalk.gray(t("next_card",a).padEnd(11))+chalk.white(`#${o.currentCard} ${t("of",a)} ${l}`)),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ╰"+u("═"))),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const f=0===s?t("continue_start",a):`${t("continue_resume",a)} ${o.currentCard}`;console.log(chalk.bold.green(" continue")+chalk.gray(" "+f)),console.log(chalk.yellow(" status")+chalk.gray(" "+t("status_full",a))),o.bookmarks.length>0&&console.log(chalk.yellow(" bookmarks")+chalk.gray(` ${o.bookmarks.length} ${t("bookmarks_desc",a)}`)),console.log(chalk.gray(" quit")+chalk.gray(" "+t("quit_desc",a))),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log()}function f(o,n){const r=i(),a=o.module,l=n.modules.find(e=>e.number===a),s=l?l.name:t("unknown_module",r),c=t("module",r).replace(":","").trim(),g=p(`${t("card",r)} ${o.number} / ${n.totalCards} · ${c} ${a} · ${s}`,y()-4);console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(g)+" "+chalk.cyan("─".repeat(Math.max(0,y()-e(g)-4))))}function w(){console.log(chalk.cyan(" ╰"+u())),console.log()}function $(e){console.log(chalk.cyan(" │ ")+chalk.white(e))}function k(){console.log(chalk.cyan(" │"))}const _=/[┌┐└┘├┤┬┴┼─│╔╗╚╝═║╠╣╦╩╬▓▒░█]/;function x(e){return/^(?: {4}|\t)/.test(e)||_.test(e)||/ {3,}/.test(e)}const C=/[\u0E00-\u0E7F]/;function v(e){try{return new Intl.Segmenter("th",{granularity:e})}catch{return null}}const M=v("word"),S=v("grapheme");export function wrapMixed(o,n){const t=[];let r="",a=0,l=!1;for(const s of function(o){const n=[],t=o=>{let t="",r="";const a=()=>{t&&(n.push({t:"atom",s:t}),t="")},l=()=>{if(r){if(a(),M)for(const{segment:e}of M.segment(r))if(e.length<=20)n.push({t:"atom",s:e});else if(S)for(const o of S.segment(e))n.push({t:"atom",s:o.segment});else for(const o of e)n.push({t:"atom",s:o});else for(const e of r)n.push({t:"atom",s:e});r=""}};for(const s of o)" "===s?(l(),a(),n.push({t:"space"})):C.test(s)?r+=s:2===e(s)?(l(),a(),n.push({t:"wide",s:s})):(l(),t+=s);l(),a()},r=/`[^`]*`/g;let a,l=0;for(;null!==(a=r.exec(o));)t(o.slice(l,a.index)),n.push({t:"code",s:a[0]}),l=a.index+a[0].length;return t(o.slice(l)),n}(o)){if("space"===s.t){""!==r&&(l=!0);continue}const o=s.s,c=e("code"===s.t?o.replace(/`/g,""):o),g=l?1:0,i="atom"===s.t&&o.length<=2&&/^[.,;:!?)\]}…'"]+$/.test(o);""!==r&&!i&&a+g+c>n?(t.push(r),r=o,a=c,l=!1):(l&&(r+=" ",a+=1,l=!1),r+=o,a+=c)}return r&&t.push(r),t}const j=/\b(?:Common bug|Common mistake|Common error|Pitfall|Gotcha|Footgun)\b[::]?|\b(?:Warning|Caution)\b[::]|(?:常见错误|常见陷阱|常见误区|陷阱|注意|警告|误区)[::]/gi,A=String.fromCharCode(1),W=String.fromCharCode(2),R=new RegExp(`([${A}${W}])`),z=/(^|[^\w*])\*\*(?=\S)([^\n]+?)(?<=\S)\*\*(?![\w*])/g;function L(e){if(!e.includes("**"))return e;const o=e.replace(/`[^`]*`/g,e=>"`"+"x".repeat(e.length-2)+"`");let n,t="",r=0;for(z.lastIndex=0;null!==(n=z.exec(o));){const o=n.index+n[1].length,a=o+2+n[2].length;t+=e.slice(r,o)+A+e.slice(o+2,a)+W,r=a+2}return t+e.slice(r)}function E(e,o,n){if(n&&(e.includes(A)||e.includes(W)||n.b)){let t="";for(const r of e.split(R))r===A?n.b=!0:r===W?n.b=!1:r&&(t+=E(r,o||n.b));return t}const t=o?chalk.bold.white:chalk.white;let r,a="",l=0;for(j.lastIndex=0;null!==(r=j.exec(e));)r.index>l&&(a+=t(e.slice(l,r.index))),a+=chalk.bold.yellow(r[0]),l=r.index+r[0].length;return l<e.length&&(a+=t(e.slice(l))),a}function P(e,o=!1,n){let t="",r=0;const a=/`([^`]*)`/g;let l;for(;null!==(l=a.exec(e));)l.index>r&&(t+=E(e.slice(r,l.index),o,n)),t+=chalk.cyan(l[1]),r=l.index+l[0].length;return r<e.length&&(t+=E(e.slice(r),o,n)),t}function q(e,o=!1){let n=!1;for(const t of e.split("\n")){if(/^\s*```/.test(t)){n=!n;continue}if(n){console.log(chalk.cyan(" │ ")+chalk.cyan(` ${t}`));continue}if(""===t){k();continue}if(x(t)){console.log(chalk.cyan(" │ ")+chalk.white(t));continue}const e={b:!1};for(const n of wrapMixed(L(t),y()-6))console.log(chalk.cyan(" │ ")+` ${P(n,o,e)}`)}}function T(e,o){const n=[];for(const t of e.split("\n"))""!==t?x(t)?n.push(t):n.push(...wrapMixed(t,o)):n.push("");return n}let N=!1,F=!1;export function setLearnAiEnabled(e,o=e){N=e,F=o}let I=new Set;export function setLearnPqsViewCards(e){I=e}let O=new Map;export function setLearnHonorRanks(e){O=e}const D=["①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩"];let B=[];export function setLearnReplies(e){B=e}let H=[];export function setLearnFaqs(e){H=e}let Q=null;export function setLearnHometask(e){Q=e}let V="full";export function setLearnFooterProfile(e){V=e}let Y=null;export function setLearnFooterExtra(e){Y=e}function G(){const e=Y?.();e&&console.log(chalk.gray(" "+e))}let K=null;export function setLearnPracticeChips(e){K=e}let Z=!1;export function setLearnShellLane(e){Z=e}let X=!1,J=new Map;export function setLearnArenaCards(e){J=new Map(e.map(e=>[e.card,e.slot]))}export function setLearnArenaLane(e){X=e}export function learnCheckpointVerb(){return U?"duck":null}let U=!1;export function setLearnDuckLane(e){U=e}let ee=null;export function setLearnPracticeCount(e){ee=e}export function renderHonorWall(e){const o=i().startsWith("zh"),{totals:n,chapters:t}=e,r=n.gold+n.silver+n.bronze,a=(e,o)=>o>0?chalk.bold.white(`${e}×${o}`):chalk.gray(`${e}×0`);if(console.log(chalk.gray(" ─────────────────────────────────────────")),console.log(chalk.bold.white(o?" 🏅 奖牌墙 ":" 🏅 Medal wall ")+a("🥇",n.gold)+chalk.gray(" · ")+a("🥈",n.silver)+chalk.gray(" · ")+a("🥉",n.bronze)+chalk.gray(o?" (永久 — 挂上墙就不会摘下)":" (permanent — once earned, never removed)")),0===r){const n=null!=e.floor?`${e.floor}+`:o?"高分":"a high score";return console.log(chalk.gray(o?` 还没有奖牌 — 单卡提问评分 ${n} 并进入该卡前三,即可永久挂墙 🥇🥈🥉`:` No medals yet — score ${n} on a card and hold its top-3 to hang one 🥇🥈🥉`)),void console.log(chalk.gray(" ─────────────────────────────────────────"))}const l=t.map(e=>{const o=`Ch${e.chapter}`,n=(e.gold>0?`🥇${e.gold}`:"")+(e.silver>0?`🥈${e.silver}`:"")+(e.bronze>0?`🥉${e.bronze}`:"");return n?chalk.white(`${o} ${n}`):chalk.gray(`${o} —`)}).join(chalk.gray(" "));console.log(" "+l);const s=t.flatMap(e=>e.cards.map(o=>({...o,chapter:e.chapter})));s.sort((e,o)=>e.rank-o.rank||e.chapter-o.chapter||e.card-o.card);for(const e of s.slice(0,24)){const n=(e.since||"").slice(0,10);console.log(chalk.white(` ${e.icon} `)+chalk.gray(`Ch${e.chapter} · `)+chalk.white(o?`第 ${e.card} 张`:`card ${e.card}`)+chalk.gray(` · ${e.score}`)+(n?chalk.gray(o?` · 始于 ${n}`:` · since ${n}`):""))}s.length>24&&console.log(chalk.gray(o?` …还有 ${s.length-24} 枚`:` …and ${s.length-24} more`)),console.log(chalk.gray(" ─────────────────────────────────────────"))}export function renderKnowledgeCard(n,r){const a=i(),l=o(n,a);f(l,r),k();const u=wrapMixed(l.title,y()-4);for(const e of u)$(chalk.bold.yellow(e));$(chalk.gray("─".repeat(Math.min(Math.max(...u.map(o=>e(o))),y()))));const p=!!(n.chart_ids&&n.chart_ids.length>0);if(p&&s(n.chart_ids.slice(0,1),r.charts,c()),l.key_point&&""!==l.key_point.trim()?(p||k(),function(e,o,n){const t=i().startsWith("zh"),r=c().cols,a="-".repeat(Math.min(y(),Math.max(24,r-6))),l=t?"要点":d("KEY POINT","要点","ประเด็นสำคัญ"),s=t?`第 ${o} / ${n} 张`:d(`Card ${o} / ${n}`,"",`การ์ด ${o} / ${n}`);console.log(chalk.cyan(" │ ")+chalk.green(a)),console.log(chalk.cyan(" │ ")+chalk.green(`${l} · ${s}`));for(const o of wrapMixed(e,y()-6))console.log(chalk.cyan(" │ ")+chalk.bold.green(" "+o));console.log(chalk.cyan(" │ ")+chalk.green(a)),k()}(l.key_point,l.number,r.totalCards)):p||k(),l.body.filter(e=>null!=e&&""!==e.trim()).forEach((e,o)=>{const n=0===o?e.match(/^([\s\S]*?(?:[.!?](?=\s|$)|[。!?]))(\s[\s\S]*)?$/):null;if(n&&n[1].trim().length<=180){q(n[1],!0);const e=n[2]?.trimStart();e&&q(e,!1)}else q(e,!1);k()}),l.icoaConnection){$(chalk.magenta(" "+t("icoa_connection",a))),$(chalk.gray(" "+"─".repeat(20)));for(const e of wrapMixed(l.icoaConnection,y()-6))$(" "+chalk.magenta(e));k()}if(n.check){const e=a.slice(0,2).toLowerCase(),o=n[`_${e}`],t=o?.checkStatement??o?.check?.statement??n.check.statement;for(const o of wrapMixed("zh"===e?"请回答 (输 y 或 n):":"th"===e?"เช็กความเข้าใจ (พิมพ์ y หรือ n):":"Quick comprehension check (type y or n):",y()-10))$(chalk.cyan(" 🤔 "+o));$(chalk.gray(" "+"─".repeat(20)));for(const e of wrapMixed(t,y()-6))$(" "+chalk.white(e));k()}w(),function(o,n){const t=i().startsWith("zh"),r=c().cols,a="-".repeat(Math.min(y(),Math.max(24,r-6))),l=chalk.gray(" ");if("minimal"===V){const e=K?K(o.number):null;console.log(chalk.gray(" "+a)),console.log(chalk.gray(" "+d(`Card ${o.number} / ${n.totalCards}`,`第 ${o.number} / ${n.totalCards} 张`,`การ์ด ${o.number} / ${n.totalCards}`))+(e?chalk.gray(d(" · practice "," · 本卡练习 "," · ฝึก "))+e:""));const r=[];if(o.check?(r.push(chalk.bold.green("[y]")+chalk.gray(d(" yes"," 是"," ใช่"))),r.push(chalk.bold.green("[n]")+chalk.gray(d(" no"," 否"," ไม่ใช่")))):r.push(chalk.bold.green("[ok]")+chalk.gray(d(" next"," 下一张"," ถัดไป"))),e){const o=Math.max(1,(e.match(/\[\d\]/g)??[]).length),n=Array.from({length:o},(e,o)=>`[${o+1}]`).join("");r.push(chalk.bold.cyan(n)+chalk.gray(d(" practice"," 练习"," ฝึก")))}Z&&r.push(chalk.bold.magenta("[sh]")+chalk.gray(t?" 实验台":" shell")),N&&r.push(chalk.bold.magenta("[/ai]")+chalk.gray(d(" 🐼 Panda tutor"," 🐼 熊猫导师"," 🐼 ครูแพนด้า")));const s=J.get(o.number);return X&&s?r.push(chalk.bold.magenta(`[contest ${s}]`)+chalk.gray(t?" 检查点":" checkpoint")):X&&0===J.size&&r.push(chalk.bold.magenta("[battle]")+chalk.gray(t?" 进竞技场":" arena")),U&&r.push(chalk.bold.magenta("[duck]")+chalk.gray(t?" 跑仿真":d(" sim bench"," 跑仿真"," ตัวจำลอง"))),o.flow&&o.flow.length>0&&r.push(chalk.bold.magenta("[flow]")+chalk.gray(t?" 互动走一遍":" walk it")),r.push(chalk.bold.cyan("[b]")+chalk.gray(d(" back"," 上一张"," ย้อนกลับ"))),r.push(chalk.bold.yellow("[e]")+chalk.gray(d(" ask/report"," 提问/报告"," ถาม/แจ้งปัญหา"))),r.push(chalk.gray("[quit]")+chalk.gray(d(""," 退出"," ออก"))),console.log(" "+r.join(l)),G(),void console.log()}const s=[];o.check?(s.push(chalk.bold.green("[y]")+chalk.gray(t?" 是":" yes")),s.push(chalk.bold.green("[n]")+chalk.gray(t?" 否":" no"))):s.push(chalk.bold.green("[ok]")+chalk.gray(t?" 继续":" next")),o.flow&&o.flow.length>0&&s.push(chalk.bold.magenta("[flow]")+chalk.gray(t?" 互动走一遍":" walk it")),N&&s.push(chalk.bold.magenta("[/ai]")+chalk.gray(t?" 🐼 熊猫导师":" 🐼 Panda tutor")),F&&s.push(chalk.bold.magenta("[/submit]")+chalk.gray(t?" 提问评分":" prompt score"));const u=O.get(o.number);var p;s.push(chalk.bold.magenta(u?`[/honors ${p=u,D[p-1]??`#${p}`}]`:"[/honors]")+chalk.gray(t?" 排行":" board")),"normal"===h?s.push(chalk.bold.cyan("[wide]")+chalk.gray(t?" 宽屏":" widen")):("wide"===h?s.push(chalk.bold.cyan("[wider]")+chalk.gray(t?" 更宽":" wider")):"wider"===h?(s.push(chalk.bold.cyan("[widest]")+chalk.gray(t?" 最宽":" widest")),s.push(chalk.bold.cyan("[wide]")+chalk.gray(t?" 回宽屏":" back to wide"))):s.push(chalk.bold.cyan("[wider]")+chalk.gray(t?" 回 wider":" back to wider")),s.push(chalk.bold.cyan("[normal]")+chalk.gray(t?" 标准":" standard")));const b=g(B,H,o.number,t),m=b.startsWith("💬");if(s.push((m?chalk.bold.yellow("[r]"):chalk.gray("[r]"))+(m?chalk.bold.white(` ${b}`):chalk.gray(` ${b}`))),s.push(chalk.bold.yellow("[e]")+chalk.gray(t?" 提问或报告":" ask or report")),Q){const e=Q,o=`${e.done}/${e.total}`,n=e.completedAt?chalk.bold.green:chalk.bold.cyan;s.push(n("[task]")+chalk.gray(t?` 本周 ${o}`:` week ${o}`))}s.push(chalk.bold.cyan("[b]")+chalk.gray(t?" 上一张":" back")),s.push(chalk.bold.cyan("[card N]")+chalk.gray(t?" 跳转":" jump")),s.push(chalk.gray("[reload]")+(t?chalk.gray(" 刷新"):"")),s.push(chalk.gray("[quit]")+(t?chalk.gray(" 退出"):""));const f=e(a);console.log(chalk.gray(" "+a)),console.log(chalk.gray(" "+(t?`第 ${o.number} / ${n.totalCards} 张`:`Card ${o.number} / ${n.totalCards}`)));let w="",$=0;for(const o of s){const n=e(o);w&&$+2+n>f?(console.log(" "+w),w=o,$=n):(w=w?w+l+o:o,$=w===o?n:$+2+n)}w&&console.log(" "+w),console.log(" "+chalk.magenta("✍ ")+chalk.magenta("[/py]")+chalk.gray(t?" Python 草稿本":" Python scratchpad")+l+chalk.magenta("[/pylist]")+chalk.gray(t?" 我的草稿":" my files")),console.log(chalk.gray(" "+a));const k=[t?"e = 就这张卡提问,或报告问题":"e = ask about this card, or report a problem",t?"更多: bookmark / unbookmark · status · lang · link":"more: bookmark / unbookmark · status · lang · link"];for(const e of k)for(const o of wrapMixed(e,f))console.log(chalk.gray(" "+o));G(),console.log()}(n,r)}export function renderCheckFeedback(e,o,n,t=!1){const r=i().startsWith("zh");if(console.log(),n)console.log(chalk.green(" ✓ ")+chalk.white(r?"答对了。":"Correct."));else if(console.log(chalk.yellow(" ✗ ")+chalk.white(r?"记下了,继续。":"Noted — moving on.")),t){const o="y"===e.check?.answer?r?"是":"Yes":r?"否":"No";console.log(chalk.gray(" "+(r?"正确答案: ":"Answer: ")+o+". "+(r?"回看上面那段。":"Re-read the paragraph above.")))}const a=r?e._zh?.solution??e.solution:e.solution;if(a&&a.length>0){console.log(),console.log(chalk.cyan(" 📝 "+(r?"解答:":"Worked solution:")));for(const e of a){for(const o of wrapMixed(e,y()-4))console.log(chalk.white(" "+o));console.log()}}console.log()}function oe(e){return[chalk.white(" "+(e?"编著:Charlie Zhu":"Created & edited by Charlie Zhu")),chalk.gray(" "+(e?"ICOA 2026 创始人 · 课程总架构师":"Founder & Chief Curriculum Architect · ICOA 2026"))]}export function renderPhaseComplete(e,o,n,t,a,s){const c=r(n.cardRange[1]-n.cardRange[0]+1),g=i().startsWith("zh"),[d,h]=n.cardRange,u=o.checkResults||{};let p=0,b=0;for(let e=d;e<=h;e++){const o=u[String(e)];o&&(p++,o.correct&&b++)}const m="-".repeat(48);console.log();for(const e of l(" "))console.log(e);console.log(),console.log(chalk.bold.yellow(" "+m)),console.log(chalk.bold.yellow(" "+(g?`阶段 ${n.number} 完成`:`Phase ${n.number} complete`))+chalk.gray(" · ")+chalk.white(n.name));const f=p>0&&b===p?chalk.bold.green:chalk.bold.white;console.log(chalk.gray(" "+(g?"理解检查得分: ":"comprehension score: "))+f(`${b}/${p}`)+chalk.gray(0===p?g?" (本阶段未作答 y/n)":" (no y/n answered)":""));const w=String(h).length;let $=!1,k=0,_=0,x=0,C=0;for(let o=d;o<=h;o++){const n=e.cards.find(e=>e.number===o);if(!n)continue;const t=n,r=t.title??t.badge??"",a=(g?t._zh?.title??t._zh?.badge??r:r)||"",l=null!=n.check,s=u[String(o)];let c;c=s?s.correct?chalk.green("✓"):chalk.red("✗"):l?chalk.gray("○"):chalk.gray("·");const i=ee?ee(o):null;i&&($=!0);const d=i?(i.solved>=i.total?chalk.green:i.solved>0?chalk.yellow:chalk.gray)(` ⚔${i.solved}/${i.total}`):"";i&&(k++,i.solved>=i.total&&_++,x+=i.solved,C+=i.total);const h=wrapMixed(a,y()-10-w-(i?6:0)),p=h[0]+(h.length>1?"…":"");console.log(chalk.gray(` ${String(o).padStart(w)} `)+c+d+chalk.white(" "+p))}if(console.log(chalk.gray(g?" ✓ 答对 · ✗ 答错 · ○ 未作答 · 无 y/n 的卡不计分":" ✓ correct · ✗ wrong · ○ unanswered · cards without a y/n are unscored")),$&&console.log(chalk.bold.cyan(" ⚔ "+(g?"卡片练习: ":"practice: "))+(_>=k?chalk.bold.green:chalk.bold.white)(`${_}/${k}`)+chalk.gray(g?` 卡全完成 · ${x}/${C} 题 AC · 行内 ⚔已过/共(绿 完成 · 黄 部分 · 灰 未碰)`:` cards complete · ${x}/${C} problems AC · ⚔solved/total per row (green done · yellow partial · gray untouched)`)),a){const e=e=>"green"===e?chalk.bold.green:"blue"===e?chalk.bold.cyan:"yellow"===e?chalk.bold.yellow:chalk.bold.red;console.log(chalk.bold.magenta(" ⭐ "+(g?"提问得分 (best): ":"Prompt scores (best): "))+(0===a.length?chalk.gray(g?"本阶段尚未提问 — 用 /ai 研究,再 /submit 评分":"none this phase — research with /ai, then /submit"):a.map(o=>chalk.gray((g?"卡":"#")+o.card+" ")+e(o.tier)(String(o.score))).join(chalk.gray(" · "))))}if(s&&!s.configured){const o=h-d+1>12,n="fill"===e.practiceMode;console.log(chalk.gray(o?g?" 🔒 本阶段通关标准制作中 — 很快更新(360 层第二阶段标准设计中)":" 🔒 Pass criteria for this phase are in production — coming soon (360-tier second-stage standard in design)":n?g?c.n>1?` 🔒 本阶段 ${c.n} 场判分赛制作中 — 很快更新;赛场挂在卡 ${c.cards},${c.n} 场全过解锁下一阶段(本轨无 research)`:` 🔒 本阶段的判分赛制作中 — 很快更新;赛场挂在卡 ${c.cards},通过即解锁下一阶段(本轨无 research)`:c.n>1?` 🔒 This phase’s ${c.n} judged arenas are in production — coming soon; they hang on cards ${c.cards} and all ${c.n} unlock the next phase (no research on this track)`:` 🔒 This phase’s judged arena is in production — coming soon; it hangs on card ${c.cards} and passing it unlocks the next phase (no research on this track)`:g?" 🔒 本阶段通关标准制作中 — 很快更新(标准范式:3 场练习赛 + 3 卡研究)":" 🔒 Pass criteria for this phase are in production — coming soon (standard: 3 arenas + 3 research cards)"))}if(s?.configured&&s.contest){const e=s.contest;if(e.slots&&e.slots.length>0)for(const o of e.slots){const e=chalk.bold.cyan(` ⚔ ${g?"练习赛":"arena"} ${n.number}-${o.slot}: `);o.passed?console.log(e+chalk.bold.green(`${o.best_ac}/${o.n} AC ✅`)):0===o.attempts?console.log(e+chalk.white(g?`${o.n} 题 · 过 ${o.need} 题 — `:`${o.n} problems · AC ${o.need} — `)+chalk.bold.green(`contest ${o.slot}`)):console.log(e+chalk.yellow(g?`最好 ${o.best_ac}/${o.n}(需 ${o.need})· 已试 ${o.attempts} 次 — `:`best ${o.best_ac}/${o.n} (need ${o.need}) · ${o.attempts} attempt(s) — `)+chalk.bold.green(`contest ${o.slot}`))}else{const o=chalk.bold.cyan(" ⚖ "+(g?"判分赛: ":"Contest: "));e.passed?console.log(o+chalk.bold.green(`${e.best_ac}/${e.n} AC ✅ `+(g?"已过关":"passed"))):0===e.attempts?console.log(o+chalk.white(g?`${e.n} 题 · 过 ${e.need} 题解锁 — 输入 `:`${e.n} problems · AC ${e.need} to pass — type `)+chalk.bold.green("contest")+chalk.white(g?" 开始":" to start")):console.log(o+chalk.yellow(g?`最好 ${e.best_ac}/${e.n} AC(需 ${e.need})· 已试 ${e.attempts} 次 — 输入 `:`best ${e.best_ac}/${e.n} AC (need ${e.need}) · ${e.attempts} attempt(s) — type `)+chalk.bold.green("contest")+chalk.yellow(g?" 再战":" to retry"))}}t&&console.log(chalk.gray(" "+(g?"下一阶段: ":"next: "))+chalk.bold.cyan(g?`阶段 ${t.number}`:`Phase ${t.number}`)+chalk.gray(" · ")+chalk.white(t.name)),console.log(chalk.bold.yellow(" "+m));for(const e of oe(g))console.log(e)}export function renderCurriculumComplete(e,o){const n=i().startsWith("zh"),t=o.checkResults||{},r="-".repeat(48);let a=0,s=0;console.log();for(const e of l(" "))console.log(e);console.log(),console.log(chalk.bold.green(" "+r)),console.log(chalk.bold.green(" 🏆 "+(n?`${e.name} — 全部完成!`:`${e.name} — complete!`))),console.log(chalk.bold.green(" "+r));for(const o of e.modules){const[e,r]=o.cardRange;let l=0,c=0;for(let o=e;o<=r;o++){const e=t[String(o)];e&&(l++,e.correct&&c++)}a+=l,s+=c;const g=l>0&&c===l?chalk.green:chalk.white;console.log(chalk.gray(" "+(n?`阶段 ${o.number}`:`Phase ${o.number}`).padEnd(8))+g(`${c}/${l}`.padEnd(7))+chalk.gray(o.name))}console.log(chalk.bold.green(" "+r)),console.log(chalk.bold.green(" "+(n?"总分 / overall: ":"Overall: "))+chalk.bold.white(`${s}/${a}`)),console.log(chalk.bold.green(" "+r));for(const e of oe(n))console.log(e);console.log()}export function renderMCQCard(e,n){const r=i(),a=o(e,r);f(a,n),k(),$(chalk.bold.yellow("🎯 "+a.title)),$(chalk.gray("─".repeat(Math.min(a.title.length+4,y())))),k();for(const e of T(a.question,y()-4))$(" "+e);k();for(const e of["A","B","C","D"])$(chalk.cyan(` ${e}.`)+" "+chalk.white(a.options[e]));k(),w(),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(" "+t("type_to_answer",r))),console.log(chalk.gray(" ")+chalk.bold.cyan("back")+chalk.gray(r.startsWith("zh")?" 上一张 · ":" previous card · ")+chalk.bold.cyan("card N")+chalk.gray(r.startsWith("zh")?" 跳转":" jump")),console.log()}export function renderMCQFeedback(e,n,r,a){const l=i(),s=o(e,l);console.log(),r?console.log(" "+chalk.bold.green(t("correct",l)+" ")+chalk.gray(`${t("one_point",l)} · ${n} = ${s.options[n]}`)):console.log(" "+chalk.bold.red(t("not_quite",l)+" ")+chalk.gray(`${t("you_chose",l)} ${n}; ${t("answer_is",l)} ${s.answer}.`)),console.log(),console.log(chalk.gray(" "+t("explanation",l)));for(const e of T(s.explanation,y()-4))console.log(chalk.gray(" "+e));const c=Object.values(a.mcqResults),g=c.filter(e=>e.correct).length;console.log(),console.log(chalk.gray(" "+t("mcq_accuracy_so_far",l)+" ")+chalk.white(`${g}/${c.length}`)),console.log(),r||(console.log(chalk.gray(" "+t("press_ok_continue",l)+" ")+chalk.bold.green("ok")+chalk.gray(" "+t("to_continue",l))),console.log())}export function renderPracticalCard(e,n){const r=i(),a=o(e,r);f(a,n),k(),$(chalk.bold.yellow("🛠 "+a.title)),$(chalk.gray("─".repeat(Math.min(a.title.length+4,y())))),k();for(const e of T(a.task,y()-4))$(" "+e);if(a.starterCode){k(),$(chalk.gray(" "+t("starter_code",r))),k();for(const e of a.starterCode.split("\n"))$(" "+chalk.cyan(e))}k(),w(),console.log(chalk.gray(" "+t("try_in_sandbox",r)+" ")+chalk.bold.cyan("!python3")+chalk.gray(" "+t("drops_into_python",r))),console.log(chalk.gray(" "+t("when_done",r))),console.log(chalk.gray(" ")+chalk.bold.green("done")+chalk.gray(" "+t("done_desc",r))),console.log(chalk.gray(" ")+chalk.bold.yellow("skip")+chalk.gray(" "+t("skip_desc",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log()}export function renderPracticalSuccess(e){const n=i(),r=o(e,n);console.log(),console.log(" "+chalk.bold.green(t("practical_recorded",n))),console.log(),console.log(chalk.gray(" "+t("reference_answer",n)));for(const e of T(r.successHint,y()-4))console.log(chalk.gray(" "+e));console.log(),console.log(chalk.gray(" "+t("press_ok_continue",n)+" ")+chalk.bold.green("ok")+chalk.gray(" "+t("to_continue",n))),console.log()}export function renderSimDemoCard(e,n){const r=i(),a=o(e,r);f(a,n),k(),$(chalk.bold.yellow("🎬 "+a.title)),k();for(const e of T(a.description,y()-4))$(" "+e);k(),$(chalk.gray(" "+t("sim_requires",r))),k(),w(),console.log(chalk.gray(" ")+chalk.bold.cyan("sim")+chalk.gray(" "+t("sim_launch_desc",r))),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+t("continue_to_next",r))),console.log(chalk.gray(" bookmark "+t("bookmark_desc",r))),console.log(chalk.gray(" back "+t("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 "+t("quit_desc",r))),console.log()}export function renderArenaTaskCard(e,n){const t=i(),r=t.startsWith("zh"),a=o(e,t);f(a,n),k(),$(chalk.bold.cyan("🏟 "+a.title)),$(chalk.gray(" "+a.origin+" · "+a.domain+" · "+a.metric)),k();for(const e of a.statement){for(const o of T(e,y()-4))$(" "+o);k()}$(chalk.bold.green(r?" 核心要点 — baseline → 解法的关键变化":" CORE DELTA — baseline → solution"));for(const e of a.core_delta)for(const o of T("• "+e,y()-6))$(" "+chalk.white(o));k(),$(chalk.gray((r?" 提交格式: ":" Submission: ")+a.submission_format)),a.hints&&$(chalk.gray(r?" 本题有 5 级提示 (a–e),进入 arena 后逐级解锁。":" 5 progressive hints (a–e) unlock inside the arena.")),k(),w(),console.log(chalk.gray(" ")+chalk.bold.cyan("arena "+a.task_id)+chalk.gray(r?" 动手做这道题(下载 / 提示 / 提交 / 榜单)":" open the arena (download / hints / submit / board)")),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续下一张":" continue to next")),console.log(chalk.gray(" back "+(r?"上一张":"previous"))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderComingSoonCard(e,n){const t=i(),r=t.startsWith("zh"),a=o(e,t);f(a,n),k(),$(chalk.bold.yellow("🔜 "+a.title)),k();const l=a.note||(r?"这道竞技场题目正在编写中,敬请期待。":"This arena task is coming soon.");for(const e of T(l,y()-4))$(" "+chalk.gray(e));k(),w(),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续":" continue")),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderMilestone(e,n){const r=i(),a=o(e,r),l=e.number===n.totalCards;console.log(),console.log(chalk.bold.yellow(" ╭"+u("═"))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+chalk.white(" "+t("milestone_header",r))),console.log(chalk.bold.yellow(" ║"));const s=` ${a.badge} ${a.emoji}`;console.log(chalk.bold.yellow(" ║ ")+chalk.bold.green(s)),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(t("in_wild_corresponds",r)));for(const e of T(a.realWorldLevel,y()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(e));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(t("whats_next",r)));for(const e of T(a.unlockedNext,y()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(e));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ╰"+u("═"))),console.log(),l?(console.log(chalk.gray(" "+t("demo_complete",r))),console.log(),console.log(chalk.gray(" "+t("unlock_full",r)+" ")+chalk.white(t("curriculum_name",r))+chalk.gray(",")),console.log(chalk.gray(" "+t("contact_team_leader",r)+" ")+chalk.bold.yellow("EA")+chalk.gray(" "+t("learn_token",r))),console.log(chalk.gray(" "+t("or_email",r)+" ")+chalk.cyan("australia@icoa2026.au")+chalk.gray(" "+t("for_partnership",r))),console.log(),console.log(chalk.gray(" "+t("type_quit",r)+" ")+chalk.bold.green("quit")+chalk.gray(" "+t("to_exit",r)+" ")+chalk.bold.green("status")+chalk.gray(" "+t("for_dashboard",r)))):(console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+t("continue_to_next",r))),console.log(chalk.gray(" status "+t("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 "+t("quit_desc",r)))),console.log()}export function renderStatus(o,r,a={}){const l=i(),s=l.startsWith("zh"),c=o.totalCards,g=n(r,c),d=r.checkResults||{},h=a.gate??null,u=!!a.gated,f=a.focus??"current",_=a.posForSlot??(e=>4===e?10:4*e),x=e=>a.practiceCount?a.practiceCount(e):ee?ee(e):null,C=r.currentCard,v=o.modules.find(e=>C>=e.cardRange[0]&&C<=e.cardRange[1]),M=(o,n)=>o+" ".repeat(Math.max(0,n-e((e=>e.replace(/\x1b\[[0-9;]*m/g,""))(o))));console.log();const S=`${o.name} — ${s?"状态":"Status"}`;console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(S)+" "+chalk.cyan("─".repeat(Math.max(4,y()-2-e(S))))),k(),$(" "+chalk.gray(t("total_progress",l)+" ")+b(g,c)+chalk.gray(` (${g}/${c})`)+chalk.gray(" "+t("streak",l)+" ")+m(r.streakDays));{let n=0,t=0,l=0,c=0,g=0,i=0;const u=[];let p=!1;for(const e of o.modules){for(let r=e.cardRange[0];r<=e.cardRange[1];r++){const e=x(r);e&&(n++,e.solved>=e.total&&t++);const a=o.cards.find(e=>e.number===r);null!=a?.check&&(l++,d[String(r)]?.correct&&c++)}const r=h?.phases.find(o=>o.phase===e.number);if(r?.configured)for(const o of r.contest?.slots??[])g++,o.passed?i++:u.push(Math.min(e.cardRange[1],e.cardRange[0]+_(o.slot)-1));r?.research&&(p=!0)}const b=(e,o)=>(e>=o?chalk.green:chalk.white)(`${e}/${o}`),m=[];n&&m.push(chalk.gray(s?"⚔ 练习卡 ":"⚔ practice cards ")+b(t,n)),g&&m.push(chalk.gray(s?"赛场 ":"arena ")+b(i,g)),l&&m.push(chalk.gray(s?"✓ 自测 ":"✓ checks ")+b(c,l)),m.length&&$(" "+m.join(chalk.gray(" "))),a._anyResearch=p;{let n=0;const t=[];let a=0,c=0,h=0;for(const e of o.modules)for(let l=e.cardRange[0];l<=e.cardRange[1];l++){c++,r.cardsCompleted.includes(l)&&a++;const e=o.cards.find(e=>e.number===l);null!=e?.check&&d[String(l)]&&h++;const s=x(l);s&&s.solved<s.total&&(n+=s.total-s.solved,t.push(l))}const p=s?"▸ 通关还差 ":"▸ to finish ",b=[],m=(e,o)=>{const n=[];let t=0;for(const r of o){const o=String(r).length+(n.length?3:0);if(t+o>e)break;t+=o,n.push(r)}return n};if(a<c&&b.push(chalk.gray(s?"卡片 ":"cards ")+chalk.white(""+(c-a))+chalk.gray(s?" 张未读":" unread")),l&&h<l&&b.push(chalk.gray("✓ ")+chalk.white(""+(l-h))+chalk.gray(s?" 题自测未答":" checks unanswered")),n>0){const o=s?`练习还差 ${n} 题`:`${n} practice problem${n>1?"s":""}`,r=s?"(卡 ":" (cards ",a=")",l=" │ ⚔ ",c=y()-e(l)-e(p)-e(o)-e(r+a);let g=m(c,t);g.length<t.length&&(g=m(c-e(` +${t.length}`),t)),!g.length&&t.length&&(g=[t[0]]);const i=t.length-g.length,d=g.join(" · ")+(i>0?` +${i}`:"");b.push(chalk.gray("⚔ ")+chalk.white(o)+chalk.gray(r+d+a))}if(g&&i<g){const o=(s?"赛 ":"arena ")+(g-i)+(s?" 场未过":" to pass"),n=s?"(卡 ":" (card ",t=")",r=" │ ",a=y()-e(r)-e(p)-e(o)-e(n+t);let l=m(a,u);l.length<u.length&&(l=m(a-e(` +${u.length}`),u)),!l.length&&u.length&&(l=[u[0]]);const c=u.length-l.length,d=l.length?n+l.join(" · ")+(c>0?` +${c}`:"")+t:"";b.push(chalk.gray(s?"赛 ":"arena ")+chalk.white(""+(g-i))+chalk.gray(s?" 场未过":" to pass")+chalk.yellow(d))}const f=a>0;f&&b.length?b.forEach((o,n)=>$(" "+(0===n?chalk.bold.yellow(p):" ".repeat(e(p)))+o)):f&&!b.length&&$(" "+chalk.bold.green(s?"✅ 通关条件已全部达成":"✅ every completion gate met"))}}k();const j=e=>s?`阶段 ${e}`:`Phase ${e}`,A=Math.max(10,Math.min(28,y()-54));for(const e of o.modules){const[n,t]=e.cardRange,a=t-n+1,l=r.cardsCompleted.filter(e=>e>=n&&e<=t).length,c=u&&!!h&&e.number>h.unlocked_through_phase,g=h?.phases.find(o=>o.phase===e.number);let i=0,b=0,m=0;const w=[],k=[];let S=0,W=0,R=0;const z=[];for(let e=n;e<=t;e++){const n=o.cards.find(o=>o.number===e);if(null!=n?.check){i++;const o=d[String(e)];o?(b++,o.correct?m++:k.push(e)):w.push(e)}const t=x(e);t&&(S++,R+=t.solved,t.solved>=t.total?W++:z.push(`${e}:${t.solved}/${t.total}`))}const L=g?.configured?g.contest?.slots??[]:[],E=e=>e.passed?chalk.green("✅"):e.attempts>0?chalk.yellow("❌"):chalk.gray("⬜"),P=l>=a&&(0===i||m===i)&&(0===S||W===S)&&(0===L.length||L.every(e=>e.passed))&&(!g?.research||g.research.passed),q=l>0||b>0||R>0||L.some(e=>e.attempts>0),T=c?chalk.gray("🔒"):P?chalk.green("✅"):e.number===v?.number?chalk.bold.cyan("▶ "):q?chalk.yellow("▶ "):chalk.gray("⬜"),N=p(e.name,A),F=[];if(F.push((l>=a?chalk.green:chalk.white)(`${l}/${a}`)+chalk.gray(s?"卡":"c")),i>0&&F.push(chalk.gray("✓")+(m===i?chalk.green:chalk.white)(`${m}/${i}`)),S>0&&F.push(chalk.gray("⚔")+(W===S?chalk.green:chalk.white)(`${W}/${S}`)+chalk.gray(s?"卡":"c")),L.length>0&&F.push(chalk.gray(s?"赛":"arena ")+L.map(E).join("")),g?.research&&F.push(chalk.gray("⭐")+(g.research.passed?chalk.green:chalk.white)(`${g.research.good_cards}/${g.research.need_cards}`)),$(" "+T+" "+chalk.white(M(j(e.number),s?5:8))+chalk.gray(M(N,A+1))+F.join(chalk.gray(" · "))),c||"all"!==f&&f!==e.number&&("current"!==f||e.number!==v?.number)){if(!c&&q&&!P){const o=[],t=L.filter(e=>!e.passed).map(o=>(o.attempts>0?chalk.yellow:chalk.gray)(`${e.number}-${o.slot}@${s?"卡":"card "}${n+_(o.slot)-1}`));t.length&&o.push(chalk.gray(s?"赛 ":"arena ")+t.join(chalk.gray(" · ")));const r=(e,o)=>e.slice(0,8).join(o)+(e.length>8?chalk.gray(" +"+(e.length-8)):"");z.length&&o.push(chalk.gray("⚔ ")+chalk.white(r(z," "))),k.length&&o.push(chalk.red("✗ ")+chalk.white(r(k.map(String),","))),w.length&&o.push(chalk.gray("○ ")+chalk.white(r(w.map(String),","))),g?.research&&!g.research.passed&&o.push(chalk.gray(`⭐ ${g.research.good_cards}/${g.research.need_cards}`)),o.forEach((e,o)=>$(chalk.gray(0===o?s?" 待办: ":" todo: ":" ")+e))}}else{const r=String(t).length;for(let l=n;l<=t;l++){const t=o.cards.find(e=>e.number===l);if(!t)continue;const c=t,g=c.title??c.badge??"",i=(s?c._zh?.title??c._zh?.badge??g:g)||"",h=null!=t.check,u=d[String(l)],p=u?u.correct?chalk.green("✓"):chalk.red("✗"):h?chalk.gray("○"):chalk.gray("·"),b=x(l),m=b?(b.solved>=b.total?chalk.green:b.solved>0?chalk.yellow:chalk.gray)(`⚔${b.solved}/${b.total}`):" ",f=l===C?chalk.bold.cyan("▶"):" ",w=wrapMixed(i,Math.max(16,y()-14-r)),k=w[0]+(w.length>1?"…":"");$(` ${f} `+chalk.gray(String(l).padStart(r))+" "+p+" "+M(m,5)+" "+chalk.white(k));const v=12===a?L.find(e=>n+_(e.slot)-1===l):void 0;if(v){const o=chalk.gray(` ${" ".repeat(r)} ⚔ ${s?"练习赛":"arena"} ${e.number}-${v.slot}: `);v.passed?$(o+chalk.bold.green(`${v.best_ac}/${v.n} AC ✅`)):0===v.attempts?$(o+chalk.gray("⬜ ")+chalk.white(s?`未开始 · ${v.n} 题 · 过 ${v.need} 题 → `:`not started · ${v.n} problems · AC ${v.need} → `)+chalk.bold.green(`contest ${v.slot}`)):$(o+chalk.yellow(s?`❌ 最好 ${v.best_ac}/${v.n}(需 ${v.need})· 已试 ${v.attempts} 次 → `:`❌ best ${v.best_ac}/${v.n} (need ${v.need}) · ${v.attempts} attempt(s) → `)+chalk.bold.green(`contest ${v.slot}`))}}if(12!==a)for(const o of L){const n=chalk.gray(` ⚔ ${s?"练习赛":"arena"} ${e.number}-${o.slot}: `);o.passed?$(n+chalk.bold.green(`${o.best_ac}/${o.n} AC ✅`)):0===o.attempts?$(n+chalk.gray("⬜ ")+chalk.white(s?`未开始 · ${o.n} 题 · 过 ${o.need} 题 → `:`not started · ${o.n} problems · AC ${o.need} → `)+chalk.bold.green(`contest ${o.slot}`)):$(n+chalk.yellow(s?`❌ 最好 ${o.best_ac}/${o.n}(需 ${o.need})· 已试 ${o.attempts} 次 → `:`❌ best ${o.best_ac}/${o.n} (need ${o.need}) · ${o.attempts} attempt(s) → `)+chalk.bold.green(`contest ${o.slot}`))}g?.research&&!g.research.passed&&$(chalk.gray(s?` ⭐ 研究: ${g.research.good_cards}/${g.research.need_cards} 卡达 ${g.research.min_score} 分 — /ai 研究后 /submit`:` ⭐ research: ${g.research.good_cards}/${g.research.need_cards} cards at ${g.research.min_score}+ — /ai then /submit`)),g&&!g.configured&&$(chalk.gray(s?" 🔒 本阶段通关标准制作中 — 很快更新":" 🔒 pass criteria for this phase in production — coming soon"))}}k(),$(chalk.gray(s?" ✓ 答对 ✗ 答错 ○ 未答 · ⚔ 练习 已过/共 · 赛 ✅ 过 ❌ 试过 ⬜ 未碰"+(a._anyResearch?" · ⭐ 研究":""):" ✓ right ✗ wrong ○ unanswered · ⚔ practice solved/total"+(a._anyResearch?" · ⭐ research":""))),s||$(chalk.gray(" arena ✅ passed ❌ tried ⬜ untouched")),$(chalk.gray(s?" 只看本阶段: ":" this phase only: ")+chalk.bold.green("status now")+chalk.gray(s?" · 某阶段: ":" · one phase: ")+chalk.bold.green("status N")+chalk.gray(s?" · 全部: ":" · all: ")+chalk.bold.green("status")),r.achievements.length>0&&$(" "+chalk.gray(t("achievements",l)+" ")+r.achievements.map(e=>chalk.bold.yellow("★ ")+chalk.white(e)).join(chalk.gray(" · "))),k(),w()}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}export function renderArenaIntro(e=12,o=1){const n=i().startsWith("zh");if(e>12){const e=n?[chalk.bold.yellow(" ⚔ 你读完 4 张卡了 — 前面是本模块的定位检查。"),chalk.white(" ⚔ 每个模块两场:")+chalk.bold.yellow("卡 4")+chalk.white(" 定位检查(8 题 8 分钟,对 6 题即可跳到下一模块),")+chalk.bold.yellow("卡 8")+chalk.white(" 完整模拟卷(35 题 40 分钟,真卷格式)。"),chalk.white(" · 敲 ")+chalk.bold.green("contest 1")+chalk.white(" 开始 — 计时同时开始;每题选一个字母提交。"),chalk.white(" · 不锁任何卡:过不过都能继续往下读。"),chalk.gray(" ▸ 现在不想打?敲 ")+chalk.bold.green("next")+chalk.gray(" 继续读卡,检查点一直在那儿等你。")]:[chalk.bold.yellow(" ⚔ Four cards down — this module's placement check is waiting."),chalk.white(" ⚔ Two checkpoints per module: ")+chalk.bold.yellow("card 4")+chalk.white(" placement check (8 questions, 8 min; 6/8 lets you skip ahead), ")+chalk.bold.yellow("card 8")+chalk.white(" full mock paper (35 questions, 40 min, real NSW format)."),chalk.white(" · Type ")+chalk.bold.green("contest 1")+chalk.white(" to start — the clock starts with it; answer each question with a letter."),chalk.white(" · Nothing locks: pass or not, you can keep reading."),chalk.gray(" ▸ Not now? Type ")+chalk.bold.green("next")+chalk.gray(" and keep reading — the checkpoint waits for you.")];console.log();for(const o of e)console.log(o);return void console.log()}const t=r(e),a=["","one","two","three"][t.n]??String(t.n),l=learnCheckpointVerb(),s=!!process.stdout.isTTY&&!/^(C|POSIX)$/i.test(process.env.LANG||"")&&!process.env.ICOA_TEST_BOOT_MODE,c=n?[chalk.bold.yellow(1===o?" ⚔ 你读完 4 张卡了 — 前面是第一个检查点。":" ⚔ 这张卡下面有一个检查点。"),t.n>1?chalk.white(" ⚔ 每 4 张卡有一场判分赛:")+chalk.bold.yellow(`卡 ${t.cards}`)+chalk.white(`,一个阶段共 ${t.n} 场。`):chalk.white(" ⚔ 每个阶段有一场判分赛:")+chalk.bold.yellow(`卡 ${t.cards}`)+chalk.white("。"),...l?[chalk.white(" · 敲 ")+chalk.bold.green(l)+chalk.white(" 进竞技场 — ")+chalk.bold.green("battle"===l?"play":"run")+chalk.white(" 本机试跑,")+chalk.bold.green("submit")+chalk.white(" 交给判分机;第一次 submit 时计时开始。")]:[chalk.white(" · 敲 ")+chalk.bold.green(`contest ${o}`)+chalk.white(" 开始 — 计时器同时开始,题目在赛场里读。")],chalk.white(" · 判分机会真的跑你的代码,不是对答案。"),chalk.white(t.n>1?` · ${t.n} 场全过 → 解锁下一阶段。`:" · 过了这一场 → 解锁下一阶段。"),chalk.gray(" ▸ 现在不想打?敲 ")+chalk.bold.green("next")+chalk.gray(" 继续读卡,赛场一直在那儿等你。")]:[chalk.bold.yellow(1===o?" ⚔ Four cards down — a checkpoint is waiting.":" ⚔ A checkpoint is waiting under this card."),t.n>1?chalk.white(" ⚔ Every 4 cards there is a judged arena: ")+chalk.bold.yellow(`cards ${t.cards}`)+chalk.white(`, ${a} per phase.`):chalk.white(" ⚔ Each phase has one judged arena: ")+chalk.bold.yellow(`card ${t.cards}`)+chalk.white("."),...l?[chalk.white(" · Type ")+chalk.bold.green(l)+chalk.white(" to enter the arena — ")+chalk.bold.green("battle"===l?"play":"run")+chalk.white(" to try it here, ")+chalk.bold.green("submit")+chalk.white(" to send it to the judge; the clock starts at your first submit.")]:[chalk.white(" · Type ")+chalk.bold.green(`contest ${o}`)+chalk.white(" to start — the clock starts with it; the problems are read inside.")],chalk.white(" · The judge really runs your code. It is not an answer key."),chalk.white(t.n>1?` · Pass all ${a} → the next phase unlocks.`:" · Pass it → the next phase unlocks."),chalk.gray(" ▸ Not now? Type ")+chalk.bold.green("next")+chalk.gray(" and keep reading — the arena waits for you.")];console.log();for(const e of c)console.log(e),s&&ne(200);console.log()}
1
+ import chalk from"chalk";import e from"string-width";import{localized as o}from"./learn-curricula.js";import{completedCount as n}from"./learn-state.js";import{t}from"./learn-i18n.js";import{arenaCadence as r}from"./learn-contest.js";import{getConfig as a}from"./config.js";import{icoaBannerLines as l}from"./banner.js";import{renderCharts as s,detectCaps as c}from"./render-card.js";import{replyChipLabel as g}from"./learn-replies.js";function i(){return(a().language||"en").toLowerCase()}function d(e,o,n){const t=i();return t.startsWith("zh")?o:t.startsWith("th")?n:e}let h="normal";export function resolveLearnWidth(e){return"normal"===e.learnWidth||"wide"===e.learnWidth||"wider"===e.learnWidth||"widest"===e.learnWidth?e.learnWidth:e.learnWide?"wide":"normal"}export function setLearnWidth(e){h=e}export function learnWidthCap(e=h){return"widest"===e?160:"wider"===e?120:"wide"===e?96:64}export function learnW(){const e=process.stdout.columns||69,o=Math.max(40,Math.min(64,e-5));return"normal"===h?o:Math.max(o,Math.min(e-6,learnWidthCap()))}const u=learnW;function y(e="─"){return e.repeat(u()+2)}function p(o,n){if(e(o)<=n)return o;let t=o;for(;t.length>0&&e(t)>Math.max(1,n-1);)t=t.slice(0,-1);return t.trimEnd()+"…"}function b(e,o,n=20){const t=o>0?e/o:0,r=Math.floor(t*n),a=n-r;return`${chalk.green("█".repeat(r))+chalk.gray("░".repeat(a))} ${(100*t).toFixed(1)}%`}function m(e){return e>=30?chalk.red("🔥🔥🔥 "+e+" days"):e>=7?chalk.yellow("🔥 "+e+" days"):e>=1?chalk.gray("· "+e+" day"+(e>1?"s":"")):chalk.gray("—")}export function renderWelcome(e,o,r){const a=i(),l=e.totalCards,s=n(o,l),c=l-s,g=e.modules.find(e=>o.currentCard>=e.cardRange[0]&&o.currentCard<=e.cardRange[1]),d=/demo/i.test(e.id);if(console.log(),console.log(chalk.cyan(" ╭"+y("═"))),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ║ ")+chalk.bold.white(" "+(e.name?.trim()||t("academy_title",a)))),console.log(chalk.cyan(" ║")),r)console.log(chalk.cyan(" ║ ")+chalk.white(" "+t(d?"welcome_new_demo":"welcome_new",a)));else{const e=new Date(o.lastSeenAt),n=Math.floor((Date.now()-e.getTime())/36e5),r=n<1?t("just_now",a):n<24?`${n}${t("ago_hours",a)}`:`${Math.floor(n/24)}${t("ago_days",a)}`;console.log(chalk.cyan(" ║ ")+chalk.white(` ${t("welcome_back",a)} ${r}`))}console.log(chalk.cyan(" ║"));const h=p(g?`${g.number}. ${g.name}`:"—",u()-14);console.log(chalk.cyan(" ║ ")+" "+chalk.gray(t("module",a).padEnd(11))+chalk.white(h)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(t("progress",a).padEnd(11))+b(s,l,Math.max(6,Math.min(20,u()-26-`${s}/${l}`.length)))+chalk.gray(` (${s}/${l})`)),console.log(chalk.cyan(" ║ ")+" "+chalk.gray(t("streak",a).padEnd(11))+m(o.streakDays)),c>0&&o.currentCard<=l&&console.log(chalk.cyan(" ║ ")+" "+chalk.gray(t("next_card",a).padEnd(11))+chalk.white(`#${o.currentCard} ${t("of",a)} ${l}`)),console.log(chalk.cyan(" ║")),console.log(chalk.cyan(" ╰"+y("═"))),console.log(),console.log(chalk.gray(" ─────────────────────────────────────────────"));const f=0===s?t("continue_start",a):`${t("continue_resume",a)} ${o.currentCard}`;console.log(chalk.bold.green(" continue")+chalk.gray(" "+f)),console.log(chalk.yellow(" status")+chalk.gray(" "+t("status_full",a))),o.bookmarks.length>0&&console.log(chalk.yellow(" bookmarks")+chalk.gray(` ${o.bookmarks.length} ${t("bookmarks_desc",a)}`)),console.log(chalk.gray(" quit")+chalk.gray(" "+t("quit_desc",a))),console.log(chalk.gray(" ─────────────────────────────────────────────")),console.log()}function f(o,n){const r=i(),a=o.module,l=n.modules.find(e=>e.number===a),s=l?l.name:t("unknown_module",r),c=t("module",r).replace(":","").trim(),g=p(`${t("card",r)} ${o.number} / ${n.totalCards} · ${c} ${a} · ${s}`,u()-4);console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(g)+" "+chalk.cyan("─".repeat(Math.max(0,u()-e(g)-4))))}function w(){console.log(chalk.cyan(" ╰"+y())),console.log()}function $(e){console.log(chalk.cyan(" │ ")+chalk.white(e))}function k(){console.log(chalk.cyan(" │"))}const _=/[┌┐└┘├┤┬┴┼─│╔╗╚╝═║╠╣╦╩╬▓▒░█]/;function x(e){return/^(?: {4}|\t)/.test(e)||_.test(e)||/ {3,}/.test(e)}const C=/[\u0E00-\u0E7F]/;function v(e){try{return new Intl.Segmenter("th",{granularity:e})}catch{return null}}const M=v("word"),S=v("grapheme");export function wrapMixed(o,n){const t=[];let r="",a=0,l=!1;for(const s of function(o){const n=[],t=o=>{let t="",r="";const a=()=>{t&&(n.push({t:"atom",s:t}),t="")},l=()=>{if(r){if(a(),M)for(const{segment:e}of M.segment(r))if(e.length<=20)n.push({t:"atom",s:e});else if(S)for(const o of S.segment(e))n.push({t:"atom",s:o.segment});else for(const o of e)n.push({t:"atom",s:o});else for(const e of r)n.push({t:"atom",s:e});r=""}};for(const s of o)" "===s?(l(),a(),n.push({t:"space"})):C.test(s)?r+=s:2===e(s)?(l(),a(),n.push({t:"wide",s:s})):(l(),t+=s);l(),a()},r=/`[^`]*`/g;let a,l=0;for(;null!==(a=r.exec(o));)t(o.slice(l,a.index)),n.push({t:"code",s:a[0]}),l=a.index+a[0].length;return t(o.slice(l)),n}(o)){if("space"===s.t){""!==r&&(l=!0);continue}const o=s.s,c=e("code"===s.t?o.replace(/`/g,""):o),g=l?1:0,i="atom"===s.t&&o.length<=2&&/^[.,;:!?)\]}…'"]+$/.test(o);""!==r&&!i&&a+g+c>n?(t.push(r),r=o,a=c,l=!1):(l&&(r+=" ",a+=1,l=!1),r+=o,a+=c)}return r&&t.push(r),t}const j=/\b(?:Common bug|Common mistake|Common error|Pitfall|Gotcha|Footgun)\b[::]?|\b(?:Warning|Caution)\b[::]|(?:常见错误|常见陷阱|常见误区|陷阱|注意|警告|误区)[::]/gi,A=String.fromCharCode(1),W=String.fromCharCode(2),R=new RegExp(`([${A}${W}])`),z=/(^|[^\w*])\*\*(?=\S)([^\n]+?)(?<=\S)\*\*(?![\w*])/g;function L(e){if(!e.includes("**"))return e;const o=e.replace(/`[^`]*`/g,e=>"`"+"x".repeat(e.length-2)+"`");let n,t="",r=0;for(z.lastIndex=0;null!==(n=z.exec(o));){const o=n.index+n[1].length,a=o+2+n[2].length;t+=e.slice(r,o)+A+e.slice(o+2,a)+W,r=a+2}return t+e.slice(r)}function E(e,o,n){if(n&&(e.includes(A)||e.includes(W)||n.b)){let t="";for(const r of e.split(R))r===A?n.b=!0:r===W?n.b=!1:r&&(t+=E(r,o||n.b));return t}const t=o?chalk.bold.white:chalk.white;let r,a="",l=0;for(j.lastIndex=0;null!==(r=j.exec(e));)r.index>l&&(a+=t(e.slice(l,r.index))),a+=chalk.bold.yellow(r[0]),l=r.index+r[0].length;return l<e.length&&(a+=t(e.slice(l))),a}function P(e,o=!1,n){let t="",r=0;const a=/`([^`]*)`/g;let l;for(;null!==(l=a.exec(e));)l.index>r&&(t+=E(e.slice(r,l.index),o,n)),t+=chalk.cyan(l[1]),r=l.index+l[0].length;return r<e.length&&(t+=E(e.slice(r),o,n)),t}function q(e,o=!1){let n=!1;for(const t of e.split("\n")){if(/^\s*```/.test(t)){n=!n;continue}if(n){console.log(chalk.cyan(" │ ")+chalk.cyan(` ${t}`));continue}if(""===t){k();continue}if(x(t)){console.log(chalk.cyan(" │ ")+chalk.white(t));continue}const e={b:!1};for(const n of wrapMixed(L(t),u()-6))console.log(chalk.cyan(" │ ")+` ${P(n,o,e)}`)}}function T(e,o){const n=[];for(const t of e.split("\n"))""!==t?x(t)?n.push(t):n.push(...wrapMixed(t,o)):n.push("");return n}let N=!1,F=!1;export function setLearnAiEnabled(e,o=e){N=e,F=o}let I=new Set;export function setLearnPqsViewCards(e){I=e}let O=new Map;export function setLearnHonorRanks(e){O=e}const D=["①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩"];let B=[];export function setLearnReplies(e){B=e}let H=[];export function setLearnFaqs(e){H=e}let Q=null;export function setLearnHometask(e){Q=e}let V="full";export function setLearnFooterProfile(e){V=e}let Y=null;export function setLearnFooterExtra(e){Y=e}function G(){const e=Y?.();e&&console.log(chalk.gray(" "+e))}let K=null;export function setLearnPracticeChips(e){K=e}let Z=!1;export function setLearnShellLane(e){Z=e}let X=!1,J=new Map;export function setLearnArenaCards(e){J=new Map(e.map(e=>[e.card,e.slot]))}export function setLearnArenaLane(e){X=e}export function learnCheckpointVerb(){return ee?"duck":null}let U=null;export function setLearnContestCards(e){U=e}export function declaredContestCards(){return U}let ee=!1;export function setLearnDuckLane(e){ee=e}let oe=null;export function setLearnPracticeCount(e){oe=e}export function renderHonorWall(e){const o=i().startsWith("zh"),{totals:n,chapters:t}=e,r=n.gold+n.silver+n.bronze,a=(e,o)=>o>0?chalk.bold.white(`${e}×${o}`):chalk.gray(`${e}×0`);if(console.log(chalk.gray(" ─────────────────────────────────────────")),console.log(chalk.bold.white(o?" 🏅 奖牌墙 ":" 🏅 Medal wall ")+a("🥇",n.gold)+chalk.gray(" · ")+a("🥈",n.silver)+chalk.gray(" · ")+a("🥉",n.bronze)+chalk.gray(o?" (永久 — 挂上墙就不会摘下)":" (permanent — once earned, never removed)")),0===r){const n=null!=e.floor?`${e.floor}+`:o?"高分":"a high score";return console.log(chalk.gray(o?` 还没有奖牌 — 单卡提问评分 ${n} 并进入该卡前三,即可永久挂墙 🥇🥈🥉`:` No medals yet — score ${n} on a card and hold its top-3 to hang one 🥇🥈🥉`)),void console.log(chalk.gray(" ─────────────────────────────────────────"))}const l=t.map(e=>{const o=`Ch${e.chapter}`,n=(e.gold>0?`🥇${e.gold}`:"")+(e.silver>0?`🥈${e.silver}`:"")+(e.bronze>0?`🥉${e.bronze}`:"");return n?chalk.white(`${o} ${n}`):chalk.gray(`${o} —`)}).join(chalk.gray(" "));console.log(" "+l);const s=t.flatMap(e=>e.cards.map(o=>({...o,chapter:e.chapter})));s.sort((e,o)=>e.rank-o.rank||e.chapter-o.chapter||e.card-o.card);for(const e of s.slice(0,24)){const n=(e.since||"").slice(0,10);console.log(chalk.white(` ${e.icon} `)+chalk.gray(`Ch${e.chapter} · `)+chalk.white(o?`第 ${e.card} 张`:`card ${e.card}`)+chalk.gray(` · ${e.score}`)+(n?chalk.gray(o?` · 始于 ${n}`:` · since ${n}`):""))}s.length>24&&console.log(chalk.gray(o?` …还有 ${s.length-24} 枚`:` …and ${s.length-24} more`)),console.log(chalk.gray(" ─────────────────────────────────────────"))}export function renderKnowledgeCard(n,r){const a=i(),l=o(n,a);f(l,r),k();const y=wrapMixed(l.title,u()-4);for(const e of y)$(chalk.bold.yellow(e));$(chalk.gray("─".repeat(Math.min(Math.max(...y.map(o=>e(o))),u()))));const p=!!(n.chart_ids&&n.chart_ids.length>0);if(p&&s(n.chart_ids.slice(0,1),r.charts,c()),l.key_point&&""!==l.key_point.trim()?(p||k(),function(e,o,n){const t=i().startsWith("zh"),r=c().cols,a="-".repeat(Math.min(u(),Math.max(24,r-6))),l=t?"要点":d("KEY POINT","要点","ประเด็นสำคัญ"),s=t?`第 ${o} / ${n} 张`:d(`Card ${o} / ${n}`,"",`การ์ด ${o} / ${n}`);console.log(chalk.cyan(" │ ")+chalk.green(a)),console.log(chalk.cyan(" │ ")+chalk.green(`${l} · ${s}`));for(const o of wrapMixed(e,u()-6))console.log(chalk.cyan(" │ ")+chalk.bold.green(" "+o));console.log(chalk.cyan(" │ ")+chalk.green(a)),k()}(l.key_point,l.number,r.totalCards)):p||k(),l.body.filter(e=>null!=e&&""!==e.trim()).forEach((e,o)=>{const n=0===o?e.match(/^([\s\S]*?(?:[.!?](?=\s|$)|[。!?]))(\s[\s\S]*)?$/):null;if(n&&n[1].trim().length<=180){q(n[1],!0);const e=n[2]?.trimStart();e&&q(e,!1)}else q(e,!1);k()}),l.icoaConnection){$(chalk.magenta(" "+t("icoa_connection",a))),$(chalk.gray(" "+"─".repeat(20)));for(const e of wrapMixed(l.icoaConnection,u()-6))$(" "+chalk.magenta(e));k()}if(n.check){const e=a.slice(0,2).toLowerCase(),o=n[`_${e}`],t=o?.checkStatement??o?.check?.statement??n.check.statement;for(const o of wrapMixed("zh"===e?"请回答 (输 y 或 n):":"th"===e?"เช็กความเข้าใจ (พิมพ์ y หรือ n):":"Quick comprehension check (type y or n):",u()-10))$(chalk.cyan(" 🤔 "+o));$(chalk.gray(" "+"─".repeat(20)));for(const e of wrapMixed(t,u()-6))$(" "+chalk.white(e));k()}w(),function(o,n){const t=i().startsWith("zh"),r=c().cols,a="-".repeat(Math.min(u(),Math.max(24,r-6))),l=chalk.gray(" ");if("minimal"===V){const e=K?K(o.number):null;console.log(chalk.gray(" "+a)),console.log(chalk.gray(" "+d(`Card ${o.number} / ${n.totalCards}`,`第 ${o.number} / ${n.totalCards} 张`,`การ์ด ${o.number} / ${n.totalCards}`))+(e?chalk.gray(d(" · practice "," · 本卡练习 "," · ฝึก "))+e:""));const r=[];if(o.check?(r.push(chalk.bold.green("[y]")+chalk.gray(d(" yes"," 是"," ใช่"))),r.push(chalk.bold.green("[n]")+chalk.gray(d(" no"," 否"," ไม่ใช่")))):r.push(chalk.bold.green("[ok]")+chalk.gray(d(" next"," 下一张"," ถัดไป"))),e){const o=Math.max(1,(e.match(/\[\d\]/g)??[]).length),n=Array.from({length:o},(e,o)=>`[${o+1}]`).join("");r.push(chalk.bold.cyan(n)+chalk.gray(d(" practice"," 练习"," ฝึก")))}Z&&r.push(chalk.bold.magenta("[sh]")+chalk.gray(t?" 实验台":" shell")),N&&r.push(chalk.bold.magenta("[/ai]")+chalk.gray(d(" 🐼 Panda tutor"," 🐼 熊猫导师"," 🐼 ครูแพนด้า")));const s=J.get(o.number);return X&&s?r.push(chalk.bold.magenta(`[contest ${s}]`)+chalk.gray(t?" 检查点":" checkpoint")):X&&0===J.size&&r.push(chalk.bold.magenta("[battle]")+chalk.gray(t?" 进竞技场":" arena")),ee&&r.push(chalk.bold.magenta("[duck]")+chalk.gray(t?" 跑仿真":d(" sim bench"," 跑仿真"," ตัวจำลอง"))),o.flow&&o.flow.length>0&&r.push(chalk.bold.magenta("[flow]")+chalk.gray(t?" 互动走一遍":" walk it")),r.push(chalk.bold.cyan("[b]")+chalk.gray(d(" back"," 上一张"," ย้อนกลับ"))),r.push(chalk.bold.yellow("[e]")+chalk.gray(d(" ask/report"," 提问/报告"," ถาม/แจ้งปัญหา"))),r.push(chalk.gray("[quit]")+chalk.gray(d(""," 退出"," ออก"))),console.log(" "+r.join(l)),G(),void console.log()}const s=[];o.check?(s.push(chalk.bold.green("[y]")+chalk.gray(t?" 是":" yes")),s.push(chalk.bold.green("[n]")+chalk.gray(t?" 否":" no"))):s.push(chalk.bold.green("[ok]")+chalk.gray(t?" 继续":" next")),o.flow&&o.flow.length>0&&s.push(chalk.bold.magenta("[flow]")+chalk.gray(t?" 互动走一遍":" walk it")),N&&s.push(chalk.bold.magenta("[/ai]")+chalk.gray(t?" 🐼 熊猫导师":" 🐼 Panda tutor")),F&&s.push(chalk.bold.magenta("[/submit]")+chalk.gray(t?" 提问评分":" prompt score"));const y=O.get(o.number);var p;s.push(chalk.bold.magenta(y?`[/honors ${p=y,D[p-1]??`#${p}`}]`:"[/honors]")+chalk.gray(t?" 排行":" board")),"normal"===h?s.push(chalk.bold.cyan("[wide]")+chalk.gray(t?" 宽屏":" widen")):("wide"===h?s.push(chalk.bold.cyan("[wider]")+chalk.gray(t?" 更宽":" wider")):"wider"===h?(s.push(chalk.bold.cyan("[widest]")+chalk.gray(t?" 最宽":" widest")),s.push(chalk.bold.cyan("[wide]")+chalk.gray(t?" 回宽屏":" back to wide"))):s.push(chalk.bold.cyan("[wider]")+chalk.gray(t?" 回 wider":" back to wider")),s.push(chalk.bold.cyan("[normal]")+chalk.gray(t?" 标准":" standard")));const b=g(B,H,o.number,t),m=b.startsWith("💬");if(s.push((m?chalk.bold.yellow("[r]"):chalk.gray("[r]"))+(m?chalk.bold.white(` ${b}`):chalk.gray(` ${b}`))),s.push(chalk.bold.yellow("[e]")+chalk.gray(t?" 提问或报告":" ask or report")),Q){const e=Q,o=`${e.done}/${e.total}`,n=e.completedAt?chalk.bold.green:chalk.bold.cyan;s.push(n("[task]")+chalk.gray(t?` 本周 ${o}`:` week ${o}`))}s.push(chalk.bold.cyan("[b]")+chalk.gray(t?" 上一张":" back")),s.push(chalk.bold.cyan("[card N]")+chalk.gray(t?" 跳转":" jump")),s.push(chalk.gray("[reload]")+(t?chalk.gray(" 刷新"):"")),s.push(chalk.gray("[quit]")+(t?chalk.gray(" 退出"):""));const f=e(a);console.log(chalk.gray(" "+a)),console.log(chalk.gray(" "+(t?`第 ${o.number} / ${n.totalCards} 张`:`Card ${o.number} / ${n.totalCards}`)));let w="",$=0;for(const o of s){const n=e(o);w&&$+2+n>f?(console.log(" "+w),w=o,$=n):(w=w?w+l+o:o,$=w===o?n:$+2+n)}w&&console.log(" "+w),console.log(" "+chalk.magenta("✍ ")+chalk.magenta("[/py]")+chalk.gray(t?" Python 草稿本":" Python scratchpad")+l+chalk.magenta("[/pylist]")+chalk.gray(t?" 我的草稿":" my files")),console.log(chalk.gray(" "+a));const k=[t?"e = 就这张卡提问,或报告问题":"e = ask about this card, or report a problem",t?"更多: bookmark / unbookmark · status · lang · link":"more: bookmark / unbookmark · status · lang · link"];for(const e of k)for(const o of wrapMixed(e,f))console.log(chalk.gray(" "+o));G(),console.log()}(n,r)}export function renderCheckFeedback(e,o,n,t=!1){const r=i().startsWith("zh");if(console.log(),n)console.log(chalk.green(" ✓ ")+chalk.white(r?"答对了。":"Correct."));else if(console.log(chalk.yellow(" ✗ ")+chalk.white(r?"记下了,继续。":"Noted — moving on.")),t){const o="y"===e.check?.answer?r?"是":"Yes":r?"否":"No";console.log(chalk.gray(" "+(r?"正确答案: ":"Answer: ")+o+". "+(r?"回看上面那段。":"Re-read the paragraph above.")))}const a=r?e._zh?.solution??e.solution:e.solution;if(a&&a.length>0){console.log(),console.log(chalk.cyan(" 📝 "+(r?"解答:":"Worked solution:")));for(const e of a){for(const o of wrapMixed(e,u()-4))console.log(chalk.white(" "+o));console.log()}}console.log()}function ne(e){return[chalk.white(" "+(e?"编著:Charlie Zhu":"Created & edited by Charlie Zhu")),chalk.gray(" "+(e?"ICOA 2026 创始人 · 课程总架构师":"Founder & Chief Curriculum Architect · ICOA 2026"))]}export function renderPhaseComplete(e,o,n,t,a,s){const c=r(n.cardRange[1]-n.cardRange[0]+1),g=i().startsWith("zh"),[d,h]=n.cardRange,y=o.checkResults||{};let p=0,b=0;for(let e=d;e<=h;e++){const o=y[String(e)];o&&(p++,o.correct&&b++)}const m="-".repeat(48);console.log();for(const e of l(" "))console.log(e);console.log(),console.log(chalk.bold.yellow(" "+m)),console.log(chalk.bold.yellow(" "+(g?`阶段 ${n.number} 完成`:`Phase ${n.number} complete`))+chalk.gray(" · ")+chalk.white(n.name));const f=p>0&&b===p?chalk.bold.green:chalk.bold.white;console.log(chalk.gray(" "+(g?"理解检查得分: ":"comprehension score: "))+f(`${b}/${p}`)+chalk.gray(0===p?g?" (本阶段未作答 y/n)":" (no y/n answered)":""));const w=String(h).length;let $=!1,k=0,_=0,x=0,C=0;for(let o=d;o<=h;o++){const n=e.cards.find(e=>e.number===o);if(!n)continue;const t=n,r=t.title??t.badge??"",a=(g?t._zh?.title??t._zh?.badge??r:r)||"",l=null!=n.check,s=y[String(o)];let c;c=s?s.correct?chalk.green("✓"):chalk.red("✗"):l?chalk.gray("○"):chalk.gray("·");const i=oe?oe(o):null;i&&($=!0);const d=i?(i.solved>=i.total?chalk.green:i.solved>0?chalk.yellow:chalk.gray)(` ⚔${i.solved}/${i.total}`):"";i&&(k++,i.solved>=i.total&&_++,x+=i.solved,C+=i.total);const h=wrapMixed(a,u()-10-w-(i?6:0)),p=h[0]+(h.length>1?"…":"");console.log(chalk.gray(` ${String(o).padStart(w)} `)+c+d+chalk.white(" "+p))}if(console.log(chalk.gray(g?" ✓ 答对 · ✗ 答错 · ○ 未作答 · 无 y/n 的卡不计分":" ✓ correct · ✗ wrong · ○ unanswered · cards without a y/n are unscored")),$&&console.log(chalk.bold.cyan(" ⚔ "+(g?"卡片练习: ":"practice: "))+(_>=k?chalk.bold.green:chalk.bold.white)(`${_}/${k}`)+chalk.gray(g?` 卡全完成 · ${x}/${C} 题 AC · 行内 ⚔已过/共(绿 完成 · 黄 部分 · 灰 未碰)`:` cards complete · ${x}/${C} problems AC · ⚔solved/total per row (green done · yellow partial · gray untouched)`)),a){const e=e=>"green"===e?chalk.bold.green:"blue"===e?chalk.bold.cyan:"yellow"===e?chalk.bold.yellow:chalk.bold.red;console.log(chalk.bold.magenta(" ⭐ "+(g?"提问得分 (best): ":"Prompt scores (best): "))+(0===a.length?chalk.gray(g?"本阶段尚未提问 — 用 /ai 研究,再 /submit 评分":"none this phase — research with /ai, then /submit"):a.map(o=>chalk.gray((g?"卡":"#")+o.card+" ")+e(o.tier)(String(o.score))).join(chalk.gray(" · "))))}if(s&&!s.configured&&null===U){const o=h-d+1>12,n="fill"===e.practiceMode;console.log(chalk.gray(o?g?" 🔒 本阶段通关标准制作中 — 很快更新(360 层第二阶段标准设计中)":" 🔒 Pass criteria for this phase are in production — coming soon (360-tier second-stage standard in design)":n?g?c.n>1?` 🔒 本阶段 ${c.n} 场判分赛制作中 — 很快更新;赛场挂在卡 ${c.cards},${c.n} 场全过解锁下一阶段(本轨无 research)`:` 🔒 本阶段的判分赛制作中 — 很快更新;赛场挂在卡 ${c.cards},通过即解锁下一阶段(本轨无 research)`:c.n>1?` 🔒 This phase’s ${c.n} judged arenas are in production — coming soon; they hang on cards ${c.cards} and all ${c.n} unlock the next phase (no research on this track)`:` 🔒 This phase’s judged arena is in production — coming soon; it hangs on card ${c.cards} and passing it unlocks the next phase (no research on this track)`:g?" 🔒 本阶段通关标准制作中 — 很快更新(标准范式:3 场练习赛 + 3 卡研究)":" 🔒 Pass criteria for this phase are in production — coming soon (standard: 3 arenas + 3 research cards)"))}if(s?.configured&&s.contest){const e=s.contest;if(e.slots&&e.slots.length>0)for(const o of e.slots){const e=chalk.bold.cyan(` ⚔ ${g?"练习赛":"arena"} ${n.number}-${o.slot}: `);o.passed?console.log(e+chalk.bold.green(`${o.best_ac}/${o.n} AC ✅`)):0===o.attempts?console.log(e+chalk.white(g?`${o.n} 题 · 过 ${o.need} 题 — `:`${o.n} problems · AC ${o.need} — `)+chalk.bold.green(`contest ${o.slot}`)):console.log(e+chalk.yellow(g?`最好 ${o.best_ac}/${o.n}(需 ${o.need})· 已试 ${o.attempts} 次 — `:`best ${o.best_ac}/${o.n} (need ${o.need}) · ${o.attempts} attempt(s) — `)+chalk.bold.green(`contest ${o.slot}`))}else{const o=chalk.bold.cyan(" ⚖ "+(g?"判分赛: ":"Contest: "));e.passed?console.log(o+chalk.bold.green(`${e.best_ac}/${e.n} AC ✅ `+(g?"已过关":"passed"))):0===e.attempts?console.log(o+chalk.white(g?`${e.n} 题 · 过 ${e.need} 题解锁 — 输入 `:`${e.n} problems · AC ${e.need} to pass — type `)+chalk.bold.green("contest")+chalk.white(g?" 开始":" to start")):console.log(o+chalk.yellow(g?`最好 ${e.best_ac}/${e.n} AC(需 ${e.need})· 已试 ${e.attempts} 次 — 输入 `:`best ${e.best_ac}/${e.n} AC (need ${e.need}) · ${e.attempts} attempt(s) — type `)+chalk.bold.green("contest")+chalk.yellow(g?" 再战":" to retry"))}}t&&console.log(chalk.gray(" "+(g?"下一阶段: ":"next: "))+chalk.bold.cyan(g?`阶段 ${t.number}`:`Phase ${t.number}`)+chalk.gray(" · ")+chalk.white(t.name)),console.log(chalk.bold.yellow(" "+m));for(const e of ne(g))console.log(e)}export function renderCurriculumComplete(e,o){const n=i().startsWith("zh"),t=o.checkResults||{},r="-".repeat(48);let a=0,s=0;console.log();for(const e of l(" "))console.log(e);console.log(),console.log(chalk.bold.green(" "+r)),console.log(chalk.bold.green(" 🏆 "+(n?`${e.name} — 全部完成!`:`${e.name} — complete!`))),console.log(chalk.bold.green(" "+r));for(const o of e.modules){const[e,r]=o.cardRange;let l=0,c=0;for(let o=e;o<=r;o++){const e=t[String(o)];e&&(l++,e.correct&&c++)}a+=l,s+=c;const g=l>0&&c===l?chalk.green:chalk.white;console.log(chalk.gray(" "+(n?`阶段 ${o.number}`:`Phase ${o.number}`).padEnd(8))+g(`${c}/${l}`.padEnd(7))+chalk.gray(o.name))}console.log(chalk.bold.green(" "+r)),console.log(chalk.bold.green(" "+(n?"总分 / overall: ":"Overall: "))+chalk.bold.white(`${s}/${a}`)),console.log(chalk.bold.green(" "+r));for(const e of ne(n))console.log(e);console.log()}export function renderMCQCard(e,n){const r=i(),a=o(e,r);f(a,n),k(),$(chalk.bold.yellow("🎯 "+a.title)),$(chalk.gray("─".repeat(Math.min(a.title.length+4,u())))),k();for(const e of T(a.question,u()-4))$(" "+e);k();for(const e of["A","B","C","D"])$(chalk.cyan(` ${e}.`)+" "+chalk.white(a.options[e]));k(),w(),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(" "+t("type_to_answer",r))),console.log(chalk.gray(" ")+chalk.bold.cyan("back")+chalk.gray(r.startsWith("zh")?" 上一张 · ":" previous card · ")+chalk.bold.cyan("card N")+chalk.gray(r.startsWith("zh")?" 跳转":" jump")),console.log()}export function renderMCQFeedback(e,n,r,a){const l=i(),s=o(e,l);console.log(),r?console.log(" "+chalk.bold.green(t("correct",l)+" ")+chalk.gray(`${t("one_point",l)} · ${n} = ${s.options[n]}`)):console.log(" "+chalk.bold.red(t("not_quite",l)+" ")+chalk.gray(`${t("you_chose",l)} ${n}; ${t("answer_is",l)} ${s.answer}.`)),console.log(),console.log(chalk.gray(" "+t("explanation",l)));for(const e of T(s.explanation,u()-4))console.log(chalk.gray(" "+e));const c=Object.values(a.mcqResults),g=c.filter(e=>e.correct).length;console.log(),console.log(chalk.gray(" "+t("mcq_accuracy_so_far",l)+" ")+chalk.white(`${g}/${c.length}`)),console.log(),r||(console.log(chalk.gray(" "+t("press_ok_continue",l)+" ")+chalk.bold.green("ok")+chalk.gray(" "+t("to_continue",l))),console.log())}export function renderPracticalCard(e,n){const r=i(),a=o(e,r);f(a,n),k(),$(chalk.bold.yellow("🛠 "+a.title)),$(chalk.gray("─".repeat(Math.min(a.title.length+4,u())))),k();for(const e of T(a.task,u()-4))$(" "+e);if(a.starterCode){k(),$(chalk.gray(" "+t("starter_code",r))),k();for(const e of a.starterCode.split("\n"))$(" "+chalk.cyan(e))}k(),w(),console.log(chalk.gray(" "+t("try_in_sandbox",r)+" ")+chalk.bold.cyan("!python3")+chalk.gray(" "+t("drops_into_python",r))),console.log(chalk.gray(" "+t("when_done",r))),console.log(chalk.gray(" ")+chalk.bold.green("done")+chalk.gray(" "+t("done_desc",r))),console.log(chalk.gray(" ")+chalk.bold.yellow("skip")+chalk.gray(" "+t("skip_desc",r))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log()}export function renderPracticalSuccess(e){const n=i(),r=o(e,n);console.log(),console.log(" "+chalk.bold.green(t("practical_recorded",n))),console.log(),console.log(chalk.gray(" "+t("reference_answer",n)));for(const e of T(r.successHint,u()-4))console.log(chalk.gray(" "+e));console.log(),console.log(chalk.gray(" "+t("press_ok_continue",n)+" ")+chalk.bold.green("ok")+chalk.gray(" "+t("to_continue",n))),console.log()}export function renderSimDemoCard(e,n){const r=i(),a=o(e,r);f(a,n),k(),$(chalk.bold.yellow("🎬 "+a.title)),k();for(const e of T(a.description,u()-4))$(" "+e);k(),$(chalk.gray(" "+t("sim_requires",r))),k(),w(),console.log(chalk.gray(" ")+chalk.bold.cyan("sim")+chalk.gray(" "+t("sim_launch_desc",r))),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+t("continue_to_next",r))),console.log(chalk.gray(" bookmark "+t("bookmark_desc",r))),console.log(chalk.gray(" back "+t("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 "+t("quit_desc",r))),console.log()}export function renderArenaTaskCard(e,n){const t=i(),r=t.startsWith("zh"),a=o(e,t);f(a,n),k(),$(chalk.bold.cyan("🏟 "+a.title)),$(chalk.gray(" "+a.origin+" · "+a.domain+" · "+a.metric)),k();for(const e of a.statement){for(const o of T(e,u()-4))$(" "+o);k()}$(chalk.bold.green(r?" 核心要点 — baseline → 解法的关键变化":" CORE DELTA — baseline → solution"));for(const e of a.core_delta)for(const o of T("• "+e,u()-6))$(" "+chalk.white(o));k(),$(chalk.gray((r?" 提交格式: ":" Submission: ")+a.submission_format)),a.hints&&$(chalk.gray(r?" 本题有 5 级提示 (a–e),进入 arena 后逐级解锁。":" 5 progressive hints (a–e) unlock inside the arena.")),k(),w(),console.log(chalk.gray(" ")+chalk.bold.cyan("arena "+a.task_id)+chalk.gray(r?" 动手做这道题(下载 / 提示 / 提交 / 榜单)":" open the arena (download / hints / submit / board)")),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续下一张":" continue to next")),console.log(chalk.gray(" back "+(r?"上一张":"previous"))),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderComingSoonCard(e,n){const t=i(),r=t.startsWith("zh"),a=o(e,t);f(a,n),k(),$(chalk.bold.yellow("🔜 "+a.title)),k();const l=a.note||(r?"这道竞技场题目正在编写中,敬请期待。":"This arena task is coming soon.");for(const e of T(l,u()-4))$(" "+chalk.gray(e));k(),w(),console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(r?" 继续":" continue")),console.log(chalk.gray(" back previous card")),console.log(chalk.gray(" card N jump to a card by number")),console.log(chalk.gray(" quit "+(r?"退出":"exit"))),console.log()}export function renderMilestone(e,n){const r=i(),a=o(e,r),l=e.number===n.totalCards;console.log(),console.log(chalk.bold.yellow(" ╭"+y("═"))),console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+chalk.white(" "+t("milestone_header",r))),console.log(chalk.bold.yellow(" ║"));const s=` ${a.badge} ${a.emoji}`;console.log(chalk.bold.yellow(" ║ ")+chalk.bold.green(s)),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(t("in_wild_corresponds",r)));for(const e of T(a.realWorldLevel,u()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(e));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ║ ")+" "+chalk.gray(t("whats_next",r)));for(const e of T(a.unlockedNext,u()-4))console.log(chalk.bold.yellow(" ║ ")+" "+chalk.white(e));console.log(chalk.bold.yellow(" ║")),console.log(chalk.bold.yellow(" ╰"+y("═"))),console.log(),l?(console.log(chalk.gray(" "+t("demo_complete",r))),console.log(),console.log(chalk.gray(" "+t("unlock_full",r)+" ")+chalk.white(t("curriculum_name",r))+chalk.gray(",")),console.log(chalk.gray(" "+t("contact_team_leader",r)+" ")+chalk.bold.yellow("EA")+chalk.gray(" "+t("learn_token",r))),console.log(chalk.gray(" "+t("or_email",r)+" ")+chalk.cyan("australia@icoa2026.au")+chalk.gray(" "+t("for_partnership",r))),console.log(),console.log(chalk.gray(" "+t("type_quit",r)+" ")+chalk.bold.green("quit")+chalk.gray(" "+t("to_exit",r)+" ")+chalk.bold.green("status")+chalk.gray(" "+t("for_dashboard",r)))):(console.log(chalk.gray(" ")+chalk.bold.green("ok")+chalk.gray(" / ")+chalk.bold.green("next")+chalk.gray(" "+t("continue_to_next",r))),console.log(chalk.gray(" status "+t("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 "+t("quit_desc",r)))),console.log()}export function renderStatus(o,r,a={}){const l=i(),s=l.startsWith("zh"),c=o.totalCards,g=n(r,c),d=r.checkResults||{},h=a.gate??null,y=!!a.gated,f=a.focus??"current",_=a.posForSlot??(e=>4===e?10:4*e),x=e=>a.practiceCount?a.practiceCount(e):oe?oe(e):null,C=r.currentCard,v=o.modules.find(e=>C>=e.cardRange[0]&&C<=e.cardRange[1]),M=(o,n)=>o+" ".repeat(Math.max(0,n-e((e=>e.replace(/\x1b\[[0-9;]*m/g,""))(o))));console.log();const S=`${o.name} — ${s?"状态":"Status"}`;console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(S)+" "+chalk.cyan("─".repeat(Math.max(4,u()-2-e(S))))),k(),$(" "+chalk.gray(t("total_progress",l)+" ")+b(g,c)+chalk.gray(` (${g}/${c})`)+chalk.gray(" "+t("streak",l)+" ")+m(r.streakDays));{let n=0,t=0,l=0,c=0,g=0,i=0;const y=[];let p=!1;for(const e of o.modules){for(let r=e.cardRange[0];r<=e.cardRange[1];r++){const e=x(r);e&&(n++,e.solved>=e.total&&t++);const a=o.cards.find(e=>e.number===r);null!=a?.check&&(l++,d[String(r)]?.correct&&c++)}const r=h?.phases.find(o=>o.phase===e.number);if(r?.configured)for(const o of r.contest?.slots??[])g++,o.passed?i++:y.push(Math.min(e.cardRange[1],e.cardRange[0]+_(o.slot)-1));r?.research&&(p=!0)}const b=(e,o)=>(e>=o?chalk.green:chalk.white)(`${e}/${o}`),m=[];n&&m.push(chalk.gray(s?"⚔ 练习卡 ":"⚔ practice cards ")+b(t,n)),g&&m.push(chalk.gray(s?"赛场 ":"arena ")+b(i,g)),l&&m.push(chalk.gray(s?"✓ 自测 ":"✓ checks ")+b(c,l)),m.length&&$(" "+m.join(chalk.gray(" "))),a._anyResearch=p;{let n=0;const t=[];let a=0,c=0,h=0;for(const e of o.modules)for(let l=e.cardRange[0];l<=e.cardRange[1];l++){c++,r.cardsCompleted.includes(l)&&a++;const e=o.cards.find(e=>e.number===l);null!=e?.check&&d[String(l)]&&h++;const s=x(l);s&&s.solved<s.total&&(n+=s.total-s.solved,t.push(l))}const p=s?"▸ 通关还差 ":"▸ to finish ",b=[],m=(e,o)=>{const n=[];let t=0;for(const r of o){const o=String(r).length+(n.length?3:0);if(t+o>e)break;t+=o,n.push(r)}return n};if(a<c&&b.push(chalk.gray(s?"卡片 ":"cards ")+chalk.white(""+(c-a))+chalk.gray(s?" 张未读":" unread")),l&&h<l&&b.push(chalk.gray("✓ ")+chalk.white(""+(l-h))+chalk.gray(s?" 题自测未答":" checks unanswered")),n>0){const o=s?`练习还差 ${n} 题`:`${n} practice problem${n>1?"s":""}`,r=s?"(卡 ":" (cards ",a=")",l=" │ ⚔ ",c=u()-e(l)-e(p)-e(o)-e(r+a);let g=m(c,t);g.length<t.length&&(g=m(c-e(` +${t.length}`),t)),!g.length&&t.length&&(g=[t[0]]);const i=t.length-g.length,d=g.join(" · ")+(i>0?` +${i}`:"");b.push(chalk.gray("⚔ ")+chalk.white(o)+chalk.gray(r+d+a))}if(g&&i<g){const o=(s?"赛 ":"arena ")+(g-i)+(s?" 场未过":" to pass"),n=s?"(卡 ":" (card ",t=")",r=" │ ",a=u()-e(r)-e(p)-e(o)-e(n+t);let l=m(a,y);l.length<y.length&&(l=m(a-e(` +${y.length}`),y)),!l.length&&y.length&&(l=[y[0]]);const c=y.length-l.length,d=l.length?n+l.join(" · ")+(c>0?` +${c}`:"")+t:"";b.push(chalk.gray(s?"赛 ":"arena ")+chalk.white(""+(g-i))+chalk.gray(s?" 场未过":" to pass")+chalk.yellow(d))}const f=a>0;f&&b.length?b.forEach((o,n)=>$(" "+(0===n?chalk.bold.yellow(p):" ".repeat(e(p)))+o)):f&&!b.length&&$(" "+chalk.bold.green(s?"✅ 通关条件已全部达成":"✅ every completion gate met"))}}k();const j=e=>s?`阶段 ${e}`:`Phase ${e}`,A=Math.max(10,Math.min(28,u()-54));for(const e of o.modules){const[n,t]=e.cardRange,a=t-n+1,l=r.cardsCompleted.filter(e=>e>=n&&e<=t).length,c=y&&!!h&&e.number>h.unlocked_through_phase,g=h?.phases.find(o=>o.phase===e.number);let i=0,b=0,m=0;const w=[],k=[];let S=0,W=0,R=0;const z=[];for(let e=n;e<=t;e++){const n=o.cards.find(o=>o.number===e);if(null!=n?.check){i++;const o=d[String(e)];o?(b++,o.correct?m++:k.push(e)):w.push(e)}const t=x(e);t&&(S++,R+=t.solved,t.solved>=t.total?W++:z.push(`${e}:${t.solved}/${t.total}`))}const L=g?.configured?g.contest?.slots??[]:[],E=e=>e.passed?chalk.green("✅"):e.attempts>0?chalk.yellow("❌"):chalk.gray("⬜"),P=l>=a&&(0===i||m===i)&&(0===S||W===S)&&(0===L.length||L.every(e=>e.passed))&&(!g?.research||g.research.passed),q=l>0||b>0||R>0||L.some(e=>e.attempts>0),T=c?chalk.gray("🔒"):P?chalk.green("✅"):e.number===v?.number?chalk.bold.cyan("▶ "):q?chalk.yellow("▶ "):chalk.gray("⬜"),N=p(e.name,A),F=[];if(F.push((l>=a?chalk.green:chalk.white)(`${l}/${a}`)+chalk.gray(s?"卡":"c")),i>0&&F.push(chalk.gray("✓")+(m===i?chalk.green:chalk.white)(`${m}/${i}`)),S>0&&F.push(chalk.gray("⚔")+(W===S?chalk.green:chalk.white)(`${W}/${S}`)+chalk.gray(s?"卡":"c")),L.length>0&&F.push(chalk.gray(s?"赛":"arena ")+L.map(E).join("")),g?.research&&F.push(chalk.gray("⭐")+(g.research.passed?chalk.green:chalk.white)(`${g.research.good_cards}/${g.research.need_cards}`)),$(" "+T+" "+chalk.white(M(j(e.number),s?5:8))+chalk.gray(M(N,A+1))+F.join(chalk.gray(" · "))),c||"all"!==f&&f!==e.number&&("current"!==f||e.number!==v?.number)){if(!c&&q&&!P){const o=[],t=L.filter(e=>!e.passed).map(o=>(o.attempts>0?chalk.yellow:chalk.gray)(`${e.number}-${o.slot}@${s?"卡":"card "}${n+_(o.slot)-1}`));t.length&&o.push(chalk.gray(s?"赛 ":"arena ")+t.join(chalk.gray(" · ")));const r=(e,o)=>e.slice(0,8).join(o)+(e.length>8?chalk.gray(" +"+(e.length-8)):"");z.length&&o.push(chalk.gray("⚔ ")+chalk.white(r(z," "))),k.length&&o.push(chalk.red("✗ ")+chalk.white(r(k.map(String),","))),w.length&&o.push(chalk.gray("○ ")+chalk.white(r(w.map(String),","))),g?.research&&!g.research.passed&&o.push(chalk.gray(`⭐ ${g.research.good_cards}/${g.research.need_cards}`)),o.forEach((e,o)=>$(chalk.gray(0===o?s?" 待办: ":" todo: ":" ")+e))}}else{const r=String(t).length;for(let l=n;l<=t;l++){const t=o.cards.find(e=>e.number===l);if(!t)continue;const c=t,g=c.title??c.badge??"",i=(s?c._zh?.title??c._zh?.badge??g:g)||"",h=null!=t.check,y=d[String(l)],p=y?y.correct?chalk.green("✓"):chalk.red("✗"):h?chalk.gray("○"):chalk.gray("·"),b=x(l),m=b?(b.solved>=b.total?chalk.green:b.solved>0?chalk.yellow:chalk.gray)(`⚔${b.solved}/${b.total}`):" ",f=l===C?chalk.bold.cyan("▶"):" ",w=wrapMixed(i,Math.max(16,u()-14-r)),k=w[0]+(w.length>1?"…":"");$(` ${f} `+chalk.gray(String(l).padStart(r))+" "+p+" "+M(m,5)+" "+chalk.white(k));const v=12===a?L.find(e=>n+_(e.slot)-1===l):void 0;if(v){const o=chalk.gray(` ${" ".repeat(r)} ⚔ ${s?"练习赛":"arena"} ${e.number}-${v.slot}: `);v.passed?$(o+chalk.bold.green(`${v.best_ac}/${v.n} AC ✅`)):0===v.attempts?$(o+chalk.gray("⬜ ")+chalk.white(s?`未开始 · ${v.n} 题 · 过 ${v.need} 题 → `:`not started · ${v.n} problems · AC ${v.need} → `)+chalk.bold.green(`contest ${v.slot}`)):$(o+chalk.yellow(s?`❌ 最好 ${v.best_ac}/${v.n}(需 ${v.need})· 已试 ${v.attempts} 次 → `:`❌ best ${v.best_ac}/${v.n} (need ${v.need}) · ${v.attempts} attempt(s) → `)+chalk.bold.green(`contest ${v.slot}`))}}if(12!==a)for(const o of L){const n=chalk.gray(` ⚔ ${s?"练习赛":"arena"} ${e.number}-${o.slot}: `);o.passed?$(n+chalk.bold.green(`${o.best_ac}/${o.n} AC ✅`)):0===o.attempts?$(n+chalk.gray("⬜ ")+chalk.white(s?`未开始 · ${o.n} 题 · 过 ${o.need} 题 → `:`not started · ${o.n} problems · AC ${o.need} → `)+chalk.bold.green(`contest ${o.slot}`)):$(n+chalk.yellow(s?`❌ 最好 ${o.best_ac}/${o.n}(需 ${o.need})· 已试 ${o.attempts} 次 → `:`❌ best ${o.best_ac}/${o.n} (need ${o.need}) · ${o.attempts} attempt(s) → `)+chalk.bold.green(`contest ${o.slot}`))}g?.research&&!g.research.passed&&$(chalk.gray(s?` ⭐ 研究: ${g.research.good_cards}/${g.research.need_cards} 卡达 ${g.research.min_score} 分 — /ai 研究后 /submit`:` ⭐ research: ${g.research.good_cards}/${g.research.need_cards} cards at ${g.research.min_score}+ — /ai then /submit`)),g&&!g.configured&&null===U&&$(chalk.gray(s?" 🔒 本阶段通关标准制作中 — 很快更新":" 🔒 pass criteria for this phase in production — coming soon"))}}k(),$(chalk.gray(s?" ✓ 答对 ✗ 答错 ○ 未答 · ⚔ 练习 已过/共 · 赛 ✅ 过 ❌ 试过 ⬜ 未碰"+(a._anyResearch?" · ⭐ 研究":""):" ✓ right ✗ wrong ○ unanswered · ⚔ practice solved/total"+(a._anyResearch?" · ⭐ research":""))),s||$(chalk.gray(" arena ✅ passed ❌ tried ⬜ untouched")),$(chalk.gray(s?" 只看本阶段: ":" this phase only: ")+chalk.bold.green("status now")+chalk.gray(s?" · 某阶段: ":" · one phase: ")+chalk.bold.green("status N")+chalk.gray(s?" · 全部: ":" · all: ")+chalk.bold.green("status")),r.achievements.length>0&&$(" "+chalk.gray(t("achievements",l)+" ")+r.achievements.map(e=>chalk.bold.yellow("★ ")+chalk.white(e)).join(chalk.gray(" · "))),k(),w()}function te(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}export function renderArenaIntro(e=12,o=1){const n=i().startsWith("zh");if(e>12){const e=n?[chalk.bold.yellow(" ⚔ 你读完 4 张卡了 — 前面是本模块的定位检查。"),chalk.white(" ⚔ 每个模块两场:")+chalk.bold.yellow("卡 4")+chalk.white(" 定位检查(8 题 8 分钟,对 6 题即可跳到下一模块),")+chalk.bold.yellow("卡 8")+chalk.white(" 完整模拟卷(35 题 40 分钟,真卷格式)。"),chalk.white(" · 敲 ")+chalk.bold.green("contest 1")+chalk.white(" 开始 — 计时同时开始;每题选一个字母提交。"),chalk.white(" · 不锁任何卡:过不过都能继续往下读。"),chalk.gray(" ▸ 现在不想打?敲 ")+chalk.bold.green("next")+chalk.gray(" 继续读卡,检查点一直在那儿等你。")]:[chalk.bold.yellow(" ⚔ Four cards down — this module's placement check is waiting."),chalk.white(" ⚔ Two checkpoints per module: ")+chalk.bold.yellow("card 4")+chalk.white(" placement check (8 questions, 8 min; 6/8 lets you skip ahead), ")+chalk.bold.yellow("card 8")+chalk.white(" full mock paper (35 questions, 40 min, real NSW format)."),chalk.white(" · Type ")+chalk.bold.green("contest 1")+chalk.white(" to start — the clock starts with it; answer each question with a letter."),chalk.white(" · Nothing locks: pass or not, you can keep reading."),chalk.gray(" ▸ Not now? Type ")+chalk.bold.green("next")+chalk.gray(" and keep reading — the checkpoint waits for you.")];console.log();for(const o of e)console.log(o);return void console.log()}const t=r(e),a=["","one","two","three"][t.n]??String(t.n),l=learnCheckpointVerb(),s=!!process.stdout.isTTY&&!/^(C|POSIX)$/i.test(process.env.LANG||"")&&!process.env.ICOA_TEST_BOOT_MODE,c=n?[chalk.bold.yellow(1===o?" ⚔ 你读完 4 张卡了 — 前面是第一个检查点。":" ⚔ 这张卡下面有一个检查点。"),t.n>1?chalk.white(" ⚔ 每 4 张卡有一场判分赛:")+chalk.bold.yellow(`卡 ${t.cards}`)+chalk.white(`,一个阶段共 ${t.n} 场。`):chalk.white(" ⚔ 每个阶段有一场判分赛:")+chalk.bold.yellow(`卡 ${t.cards}`)+chalk.white("。"),...l?[chalk.white(" · 敲 ")+chalk.bold.green(l)+chalk.white(" 进竞技场 — ")+chalk.bold.green("battle"===l?"play":"run")+chalk.white(" 本机试跑,")+chalk.bold.green("submit")+chalk.white(" 交给判分机;第一次 submit 时计时开始。")]:[chalk.white(" · 敲 ")+chalk.bold.green(`contest ${o}`)+chalk.white(" 开始 — 计时器同时开始,题目在赛场里读。")],chalk.white(" · 判分机会真的跑你的代码,不是对答案。"),chalk.white(t.n>1?` · ${t.n} 场全过 → 解锁下一阶段。`:" · 过了这一场 → 解锁下一阶段。"),chalk.gray(" ▸ 现在不想打?敲 ")+chalk.bold.green("next")+chalk.gray(" 继续读卡,赛场一直在那儿等你。")]:[chalk.bold.yellow(1===o?" ⚔ Four cards down — a checkpoint is waiting.":" ⚔ A checkpoint is waiting under this card."),t.n>1?chalk.white(" ⚔ Every 4 cards there is a judged arena: ")+chalk.bold.yellow(`cards ${t.cards}`)+chalk.white(`, ${a} per phase.`):chalk.white(" ⚔ Each phase has one judged arena: ")+chalk.bold.yellow(`card ${t.cards}`)+chalk.white("."),...l?[chalk.white(" · Type ")+chalk.bold.green(l)+chalk.white(" to enter the arena — ")+chalk.bold.green("battle"===l?"play":"run")+chalk.white(" to try it here, ")+chalk.bold.green("submit")+chalk.white(" to send it to the judge; the clock starts at your first submit.")]:[chalk.white(" · Type ")+chalk.bold.green(`contest ${o}`)+chalk.white(" to start — the clock starts with it; the problems are read inside.")],chalk.white(" · The judge really runs your code. It is not an answer key."),chalk.white(t.n>1?` · Pass all ${a} → the next phase unlocks.`:" · Pass it → the next phase unlocks."),chalk.gray(" ▸ Not now? Type ")+chalk.bold.green("next")+chalk.gray(" and keep reading — the arena waits for you.")];console.log();for(const e of c)console.log(e),s&&te(200);console.log()}
@@ -0,0 +1 @@
1
+ import{getDeviceFingerprint as e}from"./access.js";import{httpFetch as t}from"./http.js";import{LEARN_SERVER as n}from"./learn-curricula.js";import{getCliVersion as s}from"./version.js";import{pendingTrail as i,readSync as r,score as a,startupDir as o,writeSync as u}from"./venture.js";const c=()=>n.replace(/\/$/,"");function d(e){return{name:e.name,boxes:e.boxes,segments:e.segments,versions:e.versions,score:a(e),deck:e.deck,group:e.group??"starter",market:e.market,prd:e.prd}}let l=null,f=null;export function syncTrail(n,a=o()){return l?(f||(f=l.then(()=>(f=null,syncTrail(n,a)))),f):(l=(async()=>{let o=0;try{let l=i(a);do{const i=l.slice(0,200),f=await t(`${c()}/api/icoa/learn/startup/trail`,{method:"POST",headers:{"Content-Type":"application/json","X-ICOA-Client":s()},body:JSON.stringify({vid:n.vid,device_fingerprint:e(),events:i,card:d(n)}),timeoutMs:6e3,idempotent:!0});if(!f.ok)return{ok:!1,sent:o,pending:l.length};if(!(await f.json()).success)return{ok:!1,sent:o,pending:l.length};if(i.length){const e=Math.max(...i.map(e=>e.seq??0));u({last_seq:Math.max(r(a).last_seq,e),last_ok:(new Date).toISOString()},a),o+=i.length}else u({...r(a),last_ok:(new Date).toISOString()},a);l=l.slice(200)}while(l.length);return{ok:!0,sent:o,pending:0}}catch{return{ok:!1,sent:o,pending:i(a).length}}finally{l=null}})(),l)}export async function askCoach(n,i,r,a){try{const o=await t(`${c()}/api/icoa/learn/startup/ask`,{method:"POST",headers:{"Content-Type":"application/json","X-ICOA-Client":s()},body:JSON.stringify({vid:n.vid,device_fingerprint:e(),box:i,question:r,lang:a,card:d(n)}),timeoutMs:4e4}),u=await o.json().catch(()=>({}));if(429===o.status||503===o.status)return{kind:"limited",message:String(u.message||o.status)};if(!o.ok||!u.success)return{kind:"error",message:String(u.message||`HTTP ${o.status}`)};const l=Array.isArray(u.questions)?u.questions.map(e=>String(e)).filter(Boolean):[];return"off_topic"!==u.focus&&l.length?{kind:"ok",questions:l.slice(0,2),focus:String(u.focus||""),left:"number"==typeof u.left_today?u.left_today:null}:{kind:"off_topic"}}catch{return{kind:"offline"}}}async function g(n,i,r){const a=await t(`${c()}/api/icoa/learn/startup/${n}`,{method:"POST",headers:{"Content-Type":"application/json","X-ICOA-Client":s()},body:JSON.stringify({device_fingerprint:e(),...i}),timeoutMs:r}),o=await a.json().catch(()=>({}));return{status:a.status,ok:a.ok,d:o}}export async function planSurvey(e,t){try{const{status:n,ok:s,d:i}=await g("survey/plan",{vid:e.vid,card:d(e),lang:t},45e3);return 400===n&&"incomplete"===i.message?{kind:"incomplete",missing:Array.isArray(i.missing)?i.missing.map(String):[]}:429===n||503===n?{kind:"limited",message:String(i.message||n)}:s&&i.success?{kind:"ok",id:String(i.survey_id),plan:i.plan,n:Number(i.n_planned)||0,left:Number(i.left_today)||0}:{kind:"error",message:String(i.message||`HTTP ${n}`)}}catch{return{kind:"offline"}}}export async function runSurvey(e,t){try{const{status:n,ok:s,d:i}=await g("survey/run",{vid:e.vid,survey_id:t},15e3);return 429===n||503===n?{kind:"limited",message:String(i.message||n)}:s&&i.success?{kind:"running",left:"number"==typeof i.left_today?i.left_today:null}:{kind:"error",message:String(i.message||`HTTP ${n}`)}}catch{return{kind:"offline"}}}export async function surveyStatus(e,t){try{const{ok:n,d:s}=await g("survey/status",{vid:e.vid,survey_id:t},1e4);if(!n||!s.success)return null;const i=String(s.status);return{status:["planned","running","done","failed"].includes(i)?i:"unknown",done:Number(s.n_done)||0,planned:Number(s.n_planned)||0,results:s.results}}catch{return null}}export async function askSlide(n,i,r,a){try{const o=await t(`${c()}/api/icoa/learn/startup/ask`,{method:"POST",headers:{"Content-Type":"application/json","X-ICOA-Client":s()},body:JSON.stringify({vid:n.vid,device_fingerprint:e(),slide:i,question:r,lang:a,card:d(n)}),timeoutMs:4e4}),u=await o.json().catch(()=>({}));if(429===o.status||503===o.status)return{kind:"limited",message:String(u.message||o.status)};if(!o.ok||!u.success)return{kind:"error",message:String(u.message||`HTTP ${o.status}`)};const l=Array.isArray(u.questions)?u.questions.map(e=>String(e)).filter(Boolean):[];return"off_topic"!==u.focus&&l.length?{kind:"ok",questions:l.slice(0,2),focus:String(u.focus||""),left:"number"==typeof u.left_today?u.left_today:null}:{kind:"off_topic"}}catch{return{kind:"offline"}}}export async function askAdvisor(e,t,n,s){try{const{status:i,ok:r,d:a}=await g("ask",{vid:e.vid,mode:"advisor",question:t,lang:n,card:d(e),...s},4e4);return 429===i||503===i?{kind:"limited",message:String(a.message||i)}:r&&a.success?"off_topic"!==a.focus&&a.answer?{kind:"ok",answer:String(a.answer),check:String(a.check||""),left:"number"==typeof a.left_today?a.left_today:null}:{kind:"off_topic"}:{kind:"error",message:String(a.message||`HTTP ${i}`)}}catch{return{kind:"offline"}}}export async function askSuggest(e,t,n,s){try{const{status:i,ok:r,d:a}=await g("ask",{vid:e.vid,mode:"suggest",slide:t,question:n,lang:s,card:d(e)},4e4);if(429===i||503===i)return{kind:"limited",message:String(a.message||i)};if(!r||!a.success)return{kind:"error",message:String(a.message||`HTTP ${i}`)};const o=Array.isArray(a.lines)?a.lines.map(e=>String(e)).filter(Boolean):[];return"off_topic"===a.focus||!a.title&&!o.length?{kind:"off_topic"}:{kind:"ok",title:String(a.title||""),lines:o.slice(0,4),why:String(a.why||""),left:"number"==typeof a.left_today?a.left_today:null}}catch{return{kind:"offline"}}}export async function gradePqs(e){try{const{status:t,ok:n,d:s}=await g("pqs",{vid:e.vid},18e4);return 400===t&&"pqs_few"===s.code?{kind:"few",have:Number(s.have)||0,need:Number(s.need)||3}:429===t||503===t?{kind:"limited",message:String(s.message||t)}:n&&s.success?{kind:"ok",score:Number(s.score)||0,tier:String(s.tier||""),feedback:String(s.feedback||""),improve:String(s.improve||""),turns:Number(s.turns)||0,left:"number"==typeof s.left_today?s.left_today:null}:{kind:"error",message:String(s.message||`HTTP ${t}`)}}catch{return{kind:"offline"}}}export async function makeImage(e,t,n,s){try{const{status:i,ok:r,d:a}=await g("image",{vid:e.vid,slide:t,prompt:n,lang:s},15e4);return"blocked"===a.code?{kind:"blocked"}:429===i||503===i?{kind:"limited",message:String(a.message||i)}:r&&a.success&&"string"==typeof a.image?{kind:"ok",data:Buffer.from(a.image,"base64"),mime:String(a.mime||"image/jpeg"),sha:String(a.sha||"").replace(/[^a-f0-9]/g,"").slice(0,12)||`${Date.now()}`,left:"number"==typeof a.left_today?a.left_today:null}:{kind:"error",message:String(a.message||`HTTP ${i}`)}}catch{return{kind:"offline"}}}
@@ -0,0 +1 @@
1
+ import{randomBytes as e}from"node:crypto";import{appendFileSync as t,existsSync as n,mkdirSync as s,readFileSync as r,writeFileSync as o}from"node:fs";import{homedir as i}from"node:os";import{join as a}from"node:path";export function marketCalc(e){const t=e??{},n=["people","price","buy","reach","cost"].filter(e=>"number"!=typeof t[e]),s=void 0!==t.people&&void 0!==t.price?Math.round(t.people*t.price*12):null,r=void 0!==t.people&&void 0!==t.buy&&void 0!==t.reach?Math.round(t.people*t.buy*t.reach/1e4):null;return{year:s,firstYear:null!==r&&void 0!==t.price?Math.round(r*t.price*12):null,firstYearUsers:r,margin:void 0!==t.price&&void 0!==t.cost&&t.price>0?Math.round(100*(t.price-t.cost)/t.price):null,missing:n}}export const PRD_FIELDS={model:{en:"Which AI model or service, and why that one",zh:"用哪个 AI 模型或服务,为什么选它"},data:{en:"What data the AI needs, and where it comes from",zh:"AI 需要什么数据,从哪来"},eval:{en:"How you will know the AI got it right (a number)",zh:"怎么知道 AI 答对了(写一个数字)"},human:{en:"Where a person checks or confirms",zh:"哪里由人来检查或确认"},not:{en:"What the first version will NOT do",zh:"第一版不做什么"}};export function prdSheet(e){const t=e.boxes,n=(e,n,...s)=>({key:e,title:n,text:s.map(e=>(t[e]??"").trim()).filter(Boolean).join(" · "),fromCard:!0}),s=t=>({key:t,title:PRD_FIELDS[t],text:(e.prd?.[t]??"").trim(),fromCard:!1});return[n("who",{en:"Who and what hurts",zh:"给谁、痛在哪"},"user","problem"),n("ai",{en:"What the AI does, and why now",zh:"AI 做什么、为什么是现在"},"solution","ai_edge"),s("model"),s("data"),s("eval"),n("wrong",{en:"When the AI is wrong",zh:"AI 出错时"},"risk"),s("human"),n("first",{en:"First version: the two-week test",zh:"第一版:两周验证"},"first_step"),s("not")]}export const groupOf=e=>"ai"===e.group?"ai":"starter";export const BOXES=[{n:1,id:"problem",title:{en:"Problem",zh:"问题"},ask:{en:"Who has the problem, in what moment, and how much does it hurt?",zh:"谁遇到了这个问题?在什么场景?有多痛?"},example:{en:"e.g. Year 10 students lose 20 min every night finding which homework is due tomorrow.",zh:"例:十年级学生每晚花 20 分钟找「明天交哪些作业」。"},ring:{en:"Ring 1 · Pain",zh:"第 1 环 · 痛点"}},{n:2,id:"user",title:{en:"First users",zh:"第一批用户"},ask:{en:"Who exactly will use it first? Narrow enough that you could name one.",zh:"最先用它的到底是谁?具体到你能叫出一个人的名字。"},example:{en:"e.g. Year 10 students at my school who take 3+ electives.",zh:"例:我们学校选了 3 门以上选修课的十年级学生。"},ring:{en:"Ring 1 · Pain",zh:"第 1 环 · 痛点"}},{n:3,id:"alternatives",title:{en:"What they do today",zh:"他们现在怎么凑合"},ask:{en:'How do they cope right now? (There is always something — even "nothing" or a spreadsheet.)',zh:"他们现在是怎么解决的?(一定有办法 —— 哪怕是「忍着」或者一张表格。)"},example:{en:"e.g. Screenshots of the class group chat + a paper planner.",zh:"例:截图班级群 + 纸质计划本。"},ring:{en:"Ring 1 · Pain",zh:"第 1 环 · 痛点"}},{n:4,id:"solution",title:{en:"Solution",zh:"方案"},ask:{en:"What will you build, and which step does the AI do?",zh:"你要做什么?哪一步由 AI 来做?"},example:{en:"e.g. An AI that reads the school LMS every evening and sends one list.",zh:"例:每晚由 AI 读学校的学习平台,只发一张清单。"},ring:{en:"Ring 2 · AI edge",zh:"第 2 环 · AI 解法"}},{n:5,id:"ai_edge",title:{en:"Why AI, why now",zh:"为什么是 AI、为什么是现在"},ask:{en:"Take the AI away — does your product still work? Say which AI ability makes it possible, and why it was hard before.",zh:"把 AI 拿掉,产品还成立吗?说清是哪项 AI 能力让它做得成,以及为什么以前做不到。"},example:{en:"e.g. Without AI it is just a link list. An AI model can now read messy class pages and pull out due dates — two years ago that needed a person.",zh:"例:没有 AI 就只是一堆链接。现在的 AI 模型能读懂杂乱的班级页面、找出截止日期 —— 两年前这得靠人工。"},ring:{en:"Ring 2 · AI edge",zh:"第 2 环 · AI 解法"}},{n:6,id:"value",title:{en:"Unique value",zh:"独特价值"},ask:{en:"One sentence: why would they switch from what they do today?",zh:"一句话:他们为什么要放弃现在的办法来用你的?"},example:{en:"e.g. One list, zero searching — done in 10 seconds.",zh:"例:一张清单,不用找,10 秒看完。"},ring:{en:"Ring 2 · AI edge",zh:"第 2 环 · AI 解法"}},{n:7,id:"evidence",title:{en:"Evidence",zh:"证据"},ask:{en:'Who did you actually ask, how many, and what did they DO last time? (Facts, not "they would love it".)',zh:"你真的问过谁?几个人?他们上一次遇到时实际怎么做的?(要事实,不要「他们会喜欢」。)"},example:{en:"e.g. Asked 7 classmates; 5 missed a deadline last term because of it.",zh:"例:问了 7 个同学,5 个上学期因为这个错过了截止日期。"},ring:{en:"Ring 3 · Test",zh:"第 3 环 · 验证"}},{n:8,id:"segments",title:{en:"Who your users are (shares)",zh:"用户分布"},ask:{en:"Split your users into groups, give each a share (total 100%) and where the number comes from.",zh:"把用户分成几类,每类占多少(合计 100%),数字从哪来。"},example:{en:"e.g. seg Year 10 students 60% asked 7 classmates · seg parents 40% ABS 2021 census",zh:"例:seg 十年级学生 60% 问了7个同学 · seg 家长 40% ABS 2021 人口普查"},ring:{en:"Ring 3 · Test",zh:"第 3 环 · 验证"}},{n:9,id:"price",title:{en:"Who pays, how much",zh:"谁付钱、付多少"},ask:{en:"Who pays, how much, and how often? Write a number.",zh:"谁付钱?付多少?多久付一次?写一个数字。"},example:{en:"e.g. Parents, $3 a month; or the school, $500 a year.",zh:"例:家长每月 3 澳元;或者学校每年 500 澳元。"},ring:{en:"Ring 4 · Numbers",zh:"第 4 环 · 算账"}},{n:10,id:"ai_cost",title:{en:"AI cost per user",zh:"每个用户的 AI 成本"},ask:{en:"About how many AI calls does one user make a month, what does each cost, and how much of the price is left?",zh:"一个用户每月大约调用 AI 多少次、每次多少钱、扣掉之后价格里还剩多少?"},example:{en:"e.g. 30 calls a month × $0.002 = $0.06; price $4 ⇒ about $3.94 left before other costs.",zh:"例:每月 30 次 × 0.015 元 = 0.45 元;售价 25 元 ⇒ 扣掉后约剩 24.5 元(还没算其他成本)。"},ring:{en:"Ring 4 · Numbers",zh:"第 4 环 · 算账"}},{n:11,id:"moat",title:{en:"Moat",zh:"护城河"},ask:{en:"If next year's AI does your feature for free, what do you still have? Pick one — data that gets better with use, hard to switch away, a way to reach users, trust, something only you have — and give one piece of evidence.",zh:"如果明年的 AI 免费就能做你这个功能,你还剩什么?选一种 —— 越用越好的数据、用户换走很麻烦、接触用户的渠道、信任、只有你有的东西 —— 并给一条证据。"},example:{en:"e.g. Every correction a student makes teaches our list the school's page layout; 3 schools' layouts after one term.",zh:"例:学生每改一次,清单就更懂这所学校的页面格式;一个学期后我们有 3 所学校的格式。"},ring:{en:"Ring 5 · Moat",zh:"第 5 环 · 护城河"}},{n:12,id:"risk",title:{en:"When the AI gets it wrong",zh:"AI 出错时"},ask:{en:"When the AI is wrong, leaks something private, is tricked by a prompt or is misused — how will you notice, and what happens then?",zh:"AI 答错、泄露隐私、被提示词骗、被拿去做坏事时 —— 你怎么发现?之后怎么处理?"},example:{en:'e.g. If the AI misreads a due date, the student taps "wrong" and the teacher\'s page is shown instead.',zh:"例:AI 读错截止日期时,学生点「不对」,就直接显示老师的原页面。"},ring:{en:"Ring 6 · AI safety",zh:"第 6 环 · AI 安全"}},{n:13,id:"first_step",title:{en:"Two-week test",zh:"两周内的最小验证"},ask:{en:"The smallest experiment you can finish in two weeks — and the number that would count as success.",zh:"两周内能做完的最小实验 —— 以及多少算成功。"},example:{en:"e.g. Send a hand-made list to 10 classmates for 5 nights; success = 6 still read it on night 5.",zh:"例:手工整理清单发给 10 个同学,连续 5 晚;第 5 晚还有 6 人在看就算成功。"},ring:{en:"Ring 7 · Build",zh:"第 7 环 · 做出来"}}];export const SEG_N=BOXES.findIndex(e=>"segments"===e.id)+1;export const BOX_IDS=BOXES.filter(e=>"segments"!==e.id).map(e=>e.id);const h=/\d/,u=/\b(everyone|everybody|anyone|all (people|students|kids|parents))\b|所有人|大家|每个人|所有学生|任何人/i,l=/\b(would|will|might|probably|maybe|think|believe|love|like it|should)\b|会喜欢|应该会|可能|觉得|肯定会|愿意/i,d=/\b(asked|interviewed|talked|spoke|met|surveyed|watched|told me|last (time|week|month|term|year)|did)\b|问过|问了|访谈|聊过|调查|告诉我|上次|上学期|上周|上个月|观察/i,c=/^(none|nothing|no one|n\/a|没有|无|没人)[.。!!]?$/i,p=/\b(ai|a\.i\.|model|llm|gpt|machine learning|ml|neural|vision|speech|chatbot|agent)\b|人工智能|智能|模型|大模型|识别|生成|机器学习|算法/i,m=/\b(without|take (it|the ai) away|remove|now|today|recent|recently|newly|before|years? ago|202\d)\b|去掉|拿掉|没有 ?ai|没有人工智能|现在|最近|以前|过去|两年前|几年前|如今/i,g=/\b(better|smarter|our own|best|stronger) (ai|model|algorithm|technology|tech)\b|技术领先|算法更好|模型更好|更聪明|更强的 ?(ai|模型|算法)|自研(模型|算法)/i,y=/\b(check|review|human|teacher|parent|report|flag|fallback|confirm|verify|alert|log|tap|wrong)\b|人工|老师|家长|确认|检查|兜底|举报|回退|核对|报警|提醒|标记|不对/i;export function contentSize(e){return(e.match(/[㐀-鿿豈-﫿]/g)||[]).length/2+e.replace(/[㐀-鿿豈-﫿]/g," ").split(/\s+/).filter(Boolean).length}export function checkBox(e,t){const n=(t||"").trim();if(!n)return{status:"empty"};if("alternatives"===e&&c.test(n))return{status:"thin",hint:{en:'There is always an alternative — even "put up with it" or a spreadsheet. What do they do today?',zh:"一定有替代办法 —— 哪怕是「忍着」或者一张表格。他们今天到底怎么做?"}};if("user"===e&&u.test(n))return{status:"thin",hint:{en:'"Everyone" is nobody. Narrow it until you could name one real person.',zh:"「所有人」等于没有人。缩小到你能叫出一个真人的名字。"}};if(contentSize(n)<5)return{status:"thin",hint:{en:"Too short to judge — add one more concrete detail.",zh:"太短了,看不出来 —— 再加一个具体细节。"}};if("evidence"===e){if(!h.test(n))return{status:"thin",hint:{en:"How many people? Write the number.",zh:"问了几个人?写出数字。"}};if(l.test(n)&&!d.test(n))return{status:"thin",hint:{en:"That is a guess about the future. Ask what they DID last time, not what they would do.",zh:"这是对未来的猜测。问他们上一次实际做了什么,而不是会不会做。"}}}if("solution"===e&&!p.test(n))return{status:"thin",hint:{en:"Which step does the AI do? Name it — every idea here has to be AI-native.",zh:"哪一步由 AI 来做?写出来 —— 这里每个点子都必须是 AI 原生的。"}};if("ai_edge"===e){if(!p.test(n))return{status:"thin",hint:{en:"Name the AI ability (reading, seeing, listening, writing…).",zh:"写出是哪项 AI 能力(读、看、听、写……)。"}};if(!m.test(n))return{status:"thin",hint:{en:"Answer the test: what is left without AI — and why could nobody do this a few years ago?",zh:"回答这个测试:没有 AI 还剩什么?为什么几年前没人做得到?"}}}return"ai_cost"===e&&(n.match(/\d+(?:[.,]\d+)?/g)||[]).length<2?{status:"thin",hint:{en:"Write the numbers: calls a month × cost per call, then what is left of your price.",zh:"写出数字:每月调用次数 × 每次成本,再算价格里还剩多少。"}}:"moat"===e&&g.test(n)?{status:"thin",hint:{en:"A better AI is not a moat — everyone gets the next model. What do you have that a new model cannot give them?",zh:"「AI 更好」不是护城河 —— 下一代模型人人都能用。有什么是新模型给不了别人的?"}}:"risk"!==e||y.test(n)?"price"!==e||h.test(n)?"first_step"!==e||h.test(n)?{status:"solid"}:{status:"thin",hint:{en:'Add the number that counts as success (e.g. "6 of 10 still use it on day 5").',zh:"加上「多少算成功」的数字(例如「10 人里第 5 天还有 6 人在用」)。"}}:{status:"thin",hint:{en:"Write a number — and who pays it.",zh:"写一个数字 —— 以及谁来付。"}}:{status:"thin",hint:{en:"Say how you would notice the AI went wrong, and what the product does then.",zh:"说清你怎么发现 AI 出错了,以及产品之后怎么处理。"}}}export function segmentTotal(e){return Math.round(10*e.reduce((e,t)=>e+t.share,0))/10}export function checkSegments(e){if(!e.length)return{status:"empty"};const t=segmentTotal(e);return Math.abs(t-100)>1?{status:"thin",hint:{en:`Shares add up to ${t}% — make them 100%.`,zh:`合计 ${t}% —— 要凑成 100%。`}}:e.some(e=>e.source.trim().length<3)?{status:"thin",hint:{en:"Every group needs a source: a statistic, a survey, or the people you asked.",zh:"每一类都要写来源:统计数据、调查,或者你问过的人。"}}:e.length<2?{status:"thin",hint:{en:'Add at least one more group — even "everyone else" — so the survey has a comparison.',zh:"至少再加一类 —— 哪怕是「其他人」—— 调研才有对照。"}}:{status:"solid"}}export function statusOf(e,t){const n=BOXES[t-1];return"segments"===n.id?checkSegments(e.segments):checkBox(n.id,e.boxes[n.id])}export function solidCount(e){let t=0;for(let n=1;n<=BOXES.length;n++)"solid"===statusOf(e,n).status&&t++;return t}export function score(e){return Math.round(10*solidCount(e)/BOXES.length)}export function firstOpenBox(e){for(let t=1;t<=BOXES.length;t++)if("solid"!==statusOf(e,t).status)return t;return null}export function parseSegmentDetailed(e){const t=e.trim();if(!t)return{err:"no_share"};const n=t.includes("|")?"|":t.includes(",")||t.includes(",")?/[,,]/:null;if(n){const e=t.split(n).map(e=>e.trim());if(e.length>=2){const t=Number.parseFloat(e[1].replace("%",""));if(e[0]&&Number.isFinite(t)&&t>0&&t<=100)return{seg:{name:e[0],share:t,source:e.slice(2).join(" ").trim()}}}}const s=t.split(/\s+/),r=s.map((e,t)=>t>0&&(e=>{if(!/^\d+(\.\d+)?%?$/.test(e))return!1;const t=Number.parseFloat(e.replace("%",""));return t>0&&t<=100})(e)?t:-1).filter(e=>e>0);if(!r.length)return{err:"no_share"};const o=r.filter(e=>s[e].endsWith("%"));let i;if(o.length)i=o[0];else{if(1!==r.length)return{err:"ambiguous"};i=r[0]}const a=Number.parseFloat(s[i].replace("%",""));return{seg:{name:s.slice(0,i).join(" "),share:a,source:s.slice(i+1).join(" ")}}}export function parseSegment(e){const t=parseSegmentDetailed(e);return"seg"in t?t.seg:null}export function startupDir(){return process.env.ICOA_STARTUP_DIR||a(i(),".icoa","startup")}export function newVid(){return e(16).toString("hex")}export function emptyVenture(e=(new Date).toISOString()){return{v:1,vid:newVid(),name:"",boxes:{},segments:[],versions:0,created:e,updated:e}}export function loadVenture(e=startupDir()){const t=a(e,"venture.json");if(!n(t))return emptyVenture();try{const n=JSON.parse(r(t,"utf8"));if(n&&1===n.v&&"object"==typeof n.boxes&&Array.isArray(n.segments))return"string"==typeof n.vid&&/^[a-f0-9]{16,40}$/.test(n.vid)||(n.vid=newVid(),saveVenture(n,e)),n}catch{try{o(a(e,`venture.bad-${Date.now()}.json`),r(t))}catch{}}return emptyVenture()}export function saveVenture(e,t=startupDir()){s(t,{recursive:!0}),e.updated=(new Date).toISOString(),o(a(t,"venture.json"),JSON.stringify(e,null,2))}export function snapshot(e,t=startupDir()){const n=e.versions+1;return e.versions=n,s(a(t,"versions"),{recursive:!0}),saveVenture(e,t),o(a(t,"versions",`v${n}.json`),JSON.stringify(e,null,2)),n}let f=0;export function nextSeq(){return f=Math.max(Date.now(),f+1),f}export function appendTrail(e,n=startupDir()){try{s(n,{recursive:!0}),t(a(n,"trail.jsonl"),`${JSON.stringify({ts:(new Date).toISOString(),seq:nextSeq(),...e})}\n`)}catch{}}export function readTrail(e=startupDir()){const t=a(e,"trail.jsonl");if(!n(t))return[];const s=[];for(const e of r(t,"utf8").split("\n"))if(e.trim())try{s.push(JSON.parse(e))}catch{}return s}export function readSync(e=startupDir()){try{const t=JSON.parse(r(a(e,"sync.json"),"utf8"));if(t&&"number"==typeof t.last_seq)return t}catch{}return{last_seq:0}}export function writeSync(e,t=startupDir()){try{s(t,{recursive:!0}),o(a(t,"sync.json"),JSON.stringify(e))}catch{}}export function pendingTrail(e=startupDir()){const t=readSync(e).last_seq;return readTrail(e).filter(e=>"number"==typeof e.seq&&e.seq>t)}export function buildReport(e,t){const n=new Array(BOXES.length).fill(0);let s=0,r=0,o=0,i=0,a=null;const h=[];let u=0,l=0,d=0,c=0,p=0,m=0,g=0,y=0;const f=[];let v=0;for(const e of t)"image"===e.ev&&v++,"advise"===e.ev?p++:"suggest"===e.ev?m++:"drop"===e.ev?y++:"pqs"===e.ev&&"number"==typeof e.score&&f.push(e.score),"slide_edit"!==e.ev||"accept"!==e.mode&&"accept_line"!==e.mode||g++,"slide_edit"===e.ev?u++:"slide_ask"===e.ev?l++:"preview"===e.ev?d++:"export"===e.ev&&c++,"survey"===e.ev&&h.push({buy_au:e.buy_au??null,buy_cn:e.buy_cn??null}),"answer"===e.ev?(s++,e.box&&e.box>=1&&e.box<=BOXES.length&&n[e.box-1]++,"solid"===e.status&&"solid"!==e.prev_status&&i++):"undo"===e.ev?r++:"seg_add"===e.ev||"seg_del"===e.ev?(o++,n[SEG_N-1]++,"solid"===e.status&&"solid"!==e.prev_status&&i++):"save"===e.ev&&null===a&&"number"==typeof e.score&&(a=e.score);const w=t.map(e=>Date.parse(e.ts)).filter(e=>Number.isFinite(e)),b=w.length>1?Math.round((Math.max(...w)-Math.min(...w))/6e4):0;return{versions:e.versions,answers:s,undos:r,segChanges:o,improved:i,editsPerBox:n,minutes:b,scoreNow:score(e),scoreAtFirstSave:a,surveys:h,slideEdits:u,slideAsks:l,previews:d,exports:c,advises:p,suggests:m,accepts:g,drops:y,pqs:f,images:v}}export function saveSurvey(e,t,n=startupDir()){try{s(a(n,"surveys"),{recursive:!0}),o(a(n,"surveys",`${e}.json`),JSON.stringify(t)),o(a(n,"surveys","last.txt"),e)}catch{}}export function lastSurvey(e=startupDir()){try{const t=r(a(e,"surveys","last.txt"),"utf8").trim();return/^[a-f0-9]{12}$/.test(t)?JSON.parse(r(a(e,"surveys",`${t}.json`),"utf8")):null}catch{return null}}