icoa-cli 2.19.450 → 2.19.451
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/commands/sprint.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
+
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 r}from"node:path";import{fileURLToPath as s}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,computeLegend as u,loadSprintTasks as h,mediaHelpLines as m,taskSteps as f}from"../lib/sprint-meta.js";let w=!1;export function isSprintActive(){return w}const b=a(s(import.meta.url)),$=r(process.env.HOME||".",".icoa"),k=r($,"sprint-state.json"),S={"T-torch":"裸 torch:手写 attention / causal mask / perplexity","T-umap":"降维当特征提取器,不是画图工具","T-lora":"peft LoRA 参数高效微调","T-librosa":"音频特征流水线:mel / MFCC → 定长向量"},A=["",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 q(o){try{e($,{recursive:!0}),t(k,`${JSON.stringify(o,null,1)}\n`)}catch{}}function v(){return(c().language||"en").toLowerCase().startsWith("zh")}function j(o,e){return v()?o:e}function I(o){return"★".repeat(Math.max(1,Math.min(5,o||3)))}const C=r($,"sprint-memos.json");function N(o){try{e($,{recursive:!0}),t(C,`${JSON.stringify(o,null,1)}\n`)}catch{}}function O(o,e){const n=new Set(e.done),t=new Set(e.opened);console.log(),console.log(chalk.bold.cyan(j(" ⚔ IOAI 2026 · 四工具冲刺"," ⚔ IOAI 2026 · four-tool sprint"))+chalk.gray(` ${j("已攻克","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(` — ${S[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(I(o.difficulty).padEnd(5))+chalk.gray(o.needs_gpu?" ⚡":" ")+chalk.gray(` ${o.data_mb}M`)+("teleload"===o.status?chalk.gray(j(" · teleload"," · teleload")):"")+(o.judged?chalk.green(j(" · 可出分"," · scored")):""))}}console.log(),console.log(chalk.gray(" ")+chalk.cyan("open <n>")+chalk.gray(j(" 看题 · "," view · "))+chalk.cyan("done <n>")+chalk.gray(j(" 标记攻克 · "," mark cleared · "))+chalk.cyan("ai4ioai")+chalk.gray(j(" 开 AI 分屏 · "," AI in a split · "))+chalk.cyan("memo")+chalk.gray(j(" 记问题 · "," report a problem · "))+chalk.cyan("back")+chalk.gray(j(" 退出"," leave"))),console.log(chalk.gray(j(" ⬜ 没看过 ◐ 看过没做完 ✓ 攻克"," ⬜ unseen ◐ opened ✓ cleared"))),console.log(chalk.gray(u(v()))),console.log()}function T(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=h();try{const t=JSON.parse(n(function(e){const n=[r(b,"..","data",e),r(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 A)console.log(o);t.who||(t.who=""),O(e,t);const a=i(),s=null!==a,c=s?a:l({input:process.stdin,output:process.stdout,terminal:!0});s||g(c);const u=s?c.listeners("line").slice():[];c.removeAllListeners("line");const $=c.prompt.bind(c);w=!0;const S=chalk.bold.cyan("icoa ioai2026> ");c.setPrompt(S);let x=null;await new Promise(o=>{c.on("line",async l=>{const a=l.trim().replace(/^icoa\s+/i,""),[r,i]=[a.split(/\s+/)[0]?.toLowerCase()||"",a.split(/\s+/)[1]||""];if(["back","quit","exit","menu"].includes(r))return q(t),console.log(chalk.gray(" 进度已保存。")),(()=>{if(w=!1,c.removeAllListeners("line"),s){for(const o of u)c.on("line",o);c.setPrompt(chalk.green("icoa> ")),c.prompt()}else g(null),c.close()})(),void o();if(""===r||["challenges","list","ls"].includes(r))O(e,t);else if(["open","o"].includes(r)||/^\d+$/.test(r)){const o=Number.parseInt(/^\d+$/.test(r)?r:i,10),n=e.find(e=>e.seq===o);n?(t.opened.includes(o)||t.opened.push(o),q(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=f(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 T(o,58))console.log(chalk.cyan(" │ ")+chalk.white(e));console.log(chalk.cyan(" │"))}const t=v();console.log(chalk.cyan(" │ ")+chalk.gray(p(o,t)));const l=d(o,t);if(l)for(const o of T(l,58))console.log(chalk.cyan(" │ ")+chalk.gray(o));console.log(chalk.cyan(" │ ")+chalk.gray(o.meta||`⏱ 难度 ${I(o.difficulty)}`)+chalk.gray(o.needs_gpu?" ⚡ 需要 GPU":"")),console.log(chalk.cyan(" ╰──────────────────────────────────────────────────────"));for(const e of m(o,t))for(const o of T(e,60))console.log(chalk.yellow(" ")+chalk.yellow(o));const a=f(o),r=function(o){const e=f(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(j(" ▸ 就在这里敲,两步:"," ▸ Type these here, in order:"))),a.forEach((o,e)=>{console.log(chalk.gray(` ${e+1}. `)+chalk.bold.cyan(o)+chalk.gray(0===e?j(" ← 先把数据拉下来"," ← fetch the data first"):j(" ← 题面 + notebook"," ← statement + notebook")))})):r&&console.log(chalk.bold.white(j(" ▸ 就在这里敲: "," ▸ Type it right here: "))+chalk.bold.cyan(r)+chalk.gray(j(" ← 数据 + notebook 落到本机"," ← pulls the data + notebook"))),console.log(chalk.gray(" ")+chalk.cyan("ai4ioai")+chalk.gray(j(" 开 AI 分屏 · "," AI in a split · "))+chalk.cyan(`done ${o.seq}`)+chalk.gray(j(" 标记攻克 · "," mark cleared · "))+chalk.cyan("memo")+chalk.gray(j(` 记问题(自动记在第 ${o.seq} 题) · `,` report (auto-filed under ${o.seq}) · `))+chalk.cyan("back")+chalk.gray(j(" 回列表"," back to list"))),console.log()}(n)):console.log(chalk.yellow(` 没有第 ${i||r} 题。`)+chalk.gray(` 题号 1-${e.length}。`))}else if("done"===r){const o=Number.parseInt(i,10);e.some(e=>e.seq===o)?(t.done.includes(o)||t.done.push(o),q(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(r)?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(j(" 这条命令没跑成:"," That command failed: "))+chalk.gray(String(o))),console.log(chalk.gray(j(" 记一条给教练:"," Tell the coach: "))+chalk.cyan(j("memo …","memo …"))),console.log()}}(r,a.split(/\s+/).slice(1).join(" ")):"memo"===r||"note"===r?await async function(o,e,t,l){const a=function(){try{const o=JSON.parse(n(C,"utf8"));return Array.isArray(o)?o:[]}catch{return[]}}(),r=o.trim();if(["list","ls","all"].includes(r.toLowerCase())){if(console.log(),0===a.length)console.log(chalk.gray(j(" 还没有记录。"," Nothing noted yet.")));else{console.log(chalk.bold.white(j(` 📝 已记 ${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?j(" ·已上报"," ·sent"):j(" ·仅本地"," ·local only")))}console.log(chalk.gray(` ${C}`))}return console.log(chalk.gray(j(" 再记一条:"," Note another: "))+chalk.cyan("memo")+chalk.gray(j(" (光敲这一个词就给你写字的地方)"," (just the word — it gives you a place to type)"))),void console.log()}const s=r?r.split(/\s+/):[],c=s.length>0&&/^\d+$/.test(s[0])&&e.some(o=>o.seq===Number(s[0])),i=c?Number(s[0]):t;let g=(c?s.slice(1):s).join(" ").trim();if(""===g){const o=i?chalk.gray(j(` —— 记在第 ${i} 题下`,` — filed under task ${i}`)):chalk.gray(j(" —— 通用反馈"," — general feedback"));if(console.log(),console.log(chalk.bold.white(j(" 📝 撞到什么就写什么"," 📝 Say what you hit"))+o),console.log(chalk.gray(j(" 一行写完,回车就存下(不用等回复);直接回车 = 不记。"," 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(j(" 没记。"," Nothing noted."))),void console.log()}const d={ts:(new Date).toISOString(),seq:i,text:g,synced:!1};a.push(d),N(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,N(a)),console.log(),console.log(chalk.green(j(" ✓ 记下了"," ✓ noted"))+(i?chalk.gray(j(` (第 ${i} 题)`,` (task ${i})`)):"")+chalk.gray(p?j(" ·已上报"," ·sent"):j(" ·存在本机,教练可以来取"," ·saved on this machine"))),console.log(chalk.gray(j(" 继续做题就好。看全部:"," Carry on. See them all: "))+chalk.cyan("memo list")),console.log()}(a.split(/\s+/).slice(1).join(" "),e,x,c):["ai4ioai","/ai4ioai","ai"].includes(r)?(console.log(),console.log(chalk.bold.white(j(" 左右分屏,左边看题右边问 AI:"," Split the screen — tasks left, AI right:"))),console.log(chalk.gray(" 1. ")+chalk.bold.cyan("Ctrl-b %")+chalk.gray(j(" 左右分屏(上下分屏是 "," split left/right (up/down is "))+chalk.cyan('Ctrl-b "')+chalk.gray(j(")",")"))),console.log(chalk.gray(" 2. ")+chalk.gray(j("右边那格输 ","in the right pane type "))+chalk.bold.cyan("icoa")+chalk.gray(j(" ,再输 "," , then "))+chalk.bold.cyan("ai4ioai")),console.log(chalk.gray(j(" 3. 两格之间切换:"," 3. move between panes: "))+chalk.cyan("Ctrl-b ←")+chalk.gray(" / ")+chalk.cyan("Ctrl-b →")),console.log(),console.log(chalk.gray(j(" 它是弱模型 —— 单轮、2000 字符以内。把问题问准,就是这次要练的本事。"," A deliberately weak model — single-turn, 2000 chars. Asking precisely is the skill."))),console.log(chalk.gray(j(" 在 notebook 里卡住时,那边可以直接敲 "," Stuck inside a notebook? there you can type "))+chalk.cyan("ai")+chalk.gray(j(" —— 它会把那一格的代码和报错一起带上。"," — it carries that cell and its traceback."))),console.log()):["help","?","guide"].includes(r)?O(e,t):(console.log(chalk.gray(" ")+chalk.cyan("open <n>")+chalk.gray(j(" 看题 · "," view · "))+chalk.cyan("kaggle <题目id>")+chalk.gray(j(" 领数据 · "," get the data · "))+chalk.cyan("ipynb <路径>")+chalk.gray(j(" 开 notebook · "," open the notebook · "))+chalk.cyan("done <n>")+chalk.gray(j(" 标记 · "," mark · "))+chalk.cyan("memo")+chalk.gray(j(" 记问题 · "," report · "))+chalk.cyan("back")+chalk.gray(j(" 退出"," leave"))),console.log(chalk.gray(j(" 题目 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(S),c.prompt()}),s||c.once("close",()=>o()),c.prompt=$,c.prompt()})}export function registerSprintCommand(o){o.command("pandahelpme31",{hidden:!0}).action(async()=>{await runSprint()})}
|
|
@@ -57,6 +57,13 @@ export declare function baselineChip(t: SprintTaskMeta, zh: boolean): string;
|
|
|
57
57
|
* back once the box-side hydration lands.
|
|
58
58
|
*/
|
|
59
59
|
export declare function computeChip(t: SprintTaskMeta, zh: boolean): string;
|
|
60
|
+
/**
|
|
61
|
+
* The list's legend for the same three marks the cards use. It lives here, next
|
|
62
|
+
* to `computeChip`, because the two were written apart and immediately drifted:
|
|
63
|
+
* the card said "GPU optional, the baseline runs on your laptop" while the
|
|
64
|
+
* legend two screens earlier still said "needs GPU — gpu key → gpu on".
|
|
65
|
+
*/
|
|
66
|
+
export declare function computeLegend(zh: boolean): string;
|
|
60
67
|
/**
|
|
61
68
|
* The media block: what is missing, the command that fetches it, and the first
|
|
62
69
|
* line of code that reads it. Used by the download guide AND baked into the
|
package/dist/lib/sprint-meta.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as t}from"node:fs";import{dirname as n,join as i}from"node:path";import{fileURLToPath as
|
|
1
|
+
import{existsSync as e,readFileSync as t}from"node:fs";import{dirname as n,join as i}from"node:path";import{fileURLToPath as o}from"node:url";const a=n(o(import.meta.url));export function sprintDataPath(t){const n=[i(a,"..","data",t),i(a,"..","..","src","data",t)];for(const t of n)if(e(t))return t;return n[0]}let r=null;export function loadSprintTasks(){if(r)return r;try{const e=JSON.parse(t(sprintDataPath("sprint-tasks.json"),"utf8"));r=Array.isArray(e?.tasks)?e.tasks.slice().sort((e,t)=>e.seq-t.seq):[]}catch{r=[]}return r}export function sprintTaskForComp(e){if(!e)return null;const t=e.trim().toLowerCase();return loadSprintTasks().find(e=>(e.comp||"").toLowerCase()===t)??null}export function taskSteps(e){const t=[];return e.media&&t.push(`teleload ${e.media.pack}`),"teleload"===e.status?t.length>0?t:[`teleload ${e.comp??""}`.trim()]:(e.comp&&t.push(`kaggle ${e.comp}`),t)}export function baselineChip(e,t){const n=(e.baseline||"").trim();if(!n)return"";if("none"===n)return t?"📊 无 baseline — 特征要你自己建(见下)":"📊 no baseline — you build the features (below)";if("pack"===n)return t?"📊 官方 baseline.ipynb 在数据包里":"📊 the pack ships the official baseline.ipynb";const i=t?`📊 开箱 baseline ${n}`:`📊 out-of-the-box baseline ${n}`;return/\b0\.(0\d|1\d|2\d)/.test(n)||/\b0\.000/.test(n)?i+(t?" — 线性模型对这题本就无效,不是坏了":" — a linear model cannot express this task; not a bug"):i}export function computeChip(e,t){return e.needs_gpu?t?"⚡ 数据大/训练重 · GPU 可选 —— baseline 本机就能跑":"⚡ heavy (GPU optional) — the baseline still runs on your laptop":t?"💻 CPU 可做 · 现在就能开":"💻 CPU is enough · start now"}export function computeLegend(e){return e?" ⚡ 数据大/训练重(GPU 可选,baseline 本机就能跑) · teleload 数据是大包,用 teleload 拉 · 可出分 交上去有真分数":" ⚡ heavy — GPU optional, the baseline still runs locally · teleload big pack, pull with teleload · scored real score on submit"}function s(e,t){switch(e){case"audio":return t?"本机 aienv:scipy.io.wavfile.read → numpy → scipy.signal 求谱(没有 librosa)· GPU 箱上 librosa/torchaudio 都有":"on your laptop: scipy.io.wavfile.read → numpy → scipy.signal (no librosa here) · on the GPU box librosa/torchaudio both exist";case"image":return t?"PIL.Image.open 读图 → numpy":"PIL.Image.open → numpy";case"weights":return t?"torch.load(..., weights_only=True) 读权重(输入就是模型)":"torch.load(..., weights_only=True) — the model IS the input here";default:return t?"先解开包里的压缩档再读":"unpack the archive inside the pack first"}}export function mediaHelpLines(e,t){const n=e.media;if(!n)return[];const i="audio"===n.kind?t?"音频":"audio":"image"===n.kind?t?"图片":"images":"weights"===n.kind?t?"模型权重":"model weights":t?"附件档":"an archive",o="none"===(e.baseline||"").trim()?t?`⚠ 这题的信号在${i}里,CSV 只有 id 和标签 —— 通用 starter 会在第 3 格停下。`:`⚠ The signal is in the ${i}; the CSVs carry only ids and labels — the generic starter stops at cell 3.`:t?`⚠ 真信号在${i}里。只喂 CSV 也能跑完,但分数接近瞎猜(${e.baseline})。`:`⚠ The real signal is in the ${i}. CSV-only does finish, but scores near chance (${e.baseline}).`;return t?[o,`▸ 先拉数据(${n.mb}MB):teleload ${n.pack}`,`▸ 然后把 FEATURES 那一格换成:${s(n.kind,!0)}`,...n.glob?[` 文件在 <数据目录>/${n.glob}`]:[]]:[o,`▸ Pull it first (${n.mb}MB): teleload ${n.pack}`,`▸ Then replace the FEATURES cell: ${s(n.kind,!1)}`,...n.glob?[` files live at <data dir>/${n.glob}`]:[]]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "icoa-cli",
|
|
3
|
-
"version": "2.19.
|
|
3
|
+
"version": "2.19.451",
|
|
4
4
|
"description": "ICOA CLI — The world's first CLI-native cyber & AI security olympiad terminal: AI4CTF (Day 1), CTF4AI (Day 2), VLA4CTF (Pioneer Round — embodied AI)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|