icoa-cli 2.19.448 → 2.19.450

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{existsSync as o,mkdirSync as e,readFileSync as n,readdirSync as t,writeFileSync as l}from"node:fs";import{join as s}from"node:path";import chalk from"chalk";import{makeReplAsker as a}from"../lib/repl-asker.js";import{getConfig as i}from"../lib/config.js";import{logCommand as r}from"../lib/logger.js";import{openFile as c}from"../lib/open-file.js";import{serializeIpynb as g}from"../lib/notebook-doc.js";import{loadLearnState as u}from"../lib/learn-state.js";import{buildStarterCells as y,dataFileUrls as d,parseKaggleTaskList as h,parseSubmitResponse as b,validateSubmissionText as m}from"../lib/kaggle.js";function p(){return process.env.ICOA_KAGGLE_SERVER?process.env.ICOA_KAGGLE_SERVER.replace(/\/$/,""):"https://practice.icoa2026.au"}async function f(o){try{const e=await fetch(p()+o,{signal:AbortSignal.timeout(3e4)});return await e.json()}catch{return null}}async function k(o){try{const e=await fetch(o,{signal:AbortSignal.timeout(6e4)});return e.ok?await e.text():null}catch{return null}}function w(o,e){return(i().language||"en").toLowerCase().startsWith("zh")?o:e}function v(){console.log(),console.log(chalk.yellow(w(" 练习服务器现在连不上。"," The practice server is not reachable right now."))),console.log(chalk.gray(w(" 检查一下网络,或者过一会儿再试。"," Check your connection, or try again later."))),console.log()}function $(o){return s(process.cwd(),"icoa-kaggle",o)}function _(o,e){const n=[];let t="",l=0;const s=o=>/[ᄀ-ᅟ⺀-꓏가-힣豈-﫿︰-﹏＀-⦆¢-₩]/.test(o);for(const a of o){const o=s(a)?2:1;if(l+o>e){const o=t.lastIndexOf(" ");if(!s(a)&&" "!==a&&o>e/3){const e=t.slice(o+1);n.push(t.slice(0,o)),t=e,l=[...e].reduce((o,e)=>o+(s(e)?2:1),0)}else n.push(t),t="",l=0;if(" "===a&&""===t)continue}t+=a,l+=o}return""!==t.trim()&&n.push(t),n}function j(o){return"local-eval"===o?.judge?(console.log(chalk.bold.white(w(" 出分(就在 notebook 里):"," Scoring (inside the notebook):"))),void console.log(chalk.gray(w(" 跑最后一格 —— "," run the final cell — the "))+chalk.white("FINAL")+chalk.gray(w(" 那一行就是你的分数,没有东西要上传。"," line is your score. Nothing to upload.")))):"icoa-holdout"===o?.judge?(console.log(chalk.bold.white(w(" 交给 ICOA 判分(服务端评分):"," Submit to ICOA (scored on the server):"))),console.log(chalk.gray(" ")+chalk.bold.cyan(`kaggle submit ${o.comp_id}`)),void console.log(chalk.gray(w(" 与秘密测试标签比对 → 实时排名看 "," scores vs the secret test labels → live rank on "))+chalk.cyan("board"))):"nitro"===o?.judge?(console.log(chalk.bold.white(w(" 怎么知道做得对不对:"," How to tell whether you got it right:"))),console.log(chalk.gray(w(" · 这道题来自 judge.nitro-ai.org,判分在他们服务器上"," · this task comes from judge.nitro-ai.org — the judging lives on their server"))),console.log(chalk.gray(w(" · 想要真分数:去 "," · for a real score: register at "))+chalk.cyan("judge.nitro-ai.org")+chalk.gray(w(" 注册后提交"," and submit there"))),void console.log(chalk.gray(w(" · 冲刺期更快的办法:做完对照官方解答,或问 "," · faster right now: compare against the official solution, or ask "))+chalk.cyan("ai4ioai"))):(console.log(chalk.bold.white(w(" 去 Kaggle 提交(手动,用你自己的账号):"," Submit on Kaggle (manual, your own account):"))),void(o?.kaggle_url?(console.log(chalk.gray(w(" 1. 打开 "," 1. open "))+chalk.cyan(o.kaggle_url)),o?.needs_gpu?console.log(chalk.gray(w(" 2. 交 notebook 产出的那个文件 —— 最后一格写了确切步骤"," 2. submit the file your notebook produced — its final cell has the exact steps"))):console.log(chalk.gray(w(" 2. Submit Predictions → 上传 "," 2. Submit Predictions → upload "))+chalk.white("submission.csv")),console.log(chalk.gray(w(" 3. 看分数,改 MODEL 那一格,重跑,再来一轮。"," 3. read your score, improve the MODEL cell, re-run, repeat.")))):(console.log(chalk.gray(w(" 在 kaggle.com 搜这个比赛名提交,或做完对照官方解答自查。"," Search kaggle.com for this competition, or check yourself against the official solution."))),console.log(chalk.gray(w(" 卡住了问 "," Stuck? ask "))+chalk.cyan("ai4ioai")+chalk.gray(w(" —— 它是弱模型,把问题问准是这次要练的本事。"," — a deliberately weak model; asking precisely is the skill you are training."))))))}export async function runKaggle(n){const t=a(),i=async o=>await t.ask(o)??"";try{console.log(),console.log(chalk.bold.cyan(" 📊 KAGGLE PRACTICE")+chalk.gray(w(" · 真实的 ML 比赛,配一本能直接跑的 starter notebook"," · real ML competitions, a runnable starter notebook"))),console.log(chalk.gray(w(" 小题在你自己的 CPU 上跑;"," Small tasks run on your CPU; "))+chalk.magenta(w("⚡ GPU 题","⚡ GPU tasks"))+chalk.gray(w("在 ICOA 的 GPU 箱上跑。"," run on the ICOA GPU box."))),console.log();const t=await f("/api/icoa/kaggle/tasks");if(!t)return v();const a=h(t);if(0===a.length)return console.log(chalk.yellow(w(" 现在还没有上线的练习赛 —— 过一会儿再来。"," No practice competitions are live yet — check back soon."))),void console.log();let c=n?a.find(o=>o.comp_id===n):void 0;if(n&&!c&&console.log(chalk.yellow(w(` 没有叫 "${n}" 的比赛。`,` No competition called "${n}".`))),!c){console.log(chalk.white(w(" 正在开放的练习赛:"," Live practice competitions:"))),a.forEach((o,e)=>{const n=o.needs_gpu?chalk.magenta(" ⚡GPU"):"";console.log(chalk.gray(` ${e+1}. `)+chalk.cyan(o.comp_id)+chalk.gray(` — ${o.title} · ${o.metric}`)+n)});for(let o=0;o<3&&!c;o++){const o=(await i(chalk.cyan(w(" 选一个(序号或 id): "," Pick one (number or id): ")))).trim();if(!o)return;const e=Number(o);c=!Number.isNaN(e)&&a[e-1]||a.find(e=>e.comp_id===o.toLowerCase())||void 0,c||console.log(chalk.gray(w(` 输 1-${a.length} 之间的序号,或者一个 id,比如 "${a[0].comp_id}"。`,` Try a number 1-${a.length} or an id like "${a[0].comp_id}".`)))}if(!c)return}const u=c.comp_id;if(r(`kaggle: download ${u}`),c.needs_gpu)return void await async function(n,t){const a=$(n);if(console.log(),console.log(chalk.white(` ${t.title}`)+chalk.gray(` · ${t.metric}`)+chalk.bold.magenta(" ⚡ GPU task")),t.description){console.log();for(const o of _(t.description,74))console.log(chalk.white(` ${o}`))}console.log(),console.log(chalk.gray(w(" 正在取 notebook…"," Fetching the notebook…"))+chalk.gray(w(" (数据留在 GPU 箱上,不下载)"," (the dataset stays on the GPU box — no download)")));const i=await f(`/api/icoa/kaggle/${n}/starter`),r=i?.data?.starter??i?.starter;if("string"!=typeof r||0===r.length)return v();const c=s(a,"starter.ipynb");let g=!1;try{e(a,{recursive:!0}),o(c)?g=!0:l(c,r),l(s(a,"meta.json"),`${JSON.stringify(t,null,2)}\n`)}catch{return void console.log(chalk.yellow(w(" 写不进 notebook —— 检查一下这个目录的写权限。"," Could not write the notebook here — check directory permissions.")))}console.log(chalk.green(" ✓ notebook: ")+chalk.white(c)+chalk.gray(g?w(" (保留了你原来那本)"," (kept your existing one)"):w(" (里面是真正的 IOAI 题)"," (the real IOAI task inside)"))),console.log(chalk.green(" ✓ dataset: ")+chalk.white(w("已经在 GPU 箱上","already on the GPU box"))+chalk.gray(w(" —— 不用下载"," — no download needed"))),console.log(),console.log(chalk.bold.white(w(" 这是 GPU 题 —— 三步:"," This is a GPU task — 3 steps:"))),console.log(chalk.gray(" 1. ")+chalk.bold.cyan(`icoa ipynb ${c}`)),console.log(chalk.gray(" 2. ")+chalk.bold.cyan("gpu key <your-key>")+chalk.gray(w(" 然后 "," then "))+chalk.bold.cyan("gpu on")+chalk.gray(w(" (连到数据所在的那台箱子)"," (connects you to the box where the data lives)"))),console.log(chalk.gray(" 3. ")+chalk.bold.cyan("run all")+chalk.gray(w(" → notebook 在 GPU 上训练。"," → the notebook trains on the GPU."))),console.log(),console.log(chalk.gray(w(" 做题时随时看: "," While you work: "))+chalk.cyan("gpu status")+chalk.gray(w(" 你还剩多少时间 · "," your time left · "))+chalk.cyan("gpu queue")+chalk.gray(w(" 谁在用,谁在等"," who is on, who is waiting"))),console.log(),t.kaggle_url&&(console.log(chalk.gray(w(" 去 Kaggle 提交: "," Submit on Kaggle: "))+chalk.cyan(t.kaggle_url)),console.log())}(u,c);if(console.log(),console.log(chalk.white(` ${c.title}`)+chalk.gray(` · ${c.metric}`)),c.description){console.log();for(const o of _(c.description,74))console.log(chalk.white(` ${o}`))}console.log(),console.log(chalk.gray(w(" 正在下载数据…"," Downloading data…")));let b=null;const m=d(c);if(m){const[o,e,n]=await Promise.all([k(m.train),k(m.test),k(m.sample_submission)]);o&&e&&n&&(b={train:o,test:e,sample_submission:n})}if(!b){const o=await f(`/api/icoa/kaggle/${u}/data`);b=o?.data??o}if(!b?.train||!b?.test||!b?.sample_submission)return v();const p=$(u),j={...c,...b.meta??{}};try{e(p,{recursive:!0}),l(s(p,"train.csv"),b.train),l(s(p,"test.csv"),b.test),l(s(p,"sample_submission.csv"),b.sample_submission),l(s(p,"meta.json"),`${JSON.stringify(j,null,2)}\n`)}catch{return void console.log(chalk.yellow(" Could not write the data files here — check directory permissions."))}const G=s(p,"starter.ipynb");let P=!1;if(o(G))P=!0;else{const o=await f(`/api/icoa/kaggle/${u}/starter`),e=o?.data?.starter??o?.starter;"string"==typeof e&&e.length>0?l(G,e):l(G,g(y(p,j)))}const x="number"==typeof j.n_train?`${j.n_train} rows`:"labelled",C="number"==typeof j.n_test?`${j.n_test} rows`:"predict these";console.log(chalk.green(" ✓ train: ")+chalk.white(s(p,"train.csv"))+chalk.gray(` (${x})`)),console.log(chalk.green(" ✓ test: ")+chalk.white(s(p,"test.csv"))+chalk.gray(` (${C})`)),console.log(chalk.green(" ✓ format: ")+chalk.white(s(p,"sample_submission.csv"))),console.log(chalk.green(" ✓ notebook: ")+chalk.white(G)+chalk.gray(P?" (kept your existing one)":" (runnable baseline inside)")),(j.licence||j.attribution)&&console.log(chalk.gray(` licence: ${j.licence??"—"} · ${j.attribution??""}`)),console.log(),S(u,j,G),console.log()}finally{t.close()}}function S(o,e,n){e?.needs_gpu?(console.log(chalk.bold.white(" Your move — 4 steps (⚡ GPU task):")),console.log(chalk.gray(" 1. ")+chalk.bold.cyan(`icoa ipynb ${n}`)),console.log(chalk.gray(" 2. ")+chalk.bold.cyan("gpu key <your-key>")+chalk.gray(" then ")+chalk.bold.cyan("gpu on")+chalk.gray(" → ")+chalk.bold.cyan("run all")+chalk.gray(" (trains on the GPU box)")),console.log(chalk.gray(" 3. ")+chalk.bold.cyan("download <file>")+chalk.gray(" → pulls your results (submission.csv / predictions.zip) here")),console.log(chalk.gray(" 4. submit on kaggle.com — the notebook's final cell has the exact steps.")),console.log(),console.log(chalk.gray(" While you work: ")+chalk.cyan("gpu status")+chalk.gray(" your time left · ")+chalk.cyan("gpu queue")+chalk.gray(" who is on, who is waiting"))):(console.log(chalk.bold.white(" Your move — 3 steps:")),console.log(chalk.gray(" 1. ")+chalk.bold.cyan(`icoa ipynb ${n}`)+chalk.gray(" → run all (baseline trains)")),console.log(chalk.gray(" 2. it writes ")+chalk.white("submission.csv")+chalk.gray(" → verify with ")+chalk.cyan(`kaggle check ${o}`)),"icoa-holdout"===e?.judge?console.log(chalk.gray(" 3. ")+chalk.bold.cyan(`kaggle submit ${o}`)+chalk.gray(" → scored + ranked live.")):"nitro"===e?.judge?console.log(chalk.gray(" 3. scored at ")+chalk.cyan("judge.nitro-ai.org")+chalk.gray(" (not Kaggle) — or just work the val score. See below.")):console.log(chalk.gray(" 3. upload it on Kaggle yourself — then beat the baseline."))),console.log(),console.log(chalk.bold.white(" 🤝 Want AI help? Set up your cockpit:")),console.log(chalk.gray(" 1. split the screen: ")+chalk.bold.cyan("Ctrl-b %")+chalk.gray(" (lesson/work left · AI right)")),console.log(chalk.gray(" 2. in the right pane: ")+chalk.bold.cyan("icoa")+chalk.gray(" then type ")+chalk.bold.cyan("ai4ioai")+chalk.gray(" → live Gemma 3")),console.log(chalk.gray(" 3. ask it for feature ideas or bug fixes — then ")+chalk.bold.white("VERIFY")+chalk.gray(" with your val score (a tip that lowers it, drop it).")),console.log(),j(e)}export async function runKaggleGuide(e){console.log();const t=G(e,"guide");if(!t)return;const l=$(t);let a=null;try{a=JSON.parse(n(s(l,"meta.json"),"utf-8"))}catch{a=null}r(`kaggle: guide ${t}`);const i=s(l,"starter.ipynb"),c=o(s(l,"submission.csv"));console.log(chalk.bold.white(` ═══ 📖 ${a?.title??t} — walkthrough ═══`)),console.log(),console.log(chalk.gray(" Where you are: data ")+chalk.green("downloaded ✓")+chalk.gray(" · submission.csv: ")+(c?chalk.green("written ✓"):chalk.yellow("not yet — run the notebook"))),console.log(),S(t,a,i),console.log(),console.log(chalk.gray(" Inside the notebook, ")+chalk.cyan("guide")+chalk.gray(" shows the notebook-level guide.")),console.log()}function G(e,n){if(e)return e;const l=s(process.cwd(),"icoa-kaggle"),a=o(l)?t(l,{withFileTypes:!0}).filter(e=>e.isDirectory()&&(o(s(l,e.name,"sample_submission.csv"))||o(s(l,e.name,"meta.json")))).map(o=>o.name):[];if(1===a.length)return a[0];if(0===a.length)return console.log(chalk.yellow(" No downloaded competition found here — run ")+chalk.cyan("kaggle")+chalk.yellow(" first.")),console.log(),null;console.log(chalk.white(" Several competitions downloaded — pick one:"));for(const o of a)console.log(chalk.gray(` kaggle ${n} `)+chalk.cyan(o));return console.log(),null}export async function runKaggleCheck(e){console.log();const t=G(e,"check");if(!t)return;const l=$(t),a=s(l,"submission.csv"),i=s(l,"sample_submission.csv");try{if(JSON.parse(n(s(l,"meta.json"),"utf-8")).needs_gpu&&!o(i))return console.log(chalk.gray(" ⚡ GPU task — results are produced and validated by the notebook itself.")),console.log(chalk.gray(" Pull them with ")+chalk.cyan("download <file>")+chalk.gray(" inside ")+chalk.cyan("icoa ipynb")+chalk.gray(", then submit on kaggle.com (final cell has the steps).")),void console.log()}catch{}if(!o(i))return console.log(chalk.yellow(` No data for "${t}" here — run `)+chalk.cyan(`kaggle ${t}`)+chalk.yellow(" first.")),void console.log();if(!o(a))return console.log(chalk.yellow(" No submission.csv yet — open the notebook and run all cells:")),console.log(chalk.gray(" ")+chalk.cyan(`icoa ipynb ${s(l,"starter.ipynb")}`)),void console.log();const g=m(n(a,"utf-8"),n(i,"utf-8"));r(`kaggle: check ${t} → ${g.ok?"ok":`rejected: ${g.problems[0]??"format"}`}`);let u=null;try{u=JSON.parse(n(s(l,"meta.json"),"utf-8"))}catch{u=null}if(g.ok)console.log(chalk.bold.green(" ✓ submission.csv has the right format")+chalk.gray(" (matches sample_submission.csv)")),console.log(chalk.gray(" ")+chalk.white(a)),console.log(),j(u),c(l);else{console.log(chalk.bold.red(" ✗ submission.csv would be rejected:"));for(const o of g.problems)console.log(chalk.yellow(` · ${o}`));console.log(),console.log(chalk.gray(" Fix the submission cell in the notebook and re-run it."))}console.log()}export async function runKaggleSubmit(e){console.log();const t=G(e,"submit");if(!t)return;const l=$(t),i=s(l,"submission.csv"),c=s(l,"sample_submission.csv");let g=null;try{g=JSON.parse(n(s(l,"meta.json"),"utf-8"))}catch{g=null}if("local-eval"===g?.judge)return console.log(chalk.yellow(" This task is scored inside the notebook — nothing to upload.")),j(g),void console.log();if(!g||!o(c))return console.log(chalk.yellow(` No data for "${t}" here — run `)+chalk.cyan(`kaggle ${t}`)+chalk.yellow(" first.")),void console.log();if("icoa-holdout"!==g.judge)return console.log(chalk.yellow(" This competition is judged on kaggle.com — nothing to submit here.")),console.log(),j(g),void console.log();if(!o(i))return console.log(chalk.yellow(" No submission.csv yet — open the notebook and run all cells:")),console.log(chalk.gray(" ")+chalk.cyan(`icoa ipynb ${s(l,"starter.ipynb")}`)),void console.log();const y=n(i,"utf-8"),d=m(y,n(c,"utf-8"));if(!d.ok){r(`kaggle: submit ${t} → local-reject: ${d.problems[0]??"format"}`),console.log(chalk.bold.red(" ✗ submission.csv would be rejected:"));for(const o of d.problems)console.log(chalk.yellow(` · ${o}`));return console.log(),console.log(chalk.gray(" Fix the submission cell in the notebook and re-run it.")),void console.log()}let h=u()?.token??"";if(!h){const o=a();try{h=(await o.ask(chalk.cyan(" Your learn token: "))??"").trim()}finally{o.close()}if(!h)return console.log(chalk.gray(" A learn token identifies you on the board — ask your coach for one.")),void console.log()}console.log(chalk.gray(" Scoring on the server…"));const f=await async function(o,e){try{const n=await fetch(p()+o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:AbortSignal.timeout(6e4)});return await n.json()}catch{return null}}(`/api/icoa/kaggle/${t}/submit`,{token:h,submission_csv:y}),k=b(f);if(r(`kaggle: submit ${t} → ${k.ok?`${k.metric}=${k.score}${k.deduped?" (deduped)":""} rank=${k.rank??"-"}`:k.reason??"error"}`),console.log(),k.ok){const o=`${k.metric}: ${Number(k.score).toFixed(4).replace(/\.?0+$/,"")}`;k.deduped?(console.log(chalk.bold.white(` ✓ already scored — ${o}`)),console.log(chalk.gray(" These exact predictions were scored before. Improve the MODEL cell and re-run."))):(console.log(chalk.bold.green(` ✓ scored — ${o}`)),"number"==typeof k.rank&&"number"==typeof k.fieldSize&&console.log(chalk.bold.white(` 🏁 board rank #${k.rank}`)+chalk.gray(` of ${k.fieldSize}`))),k.boardEvent&&console.log(chalk.gray(" standings: ")+chalk.cyan(`board ${k.boardEvent} ${t}`))}else switch(k.reason){case"bad_token":console.log(chalk.bold.red(" ✗ that learn token was not accepted")+chalk.gray(" (invalid or expired)")),console.log(chalk.gray(" Check the token with your coach, then try again."));break;case"format":console.log(chalk.bold.red(" ✗ the server rejected submission.csv:"));for(const o of k.problems??[])console.log(chalk.yellow(` · ${o}`));break;case"event_closed":case"outside_window":console.log(chalk.bold.yellow(" ⏱ the submission window for this competition is closed."));break;case"cap_reached":console.log(chalk.bold.yellow(" ⏱ you have used all your submissions for this competition."));break;case"kaggle_judged":console.log(chalk.yellow(" This competition is judged on kaggle.com — nothing to submit here."));break;default:console.log(chalk.yellow(" The scoring server is not reachable right now — try again in a minute."))}console.log()}export function registerKaggleCommand(o){o.command("kaggle").argument("[action]",'competition id, or "check" / "submit"').argument("[comp]",'competition id (with "check" / "submit")').description("Kaggle-style ML practice — dataset + starter notebook, check & submit").action(async(o,e)=>{"check"===o?await runKaggleCheck(e):"submit"===o?await runKaggleSubmit(e):"guide"===o?await runKaggleGuide(e):await runKaggle(o)}),o.command("guide").argument("[comp]","competition id").description("Show the competition walkthrough (3 steps + AI cockpit)").action(async o=>{await runKaggleGuide(o)})}
1
+ import{existsSync as o,mkdirSync as e,readFileSync as n,readdirSync as t,writeFileSync as l}from"node:fs";import{join as s}from"node:path";import chalk from"chalk";import{makeReplAsker as a}from"../lib/repl-asker.js";import{getConfig as i}from"../lib/config.js";import{logCommand as r}from"../lib/logger.js";import{openFile as c}from"../lib/open-file.js";import{serializeIpynb as g}from"../lib/notebook-doc.js";import{loadLearnState as u}from"../lib/learn-state.js";import{buildStarterCells as d,dataFileUrls as y,parseKaggleTaskList as h,parseSubmitResponse as m,validateSubmissionText as b}from"../lib/kaggle.js";import{mediaHelpLines as p,sprintTaskForComp as f}from"../lib/sprint-meta.js";function k(){return process.env.ICOA_KAGGLE_SERVER?process.env.ICOA_KAGGLE_SERVER.replace(/\/$/,""):"https://practice.icoa2026.au"}async function w(o){try{const e=await fetch(k()+o,{signal:AbortSignal.timeout(3e4)});return await e.json()}catch{return null}}async function v(o){try{const e=await fetch(o,{signal:AbortSignal.timeout(6e4)});return e.ok?await e.text():null}catch{return null}}function $(){return(i().language||"en").toLowerCase().startsWith("zh")}function j(o,e){return $()?o:e}function _(){console.log(),console.log(chalk.yellow(j(" 练习服务器现在连不上。"," The practice server is not reachable right now."))),console.log(chalk.gray(j(" 检查一下网络,或者过一会儿再试。"," Check your connection, or try again later."))),console.log()}function S(o){return s(process.cwd(),"icoa-kaggle",o)}function G(o,e){const n=[];let t="",l=0;const s=o=>/[ᄀ-ᅟ⺀-꓏가-힣豈-﫿︰-﹏＀-⦆¢-₩]/.test(o);for(const a of o){const o=s(a)?2:1;if(l+o>e){const o=t.lastIndexOf(" ");if(!s(a)&&" "!==a&&o>e/3){const e=t.slice(o+1);n.push(t.slice(0,o)),t=e,l=[...e].reduce((o,e)=>o+(s(e)?2:1),0)}else n.push(t),t="",l=0;if(" "===a&&""===t)continue}t+=a,l+=o}return""!==t.trim()&&n.push(t),n}function P(o){return"local-eval"===o?.judge?(console.log(chalk.bold.white(j(" 出分(就在 notebook 里):"," Scoring (inside the notebook):"))),void console.log(chalk.gray(j(" 跑最后一格 —— "," run the final cell — the "))+chalk.white("FINAL")+chalk.gray(j(" 那一行就是你的分数,没有东西要上传。"," line is your score. Nothing to upload.")))):"icoa-holdout"===o?.judge?(console.log(chalk.bold.white(j(" 交给 ICOA 判分(服务端评分):"," Submit to ICOA (scored on the server):"))),console.log(chalk.gray(" ")+chalk.bold.cyan(`kaggle submit ${o.comp_id}`)),void console.log(chalk.gray(j(" 与秘密测试标签比对 → 实时排名看 "," scores vs the secret test labels → live rank on "))+chalk.cyan("board"))):"nitro"===o?.judge?(console.log(chalk.bold.white(j(" 怎么知道做得对不对:"," How to tell whether you got it right:"))),console.log(chalk.gray(j(" · 这道题来自 judge.nitro-ai.org,判分在他们服务器上"," · this task comes from judge.nitro-ai.org — the judging lives on their server"))),console.log(chalk.gray(j(" · 想要真分数:去 "," · for a real score: register at "))+chalk.cyan("judge.nitro-ai.org")+chalk.gray(j(" 注册后提交"," and submit there"))),void console.log(chalk.gray(j(" · 冲刺期更快的办法:做完对照官方解答,或问 "," · faster right now: compare against the official solution, or ask "))+chalk.cyan("ai4ioai"))):(console.log(chalk.bold.white(j(" 去 Kaggle 提交(手动,用你自己的账号):"," Submit on Kaggle (manual, your own account):"))),void(o?.kaggle_url?(console.log(chalk.gray(j(" 1. 打开 "," 1. open "))+chalk.cyan(o.kaggle_url)),o?.needs_gpu?console.log(chalk.gray(j(" 2. 交 notebook 产出的那个文件 —— 最后一格写了确切步骤"," 2. submit the file your notebook produced — its final cell has the exact steps"))):console.log(chalk.gray(j(" 2. Submit Predictions → 上传 "," 2. Submit Predictions → upload "))+chalk.white("submission.csv")),console.log(chalk.gray(j(" 3. 看分数,改 MODEL 那一格,重跑,再来一轮。"," 3. read your score, improve the MODEL cell, re-run, repeat.")))):(console.log(chalk.gray(j(" 在 kaggle.com 搜这个比赛名提交,或做完对照官方解答自查。"," Search kaggle.com for this competition, or check yourself against the official solution."))),console.log(chalk.gray(j(" 卡住了问 "," Stuck? ask "))+chalk.cyan("ai4ioai")+chalk.gray(j(" —— 它是弱模型,把问题问准是这次要练的本事。"," — a deliberately weak model; asking precisely is the skill you are training."))))))}export async function runKaggle(n){const t=a(),i=async o=>await t.ask(o)??"";try{console.log(),console.log(chalk.bold.cyan(" 📊 KAGGLE PRACTICE")+chalk.gray(j(" · 真实的 ML 比赛,配一本能直接跑的 starter notebook"," · real ML competitions, a runnable starter notebook"))),console.log(chalk.gray(j(" 小题在你自己的 CPU 上跑;"," Small tasks run on your CPU; "))+chalk.magenta(j("⚡ GPU 题","⚡ GPU tasks"))+chalk.gray(j("在 ICOA 的 GPU 箱上跑。"," run on the ICOA GPU box."))),console.log();const t=await w("/api/icoa/kaggle/tasks");if(!t)return _();const a=h(t);if(0===a.length)return console.log(chalk.yellow(j(" 现在还没有上线的练习赛 —— 过一会儿再来。"," No practice competitions are live yet — check back soon."))),void console.log();let c=n?a.find(o=>o.comp_id===n):void 0;if(n&&!c&&console.log(chalk.yellow(j(` 没有叫 "${n}" 的比赛。`,` No competition called "${n}".`))),!c){console.log(chalk.white(j(" 正在开放的练习赛:"," Live practice competitions:"))),a.forEach((o,e)=>{const n=o.needs_gpu?chalk.magenta(" ⚡GPU"):"";console.log(chalk.gray(` ${e+1}. `)+chalk.cyan(o.comp_id)+chalk.gray(` — ${o.title} · ${o.metric}`)+n)});for(let o=0;o<3&&!c;o++){const o=(await i(chalk.cyan(j(" 选一个(序号或 id): "," Pick one (number or id): ")))).trim();if(!o)return;const e=Number(o);c=!Number.isNaN(e)&&a[e-1]||a.find(e=>e.comp_id===o.toLowerCase())||void 0,c||console.log(chalk.gray(j(` 输 1-${a.length} 之间的序号,或者一个 id,比如 "${a[0].comp_id}"。`,` Try a number 1-${a.length} or an id like "${a[0].comp_id}".`)))}if(!c)return}const u=c.comp_id;if(r(`kaggle: download ${u}`),c.needs_gpu)return void await async function(n,t){const a=S(n);if(console.log(),console.log(chalk.white(` ${t.title}`)+chalk.gray(` · ${t.metric}`)+chalk.bold.magenta(" ⚡ GPU task")),t.description){console.log();for(const o of G(t.description,74))console.log(chalk.white(` ${o}`))}console.log(),console.log(chalk.gray(j(" 正在取 notebook…"," Fetching the notebook…"))+chalk.gray(j(" (数据留在 GPU 箱上,不下载)"," (the dataset stays on the GPU box — no download)")));const i=await w(`/api/icoa/kaggle/${n}/starter`),r=i?.data?.starter??i?.starter;if("string"!=typeof r||0===r.length)return _();const c=s(a,"starter.ipynb");let g=!1;try{e(a,{recursive:!0}),o(c)?g=!0:l(c,r),l(s(a,"meta.json"),`${JSON.stringify(t,null,2)}\n`)}catch{return void console.log(chalk.yellow(j(" 写不进 notebook —— 检查一下这个目录的写权限。"," Could not write the notebook here — check directory permissions.")))}console.log(chalk.green(" ✓ notebook: ")+chalk.white(c)+chalk.gray(g?j(" (保留了你原来那本)"," (kept your existing one)"):j(" (里面是真正的 IOAI 题)"," (the real IOAI task inside)"))),console.log(chalk.green(" ✓ dataset: ")+chalk.white(j("已经在 GPU 箱上","already on the GPU box"))+chalk.gray(j(" —— 不用下载"," — no download needed"))),console.log(),console.log(chalk.bold.white(j(" 这是 GPU 题 —— 三步:"," This is a GPU task — 3 steps:"))),console.log(chalk.gray(" 1. ")+chalk.bold.cyan(`icoa ipynb ${c}`)),console.log(chalk.gray(" 2. ")+chalk.bold.cyan("gpu key <your-key>")+chalk.gray(j(" 然后 "," then "))+chalk.bold.cyan("gpu on")+chalk.gray(j(" (连到数据所在的那台箱子)"," (connects you to the box where the data lives)"))),console.log(chalk.gray(" 3. ")+chalk.bold.cyan("run all")+chalk.gray(j(" → notebook 在 GPU 上训练。"," → the notebook trains on the GPU."))),console.log(),console.log(chalk.gray(j(" 做题时随时看: "," While you work: "))+chalk.cyan("gpu status")+chalk.gray(j(" 你还剩多少时间 · "," your time left · "))+chalk.cyan("gpu queue")+chalk.gray(j(" 谁在用,谁在等"," who is on, who is waiting"))),console.log(),t.kaggle_url&&(console.log(chalk.gray(j(" 去 Kaggle 提交: "," Submit on Kaggle: "))+chalk.cyan(t.kaggle_url)),console.log())}(u,c);if(console.log(),console.log(chalk.white(` ${c.title}`)+chalk.gray(` · ${c.metric}`)),c.description){console.log();for(const o of G(c.description,74))console.log(chalk.white(` ${o}`))}console.log(),console.log(chalk.gray(j(" 正在下载数据…"," Downloading data…")));let m=null;const b=y(c);if(b){const[o,e,n]=await Promise.all([v(b.train),v(b.test),v(b.sample_submission)]);o&&e&&n&&(m={train:o,test:e,sample_submission:n})}if(!m){const o=await w(`/api/icoa/kaggle/${u}/data`);m=o?.data??o}if(!m?.train||!m?.test||!m?.sample_submission)return _();const p=S(u),k={...c,...m.meta??{}};try{e(p,{recursive:!0}),l(s(p,"train.csv"),m.train),l(s(p,"test.csv"),m.test),l(s(p,"sample_submission.csv"),m.sample_submission),l(s(p,"meta.json"),`${JSON.stringify(k,null,2)}\n`)}catch{return void console.log(chalk.yellow(" Could not write the data files here — check directory permissions."))}const $=s(p,"starter.ipynb");let P=!1;if(o($))P=!0;else{const o=await w(`/api/icoa/kaggle/${u}/starter`),e=o?.data?.starter??o?.starter;"string"==typeof e&&e.length>0?l($,e):l($,g(d(p,k)))}const A="number"==typeof k.n_train?`${k.n_train} rows`:"labelled",C="number"==typeof k.n_test?`${k.n_test} rows`:"predict these";console.log(chalk.green(" ✓ train: ")+chalk.white(s(p,"train.csv"))+chalk.gray(` (${A})`)),console.log(chalk.green(" ✓ test: ")+chalk.white(s(p,"test.csv"))+chalk.gray(` (${C})`)),console.log(chalk.green(" ✓ format: ")+chalk.white(s(p,"sample_submission.csv")));const E=f(u),U="none"===(E?.baseline||"").trim();console.log(chalk.green(" ✓ notebook: ")+chalk.white($)+chalk.gray(P?" (kept your existing one)":U?j(" (starter 在里面,FEATURES 那一格要你自己写)"," (starter inside — the FEATURES cell is yours to write)"):" (runnable baseline inside)")),(k.licence||k.attribution)&&console.log(chalk.gray(` licence: ${k.licence??"—"} · ${k.attribution??""}`)),console.log(),x(u,k,$),console.log()}finally{t.close()}}function A(o){const e=$();switch(o){case"audio":return e?"音频":"audio";case"image":return e?"图片":"images";case"weights":return e?"模型权重":"model weights";default:return e?"附件":"the extra files"}}function x(o,e,n){const t=f(o),l=t?p(t,$()):[];if(l.length>0){for(const o of l)for(const e of G(o,74))console.log(chalk.yellow(` ${e}`));console.log()}if(e?.needs_gpu)console.log(chalk.bold.white(" Your move — 4 steps (⚡ GPU task):")),console.log(chalk.gray(" 1. ")+chalk.bold.cyan(`icoa ipynb ${n}`)),console.log(chalk.gray(" 2. ")+chalk.bold.cyan("gpu key <your-key>")+chalk.gray(" then ")+chalk.bold.cyan("gpu on")+chalk.gray(" → ")+chalk.bold.cyan("run all")+chalk.gray(" (trains on the GPU box)")),console.log(chalk.gray(" 3. ")+chalk.bold.cyan("download <file>")+chalk.gray(" → pulls your results (submission.csv / predictions.zip) here")),console.log(chalk.gray(" 4. submit on kaggle.com — the notebook's final cell has the exact steps.")),console.log(),console.log(chalk.gray(" While you work: ")+chalk.cyan("gpu status")+chalk.gray(" your time left · ")+chalk.cyan("gpu queue")+chalk.gray(" who is on, who is waiting"));else{const l=t?.media?.pack,s="none"===(t?.baseline||"").trim();console.log(chalk.bold.white(l?j(" 接下来 4 步:"," Your move — 4 steps:"):j(" 接下来 3 步:"," Your move — 3 steps:")));let a=1;l&&console.log(chalk.gray(` ${a++}. `)+chalk.bold.cyan(`teleload ${l}`)+chalk.gray(j(` → 把${A(t?.media?.kind)}拉下来(CSV 里没有)`,` → fetch the ${A(t?.media?.kind)} (the CSVs do not carry it)`))),console.log(chalk.gray(` ${a++}. `)+chalk.bold.cyan(`icoa ipynb ${n}`)+chalk.gray(s?j(" → run all 到 FEATURES 那格会停,那格是你的活"," → run all stops at FEATURES — that cell is your job"):" → run all (baseline trains)")),console.log(chalk.gray(` ${a++}. it writes `)+chalk.white("submission.csv")+chalk.gray(" → verify with ")+chalk.cyan(`kaggle check ${o}`)),"icoa-holdout"===e?.judge?console.log(chalk.gray(` ${a}. `)+chalk.bold.cyan(`kaggle submit ${o}`)+chalk.gray(" → scored + ranked live.")):"nitro"===e?.judge?console.log(chalk.gray(` ${a}. scored at `)+chalk.cyan("judge.nitro-ai.org")+chalk.gray(" (not Kaggle) — or just work the val score. See below.")):console.log(chalk.gray(` ${a}. upload it on Kaggle yourself — then beat the baseline.`))}console.log(),console.log(chalk.bold.white(" 🤝 Want AI help? Set up your cockpit:")),console.log(chalk.gray(" 1. split the screen: ")+chalk.bold.cyan("Ctrl-b %")+chalk.gray(" (lesson/work left · AI right)")),console.log(chalk.gray(" 2. in the right pane: ")+chalk.bold.cyan("icoa")+chalk.gray(" then type ")+chalk.bold.cyan("ai4ioai")+chalk.gray(" → live Gemma 3")),console.log(chalk.gray(" 3. ask it for feature ideas or bug fixes — then ")+chalk.bold.white("VERIFY")+chalk.gray(" with your val score (a tip that lowers it, drop it).")),console.log(),P(e)}export async function runKaggleGuide(e){console.log();const t=C(e,"guide");if(!t)return;const l=S(t);let a=null;try{a=JSON.parse(n(s(l,"meta.json"),"utf-8"))}catch{a=null}r(`kaggle: guide ${t}`);const i=s(l,"starter.ipynb"),c=o(s(l,"submission.csv"));console.log(chalk.bold.white(` ═══ 📖 ${a?.title??t} — walkthrough ═══`)),console.log(),console.log(chalk.gray(" Where you are: data ")+chalk.green("downloaded ✓")+chalk.gray(" · submission.csv: ")+(c?chalk.green("written ✓"):chalk.yellow("not yet — run the notebook"))),console.log(),x(t,a,i),console.log(),console.log(chalk.gray(" Inside the notebook, ")+chalk.cyan("guide")+chalk.gray(" shows the notebook-level guide.")),console.log()}function C(e,n){if(e)return e;const l=s(process.cwd(),"icoa-kaggle"),a=o(l)?t(l,{withFileTypes:!0}).filter(e=>e.isDirectory()&&(o(s(l,e.name,"sample_submission.csv"))||o(s(l,e.name,"meta.json")))).map(o=>o.name):[];if(1===a.length)return a[0];if(0===a.length)return console.log(chalk.yellow(" No downloaded competition found here — run ")+chalk.cyan("kaggle")+chalk.yellow(" first.")),console.log(),null;console.log(chalk.white(" Several competitions downloaded — pick one:"));for(const o of a)console.log(chalk.gray(` kaggle ${n} `)+chalk.cyan(o));return console.log(),null}export async function runKaggleCheck(e){console.log();const t=C(e,"check");if(!t)return;const l=S(t),a=s(l,"submission.csv"),i=s(l,"sample_submission.csv");try{if(JSON.parse(n(s(l,"meta.json"),"utf-8")).needs_gpu&&!o(i))return console.log(chalk.gray(" ⚡ GPU task — results are produced and validated by the notebook itself.")),console.log(chalk.gray(" Pull them with ")+chalk.cyan("download <file>")+chalk.gray(" inside ")+chalk.cyan("icoa ipynb")+chalk.gray(", then submit on kaggle.com (final cell has the steps).")),void console.log()}catch{}if(!o(i))return console.log(chalk.yellow(` No data for "${t}" here — run `)+chalk.cyan(`kaggle ${t}`)+chalk.yellow(" first.")),void console.log();if(!o(a))return console.log(chalk.yellow(" No submission.csv yet — open the notebook and run all cells:")),console.log(chalk.gray(" ")+chalk.cyan(`icoa ipynb ${s(l,"starter.ipynb")}`)),void console.log();const g=b(n(a,"utf-8"),n(i,"utf-8"));r(`kaggle: check ${t} → ${g.ok?"ok":`rejected: ${g.problems[0]??"format"}`}`);let u=null;try{u=JSON.parse(n(s(l,"meta.json"),"utf-8"))}catch{u=null}if(g.ok)console.log(chalk.bold.green(" ✓ submission.csv has the right format")+chalk.gray(" (matches sample_submission.csv)")),console.log(chalk.gray(" ")+chalk.white(a)),console.log(),P(u),c(l);else{console.log(chalk.bold.red(" ✗ submission.csv would be rejected:"));for(const o of g.problems)console.log(chalk.yellow(` · ${o}`));console.log(),console.log(chalk.gray(" Fix the submission cell in the notebook and re-run it."))}console.log()}export async function runKaggleSubmit(e){console.log();const t=C(e,"submit");if(!t)return;const l=S(t),i=s(l,"submission.csv"),c=s(l,"sample_submission.csv");let g=null;try{g=JSON.parse(n(s(l,"meta.json"),"utf-8"))}catch{g=null}if("local-eval"===g?.judge)return console.log(chalk.yellow(" This task is scored inside the notebook — nothing to upload.")),P(g),void console.log();if(!g||!o(c))return console.log(chalk.yellow(` No data for "${t}" here — run `)+chalk.cyan(`kaggle ${t}`)+chalk.yellow(" first.")),void console.log();if("icoa-holdout"!==g.judge)return console.log(chalk.yellow(" This competition is judged on kaggle.com — nothing to submit here.")),console.log(),P(g),void console.log();if(!o(i))return console.log(chalk.yellow(" No submission.csv yet — open the notebook and run all cells:")),console.log(chalk.gray(" ")+chalk.cyan(`icoa ipynb ${s(l,"starter.ipynb")}`)),void console.log();const d=n(i,"utf-8"),y=b(d,n(c,"utf-8"));if(!y.ok){r(`kaggle: submit ${t} → local-reject: ${y.problems[0]??"format"}`),console.log(chalk.bold.red(" ✗ submission.csv would be rejected:"));for(const o of y.problems)console.log(chalk.yellow(` · ${o}`));return console.log(),console.log(chalk.gray(" Fix the submission cell in the notebook and re-run it.")),void console.log()}let h=u()?.token??"";if(!h){const o=a();try{h=(await o.ask(chalk.cyan(" Your learn token: "))??"").trim()}finally{o.close()}if(!h)return console.log(chalk.gray(" A learn token identifies you on the board — ask your coach for one.")),void console.log()}console.log(chalk.gray(" Scoring on the server…"));const p=await async function(o,e){try{const n=await fetch(k()+o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e),signal:AbortSignal.timeout(6e4)});return await n.json()}catch{return null}}(`/api/icoa/kaggle/${t}/submit`,{token:h,submission_csv:d}),f=m(p);if(r(`kaggle: submit ${t} → ${f.ok?`${f.metric}=${f.score}${f.deduped?" (deduped)":""} rank=${f.rank??"-"}`:f.reason??"error"}`),console.log(),f.ok){const o=`${f.metric}: ${Number(f.score).toFixed(4).replace(/\.?0+$/,"")}`;f.deduped?(console.log(chalk.bold.white(` ✓ already scored — ${o}`)),console.log(chalk.gray(" These exact predictions were scored before. Improve the MODEL cell and re-run."))):(console.log(chalk.bold.green(` ✓ scored — ${o}`)),"number"==typeof f.rank&&"number"==typeof f.fieldSize&&console.log(chalk.bold.white(` 🏁 board rank #${f.rank}`)+chalk.gray(` of ${f.fieldSize}`))),f.boardEvent&&console.log(chalk.gray(" standings: ")+chalk.cyan(`board ${f.boardEvent} ${t}`))}else switch(f.reason){case"bad_token":console.log(chalk.bold.red(" ✗ that learn token was not accepted")+chalk.gray(" (invalid or expired)")),console.log(chalk.gray(" Check the token with your coach, then try again."));break;case"format":console.log(chalk.bold.red(" ✗ the server rejected submission.csv:"));for(const o of f.problems??[])console.log(chalk.yellow(` · ${o}`));break;case"event_closed":case"outside_window":console.log(chalk.bold.yellow(" ⏱ the submission window for this competition is closed."));break;case"cap_reached":console.log(chalk.bold.yellow(" ⏱ you have used all your submissions for this competition."));break;case"kaggle_judged":console.log(chalk.yellow(" This competition is judged on kaggle.com — nothing to submit here."));break;default:console.log(chalk.yellow(" The scoring server is not reachable right now — try again in a minute."))}console.log()}export function registerKaggleCommand(o){o.command("kaggle").argument("[action]",'competition id, or "check" / "submit"').argument("[comp]",'competition id (with "check" / "submit")').description("Kaggle-style ML practice — dataset + starter notebook, check & submit").action(async(o,e)=>{"check"===o?await runKaggleCheck(e):"submit"===o?await runKaggleSubmit(e):"guide"===o?await runKaggleGuide(e):await runKaggle(o)}),o.command("guide").argument("[comp]","competition id").description("Show the competition walkthrough (3 steps + AI cockpit)").action(async o=>{await runKaggleGuide(o)})}
@@ -1 +1 @@
1
- import{existsSync as e,mkdirSync as o,readFileSync as n,writeFileSync as t}from"node:fs";import{createInterface as l}from"node:readline";import{dirname as a,join as s}from"node:path";import{fileURLToPath as r}from"node:url";import chalk from"chalk";import{getConfig as i}from"../lib/config.js";import{getMainRl as c,setMainRl as g}from"../lib/main-rl.js";import{logCommand as y}from"../lib/logger.js";let d=!1;export function isSprintActive(){return d}const p=a(r(import.meta.url)),u=s(process.env.HOME||".",".icoa"),h=s(u,"sprint-state.json"),m={"T-torch":"裸 torch:手写 attention / causal mask / perplexity","T-umap":"降维当特征提取器,不是画图工具","T-lora":"peft LoRA 参数高效微调","T-librosa":"音频特征流水线:mel / MFCC → 定长向量"},f=["",chalk.bold.cyan(" ASTANA 2027"),chalk.gray(" — 给还没出发的你"),"",chalk.white(" 草原的风从额尔齐斯河吹到阿斯塔纳的时候,会带着一点雪的味道。"),chalk.white(" 你还没去过那里。但那里已经有一个座位,写着你的名字。"),"",chalk.white(" 你现在坐在屏幕前,离比赛还有几天。"),chalk.white(" 你可能会想:几天能改变什么?"),"",chalk.white(" 足够让一个人从「看着题发呆」变成「看到题就知道该拆哪一层」。"),chalk.white(" 足够让手指记住 import torch 之后该敲什么。"),chalk.white(" 足够让你在比赛那天早上醒来时,不再害怕。"),"",chalk.bold.yellow(" M")+chalk.white(" —— 你总是第一个说「我先试试」的那个。别停。"),chalk.bold.yellow(" V")+chalk.white(" —— 你总是问「为什么是这样」的那个。继续问。"),chalk.bold.yellow(" A")+chalk.white(" —— 你总是在别人放弃时还在改最后一版的那个。改下去。"),"",chalk.white(" 你们三个人,一个人是一条腿走路,三个人是奔跑。"),"",chalk.white(" 你们要面对的不是一场考试,是一次证明:"),chalk.bold.white(" 中国的高中生,可以在 AI 的赛场上,和世界站在同一排。"),"",chalk.white(" 而 2027 年的阿斯塔纳,是我们下一个约定。"),"",chalk.gray(" 现在,把这行字关掉,去做第 1 题。"),chalk.gray(" — 熊猫教练"),""];function w(o){const n=[s(p,"..","data",o),s(p,"..","..","src","data",o)];for(const o of n)if(e(o))return o;return n[0]}function b(e){try{o(u,{recursive:!0}),t(h,`${JSON.stringify(e,null,1)}\n`)}catch{}}function k(e,o){return(i().language||"en").toLowerCase().startsWith("zh")?e:o}function $(e){return"★".repeat(Math.max(1,Math.min(5,e||3)))}const S=s(u,"sprint-memos.json");function A(e){try{o(u,{recursive:!0}),t(S,`${JSON.stringify(e,null,1)}\n`)}catch{}}function q(e,o){const n=new Set(o.done),t=new Set(o.opened);console.log(),console.log(chalk.bold.cyan(k(" ⚔ IOAI 2026 · 四工具冲刺"," ⚔ IOAI 2026 · four-tool sprint"))+chalk.gray(` ${k("已攻克","cleared")} ${n.size} / ${e.length}`));const l=new Map;for(const o of e)l.has(o.bullseye)||l.set(o.bullseye,[]),l.get(o.bullseye)?.push(o);for(const[e,o]of l){console.log(),console.log(chalk.bold.white(` ${e}`)+chalk.gray(` — ${m[e]||""}`));for(const e of o){const o=n.has(e.seq)?chalk.green("✓"):t.has(e.seq)?chalk.yellow("◐"):chalk.gray("⬜");console.log(` ${o} ${chalk.bold.white(String(e.seq).padStart(2))} `+chalk.white(e.title.slice(0,34).padEnd(34))+chalk.gray($(e.difficulty).padEnd(5))+chalk.gray(e.needs_gpu?" ⚡":" ")+chalk.gray(` ${e.data_mb}M`)+("teleload"===e.status?chalk.gray(k(" · teleload"," · teleload")):"")+(e.judged?chalk.green(k(" · 可出分"," · scored")):""))}}console.log(),console.log(chalk.gray(" ")+chalk.cyan("open <n>")+chalk.gray(k(" 看题 · "," view · "))+chalk.cyan("done <n>")+chalk.gray(k(" 标记攻克 · "," mark cleared · "))+chalk.cyan("ai4ioai")+chalk.gray(k(" 开 AI 分屏 · "," AI in a split · "))+chalk.cyan("memo")+chalk.gray(k(" 记问题 · "," report a problem · "))+chalk.cyan("back")+chalk.gray(k(" 退出"," leave"))),console.log(chalk.gray(k(" ⬜ 没看过 ◐ 看过没做完 ✓ 攻克"," ⬜ unseen ◐ opened ✓ cleared"))),console.log(chalk.gray(k(" ⚡ 要 GPU(notebook 里 gpu key → gpu on) · teleload 数据是大包,用 teleload 拉 · 可出分 交上去有真分数"," ⚡ needs GPU (inside the notebook: gpu key → gpu on) · teleload big pack, pull with teleload · scored real score on submit"))),console.log()}function v(e,o){const n=[];let t="",l=0;for(const a of e){const e=/[ -鿿＀-￯]/.test(a)?2:1;l+e>o&&(n.push(t),t="",l=0),t+=a,l+=e}return t&&n.push(t),n}export async function runSprint(){y("sprint");const e=function(){try{const e=JSON.parse(n(w("sprint-tasks.json"),"utf8")),o=Array.isArray(e?.tasks)?e.tasks:[];try{const e=JSON.parse(n(w("sprint-cards.json"),"utf8")),t=new Map((e.cards||[]).map(e=>[e.seq,e]));for(const e of o){const o=t.get(e.seq);o&&Object.assign(e,{star:o.star,trap:o.trap,action:o.action,hint:o.hint,meta:o.meta})}}catch{}return o.sort((e,o)=>e.seq-o.seq)}catch{return[]}}();if(0===e.length)return console.log(),console.log(chalk.yellow(" 冲刺题单还没装进这个版本。")),console.log(chalk.gray(" 升级后再试:")+chalk.cyan("npm install -g icoa-cli@latest")),void console.log();const o=function(){try{const e=JSON.parse(n(h,"utf8"));return{who:e.who||"",opened:e.opened||[],done:e.done||[]}}catch{return{who:"",opened:[],done:[]}}}();if(0===o.opened.length&&0===o.done.length)for(const e of f)console.log(e);o.who||(o.who=""),q(e,o);const t=c(),a=null!==t,s=a?t:l({input:process.stdin,output:process.stdout,terminal:!0});a||g(s);const r=a?s.listeners("line").slice():[];s.removeAllListeners("line");const i=s.prompt.bind(s);d=!0;const p=chalk.bold.cyan("icoa ioai2026> ");s.setPrompt(p);let u=null;await new Promise(t=>{s.on("line",async l=>{const c=l.trim().replace(/^icoa\s+/i,""),[h,m]=[c.split(/\s+/)[0]?.toLowerCase()||"",c.split(/\s+/)[1]||""];if(["back","quit","exit","menu"].includes(h))return b(o),console.log(chalk.gray(" 进度已保存。")),(()=>{if(d=!1,s.removeAllListeners("line"),a){for(const e of r)s.on("line",e);s.setPrompt(chalk.green("icoa> ")),s.prompt()}else g(null),s.close()})(),void t();if(""===h||["challenges","list","ls"].includes(h))q(e,o);else if(["open","o"].includes(h)||/^\d+$/.test(h)){const n=Number.parseInt(/^\d+$/.test(h)?h:m,10),t=e.find(e=>e.seq===n);t?(o.opened.includes(n)||o.opened.push(n),b(o),u=n,function(e){console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(`${e.seq} · ${e.title}`)+chalk.gray(` · ${e.bullseye}`)+chalk.cyan(" ─────")),console.log(chalk.cyan(" │"));const o=[e.star,e.trap,e.action,e.hint?` ${e.hint}`:""].filter(Boolean);0===o.length&&e.topic_cn&&o.push(`▸ ${e.topic_cn}`);for(const e of o){for(const o of v(e,58))console.log(chalk.cyan(" │ ")+chalk.white(o));console.log(chalk.cyan(" │"))}console.log(chalk.cyan(" │ ")+chalk.gray(e.meta||`⏱ 难度 ${$(e.difficulty)}`)+chalk.gray(e.needs_gpu?" ⚡ 需要 GPU":"")),console.log(chalk.cyan(" ╰──────────────────────────────────────────────────────"));const n=function(e){const o=/(?:kaggle|teleload)\s+[a-z0-9][a-z0-9-]*/i.exec(e.action||"");return o?o[0]:null}(e);n&&console.log(chalk.bold.white(k(" ▸ 就在这里敲: "," ▸ Type it right here: "))+chalk.bold.cyan(n)+chalk.gray(k(" ← 数据 + notebook 落到本机"," ← pulls the data + notebook"))),console.log(chalk.gray(" ")+chalk.cyan("ai4ioai")+chalk.gray(k(" 开 AI 分屏 · "," AI in a split · "))+chalk.cyan(`done ${e.seq}`)+chalk.gray(k(" 标记攻克 · "," mark cleared · "))+chalk.cyan("memo")+chalk.gray(k(` 记问题(自动记在第 ${e.seq} 题) · `,` report (auto-filed under ${e.seq}) · `))+chalk.cyan("back")+chalk.gray(k(" 回列表"," back to list"))),console.log()}(t)):console.log(chalk.yellow(` 没有第 ${m||h} 题。`)+chalk.gray(` 题号 1-${e.length}。`))}else if("done"===h){const n=Number.parseInt(m,10);e.some(e=>e.seq===n)?(o.done.includes(n)||o.done.push(n),b(o),console.log(chalk.green(` ✓ 第 ${n} 题标记为攻克`)+chalk.gray(` (${o.done.length}/${e.length})`))):console.log(chalk.yellow(` 题号 1-${e.length}。`))}else["kaggle","teleload","ipynb"].includes(h)?await async function(e,o){const n=o.split(/\s+/).filter(Boolean);try{if("teleload"===e){const{runTeleload:e}=await import("./teleload.js");return void await e(n[0])}if("ipynb"===e){const{runIpynb:e}=await import("./ipynb.js");return void await e(n[0])}const o=await import("./kaggle.js"),t=(n[0]||"").toLowerCase();"submit"===t?await o.runKaggleSubmit(n[1]):"check"===t?await o.runKaggleCheck(n[1]):"guide"===t?await o.runKaggleGuide(n[1]):await o.runKaggle(n[0])}catch(e){console.log(),console.log(chalk.yellow(k(" 这条命令没跑成:"," That command failed: "))+chalk.gray(String(e))),console.log(chalk.gray(k(" 记一条给教练:"," Tell the coach: "))+chalk.cyan(k("memo …","memo …"))),console.log()}}(h,c.split(/\s+/).slice(1).join(" ")):"memo"===h||"note"===h?await async function(e,o,t,l){const a=function(){try{const e=JSON.parse(n(S,"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}(),s=e.trim();if(["list","ls","all"].includes(s.toLowerCase())){if(console.log(),0===a.length)console.log(chalk.gray(k(" 还没有记录。"," Nothing noted yet.")));else{console.log(chalk.bold.white(k(` 📝 已记 ${a.length} 条`,` 📝 ${a.length} noted`)));for(const e of a.slice(-12)){const o=e.seq?chalk.cyan(`#${e.seq}`):chalk.gray("—");console.log(` ${o} ${chalk.white(e.text.slice(0,60))}`+chalk.gray(e.synced?k(" ·已上报"," ·sent"):k(" ·仅本地"," ·local only")))}console.log(chalk.gray(` ${S}`))}return console.log(chalk.gray(k(" 再记一条:"," Note another: "))+chalk.cyan("memo")+chalk.gray(k(" (光敲这一个词就给你写字的地方)"," (just the word — it gives you a place to type)"))),void console.log()}const r=s?s.split(/\s+/):[],i=r.length>0&&/^\d+$/.test(r[0])&&o.some(e=>e.seq===Number(r[0])),c=i?Number(r[0]):t;let g=(i?r.slice(1):r).join(" ").trim();if(""===g){const e=c?chalk.gray(k(` —— 记在第 ${c} 题下`,` — filed under task ${c}`)):chalk.gray(k(" —— 通用反馈"," — general feedback"));if(console.log(),console.log(chalk.bold.white(k(" 📝 撞到什么就写什么"," 📝 Say what you hit"))+e),console.log(chalk.gray(k(" 一行写完,回车就存下(不用等回复);直接回车 = 不记。"," One line, Enter files it (no reply comes back). Empty Enter cancels."))),g=await function(e,o){return new Promise(n=>{e.question(o,e=>n(e.trim()))})}(l,chalk.cyan(" memo > ")),""===g)return console.log(chalk.gray(k(" 没记。"," Nothing noted."))),void console.log()}const d={ts:(new Date).toISOString(),seq:c,text:g,synced:!1};a.push(d),A(a),y(`sprint: memo${c?` ${c}`:""} — ${g}`);let p=!1;try{const{loadLearnState:e}=await import("../lib/learn-state.js"),o=e()?.token??"";if(o){const{syncCardFeedback:e}=await import("../lib/learn-curricula.js");p=await e(o,{curriculum_id:"pandahelpme31",card_number:c??0,feedback_text:g})}}catch{}p&&(d.synced=!0,A(a)),console.log(),console.log(chalk.green(k(" ✓ 记下了"," ✓ noted"))+(c?chalk.gray(k(` (第 ${c} 题)`,` (task ${c})`)):"")+chalk.gray(p?k(" ·已上报"," ·sent"):k(" ·存在本机,教练可以来取"," ·saved on this machine"))),console.log(chalk.gray(k(" 继续做题就好。看全部:"," Carry on. See them all: "))+chalk.cyan("memo list")),console.log()}(c.split(/\s+/).slice(1).join(" "),e,u,s):["ai4ioai","/ai4ioai","ai"].includes(h)?(console.log(),console.log(chalk.bold.white(k(" 左右分屏,左边看题右边问 AI:"," Split the screen — tasks left, AI right:"))),console.log(chalk.gray(" 1. ")+chalk.bold.cyan("Ctrl-b %")+chalk.gray(k(" 左右分屏(上下分屏是 "," split left/right (up/down is "))+chalk.cyan('Ctrl-b "')+chalk.gray(k(")",")"))),console.log(chalk.gray(" 2. ")+chalk.gray(k("右边那格输 ","in the right pane type "))+chalk.bold.cyan("icoa")+chalk.gray(k(" ,再输 "," , then "))+chalk.bold.cyan("ai4ioai")),console.log(chalk.gray(k(" 3. 两格之间切换:"," 3. move between panes: "))+chalk.cyan("Ctrl-b ←")+chalk.gray(" / ")+chalk.cyan("Ctrl-b →")),console.log(),console.log(chalk.gray(k(" 它是弱模型 —— 单轮、2000 字符以内。把问题问准,就是这次要练的本事。"," A deliberately weak model — single-turn, 2000 chars. Asking precisely is the skill."))),console.log(chalk.gray(k(" 在 notebook 里卡住时,那边可以直接敲 "," Stuck inside a notebook? there you can type "))+chalk.cyan("ai")+chalk.gray(k(" —— 它会把那一格的代码和报错一起带上。"," — it carries that cell and its traceback."))),console.log()):["help","?","guide"].includes(h)?q(e,o):(console.log(chalk.gray(" ")+chalk.cyan("open <n>")+chalk.gray(k(" 看题 · "," view · "))+chalk.cyan("kaggle <题目id>")+chalk.gray(k(" 领数据 · "," get the data · "))+chalk.cyan("ipynb <路径>")+chalk.gray(k(" 开 notebook · "," open the notebook · "))+chalk.cyan("done <n>")+chalk.gray(k(" 标记 · "," mark · "))+chalk.cyan("memo")+chalk.gray(k(" 记问题 · "," report · "))+chalk.cyan("back")+chalk.gray(k(" 退出"," leave"))),console.log(chalk.gray(k(" 题目 id 在卡片的 ▸ 那一行,例如 "," The task id is on the card’s ▸ line, e.g. "))+chalk.cyan("open 17")+chalk.gray(" → ")+chalk.cyan("kaggle s17-bazarul-lui-riki")));s.prompt=i,s.setPrompt(p),s.prompt()}),a||s.once("close",()=>t()),s.prompt=i,s.prompt()})}export function registerSprintCommand(e){e.command("pandahelpme31",{hidden:!0}).action(async()=>{await runSprint()})}
1
+ import{existsSync as o,mkdirSync as e,readFileSync as n,writeFileSync as t}from"node:fs";import{createInterface as l}from"node:readline";import{dirname as a,join as s}from"node:path";import{fileURLToPath as r}from"node:url";import chalk from"chalk";import{getConfig as c}from"../lib/config.js";import{getMainRl as i,setMainRl as g}from"../lib/main-rl.js";import{logCommand as y}from"../lib/logger.js";import{baselineChip as d,computeChip as p,loadSprintTasks as u,mediaHelpLines as h,taskSteps as m}from"../lib/sprint-meta.js";let f=!1;export function isSprintActive(){return f}const b=a(r(import.meta.url)),w=s(process.env.HOME||".",".icoa"),k=s(w,"sprint-state.json"),$={"T-torch":"裸 torch:手写 attention / causal mask / perplexity","T-umap":"降维当特征提取器,不是画图工具","T-lora":"peft LoRA 参数高效微调","T-librosa":"音频特征流水线:mel / MFCC → 定长向量"},S=["",chalk.bold.cyan(" ASTANA 2027"),chalk.gray(" — 给还没出发的你"),"",chalk.white(" 草原的风从额尔齐斯河吹到阿斯塔纳的时候,会带着一点雪的味道。"),chalk.white(" 你还没去过那里。但那里已经有一个座位,写着你的名字。"),"",chalk.white(" 你现在坐在屏幕前,离比赛还有几天。"),chalk.white(" 你可能会想:几天能改变什么?"),"",chalk.white(" 足够让一个人从「看着题发呆」变成「看到题就知道该拆哪一层」。"),chalk.white(" 足够让手指记住 import torch 之后该敲什么。"),chalk.white(" 足够让你在比赛那天早上醒来时,不再害怕。"),"",chalk.bold.yellow(" M")+chalk.white(" —— 你总是第一个说「我先试试」的那个。别停。"),chalk.bold.yellow(" V")+chalk.white(" —— 你总是问「为什么是这样」的那个。继续问。"),chalk.bold.yellow(" A")+chalk.white(" —— 你总是在别人放弃时还在改最后一版的那个。改下去。"),"",chalk.white(" 你们三个人,一个人是一条腿走路,三个人是奔跑。"),"",chalk.white(" 你们要面对的不是一场考试,是一次证明:"),chalk.bold.white(" 中国的高中生,可以在 AI 的赛场上,和世界站在同一排。"),"",chalk.white(" 而 2027 年的阿斯塔纳,是我们下一个约定。"),"",chalk.gray(" 现在,把这行字关掉,去做第 1 题。"),chalk.gray(" — 熊猫教练"),""];function A(o){try{e(w,{recursive:!0}),t(k,`${JSON.stringify(o,null,1)}\n`)}catch{}}function q(){return(c().language||"en").toLowerCase().startsWith("zh")}function v(o,e){return q()?o:e}function j(o){return"★".repeat(Math.max(1,Math.min(5,o||3)))}const I=s(w,"sprint-memos.json");function C(o){try{e(w,{recursive:!0}),t(I,`${JSON.stringify(o,null,1)}\n`)}catch{}}function N(o,e){const n=new Set(e.done),t=new Set(e.opened);console.log(),console.log(chalk.bold.cyan(v(" ⚔ IOAI 2026 · 四工具冲刺"," ⚔ IOAI 2026 · four-tool sprint"))+chalk.gray(` ${v("已攻克","cleared")} ${n.size} / ${o.length}`));const l=new Map;for(const e of o)l.has(e.bullseye)||l.set(e.bullseye,[]),l.get(e.bullseye)?.push(e);for(const[o,e]of l){console.log(),console.log(chalk.bold.white(` ${o}`)+chalk.gray(` — ${$[o]||""}`));for(const o of e){const e=n.has(o.seq)?chalk.green("✓"):t.has(o.seq)?chalk.yellow("◐"):chalk.gray("⬜");console.log(` ${e} ${chalk.bold.white(String(o.seq).padStart(2))} `+chalk.white(o.title.slice(0,34).padEnd(34))+chalk.gray(j(o.difficulty).padEnd(5))+chalk.gray(o.needs_gpu?" ⚡":" ")+chalk.gray(` ${o.data_mb}M`)+("teleload"===o.status?chalk.gray(v(" · teleload"," · teleload")):"")+(o.judged?chalk.green(v(" · 可出分"," · scored")):""))}}console.log(),console.log(chalk.gray(" ")+chalk.cyan("open <n>")+chalk.gray(v(" 看题 · "," view · "))+chalk.cyan("done <n>")+chalk.gray(v(" 标记攻克 · "," mark cleared · "))+chalk.cyan("ai4ioai")+chalk.gray(v(" 开 AI 分屏 · "," AI in a split · "))+chalk.cyan("memo")+chalk.gray(v(" 记问题 · "," report a problem · "))+chalk.cyan("back")+chalk.gray(v(" 退出"," leave"))),console.log(chalk.gray(v(" ⬜ 没看过 ◐ 看过没做完 ✓ 攻克"," ⬜ unseen ◐ opened ✓ cleared"))),console.log(chalk.gray(v(" ⚡ 要 GPU(notebook 里 gpu key → gpu on) · teleload 数据是大包,用 teleload 拉 · 可出分 交上去有真分数"," ⚡ needs GPU (inside the notebook: gpu key → gpu on) · teleload big pack, pull with teleload · scored real score on submit"))),console.log()}function O(o,e){const n=[];let t="",l=0;for(const a of o){const o=/[ -鿿＀-￯]/.test(a)?2:1;l+o>e&&(n.push(t),t="",l=0),t+=a,l+=o}return t&&n.push(t),n}export async function runSprint(){y("sprint");const e=function(){try{const e=u();try{const t=JSON.parse(n(function(e){const n=[s(b,"..","data",e),s(b,"..","..","src","data",e)];for(const e of n)if(o(e))return e;return n[0]}("sprint-cards.json"),"utf8")),l=new Map((t.cards||[]).map(o=>[o.seq,o]));for(const o of e){const e=l.get(o.seq);e&&Object.assign(o,{star:e.star,trap:e.trap,action:e.action,hint:e.hint,meta:e.meta})}}catch{}return e.sort((o,e)=>o.seq-e.seq)}catch{return[]}}();if(0===e.length)return console.log(),console.log(chalk.yellow(" 冲刺题单还没装进这个版本。")),console.log(chalk.gray(" 升级后再试:")+chalk.cyan("npm install -g icoa-cli@latest")),void console.log();const t=function(){try{const o=JSON.parse(n(k,"utf8"));return{who:o.who||"",opened:o.opened||[],done:o.done||[]}}catch{return{who:"",opened:[],done:[]}}}();if(0===t.opened.length&&0===t.done.length)for(const o of S)console.log(o);t.who||(t.who=""),N(e,t);const a=i(),r=null!==a,c=r?a:l({input:process.stdin,output:process.stdout,terminal:!0});r||g(c);const w=r?c.listeners("line").slice():[];c.removeAllListeners("line");const $=c.prompt.bind(c);f=!0;const T=chalk.bold.cyan("icoa ioai2026> ");c.setPrompt(T);let x=null;await new Promise(o=>{c.on("line",async l=>{const a=l.trim().replace(/^icoa\s+/i,""),[s,i]=[a.split(/\s+/)[0]?.toLowerCase()||"",a.split(/\s+/)[1]||""];if(["back","quit","exit","menu"].includes(s))return A(t),console.log(chalk.gray(" 进度已保存。")),(()=>{if(f=!1,c.removeAllListeners("line"),r){for(const o of w)c.on("line",o);c.setPrompt(chalk.green("icoa> ")),c.prompt()}else g(null),c.close()})(),void o();if(""===s||["challenges","list","ls"].includes(s))N(e,t);else if(["open","o"].includes(s)||/^\d+$/.test(s)){const o=Number.parseInt(/^\d+$/.test(s)?s:i,10),n=e.find(e=>e.seq===o);n?(t.opened.includes(o)||t.opened.push(o),A(t),x=o,function(o){console.log(),console.log(chalk.cyan(" ╭─ ")+chalk.bold.white(`${o.seq} · ${o.title}`)+chalk.gray(` · ${o.bullseye}`)+chalk.cyan(" ─────")),console.log(chalk.cyan(" │"));const e=m(o).length>1,n=[o.star,o.trap,e?"":o.action,o.hint?` ${o.hint}`:""].filter(Boolean);0===n.length&&o.topic_cn&&n.push(`▸ ${o.topic_cn}`);for(const o of n){for(const e of O(o,58))console.log(chalk.cyan(" │ ")+chalk.white(e));console.log(chalk.cyan(" │"))}const t=q();console.log(chalk.cyan(" │ ")+chalk.gray(p(o,t)));const l=d(o,t);if(l)for(const o of O(l,58))console.log(chalk.cyan(" │ ")+chalk.gray(o));console.log(chalk.cyan(" │ ")+chalk.gray(o.meta||`⏱ 难度 ${j(o.difficulty)}`)+chalk.gray(o.needs_gpu?" ⚡ 需要 GPU":"")),console.log(chalk.cyan(" ╰──────────────────────────────────────────────────────"));for(const e of h(o,t))for(const o of O(e,60))console.log(chalk.yellow(" ")+chalk.yellow(o));const a=m(o),s=function(o){const e=m(o);if(e.length>0)return e[0];const n=/(?:kaggle|teleload)\s+[a-z0-9][a-z0-9-]*/i.exec(o.action||"");return n?n[0]:null}(o);a.length>1?(console.log(chalk.bold.white(v(" ▸ 就在这里敲,两步:"," ▸ Type these here, in order:"))),a.forEach((o,e)=>{console.log(chalk.gray(` ${e+1}. `)+chalk.bold.cyan(o)+chalk.gray(0===e?v(" ← 先把数据拉下来"," ← fetch the data first"):v(" ← 题面 + notebook"," ← statement + notebook")))})):s&&console.log(chalk.bold.white(v(" ▸ 就在这里敲: "," ▸ Type it right here: "))+chalk.bold.cyan(s)+chalk.gray(v(" ← 数据 + notebook 落到本机"," ← pulls the data + notebook"))),console.log(chalk.gray(" ")+chalk.cyan("ai4ioai")+chalk.gray(v(" 开 AI 分屏 · "," AI in a split · "))+chalk.cyan(`done ${o.seq}`)+chalk.gray(v(" 标记攻克 · "," mark cleared · "))+chalk.cyan("memo")+chalk.gray(v(` 记问题(自动记在第 ${o.seq} 题) · `,` report (auto-filed under ${o.seq}) · `))+chalk.cyan("back")+chalk.gray(v(" 回列表"," back to list"))),console.log()}(n)):console.log(chalk.yellow(` 没有第 ${i||s} 题。`)+chalk.gray(` 题号 1-${e.length}。`))}else if("done"===s){const o=Number.parseInt(i,10);e.some(e=>e.seq===o)?(t.done.includes(o)||t.done.push(o),A(t),console.log(chalk.green(` ✓ 第 ${o} 题标记为攻克`)+chalk.gray(` (${t.done.length}/${e.length})`))):console.log(chalk.yellow(` 题号 1-${e.length}。`))}else["kaggle","teleload","ipynb"].includes(s)?await async function(o,e){const n=e.split(/\s+/).filter(Boolean);try{if("teleload"===o){const{runTeleload:o}=await import("./teleload.js");return void await o(n[0])}if("ipynb"===o){const{runIpynb:o}=await import("./ipynb.js");return void await o(n[0])}const e=await import("./kaggle.js"),t=(n[0]||"").toLowerCase();"submit"===t?await e.runKaggleSubmit(n[1]):"check"===t?await e.runKaggleCheck(n[1]):"guide"===t?await e.runKaggleGuide(n[1]):await e.runKaggle(n[0])}catch(o){console.log(),console.log(chalk.yellow(v(" 这条命令没跑成:"," That command failed: "))+chalk.gray(String(o))),console.log(chalk.gray(v(" 记一条给教练:"," Tell the coach: "))+chalk.cyan(v("memo …","memo …"))),console.log()}}(s,a.split(/\s+/).slice(1).join(" ")):"memo"===s||"note"===s?await async function(o,e,t,l){const a=function(){try{const o=JSON.parse(n(I,"utf8"));return Array.isArray(o)?o:[]}catch{return[]}}(),s=o.trim();if(["list","ls","all"].includes(s.toLowerCase())){if(console.log(),0===a.length)console.log(chalk.gray(v(" 还没有记录。"," Nothing noted yet.")));else{console.log(chalk.bold.white(v(` 📝 已记 ${a.length} 条`,` 📝 ${a.length} noted`)));for(const o of a.slice(-12)){const e=o.seq?chalk.cyan(`#${o.seq}`):chalk.gray("—");console.log(` ${e} ${chalk.white(o.text.slice(0,60))}`+chalk.gray(o.synced?v(" ·已上报"," ·sent"):v(" ·仅本地"," ·local only")))}console.log(chalk.gray(` ${I}`))}return console.log(chalk.gray(v(" 再记一条:"," Note another: "))+chalk.cyan("memo")+chalk.gray(v(" (光敲这一个词就给你写字的地方)"," (just the word — it gives you a place to type)"))),void console.log()}const r=s?s.split(/\s+/):[],c=r.length>0&&/^\d+$/.test(r[0])&&e.some(o=>o.seq===Number(r[0])),i=c?Number(r[0]):t;let g=(c?r.slice(1):r).join(" ").trim();if(""===g){const o=i?chalk.gray(v(` —— 记在第 ${i} 题下`,` — filed under task ${i}`)):chalk.gray(v(" —— 通用反馈"," — general feedback"));if(console.log(),console.log(chalk.bold.white(v(" 📝 撞到什么就写什么"," 📝 Say what you hit"))+o),console.log(chalk.gray(v(" 一行写完,回车就存下(不用等回复);直接回车 = 不记。"," One line, Enter files it (no reply comes back). Empty Enter cancels."))),g=await function(o,e){return new Promise(n=>{o.question(e,o=>n(o.trim()))})}(l,chalk.cyan(" memo > ")),""===g)return console.log(chalk.gray(v(" 没记。"," Nothing noted."))),void console.log()}const d={ts:(new Date).toISOString(),seq:i,text:g,synced:!1};a.push(d),C(a),y(`sprint: memo${i?` ${i}`:""} — ${g}`);let p=!1;try{const{loadLearnState:o}=await import("../lib/learn-state.js"),e=o()?.token??"";if(e){const{syncCardFeedback:o}=await import("../lib/learn-curricula.js");p=await o(e,{curriculum_id:"pandahelpme31",card_number:i??0,feedback_text:g})}}catch{}p&&(d.synced=!0,C(a)),console.log(),console.log(chalk.green(v(" ✓ 记下了"," ✓ noted"))+(i?chalk.gray(v(` (第 ${i} 题)`,` (task ${i})`)):"")+chalk.gray(p?v(" ·已上报"," ·sent"):v(" ·存在本机,教练可以来取"," ·saved on this machine"))),console.log(chalk.gray(v(" 继续做题就好。看全部:"," Carry on. See them all: "))+chalk.cyan("memo list")),console.log()}(a.split(/\s+/).slice(1).join(" "),e,x,c):["ai4ioai","/ai4ioai","ai"].includes(s)?(console.log(),console.log(chalk.bold.white(v(" 左右分屏,左边看题右边问 AI:"," Split the screen — tasks left, AI right:"))),console.log(chalk.gray(" 1. ")+chalk.bold.cyan("Ctrl-b %")+chalk.gray(v(" 左右分屏(上下分屏是 "," split left/right (up/down is "))+chalk.cyan('Ctrl-b "')+chalk.gray(v(")",")"))),console.log(chalk.gray(" 2. ")+chalk.gray(v("右边那格输 ","in the right pane type "))+chalk.bold.cyan("icoa")+chalk.gray(v(" ,再输 "," , then "))+chalk.bold.cyan("ai4ioai")),console.log(chalk.gray(v(" 3. 两格之间切换:"," 3. move between panes: "))+chalk.cyan("Ctrl-b ←")+chalk.gray(" / ")+chalk.cyan("Ctrl-b →")),console.log(),console.log(chalk.gray(v(" 它是弱模型 —— 单轮、2000 字符以内。把问题问准,就是这次要练的本事。"," A deliberately weak model — single-turn, 2000 chars. Asking precisely is the skill."))),console.log(chalk.gray(v(" 在 notebook 里卡住时,那边可以直接敲 "," Stuck inside a notebook? there you can type "))+chalk.cyan("ai")+chalk.gray(v(" —— 它会把那一格的代码和报错一起带上。"," — it carries that cell and its traceback."))),console.log()):["help","?","guide"].includes(s)?N(e,t):(console.log(chalk.gray(" ")+chalk.cyan("open <n>")+chalk.gray(v(" 看题 · "," view · "))+chalk.cyan("kaggle <题目id>")+chalk.gray(v(" 领数据 · "," get the data · "))+chalk.cyan("ipynb <路径>")+chalk.gray(v(" 开 notebook · "," open the notebook · "))+chalk.cyan("done <n>")+chalk.gray(v(" 标记 · "," mark · "))+chalk.cyan("memo")+chalk.gray(v(" 记问题 · "," report · "))+chalk.cyan("back")+chalk.gray(v(" 退出"," leave"))),console.log(chalk.gray(v(" 题目 id 在卡片的 ▸ 那一行,例如 "," The task id is on the card’s ▸ line, e.g. "))+chalk.cyan("open 17")+chalk.gray(" → ")+chalk.cyan("kaggle s17-bazarul-lui-riki")));c.prompt=$,c.setPrompt(T),c.prompt()}),r||c.once("close",()=>o()),c.prompt=$,c.prompt()})}export function registerSprintCommand(o){o.command("pandahelpme31",{hidden:!0}).action(async()=>{await runSprint()})}
@@ -1 +1 @@
1
- import{spawn as o}from"node:child_process";import{createHash as e}from"node:crypto";import{createReadStream as t,createWriteStream as n,existsSync as r,mkdirSync as a,renameSync as s,rmSync as l,statSync as i}from"node:fs";import{Readable as c}from"node:stream";import{pipeline as d}from"node:stream/promises";import{join as g}from"node:path";import chalk from"chalk";function u(){if(process.env.ICOA_AIDATA_DIR)return process.env.ICOA_AIDATA_DIR;const o="/data/aiproblems";try{if(r(o)&&i(o).isDirectory())return o}catch{}return g(process.cwd(),"icoa-aidata")}function f(o){return g(u(),o.platform,o.id)}function h(o){return o>=1024?`${(o/1024).toFixed(1)}G`:`${o}M`}function y(e,t){return new Promise(n=>{const r=o(e,t,{stdio:"ignore",shell:!1});r.on("error",()=>n(!1)),r.on("close",o=>n(0===o))})}async function p(o){const i=f(o);if(r(i))return console.log(),console.log(chalk.green(` ✓ ${o.id} is already here`)+chalk.gray(` (${i})`)),console.log(chalk.gray(" Nothing to do. ")+chalk.cyan("teleload")+chalk.gray(" lists the rest.")),void console.log();const p=g(u(),o.platform);a(p,{recursive:!0});const m=g(p,`.${o.id}.tar.zst.part`);if(console.log(),console.log(chalk.bold.white(` ⬇ ${o.id}`)+chalk.gray(` · ${h(o.tar_mb)} packed → ${h(o.unpacked_mb)} on disk · ${o.n_files} files`)),console.log(chalk.gray(" Straight from the Singapore data node — nothing goes through your laptop.")),console.log(),!await async function(o,e){const t=Date.now();let r=0,a=1048576*o.tar_mb,s=0;const l=Boolean(process.stdout.isTTY);let i=-1;const g=(o=!1)=>{const e=a>0?Math.min(100,Math.round(r/a*100)):0,n=(Date.now()-t)/1e3,s=n>0?r/1048576/n:0,c=r/1048576,d=a/1048576,g=n>=3&&r>=4194304&&s>0&&a>r?(a-r)/1048576/s:0;if(!l){const t=Math.floor(e/25);return void((t>i||o)&&(i=t,console.log(chalk.cyan(` ${String(e).padStart(3)}% · ${c.toFixed(0)}/${d.toFixed(0)} MB · ${s.toFixed(1)} MB/s`))))}const u=Math.round(e/5),f="█".repeat(u)+"░".repeat(20-u),h=o?"":` · ${function(o){if(!Number.isFinite(o)||o<=0)return"--";const e=Math.floor(o/60),t=Math.round(o%60);return e>0?`${e}m${String(t).padStart(2,"0")}s`:`${t}s`}(g)} left`,y=` ${f} ${String(e).padStart(3)}% · ${c.toFixed(0)}/${d.toFixed(0)} MB · ${s.toFixed(1)} MB/s${h}`;process.stdout.write(`\r${chalk.cyan(y)}${" ".repeat(12)}${o?"\n":""}`)};try{const t=await fetch(o.url,{signal:AbortSignal.timeout(36e5)});if(!t.ok||!t.body)return!1;const l=Number(t.headers.get("content-length"));Number.isFinite(l)&&l>0&&(a=l);const i=n(e),u=c.fromWeb(t.body);return u.on("data",o=>{r+=o.length;const e=Date.now();e-s>250&&(s=e,g())}),await d(u,i),g(!0),!0}catch{return process.stdout.write("\n"),!1}}(o,m))return l(m,{force:!0}),console.log(chalk.yellow(" ✗ Download failed.")+chalk.gray(" Nothing was changed — just run it again.")),void console.log();process.stdout.write(chalk.gray(" checking the file is intact… "));const w=await($=m,new Promise((o,n)=>{const r=e("sha256"),a=t($);a.on("data",o=>{r.update(o)}),a.on("end",()=>o(r.digest("hex"))),a.on("error",n)})).catch(()=>"");var $;if(o.sha256&&w!==o.sha256)return l(m,{force:!0}),console.log(chalk.yellow("✗")),console.log(chalk.yellow(" The file arrived damaged and was discarded.")+chalk.gray(" Run it again.")),void console.log();console.log(chalk.green("✓")),process.stdout.write(chalk.gray(" unpacking… "));const b=g(p,`.${o.id}.staging`);l(b,{recursive:!0,force:!0});const v=await async function(o,e){if(a(e,{recursive:!0}),await y("tar",["-xf",o,"-C",e]))return!0;if(await y("tar",["--zstd","-xf",o,"-C",e]))return!0;if(await y("tar",["-I","unzstd","-xf",o,"-C",e]))return!0;const t=`${o}.plain`;if(await y("zstd",["-d","-f","-o",t,o])){const o=await y("tar",["-xf",t,"-C",e]);return l(t,{force:!0}),o}return!1}(m,b);if(l(m,{force:!0}),!v)return l(b,{recursive:!0,force:!0}),console.log(chalk.yellow("✗")),console.log(chalk.yellow(" Could not unpack the archive.")+chalk.gray(" Run it again.")),void console.log();const k=g(b,o.id);try{s(r(k)?k:b,i)}catch{return console.log(chalk.yellow("✗")),console.log(chalk.yellow(" Could not move the data into place.")+chalk.gray(" Check disk space.")),void console.log()}l(b,{recursive:!0,force:!0}),console.log(chalk.green("✓")),console.log(),console.log(chalk.green(" 🎁 ready: ")+chalk.white(i)),console.log(chalk.gray(" Open it in a notebook — the path above is the dataset root.")),console.log(chalk.gray(" ")+chalk.cyan("teleload")+chalk.gray(" lists what else is available.")),console.log()}export async function runTeleload(o){const e=await async function(){try{const o=await fetch(process.env.ICOA_TELELOAD_MANIFEST||"https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/manifest.json",{signal:AbortSignal.timeout(3e4)});if(!o.ok)return null;const e=await o.json(),t=Array.isArray(e?.packs)?e.packs:null;return t?t.slice().sort((o,e)=>o.n-e.n):null}catch{return null}}();if(!e)return console.log(),console.log(chalk.yellow(" Could not reach the dataset node right now.")),console.log(chalk.gray(" Check your connection and try again — nothing was changed.")),void console.log();if(0===e.length)return console.log(),console.log(chalk.gray(" No on-demand datasets are published yet — everything ships inside this machine.")),void console.log();const t=(o??"").trim().replace(/^#/,"");if(""===t)return function(o){console.log(),console.log(chalk.bold.cyan(" ⬇ TELELOAD")+chalk.gray(" · big datasets, pulled straight from the data node")),console.log();for(const e of o){const o=r(f(e))?chalk.green("✓ here"):chalk.gray("⬇ not yet");console.log(` ${chalk.bold.white(String(e.n))}. ${chalk.white(e.id.padEnd(34))}`+chalk.gray(`${h(e.unpacked_mb).padStart(6)} `)+o)}console.log(),console.log(chalk.gray(" Pull one with ")+chalk.cyan("teleload <number>")+chalk.gray(" (e.g. ")+chalk.cyan("teleload 2")+chalk.gray(")")),console.log(chalk.gray(" Everything smaller than 0.6 G already ships inside this machine — no pull needed.")),console.log()}(e);const n=Number.parseInt(t,10);let a=Number.isFinite(n)?e.find(o=>o.n===n):void 0;if(!a){const o=t.toLowerCase();a=e.find(e=>e.id.toLowerCase()===o)??e.find(e=>e.id.toLowerCase().includes(o))}if(!a){console.log(),console.log(chalk.yellow(` No dataset called "${t}".`)),console.log(chalk.gray(" These are the ones you can pull:"));for(const o of e)console.log(chalk.gray(` ${o.n}. ${o.id}`));return console.log(chalk.gray(" Try ")+chalk.cyan(`teleload ${e[0].n}`)+chalk.gray(" — or just ")+chalk.cyan("teleload")+chalk.gray(" to see sizes.")),void console.log()}await p(a)}export function registerTeleloadCommand(o){o.command("teleload").argument("[pack]","pack number (or id) from `teleload`").description("Pull a big dataset from the data node onto this machine").action(async o=>{await runTeleload(o)})}
1
+ import{spawn as o}from"node:child_process";import{createHash as e}from"node:crypto";import{createReadStream as t,createWriteStream as n,existsSync as a,mkdirSync as r,renameSync as s,rmSync as i,statSync as l,writeFileSync as c}from"node:fs";import{Readable as d}from"node:stream";import{pipeline as g}from"node:stream/promises";import{join as u}from"node:path";import chalk from"chalk";import{buildMediaStarterCells as f}from"../lib/kaggle.js";import{serializeIpynb as h}from"../lib/notebook-doc.js";import{loadSprintTasks as y}from"../lib/sprint-meta.js";import{getConfig as p}from"../lib/config.js";function m(){if(process.env.ICOA_AIDATA_DIR)return process.env.ICOA_AIDATA_DIR;const o="/data/aiproblems";try{if(a(o)&&l(o).isDirectory())return o}catch{}return u(process.cwd(),"icoa-aidata")}function w(o){return u(m(),o.platform,o.id)}function b(o){return o>=1024?`${(o/1024).toFixed(1)}G`:`${o}M`}function $(e,t){return new Promise(n=>{const a=o(e,t,{stdio:"ignore",shell:!1});a.on("error",()=>n(!1)),a.on("close",o=>n(0===o))})}async function v(o){const l=w(o);if(a(l))return console.log(),console.log(chalk.green(` ✓ ${o.id} is already here`)+chalk.gray(` (${l})`)),console.log(chalk.gray(" Nothing to do. ")+chalk.cyan("teleload")+chalk.gray(" lists the rest.")),void console.log();const v=u(m(),o.platform);r(v,{recursive:!0});const k=u(v,`.${o.id}.tar.zst.part`);if(console.log(),console.log(chalk.bold.white(` ⬇ ${o.id}`)+chalk.gray(` · ${b(o.tar_mb)} packed → ${b(o.unpacked_mb)} on disk · ${o.n_files} files`)),console.log(chalk.gray(" Straight from the Singapore data node — nothing goes through your laptop.")),console.log(),!await async function(o,e){const t=Date.now();let a=0,r=1048576*o.tar_mb,s=0;const i=Boolean(process.stdout.isTTY);let l=-1;const c=(o=!1)=>{const e=r>0?Math.min(100,Math.round(a/r*100)):0,n=(Date.now()-t)/1e3,s=n>0?a/1048576/n:0,c=a/1048576,d=r/1048576,g=n>=3&&a>=4194304&&s>0&&r>a?(r-a)/1048576/s:0;if(!i){const t=Math.floor(e/25);return void((t>l||o)&&(l=t,console.log(chalk.cyan(` ${String(e).padStart(3)}% · ${c.toFixed(0)}/${d.toFixed(0)} MB · ${s.toFixed(1)} MB/s`))))}const u=Math.round(e/5),f="█".repeat(u)+"░".repeat(20-u),h=o?"":` · ${function(o){if(!Number.isFinite(o)||o<=0)return"--";const e=Math.floor(o/60),t=Math.round(o%60);return e>0?`${e}m${String(t).padStart(2,"0")}s`:`${t}s`}(g)} left`,y=` ${f} ${String(e).padStart(3)}% · ${c.toFixed(0)}/${d.toFixed(0)} MB · ${s.toFixed(1)} MB/s${h}`;process.stdout.write(`\r${chalk.cyan(y)}${" ".repeat(12)}${o?"\n":""}`)};try{const t=await fetch(o.url,{signal:AbortSignal.timeout(36e5)});if(!t.ok||!t.body)return!1;const i=Number(t.headers.get("content-length"));Number.isFinite(i)&&i>0&&(r=i);const l=n(e),u=d.fromWeb(t.body);return u.on("data",o=>{a+=o.length;const e=Date.now();e-s>250&&(s=e,c())}),await g(u,l),c(!0),!0}catch{return process.stdout.write("\n"),!1}}(o,k))return i(k,{force:!0}),console.log(chalk.yellow(" ✗ Download failed.")+chalk.gray(" Nothing was changed — just run it again.")),void console.log();process.stdout.write(chalk.gray(" checking the file is intact… "));const C=await(A=k,new Promise((o,n)=>{const a=e("sha256"),r=t(A);r.on("data",o=>{a.update(o)}),r.on("end",()=>o(a.digest("hex"))),r.on("error",n)})).catch(()=>"");var A;if(o.sha256&&C!==o.sha256)return i(k,{force:!0}),console.log(chalk.yellow("✗")),console.log(chalk.yellow(" The file arrived damaged and was discarded.")+chalk.gray(" Run it again.")),void console.log();console.log(chalk.green("✓")),process.stdout.write(chalk.gray(" unpacking… "));const x=u(v,`.${o.id}.staging`);i(x,{recursive:!0,force:!0});const S=await async function(o,e){if(r(e,{recursive:!0}),await $("tar",["-xf",o,"-C",e]))return!0;if(await $("tar",["--zstd","-xf",o,"-C",e]))return!0;if(await $("tar",["-I","unzstd","-xf",o,"-C",e]))return!0;const t=`${o}.plain`;if(await $("zstd",["-d","-f","-o",t,o])){const o=await $("tar",["-xf",t,"-C",e]);return i(t,{force:!0}),o}return!1}(k,x);if(i(k,{force:!0}),!S)return i(x,{recursive:!0,force:!0}),console.log(chalk.yellow("✗")),console.log(chalk.yellow(" Could not unpack the archive.")+chalk.gray(" Run it again.")),void console.log();const T=u(x,o.id);try{s(a(T)?T:x,l)}catch{return console.log(chalk.yellow("✗")),console.log(chalk.yellow(" Could not move the data into place.")+chalk.gray(" Check disk space.")),void console.log()}i(x,{recursive:!0,force:!0}),console.log(chalk.green("✓")),console.log(),console.log(chalk.green(" 🎁 ready: ")+chalk.white(l));const M=y().find(e=>e.media?.pack===o.id),_=u(l,"starter.ipynb");if(M&&!a(_))try{c(_,h(f(l,M))),console.log(chalk.gray(" ▸ ")+chalk.bold.cyan(`icoa ipynb ${_}`)+chalk.gray((p().language||"en").toLowerCase().startsWith("zh")?" ← 清点 + 出一张图 + 说明要建什么":" ← inventory + one figure + what to build"))}catch{console.log(chalk.gray(" Open it in a notebook — the path above is the dataset root."))}else console.log(chalk.gray(" Open it in a notebook — the path above is the dataset root."));console.log(chalk.gray(" ")+chalk.cyan("teleload")+chalk.gray(" lists what else is available.")),console.log()}export async function runTeleload(o){const e=await async function(){try{const o=await fetch(process.env.ICOA_TELELOAD_MANIFEST||"https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/manifest.json",{signal:AbortSignal.timeout(3e4)});if(!o.ok)return null;const e=await o.json(),t=Array.isArray(e?.packs)?e.packs:null;return t?t.slice().sort((o,e)=>o.n-e.n):null}catch{return null}}();if(!e)return console.log(),console.log(chalk.yellow(" Could not reach the dataset node right now.")),console.log(chalk.gray(" Check your connection and try again — nothing was changed.")),void console.log();if(0===e.length)return console.log(),console.log(chalk.gray(" No on-demand datasets are published yet — everything ships inside this machine.")),void console.log();const t=(o??"").trim().replace(/^#/,"");if(""===t)return function(o){console.log(),console.log(chalk.bold.cyan(" ⬇ TELELOAD")+chalk.gray(" · big datasets, pulled straight from the data node")),console.log();for(const e of o){const o=a(w(e))?chalk.green("✓ here"):chalk.gray("⬇ not yet");console.log(` ${chalk.bold.white(String(e.n))}. ${chalk.white(e.id.padEnd(34))}`+chalk.gray(`${b(e.unpacked_mb).padStart(6)} `)+o)}console.log(),console.log(chalk.gray(" Pull one with ")+chalk.cyan("teleload <number>")+chalk.gray(" (e.g. ")+chalk.cyan("teleload 2")+chalk.gray(")"));const e="/data/aiproblems"===m();console.log(chalk.gray(e?" Smaller datasets are already baked into this boxthose need no pull.":" On a laptop nothing is pre-installed: whatever a task needs, pull it here first.")),console.log()}(e);const n=Number.parseInt(t,10);let r=Number.isFinite(n)?e.find(o=>o.n===n):void 0;if(!r){const o=t.toLowerCase();r=e.find(e=>e.id.toLowerCase()===o)??e.find(e=>e.id.toLowerCase().includes(o))}if(!r){console.log(),console.log(chalk.yellow(` No dataset called "${t}".`)),console.log(chalk.gray(" These are the ones you can pull:"));for(const o of e)console.log(chalk.gray(` ${o.n}. ${o.id}`));return console.log(chalk.gray(" Try ")+chalk.cyan(`teleload ${e[0].n}`)+chalk.gray(" — or just ")+chalk.cyan("teleload")+chalk.gray(" to see sizes.")),void console.log()}await v(r)}export function registerTeleloadCommand(o){o.command("teleload").argument("[pack]","pack number (or id) from `teleload`").description("Pull a big dataset from the data node onto this machine").action(async o=>{await runTeleload(o)})}
@@ -8,7 +8,7 @@
8
8
  "action": "▸ 领数据:kaggle s01-sound-of-nature",
9
9
  "meta": "⏱ 参考 25 分钟 · 难度 ★★☆☆☆",
10
10
  "note": "288 条训练 9 类,wav 全是 5 秒 44.1kHz,先重采到 16k",
11
- "hint": "先用 torchaudio 读一条 wav 走 MelSpectrogramlog 打出 shape,再照着写 Dataset。"
11
+ "hint": "本机没有 torchaudio/librosa:用 scipy.io.wavfile.read 读一条 wav → numpy,先打出 shape 再写 Dataset(GPU 箱上两个库都有)。"
12
12
  },
13
13
  {
14
14
  "seq": 2,
@@ -35,7 +35,7 @@
35
35
  "action": "▸ 领数据:kaggle s04-is-that-audio",
36
36
  "meta": "⏱ 参考 25 分钟 · 难度 ★★☆☆☆",
37
37
  "note": "官方承认本轮有泄漏:样本 id 的 A_/B_ 前缀本身就带类组信息",
38
- "hint": "先统计 train.csv 每类样本数,再定分层切分和 mel 的固定帧数。"
38
+ "hint": "先统计 train.csv 每类样本数,再定分层切分和固定帧数(本机求谱用 scipy.signal,librosa 只在 GPU 箱上有)。"
39
39
  },
40
40
  {
41
41
  "seq": 5,
@@ -14,7 +14,14 @@
14
14
  "dir": "sound-of-nature-aicc-round-3",
15
15
  "topic_cn": "360 条 5 秒自然/动物声音的多类分类(cat 等类别),官方解答 = mel-spectrogram + CNN + macro F1 选模",
16
16
  "comp": "s01-sound-of-nature",
17
- "status": "ready"
17
+ "status": "ready",
18
+ "baseline": "none",
19
+ "media": {
20
+ "kind": "audio",
21
+ "pack": "s01-sound-of-nature",
22
+ "mb": 152,
23
+ "glob": "audio/*.wav"
24
+ }
18
25
  },
19
26
  {
20
27
  "seq": 2,
@@ -28,7 +35,8 @@
28
35
  "dir": "mortys-time-paradox-aicc-round-3",
29
36
  "topic_cn": "8 个周期性特征的无标签聚类:先用 sin/cos 周期编码还原结构,再聚类 + 候选标签多数投票定类",
30
37
  "comp": "s02-mortys-time-paradox",
31
- "status": "ready"
38
+ "status": "ready",
39
+ "baseline": "val acc 0.79"
32
40
  },
33
41
  {
34
42
  "seq": 3,
@@ -42,7 +50,8 @@
42
50
  "dir": "nitro/53_roai-2025_lot-baraj-2_t1_how-toxic-are-you-online",
43
51
  "topic_cn": "国家队选拔第2日:四标签毒性多标签分类,逐标签F1线性插值计分,另在30%子集上单独评稳健性;赛中明令禁用transformers",
44
52
  "comp": "s03-how-toxic-are-you-online",
45
- "status": "ready"
53
+ "status": "ready",
54
+ "baseline": "val acc 0.935"
46
55
  },
47
56
  {
48
57
  "seq": 4,
@@ -56,7 +65,14 @@
56
65
  "dir": "is-that-audio-aicc-round-1-2",
57
66
  "topic_cn": "260 条 wav 的多类音频分类(A/B 两组前缀),官方解答走 mel-spectrogram + CNN;官方承认该轮数据存在泄漏,定位为教学素材",
58
67
  "comp": "s04-is-that-audio",
59
- "status": "ready"
68
+ "status": "ready",
69
+ "baseline": "val acc 0.811",
70
+ "media": {
71
+ "kind": "audio",
72
+ "pack": "s04-is-that-audio-aicc-round-1-2",
73
+ "mb": 12,
74
+ "glob": "data/raw_audio/*.wav"
75
+ }
60
76
  },
61
77
  {
62
78
  "seq": 5,
@@ -71,7 +87,8 @@
71
87
  "topic_cn": "给出文章缺口的前文/后文与 4 个候选句,选出被挖掉的那一句(BERT 微调四选一)",
72
88
  "comp": "s05-essay-gap",
73
89
  "status": "ready",
74
- "judged": true
90
+ "judged": true,
91
+ "baseline": "val acc 0.275"
75
92
  },
76
93
  {
77
94
  "seq": 6,
@@ -88,7 +105,14 @@
88
105
  "status": "teleload",
89
106
  "pack": "s06-face-matching-aicc-round-2",
90
107
  "pack_mb": 8,
91
- "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s06-face-matching-aicc-round-2.tar.zst"
108
+ "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s06-face-matching-aicc-round-2.tar.zst",
109
+ "baseline": "none",
110
+ "media": {
111
+ "kind": "image",
112
+ "pack": "s06-face-matching-aicc-round-2",
113
+ "mb": 8,
114
+ "glob": "face-matching/images/*.jpg"
115
+ }
92
116
  },
93
117
  {
94
118
  "seq": 7,
@@ -103,7 +127,8 @@
103
127
  "topic_cn": "科学论断 × 证据段落的三分类蕴含判断(支持/反驳/信息不足),官方解答 = transformer 微调 + 交叉验证 ensemble,macro F1",
104
128
  "comp": "s07-scientific-facts",
105
129
  "status": "ready",
106
- "judged": true
130
+ "judged": true,
131
+ "baseline": "val acc 0.641"
107
132
  },
108
133
  {
109
134
  "seq": 8,
@@ -117,7 +142,8 @@
117
142
  "dir": "nitro/47_nitro_spooky-round-2025_t2_spooky-disaster-or-creepy-pizza",
118
143
  "topic_cn": "音频修复:500段声音各4000个采样点,部分片段被填0,重建缺失值(MSE);数据200Hz生成、需重采样到44.1kHz才可听",
119
144
  "comp": "s08-spooky-disaster-or-creepy-pizza",
120
- "status": "ready"
145
+ "status": "ready",
146
+ "baseline": "val RMSE 0.726"
121
147
  },
122
148
  {
123
149
  "seq": 9,
@@ -131,7 +157,8 @@
131
157
  "dir": "alchemy-aicc-round-4",
132
158
  "topic_cn": "「小炼金术」式语义合成:给 item1+item2 预测合成结果(如 bird+fire→phoenix),候选集封闭,官方解答用 BERT 打分 + 匈牙利算法做全局指派",
133
159
  "comp": "s09-alchemy",
134
- "status": "ready"
160
+ "status": "ready",
161
+ "baseline": "val acc 0.000"
135
162
  },
136
163
  {
137
164
  "seq": 10,
@@ -145,7 +172,8 @@
145
172
  "dir": "nitro/24_algolymp_algolymp-preojia-xi-xii_t2_hello-aliens",
146
173
  "topic_cn": "50维射电频谱:①信号/噪声二分类(F1≥0.98) ②接触概率回归 ③来源三分类;题面明说有效信号只住在低维流形上",
147
174
  "comp": "s10-hello-aliens",
148
- "status": "ready"
175
+ "status": "ready",
176
+ "baseline": "val RMSE 19.29"
149
177
  },
150
178
  {
151
179
  "seq": 11,
@@ -162,7 +190,14 @@
162
190
  "status": "teleload",
163
191
  "pack": "s11-haunt-me",
164
192
  "pack_mb": 65,
165
- "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s11-haunt-me.tar.zst"
193
+ "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s11-haunt-me.tar.zst",
194
+ "baseline": "none",
195
+ "media": {
196
+ "kind": "image",
197
+ "pack": "s11-haunt-me",
198
+ "mb": 65,
199
+ "glob": "Starter_kit/images/{train,inference}/*.jpg"
200
+ }
166
201
  },
167
202
  {
168
203
  "seq": 12,
@@ -176,7 +211,13 @@
176
211
  "dir": "audio-demixing-aicc-round-2",
177
212
  "topic_cn": "2897 条 5 秒 wav:把混合音轨拆成两路信号,UNet + PIT(置换不变)损失,提交两路波形的 base85 编码",
178
213
  "comp": "s12-audio-demixing",
179
- "status": "ready"
214
+ "status": "ready",
215
+ "baseline": "val acc 0.000",
216
+ "media": {
217
+ "kind": "audio",
218
+ "pack": "audio-demixing-aicc-round-2",
219
+ "mb": 1223
220
+ }
180
221
  },
181
222
  {
182
223
  "seq": 13,
@@ -190,7 +231,8 @@
190
231
  "dir": "polarity-aicc-round-7",
191
232
  "topic_cn": "判断词对是同义还是反义(cash/money=0,inferior/worse=?)——训练集只有 897 字节(约 40 对),官方解答用掩码语言模型在模板句上取 logit 当特征再训分类器",
192
233
  "comp": "s13-polarity",
193
- "status": "ready"
234
+ "status": "ready",
235
+ "baseline": "val acc 0.600"
194
236
  },
195
237
  {
196
238
  "seq": 15,
@@ -207,7 +249,14 @@
207
249
  "status": "teleload",
208
250
  "pack": "s15-find-the-ducks",
209
251
  "pack_mb": 535,
210
- "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s15-find-the-ducks.tar.zst"
252
+ "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s15-find-the-ducks.tar.zst",
253
+ "baseline": "none",
254
+ "media": {
255
+ "kind": "archive",
256
+ "pack": "s15-find-the-ducks",
257
+ "mb": 535,
258
+ "glob": "custom_archive__custom_archive.zip"
259
+ }
211
260
  },
212
261
  {
213
262
  "seq": 16,
@@ -221,7 +270,8 @@
221
270
  "dir": "lost-interpreter-aicc-round-5",
222
271
  "topic_cn": "给一段自定义字节码程序(OP5 13 ; OP7 -2 ; …)预测其数值输出,官方解答用 LSTM 端到端学「执行」,判分 MAE",
223
272
  "comp": "s16-lost-interpreter",
224
- "status": "ready"
273
+ "status": "ready",
274
+ "baseline": "val RMSE 103.70"
225
275
  },
226
276
  {
227
277
  "seq": 17,
@@ -236,7 +286,8 @@
236
286
  "topic_cn": "①英文商品描述判可食用(macro F1) ②西班牙语查询跨语种检索英文商品(top-1);训练集里is_food=-1的行专供跨语种对齐",
237
287
  "comp": "s17-bazarul-lui-riki",
238
288
  "status": "ready",
239
- "judged": true
289
+ "judged": true,
290
+ "baseline": "val acc 0.955"
240
291
  },
241
292
  {
242
293
  "seq": 18,
@@ -250,7 +301,8 @@
250
301
  "dir": "nitro/30_nitro_pre-iaio-2026_t4_the-hieroglyph-hunter",
251
302
  "topic_cn": "emoji序列→英文句子语义检索:1000句语料(含爱丽丝梦游仙境干扰句),查询分字面/习语/网络俚语三档难度,只给少量support示例",
252
303
  "comp": "s18-the-hieroglyph-hunter",
253
- "status": "ready"
304
+ "status": "ready",
305
+ "baseline": "none"
254
306
  },
255
307
  {
256
308
  "seq": 19,
@@ -265,7 +317,8 @@
265
317
  "topic_cn": "128×128合成月面图:①数陨石坑个数(MAE) ②估计侵蚀年龄参数1.0-5.0(MAE)",
266
318
  "comp": "s19-lunar-craters",
267
319
  "status": "ready",
268
- "judged": true
320
+ "judged": true,
321
+ "baseline": "val RMSE 1.076"
269
322
  },
270
323
  {
271
324
  "seq": 20,
@@ -282,7 +335,14 @@
282
335
  "status": "teleload",
283
336
  "pack": "s20-latent-model-classification-ai",
284
337
  "pack_mb": 5,
285
- "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s20-latent-model-classification-ai.tar.zst"
338
+ "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s20-latent-model-classification-ai.tar.zst",
339
+ "baseline": "pack",
340
+ "media": {
341
+ "kind": "weights",
342
+ "pack": "s20-latent-model-classification-ai",
343
+ "mb": 5,
344
+ "glob": "modelA_penultimate.pth"
345
+ }
286
346
  },
287
347
  {
288
348
  "seq": 21,
@@ -296,7 +356,8 @@
296
356
  "dir": "autocorrect-aicc-round-1-2",
297
357
  "topic_cn": "13MB 英文语料的字符级纠错:错字文本与正确文本等长,官方明确提示用 encoder-only 而非 seq2seq,且整段推理必须在 250 秒内跑完",
298
358
  "comp": "s21-autocorrect",
299
- "status": "ready"
359
+ "status": "ready",
360
+ "baseline": "val acc 0.0005"
300
361
  },
301
362
  {
302
363
  "seq": 22,
@@ -313,7 +374,14 @@
313
374
  "status": "teleload",
314
375
  "pack": "s22-sticky-note-blindness-aicc-rou",
315
376
  "pack_mb": 87,
316
- "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s22-sticky-note-blindness-aicc-rou.tar.zst"
377
+ "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s22-sticky-note-blindness-aicc-rou.tar.zst",
378
+ "baseline": "none",
379
+ "media": {
380
+ "kind": "weights",
381
+ "pack": "s22-sticky-note-blindness-aicc-rou",
382
+ "mb": 87,
383
+ "glob": "class_embeddings.pt"
384
+ }
317
385
  },
318
386
  {
319
387
  "seq": 23,
@@ -328,7 +396,8 @@
328
396
  "topic_cn": "全国赛:①文本是人写还是AI生成(macro F1≥95才满分) ②四大主题分类——但训练集根本没有主题标签,必须零样本/无监督做",
329
397
  "comp": "s23-om-vs-ai",
330
398
  "status": "ready",
331
- "judged": true
399
+ "judged": true,
400
+ "baseline": "val acc 0.934"
332
401
  },
333
402
  {
334
403
  "seq": 24,
@@ -342,7 +411,8 @@
342
411
  "dir": "nitro/56_roai-2025_lot-baraj-1_t2_angry-birds",
343
412
  "topic_cn": "国家队选拔:训练集里土鸟几乎总配陆地背景、水鸟几乎总配水背景;最终按(鸟种×背景)四种组合中最差的一档准确率计分;允许ResNet50",
344
413
  "comp": "s24-angry-birds",
345
- "status": "ready"
414
+ "status": "ready",
415
+ "baseline": "val acc 0.756"
346
416
  },
347
417
  {
348
418
  "seq": 25,
@@ -356,7 +426,8 @@
356
426
  "dir": "nitro/49_cram-school_cram-school-training-1_t2_smart-waste-classifier",
357
427
  "topic_cn": "垃圾图六分类(纸板/塑料/其他/玻璃/金属/纸),macro F1",
358
428
  "comp": "s25-smart-waste-classifier",
359
- "status": "ready"
429
+ "status": "ready",
430
+ "baseline": "val acc 0.182"
360
431
  },
361
432
  {
362
433
  "seq": 26,
@@ -369,13 +440,15 @@
369
440
  "cli_mode": "kaggle-arena",
370
441
  "dir": "nitro/34_gaia_ai-league-i_t2_x-planet-x-model-selection",
371
442
  "topic_cn": "1000个回归模型里只有5个是在未损坏标签上训出来的,仅凭它们在训练特征上的预测矩阵把这5个揪出来",
372
- "comp": null,
373
- "status": "teleload",
443
+ "comp": "s26-planet-x",
444
+ "status": "ready",
374
445
  "pack": "s26-x-planet-x-model-selection",
375
446
  "pack_mb": 7,
376
447
  "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s26-x-planet-x-model-selection.tar.zst",
377
448
  "submit_shape": "indices",
378
- "submit_note": "Answer is 5 model indices, not a per-row prediction — there is no test.csv to score and none is needed. Scored at judge.nitro-ai.org; an official 100-point solution exists to check yourself against."
449
+ "submit_note": "Answer is 5 model indices, not a per-row prediction — there is no test.csv to score and none is needed. Scored at judge.nitro-ai.org; an official 100-point solution exists to check yourself against.",
450
+ "baseline": "none",
451
+ "judged": true
379
452
  }
380
453
  ]
381
454
  }
@@ -12,6 +12,9 @@ export interface EditorCommand {
12
12
  cmd: string;
13
13
  args: string[];
14
14
  }
15
+ /** Full argv for the editor child: the user's own args, then the vim
16
+ * compat fix when applicable, then the file. Pure given `probe`. */
17
+ export declare function buildEditorArgv(ed: EditorCommand, file: string, probe?: (cmd: string) => boolean): string[];
15
18
  /** $VISUAL → $EDITOR → vi (notepad on native Windows). vi is the POSIX
16
19
  * floor — present on every baseline terminal, and what the coretools track
17
20
  * teaches — whereas nano isn't guaranteed installed. Values like "code -w"
@@ -1 +1 @@
1
- import{spawnSync as r}from"node:child_process";import{mkdtempSync as o,readFileSync as t,rmSync as s,writeFileSync as e}from"node:fs";import{tmpdir as i}from"node:os";import{join as n}from"node:path";export function resolveEditor(r=process.env,o=process.platform){const t=(r.VISUAL??"").trim()||(r.EDITOR??"").trim();if(t){const r=t.split(/\s+/);return{cmd:r[0],args:r.slice(1)}}return"win32"===o?{cmd:"notepad",args:[]}:{cmd:"vi",args:[]}}export function editTextInEditor(c,d=".py"){const l=o(n(i(),"icoa-cell-")),m=n(l,`cell${d}`);e(m,""===c||c.endsWith("\n")?c:`${c}\n`);const p=resolveEditor(),a=process.stdin,f=!!a.isTTY&&a.isRaw;try{a.isTTY&&a.setRawMode(!1);const o=r(p.cmd,[...p.args,m],{stdio:"inherit"});return o.error||0!==o.status?null:t(m,"utf8")}catch{return null}finally{a.isTTY&&f&&a.setRawMode(!0),s(l,{recursive:!0,force:!0})}}
1
+ import{spawnSync as t}from"node:child_process";import{mkdtempSync as e,readFileSync as r,rmSync as o,writeFileSync as i}from"node:fs";import{tmpdir as s}from"node:os";import{join as n}from"node:path";const c=["-c","set nocompatible","-c","set backspace=indent,eol,start"],d=new Set(["vi","vim","vim.tiny","vim.basic","vimx"]),a=new Map;function p(e){const r=a.get(e);if(void 0!==r)return r;let o=!1;try{const r=t(e,["--version"],{encoding:"utf8",timeout:2e3});o=/VIM - Vi IMproved/.test(r.stdout??"")}catch{o=!1}return a.set(e,o),o}export function buildEditorArgv(t,e,r=p){return function(t){const e=(t.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.exe$/,"");return d.has(e)}(t.cmd)&&r(t.cmd)?[...t.args,...c,e]:[...t.args,e]}export function resolveEditor(t=process.env,e=process.platform){const r=(t.VISUAL??"").trim()||(t.EDITOR??"").trim();if(r){const t=r.split(/\s+/);return{cmd:t[0],args:t.slice(1)}}return"win32"===e?{cmd:"notepad",args:[]}:{cmd:"vi",args:[]}}export function editTextInEditor(c,d=".py"){const a=e(n(s(),"icoa-cell-")),p=n(a,`cell${d}`);i(p,""===c||c.endsWith("\n")?c:`${c}\n`);const l=resolveEditor(),m=process.stdin,u=!!m.isTTY&&m.isRaw;try{m.isTTY&&m.setRawMode(!1);const e=t(l.cmd,buildEditorArgv(l,p),{stdio:"inherit"});return e.error||0!==e.status?null:r(p,"utf8")}catch{return null}finally{m.isTTY&&u&&m.setRawMode(!0),o(a,{recursive:!0,force:!0})}}
@@ -91,3 +91,25 @@ export interface SubmissionVerdict {
91
91
  * naive comma-splitting is safe here.
92
92
  */
93
93
  export declare function validateSubmissionText(submission: string, sample: string): SubmissionVerdict;
94
+ /**
95
+ * Starter cells for a teleload-only task — the 6 sprint tasks whose dataset is a
96
+ * pack of images / weights / archives rather than a CSV three-pack.
97
+ *
98
+ * Those tasks shipped with NO notebook at all: `teleload` unpacked a folder and
99
+ * left the student staring at it. This is deliberately an ORIENTATION starter,
100
+ * not a solution — it inventories the pack, draws one picture of what is inside,
101
+ * and states what has to be built. Shipping the official winning notebook here
102
+ * would hand over the answer and delete the exercise.
103
+ *
104
+ * Same cell model as the CSV starter: markdown for prose, python for work, one
105
+ * `plt.show()` so `icoa ipynb` writes exactly one figure and opens one viewer.
106
+ */
107
+ export declare function buildMediaStarterCells(dir: string, task: {
108
+ seq?: number;
109
+ title?: string;
110
+ topic_cn?: string;
111
+ media?: {
112
+ kind?: string;
113
+ glob?: string;
114
+ };
115
+ }): NbCell[];