icoa-cli 2.19.102 → 2.19.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/ai4ctf.js +1 -1
- package/dist/commands/exam.js +1 -1
- package/dist/commands/lang.js +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/gemini.d.ts +12 -2
- package/dist/lib/gemini.js +1 -1
- package/dist/lib/i18n.js +1 -1
- package/dist/repl.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.js +1 -1
- package/package.json +1 -1
- package/translations/bn/i18n-snippet.ts +1 -0
- package/translations/lo/i18n-snippet.ts +1 -0
- package/translations/uz/i18n-snippet.ts +1 -0
- package/dist/commands/hint.d.ts +0 -2
- package/dist/commands/hint.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{Command as o}from"commander";import chalk from"chalk";import{registerCtfCommands as e}from"./commands/ctf.js";import{
|
|
2
|
+
import{Command as o}from"commander";import chalk from"chalk";import{registerCtfCommands as e}from"./commands/ctf.js";import{registerRefCommand as n}from"./commands/ref.js";import{registerShellCommand as r}from"./commands/shell.js";import{registerFilesCommand as s}from"./commands/files.js";import{registerConnectCommand as t}from"./commands/connect.js";import{registerNoteCommand as i}from"./commands/note.js";import{registerLogCommand as a}from"./commands/log.js";import{registerLangCommand as l}from"./commands/lang.js";import{registerSetupCommand as m}from"./commands/setup.js";import{registerEnvCommand as c}from"./commands/env.js";import{registerAi4ctfCommand as g}from"./commands/ai4ctf.js";import{registerExamCommand as d}from"./commands/exam.js";import{registerCtf4aiDemoCommand as p}from"./commands/ctf4ai-demo.js";import{registerThemeCommand as y}from"./commands/theme.js";import{getConfig as h,saveConfig as f}from"./lib/config.js";import{startRepl as u}from"./repl.js";import{setTerminalTheme as w}from"./lib/theme.js";import{checkForUpdates as T}from"./lib/update-check.js";import{readFileSync as b}from"node:fs";import{fileURLToPath as C}from"node:url";import{dirname as $,join as _}from"node:path";const A=$(C(import.meta.url)),v=JSON.parse(b(_(A,"..","package.json"),"utf-8")).version,E=chalk.cyan(" ─────────────────────────────────────────────────────"),j=`\n${E}\n\n ${chalk.bold.white("██╗ ██████╗ ██████╗ █████╗")}\n ${chalk.bold.white("██║██╔════╝██╔═══██╗██╔══██╗")}\n ${chalk.bold.white("██║██║ ██║ ██║███████║")}\n ${chalk.bold.white("██║██║ ██║ ██║██╔══██║")}\n ${chalk.bold.white("██║╚██████╗╚██████╔╝██║ ██║")}\n ${chalk.bold.white("╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝")}\n\n ${chalk.yellow("International Cyber Olympiad in AI 2026")}\n ${chalk.bold.magenta("The World's First AI-Native CLI Operating System")}\n ${chalk.bold.magenta("for Cybersecurity & AI Security Competition")}\n ${chalk.bold.magenta("and Olympiad for K-12")}\n\n ${chalk.green.bold("AI4CTF")}${chalk.gray("[Day 1]")} ${chalk.white("AI as your teammate")}\n ${chalk.red.bold("CTF4AI")}${chalk.gray("[Day 2]")} ${chalk.white("Challenge & evaluate AI systems")}\n ${chalk.bold.yellow("AI is your ally. AI is your target.")}\n\n ${chalk.white("Sydney, Australia")} ${chalk.gray("Jun 27 - Jul 2, 2026")}\n ${chalk.cyan.underline("https://icoa2026.au")}\n\n ${chalk.gray(`CLI-Native Competition Terminal v${v}`)}\n\n${E}\n`;process.on("uncaughtException",o=>{"__REPL_NO_EXIT__"!==o.message&&(console.error(chalk.red("Error:"),o.message),process.exit(1))}),process.on("unhandledRejection",o=>{const e=o instanceof Error?o.message:String(o);"__REPL_NO_EXIT__"!==e&&(console.error(chalk.red("Error:"),e),process.exit(1))});const I=new o;if(I.name("icoa").version(v).description("ICOA CLI — CLI-Native CTF Competition Terminal").option("--resume","Resume previous session").action(async o=>{const e=h();w("high-contrast"===e.themeVariant?"high-contrast":"dark"),T();const n=process.env.LANG||process.env.LC_ALL||process.env.LC_CTYPE||"";if(!/UTF-?8/i.test(n))if("win32"===process.platform){let o="";try{const{execFileSync:e}=await import("node:child_process");o=e("chcp.com",[],{encoding:"utf-8",timeout:1500,stdio:["ignore","pipe","ignore"]}).trim()}catch{}o.includes("65001")||(console.log(chalk.yellow("⚠ Windows terminal is not using UTF-8 (current: "+(o||"unknown")+").")),console.log(chalk.gray(' Non-English text (Ukrainian, Chinese, Japanese, etc.) may show as "?" or garbled glyphs.')),console.log(chalk.gray(" Fix (run before ")+chalk.cyan("icoa")+chalk.gray("): ")+chalk.cyan("chcp 65001")),console.log(chalk.gray(" Or stay in English inside the CLI: ")+chalk.cyan("lang en")),console.log())}else console.log(chalk.yellow("⚠ Your terminal locale is not UTF-8 (LANG="+(n||"(unset)")+").")),console.log(chalk.gray(' Non-English text and box characters may display as "?" or garbled glyphs.')),console.log(chalk.gray(" Fix: ")+chalk.cyan("export LANG=en_US.UTF-8")+chalk.gray(" (or your locale, e.g. ")+chalk.cyan("zh_CN.UTF-8")+chalk.gray(", ")+chalk.cyan("uk_UA.UTF-8")+chalk.gray(")")),console.log();if(console.log(j),process.argv.length<=2||o.resume)return o.resume||await async function(){const o=process.stdin;if(o.isTTY&&"function"==typeof o.setRawMode)return new Promise(e=>{let n=!1;const r=()=>{if(!n){n=!0,o.removeListener("data",s);try{o.setRawMode(!1)}catch{}o.pause(),e()}},s=()=>r();o.setRawMode(!0),o.resume(),o.once("data",s),console.log(chalk.gray(" (press any key to continue...)")),setTimeout(r,3e3)});await new Promise(o=>setTimeout(o,3e3))}(),void u(I,!!o.resume)}),e(I),n(I),r(I),s(I),t(I),i(I),a(I),l(I),m(I),c(I),g(I),d(I),p(I),y(I),I.command("model",{hidden:!0}).argument("[name]","model name to switch to").action(o=>{const e=h().geminiModel||"gemini-2.5-flash";o?(f({geminiModel:o}),console.log(),console.log(chalk.green(" Model switched: ")+chalk.gray(e)+chalk.white(" -> ")+chalk.bold.white(o)),console.log()):(console.log(),console.log(chalk.gray(" Current model: ")+chalk.white(e)),console.log(),console.log(chalk.gray(" Available models:")),console.log(chalk.bold.white(" Gemini 3.x (Latest)")),console.log(chalk.white(" model gemini-3.1-pro-preview ")+chalk.gray("Most powerful, paid")),console.log(chalk.white(" model gemini-3-flash-preview ")+chalk.gray("Fast, free tier")),console.log(chalk.bold.white(" Gemini 2.5 (Stable)")),console.log(chalk.white(" model gemini-2.5-flash ")+chalk.gray("Fast, free tier (default)")),console.log(chalk.white(" model gemini-2.5-pro ")+chalk.gray("Strong reasoning, paid")),console.log(chalk.bold.white(" Open Source")),console.log(chalk.white(" model gemma-4-31b-it ")+chalk.gray("Free, open-source")),console.log(chalk.white(" model <any-model-id> ")+chalk.gray("Custom model")),console.log(),console.log(chalk.gray(" Translation uses gemini-3.1-pro-preview for best quality.")),console.log())}),"1"===process.env.ICOA_RESET_STATE)try{const{clearExamState:o}=await import("./lib/exam-state.js");o(),console.log(chalk.yellow("⚠ ICOA_RESET_STATE=1 — local exam state wiped.")),console.log(chalk.gray(" (Token NOT revoked server-side. Re-enter a fresh token with `exam <token>`.)")),console.log()}catch(o){console.log(chalk.red("⚠ ICOA_RESET_STATE: could not clear state — ")+chalk.gray(String(o)))}I.parse();
|
package/dist/lib/gemini.d.ts
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import type { HintLevel, ChallengeContext } from '../types/index.js';
|
|
2
2
|
export declare function filterFlagPatterns(text: string): string;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @deprecated Local hint generation is disabled as of 2026-04-24.
|
|
5
|
+
* All AI interaction goes through the server gateway. Use `ai4ctf` chat
|
|
6
|
+
* or the integrated `help` / `hint` commands inside `exam` mode instead.
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateHint(_level: HintLevel, _question: string, _context?: ChallengeContext): Promise<{
|
|
4
9
|
text: string;
|
|
5
10
|
tokensUsed: number;
|
|
6
11
|
}>;
|
|
7
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @deprecated Runtime translation is disabled. Translations are pre-baked
|
|
14
|
+
* at build time via `panda/translate-*.js` scripts and shipped in
|
|
15
|
+
* `translations/<lang>/` — CLI never translates at runtime.
|
|
16
|
+
*/
|
|
17
|
+
export declare function translateText(_text: string, _targetLang: string): Promise<string>;
|
|
8
18
|
export declare function setApiKey(key: string): void;
|
|
9
19
|
export declare function createChatSession(context?: ChallengeContext, customSystemPrompt?: string): Promise<{
|
|
10
20
|
sendMessage: (msg: string) => Promise<{
|
package/dist/lib/gemini.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GoogleGenAI as e}from"@google/genai";import chalk from"chalk";import{readFileSync as t}from"node:fs";import{dirname as
|
|
1
|
+
import{GoogleGenAI as e}from"@google/genai";import chalk from"chalk";import{readFileSync as t}from"node:fs";import{dirname as o,join as n}from"node:path";import{fileURLToPath as r}from"node:url";import{getConfig as a,saveConfig as s}from"./config.js";import{getRealExamState as i}from"./exam-state.js";const c=o(r(import.meta.url));let l=null;function p(){if(l)return l;try{const e=JSON.parse(t(n(c,"..","..","package.json"),"utf-8"));l=e.version||"unknown"}catch{l="unknown"}return l}export function filterFlagPatterns(e){return e.replace(/icoa\{[^}]*\}/gi,"[FLAG REDACTED]")}const u="Local AI model path has been disabled (2026-04-24). ICOA provides all AI server-side — no API key setup needed. Use `ai4ctf` (chat) or `exam` (with integrated help/hint) instead.";export async function generateHint(e,t,o){throw new Error(u)}export async function translateText(e,t){throw new Error(u)}export function setApiKey(e){s({geminiApiKey:e})}export async function createChatSession(e,t){const o=a();let n=t||"You are an AI teammate in the ICOA cybersecurity CTF competition (International Cyber Olympiad in AI 2026, Sydney).\n\nYou're a friendly, knowledgeable cybersecurity partner — like a fellow competitor sitting next to the user. Be conversational, encouraging, and collaborative.\n\nRULES:\n- Help the competitor think through challenges, brainstorm approaches, explain concepts\n- You MAY discuss vulnerability types, tools, techniques, and methodologies\n- You MAY suggest approaches and help debug code\n- Do NOT provide complete working exploits or full solution scripts\n- Do NOT provide flags or flag fragments\n- Never output anything matching flag format: icoa{...}\n- If you don't know something, say so honestly\n- Keep responses concise unless the user asks for detail\n- When the user opens a challenge, use the context to give relevant advice";e&&(n+=`\n\nThe competitor is currently working on:\nChallenge: ${e.name}\nCategory: ${e.category}`);const r=o.ctfdUrl||"https://practice.icoa2026.au",s=o.deviceFingerprint||"",c=o.geminiModel||"gemini-2.5-flash",l=[];return{async sendMessage(e){l.push({role:"user",text:e});const t=i(),o={systemPrompt:n,messages:l,model:c,maxTokens:2048,deviceFingerprint:s};t?.session?.token&&(o.examToken=t.session.token);const a=await fetch(`${r}/api/icoa/ai/chat`,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`icoa-cli/${p()}`},body:JSON.stringify(o),signal:AbortSignal.timeout(6e4)});if(!a.ok){const e=(await a.json().catch(()=>({message:"AI proxy error"}))).message||`AI proxy returned ${a.status}`;if(401===a.status)throw new Error(chalk.yellow("⚠ ")+"Exam token expired. Re-enter via `exam <token>`.");if(403===a.status)throw new Error(chalk.yellow("⚠ ")+e);if(429===a.status)throw new Error(chalk.yellow("⏳ ")+e);throw new Error(e)}const u=await a.json(),m=filterFlagPatterns(u.data?.text||""),h=u.data?.tokensUsed||0;return l.push({role:"model",text:m}),{text:m,tokensUsed:h}}}}
|