icoa-cli 2.19.85 → 2.19.87

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.
@@ -1045,6 +1045,9 @@ export function registerExamCommand(program) {
1045
1045
  state.answers[num] = c;
1046
1046
  state._lastQ = num;
1047
1047
  saveExamState(state);
1048
+ // UX: visible "saved" indicator reassures beginners their answer is safe
1049
+ // even if they Ctrl+C or lose network. Neutral — doesn't reveal correctness.
1050
+ console.log(chalk.gray(' ✓ saved'));
1048
1051
  // Per-question sync to server (real exam only). Best-effort, fire-and-forget.
1049
1052
  // If timer expires or network drops before final submit, the server still
1050
1053
  // has the answer. Final submit is authoritative and overwrites this.
@@ -1792,6 +1795,34 @@ export function registerExamCommand(program) {
1792
1795
  await playDemoIntro();
1793
1796
  saveConfig({ demoIntroSeen: true });
1794
1797
  }
1798
+ // T2-6: Pre-start confirmation. Prevents accidental launches (user typed
1799
+ // `demo` instead of exploring the menu). No timer pressure, but exam
1800
+ // state + AI budget get allocated the moment the first question lands,
1801
+ // so a 1-line "are you ready?" gate is cheap insurance. Ctrl+C here
1802
+ // cleanly exits via the REPL's SIGINT handler.
1803
+ console.log();
1804
+ console.log(chalk.white(' Demo: ') + chalk.gray(`${DEMO_PICK_SIZE} questions drawn from a pool of ${DEMO_POOL_SIZE}. No timer. Free practice.`));
1805
+ console.log(chalk.gray(' You can pause with ') + chalk.cyan('Ctrl+C') + chalk.gray(' or leave with ') + chalk.cyan('back') + chalk.gray(' at any time.'));
1806
+ await new Promise((resolve) => {
1807
+ process.stdout.write(chalk.bold.yellow(' Press Enter to begin... '));
1808
+ const wasRaw = process.stdin.isTTY ? process.stdin.isRaw : false;
1809
+ if (process.stdin.isTTY && process.stdin.setRawMode) {
1810
+ process.stdin.setRawMode(false);
1811
+ }
1812
+ const onData = (chunk) => {
1813
+ const s = chunk.toString();
1814
+ if (s.includes('\n') || s.includes('\r')) {
1815
+ process.stdin.removeListener('data', onData);
1816
+ if (process.stdin.isTTY && process.stdin.setRawMode) {
1817
+ process.stdin.setRawMode(wasRaw);
1818
+ }
1819
+ process.stdout.write('\n');
1820
+ resolve();
1821
+ }
1822
+ };
1823
+ process.stdin.on('data', onData);
1824
+ process.stdin.resume();
1825
+ });
1795
1826
  const DEMO_QUESTIONS = pickDemoQuestions(DEMO_PICK_SIZE);
1796
1827
  const DEMO_SESSION = getLocalizedDemoSession();
1797
1828
  // Demo uses separate state file — doesn't conflict with real exam
package/dist/index.js CHANGED
@@ -104,6 +104,18 @@ program
104
104
  // Force hacker theme: black background + green text
105
105
  setTerminalTheme();
106
106
  checkForUpdates();
107
+ // T2-7: UTF-8 locale sanity check. Non-UTF-8 terminals mangle the box-
108
+ // drawing banner, the ✓/✗/⚠ glyphs used throughout the CLI, and any
109
+ // Cyrillic/CJK/Arabic/Devanagari/etc. translation text. Warn once at
110
+ // startup (not blocking) so students see a concrete fix hint instead of
111
+ // wondering why "哪个命令..." appears as "????..." on their machine.
112
+ const envLang = process.env.LANG || process.env.LC_ALL || process.env.LC_CTYPE || '';
113
+ if (!/UTF-?8/i.test(envLang)) {
114
+ console.log(chalk.yellow('⚠ Your terminal locale is not UTF-8 (LANG=' + (envLang || '(unset)') + ').'));
115
+ console.log(chalk.gray(' Non-English text and box characters may display as "?" or garbled glyphs.'));
116
+ 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(')'));
117
+ console.log();
118
+ }
107
119
  console.log(BANNER);
108
120
  // If running interactively (no extra args or --resume), start REPL
