icoa-cli 2.19.71 → 2.19.73

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.
@@ -1040,6 +1040,20 @@ export function registerExamCommand(program) {
1040
1040
  state.answers[num] = c;
1041
1041
  state._lastQ = num;
1042
1042
  saveExamState(state);
1043
+ // Per-question sync to server (real exam only). Best-effort, fire-and-forget.
1044
+ // If timer expires or network drops before final submit, the server still
1045
+ // has the answer. Final submit is authoritative and overwrites this.
1046
+ const tokenForSync = state.session.token;
1047
+ if (tokenForSync && state.session.examId !== 'demo-free') {
1048
+ const cfg = getConfig();
1049
+ const url = `${cfg.ctfdUrl || 'https://practice.icoa2026.au'}/api/icoa/exams/${state.session.examId}/answer`;
1050
+ fetch(url, {
1051
+ method: 'POST',
1052
+ headers: { 'Content-Type': 'application/json' },
1053
+ body: JSON.stringify({ token: tokenForSync, question: num, answer: c }),
1054
+ signal: AbortSignal.timeout(5000),
1055
+ }).catch(() => { }); // silent failure — local state still saved
1056
+ }
1043
1057
  const answered = Object.keys(state.answers).length;
1044
1058
  const total = state.session.questionCount;
1045
1059
  printSuccess(`Q${num}: ${c} ✓ (${answered}/${total} answered)`);
package/dist/repl.js CHANGED
@@ -704,7 +704,11 @@ export async function startRepl(program, resumeMode) {
704
704
  // ─── Mode-based command filtering ───
705
705
  const selectionCommands = ['exam', 'demo', 'retry', 'nations', 'next', 'prev', 'continue', 'setup', 'lang', 'ref', 'ai4ctf', 'ctf4ai', 'mark', 'unmark', 'review', 'submit'];
706
706
  const organizerCommands = ['join', 'exam', 'demo', 'retry', 'next', 'prev', 'logout', 'setup', 'lang', 'ref', 'ctf', 'mark', 'unmark', 'review', 'submit'];
707
- if (mode === 'selection' && !selectionCommands.includes(cmd)) {
707
+ // Selection mode allows shell commands prefixed with ! — contestants
708
+ // need !python3, !cat, !base64 etc. for practical questions (Q31-Q40).
709
+ // BLOCKED_COMMANDS check downstream still rejects dangerous ones.
710
+ const isShellCommand = input.startsWith('!') || cmd.startsWith('!');
711
+ if (mode === 'selection' && !isShellCommand && !selectionCommands.includes(cmd)) {
708
712
  console.log(chalk.gray(' Not available in Selection mode.'));
709
713
  if (examState) {
710
714
  const currentQ = examState._lastQ || 1;
@@ -764,7 +768,9 @@ export async function startRepl(program, resumeMode) {
764
768
  }
765
769
  }
766
770
  // Force Python 3.12 — rewrite python/python3 to correct binary
767
- let resolvedInput = input;
771
+ // Strip optional ! prefix that contestants use to disambiguate shell
772
+ // commands from CLI commands (e.g. !python3 vs cli's "python" command).
773
+ let resolvedInput = input.startsWith('!') ? input.slice(1).trim() : input;
768
774
  if (process.platform === 'darwin') {
769
775
  const py12 = '/opt/homebrew/opt/python@3.12/bin/python3.12';
770
776
  resolvedInput = resolvedInput
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.71",
3
+ "version": "2.19.73",
4
4
  "description": "ICOA CLI — The world's first CLI-native CTF competition terminal",
5
5
  "type": "module",
6
6
  "bin": {