icoa-cli 2.19.86 → 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.
- package/dist/commands/exam.js +28 -0
- package/dist/index.js +12 -0
- package/dist/repl.js +11 -2
- package/package.json +1 -1
package/dist/commands/exam.js
CHANGED
|
@@ -1795,6 +1795,34 @@ export function registerExamCommand(program) {
|
|
|
1795
1795
|
await playDemoIntro();
|
|
1796
1796
|
saveConfig({ demoIntroSeen: true });
|
|
1797
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
|
+
});
|
|
1798
1826
|
const DEMO_QUESTIONS = pickDemoQuestions(DEMO_PICK_SIZE);
|
|
1799
1827
|
const DEMO_SESSION = getLocalizedDemoSession();
|
|
1800
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
|
@@ -724,10 +724,19 @@ export async function startRepl(program, resumeMode) {
|
|
|
724
724
|
console.log(chalk.green(' Access granted! Token bound to this device.'));
|
|
725
725
|
}
|
|
726
726
|
else if (result === 'already_bound') {
|
|
727
|
-
console.log(
|
|
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.'));
|
|
728
731
|
}
|
|
729
732
|
else {
|
|
730
|
-
console.log(
|
|
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.'));
|
|
731
740
|
}
|
|
732
741
|
console.log();
|
|
733
742
|
rl.prompt();
|