109
121
  if (process.argv.length <= 2 || opts.resume) {
package/dist/repl.js CHANGED
@@ -192,6 +192,14 @@ function printSelectionMenu() {
192
192
  console.log(chalk.white(' lang es') + chalk.gray(' Switch language (17 supported)'));
193
193
  console.log(chalk.gray(' ─────────────────────────────────────────────'));
194
194
  }
195
+ // Beginner-friendly safety net: make it obvious how to pause / exit / get help.
196
+ // This is the first place a new K-12 user lands, so the three escape hatches
197
+ // need to be visible without cluttering the main command list above.
198
+ console.log(chalk.gray(' ') +
199
+ chalk.gray('Tip: ') + chalk.cyan('help') + chalk.gray(' for commands · ') +
200
+ chalk.cyan('Ctrl+C') + chalk.gray(' pauses · ') +
201
+ chalk.cyan('exit') + chalk.gray(' → menu · ') +
202
+ chalk.cyan('quit') + chalk.gray(' closes CLI'));
195
203
  console.log();
196
204
  }
197
205
  export async function startRepl(program, resumeMode) {
@@ -716,10 +724,19 @@ export async function startRepl(program, resumeMode) {
716
724
  console.log(chalk.green(' Access granted! Token bound to this device.'));
717
725
  }
718
726
  else if (result === 'already_bound') {
719
- console.log(chalk.red(' Token already activated on another device.'));
727
+ console.log();
728
+ console.log(chalk.red(' Token already activated on a different device.'));
729
+ console.log(chalk.gray(' Each token binds to the first device that uses it. If you lost the device,'));
730
+ console.log(chalk.gray(' contact your proctor to have the token re-issued for a new device.'));
720
731
  }
721
732
  else {
722
- console.log(chalk.red(' Invalid token.'));
733
+ console.log();
734
+ console.log(chalk.red(' Token not recognized.'));
735
+ console.log(chalk.gray(' Possible reasons:'));
736
+ console.log(chalk.white(' • ') + chalk.gray('Typo — tokens are case-insensitive, 10 chars, start with a 2-letter country code (e.g. ') + chalk.cyan('UAK7M2R9Q4') + chalk.gray(')'));
737
+ console.log(chalk.white(' • ') + chalk.gray('Expired — ask your proctor or organizer for a fresh token'));
738
+ console.log(chalk.white(' • ') + chalk.gray('Network — verify connection to ') + chalk.cyan('practice.icoa2026.au'));
739
+ console.log(chalk.gray(' Still stuck? type ') + chalk.cyan('help') + chalk.gray(' or try ') + chalk.cyan('exam demo') + chalk.gray(' for a free practice round.'));
723
740
  }
724
741
  console.log();
725
742
  rl.prompt();
@@ -975,6 +992,28 @@ export async function startRepl(program, resumeMode) {
975
992
  console.log();
976
993
  rl.prompt();
977
994
  });
995
+ // SIGINT (Ctrl+C) — intercept gracefully so beginners don't lose confidence.
996
+ // Without this listener, readline's default is to raise SIGINT which our
997
+ // theme.ts handler converts to process.exit(130). Installing this listener
998
+ // swallows that path and lets the user get oriented. If they want to exit,
999
+ // they type `quit` or hit Ctrl+D (sends EOF → 'close' event below).
1000
+ rl.on('SIGINT', () => {
1001
+ console.log();
1002
+ if (isChatActive() || isCtf4aiActive()) {
1003
+ console.log(chalk.yellow(' Type ') + chalk.bold.cyan('exit') + chalk.yellow(' to leave chat, or Ctrl+D to close ICOA CLI.'));
1004
+ }
1005
+ else if (getExamState()) {
1006
+ console.log(chalk.yellow(' Exam paused. Your answers are auto-saved.'));
1007
+ console.log(chalk.white(' Resume: ') + chalk.cyan('exam q 1') +
1008
+ chalk.gray(' · Back to menu: ') + chalk.cyan('back') +
1009
+ chalk.gray(' · Close CLI: ') + chalk.cyan('quit'));
1010
+ }
1011
+ else {
1012
+ console.log(chalk.yellow(' Press Ctrl+D or type ') + chalk.bold.cyan('quit') + chalk.yellow(' to close. ') + chalk.bold.cyan('help') + chalk.yellow(' for commands.'));
1013
+ }
1014
+ console.log();
1015
+ rl.prompt();
1016
+ });
978
1017
  rl.on('close', () => {
979
1018
  stopLogSync();
980
1019
  recordExit();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.85",
3
+ "version": "2.19.87",
4
4
  "description": "ICOA CLI — The world's first CLI-native CTF competition terminal",
5
5
  "type": "module",
6
6
  "bin": {
@@ -25,7 +25,7 @@
25
25
  "icoa",
26
26
  "competition"
27
27
  ],
28
- "license": "SEE LICENSE IN LICENSE",
28
+ "license": "BUSL-1.1",
29
29
  "dependencies": {
30
30
  "@google/genai": "^1.48.0",
31
31
  "@inquirer/prompts": "^7.5.0",