icoa-cli 2.19.15 → 2.19.16
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 +19 -0
- package/dist/lib/log-sync.js +1 -1
- package/dist/repl.js +4 -4
- package/package.json +1 -1
package/dist/commands/exam.js
CHANGED
|
@@ -695,8 +695,27 @@ export function registerExamCommand(program) {
|
|
|
695
695
|
console.log();
|
|
696
696
|
const questionsSnapshot = [...state.questions];
|
|
697
697
|
const answersSnapshot = { ...state.answers };
|
|
698
|
+
const helpState = getHelpState(state);
|
|
698
699
|
clearExamState();
|
|
699
700
|
const percentage = Math.round(score / total * 100);
|
|
701
|
+
// Report demo stats to server
|
|
702
|
+
const config = getConfig();
|
|
703
|
+
fetch('https://practice.icoa2026.au/api/icoa/demo-stats', {
|
|
704
|
+
method: 'POST',
|
|
705
|
+
headers: { 'Content-Type': 'application/json' },
|
|
706
|
+
body: JSON.stringify({
|
|
707
|
+
type: 'demo-exam',
|
|
708
|
+
score,
|
|
709
|
+
total,
|
|
710
|
+
lang: config.language || 'en',
|
|
711
|
+
help_used: helpState.used,
|
|
712
|
+
help_max: helpState.max,
|
|
713
|
+
tokens_used: 0,
|
|
714
|
+
solved: percentage >= 60 ? 1 : 0,
|
|
715
|
+
timestamp: new Date().toISOString(),
|
|
716
|
+
}),
|
|
717
|
+
signal: AbortSignal.timeout(5000),
|
|
718
|
+
}).catch(() => { });
|
|
700
719
|
console.log();
|
|
701
720
|
console.log(chalk.cyan(' ═══════════════════════════════════════'));
|
|
702
721
|
console.log();
|
package/dist/lib/log-sync.js
CHANGED
|
@@ -49,7 +49,7 @@ async function syncLogs() {
|
|
|
49
49
|
};
|
|
50
50
|
try {
|
|
51
51
|
// POST to CTFd server audit endpoint
|
|
52
|
-
const url = new URL('/api/
|
|
52
|
+
const url = new URL('/api/icoa/audit', config.ctfdUrl).href;
|
|
53
53
|
const res = await fetch(url, {
|
|
54
54
|
method: 'POST',
|
|
55
55
|
headers: {
|
package/dist/repl.js
CHANGED
|
@@ -10,6 +10,7 @@ import { getExamState } from './lib/exam-state.js';
|
|
|
10
10
|
import { resetTerminalTheme } from './lib/theme.js';
|
|
11
11
|
import { ensureSandbox, runInSandbox, isDockerAvailable } from './lib/sandbox.js';
|
|
12
12
|
import { logCommand } from './lib/logger.js';
|
|
13
|
+
import { startLogSync, stopLogSync } from './lib/log-sync.js';
|
|
13
14
|
import { existsSync, mkdirSync } from 'node:fs';
|
|
14
15
|
import { join } from 'node:path';
|
|
15
16
|
import { homedir } from 'node:os';
|
|
@@ -301,8 +302,7 @@ export async function startRepl(program, resumeMode) {
|
|
|
301
302
|
});
|
|
302
303
|
let processing = false;
|
|
303
304
|
setReplMode(true);
|
|
304
|
-
|
|
305
|
-
// startLogSync();
|
|
305
|
+
startLogSync();
|
|
306
306
|
rl.prompt();
|
|
307
307
|
rl.on('line', async (line) => {
|
|
308
308
|
if (processing)
|
|
@@ -349,7 +349,7 @@ export async function startRepl(program, resumeMode) {
|
|
|
349
349
|
rl.prompt();
|
|
350
350
|
return;
|
|
351
351
|
}
|
|
352
|
-
|
|
352
|
+
stopLogSync();
|
|
353
353
|
recordExit();
|
|
354
354
|
console.log(chalk.gray(' Session saved. Use ') + chalk.white('icoa --resume') + chalk.gray(' to continue.'));
|
|
355
355
|
resetTerminalTheme();
|
|
@@ -657,7 +657,7 @@ export async function startRepl(program, resumeMode) {
|
|
|
657
657
|
rl.prompt();
|
|
658
658
|
});
|
|
659
659
|
rl.on('close', () => {
|
|
660
|
-
|
|
660
|
+
stopLogSync();
|
|
661
661
|
recordExit();
|
|
662
662
|
resetTerminalTheme();
|
|
663
663
|
realExit(0);
|