@jpetit/toolkit 3.0.4 → 3.0.6
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/package.json +11 -6
- package/toolkit/index.ts +18 -1
- package/.prettierignore +0 -11
- package/.prettierrc.json +0 -9
- package/.vscode/settings.json +0 -26
- package/assets.zip +0 -0
- package/eslint.config.mjs +0 -31
- package/lib/ai.ts +0 -138
- package/lib/assets.ts +0 -31
- package/lib/cleaner.ts +0 -58
- package/lib/compilers/_frompython.ts +0 -388
- package/lib/compilers/base.ts +0 -97
- package/lib/compilers/gcc.ts +0 -47
- package/lib/compilers/gxx.ts +0 -47
- package/lib/compilers/index.ts +0 -61
- package/lib/compilers/python3.ts +0 -67
- package/lib/data.ts +0 -19
- package/lib/doctor.ts +0 -104
- package/lib/generate.ts +0 -333
- package/lib/maker.ts +0 -535
- package/lib/settings.ts +0 -42
- package/lib/tui.ts +0 -69
- package/lib/utils.ts +0 -83
- package/problems/maxim2.pbm/Main.java +0 -13
- package/problems/maxim2.pbm/distillation.yml +0 -7
- package/problems/maxim2.pbm/distilled-01.inp +0 -1
- package/problems/maxim2.pbm/distilled-02.inp +0 -1
- package/problems/maxim2.pbm/distilled-03.inp +0 -1
- package/problems/maxim2.pbm/distiller.yml +0 -2
- package/problems/maxim2.pbm/generate-inputs.py +0 -9
- package/problems/maxim2.pbm/handler.yml +0 -2
- package/problems/maxim2.pbm/ma-1.inp +0 -1
- package/problems/maxim2.pbm/ma-2.inp +0 -1
- package/problems/maxim2.pbm/ma-3.inp +0 -1
- package/problems/maxim2.pbm/ma-4.inp +0 -1
- package/problems/maxim2.pbm/ma-5.inp +0 -1
- package/problems/maxim2.pbm/per-doubles.inp +0 -1
- package/problems/maxim2.pbm/problem.ca.html +0 -11
- package/problems/maxim2.pbm/problem.ca.md +0 -19
- package/problems/maxim2.pbm/problem.ca.tex +0 -17
- package/problems/maxim2.pbm/problem.ca.txt +0 -19
- package/problems/maxim2.pbm/problem.ca.yml +0 -3
- package/problems/maxim2.pbm/problem.en.html +0 -11
- package/problems/maxim2.pbm/problem.en.md +0 -19
- package/problems/maxim2.pbm/problem.en.tex +0 -16
- package/problems/maxim2.pbm/problem.en.txt +0 -19
- package/problems/maxim2.pbm/problem.en.yml +0 -4
- package/problems/maxim2.pbm/sample-1.inp +0 -1
- package/problems/maxim2.pbm/sample-2.inp +0 -1
- package/problems/maxim2.pbm/sample-3.inp +0 -1
- package/problems/maxim2.pbm/solution.c +0 -12
- package/problems/maxim2.pbm/solution.cc +0 -13
- package/problems/maxim2.pbm/solution.java +0 -13
- package/problems/maxim2.pbm/solution.pas +0 -9
- package/problems/maxim2.pbm/solution.py +0 -5
- package/problems/maxim2.pbm/tags.yml +0 -2
- package/problems/maxim2.pbm/test_-1_-1.inp +0 -1
- package/problems/maxim2.pbm/test_-1_-2.inp +0 -1
- package/problems/maxim2.pbm/test_-1_0.inp +0 -1
- package/problems/maxim2.pbm/test_-1_1.inp +0 -1
- package/problems/maxim2.pbm/test_-2_-1.inp +0 -1
- package/problems/maxim2.pbm/test_-2_-2.inp +0 -1
- package/problems/maxim2.pbm/test_-2_0.inp +0 -1
- package/problems/maxim2.pbm/test_-2_1.inp +0 -1
- package/problems/maxim2.pbm/test_0_-1.inp +0 -1
- package/problems/maxim2.pbm/test_0_-2.inp +0 -1
- package/problems/maxim2.pbm/test_0_0.inp +0 -1
- package/problems/maxim2.pbm/test_0_1.inp +0 -1
- package/problems/maxim2.pbm/test_1_-1.inp +0 -1
- package/problems/maxim2.pbm/test_1_-2.inp +0 -1
- package/problems/maxim2.pbm/test_1_0.inp +0 -1
- package/problems/maxim2.pbm/test_1_1.inp +0 -1
- package/test.ts +0 -3
- package/toolkit/ai.ts +0 -30
- package/toolkit/clean.ts +0 -19
- package/toolkit/compilers.ts +0 -29
- package/toolkit/create-jutge-ai.ts +0 -101
- package/toolkit/create-template.ts +0 -51
- package/toolkit/create-wizard.ts +0 -4
- package/toolkit/create.ts +0 -75
- package/toolkit/doctor.ts +0 -17
- package/toolkit/init.ts +0 -66
- package/toolkit/make.ts +0 -60
- package/toolkit/verify.ts +0 -19
- package/tsconfig.json +0 -38
- package/types/zip.d.ts +0 -4
package/lib/utils.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import humanId from 'human-id'
|
|
2
|
-
import { customAlphabet } from 'nanoid'
|
|
3
|
-
|
|
4
|
-
export async function readYaml(path: string): Promise<any> {
|
|
5
|
-
const file = Bun.file(path)
|
|
6
|
-
if (!(await file.exists())) {
|
|
7
|
-
throw new Error(`File '${path}' not found`)
|
|
8
|
-
}
|
|
9
|
-
const content = await file.text()
|
|
10
|
-
return Bun.YAML.parse(content)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export async function readJson(path: string): Promise<any> {
|
|
14
|
-
const file = Bun.file(path)
|
|
15
|
-
if (!(await file.exists())) {
|
|
16
|
-
throw new Error(`File '${path}' not found`)
|
|
17
|
-
}
|
|
18
|
-
const content = await file.text()
|
|
19
|
-
return JSON.parse(content)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export async function fileSize(path: string): Promise<number> {
|
|
23
|
-
const file = Bun.file(path)
|
|
24
|
-
const stat = await file.stat()
|
|
25
|
-
return stat.size
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export async function filesAreEqual(path1: string, path2: string): Promise<boolean> {
|
|
29
|
-
const file1 = Bun.file(path1)
|
|
30
|
-
const file2 = Bun.file(path2)
|
|
31
|
-
const bytes1 = await file1.bytes()
|
|
32
|
-
const bytes2 = await file2.bytes()
|
|
33
|
-
return bytes1.length === bytes2.length && bytes1.every((b, i) => b === bytes2[i])
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Guess user name from git config
|
|
37
|
-
export async function guessUserName(): Promise<string | null> {
|
|
38
|
-
try {
|
|
39
|
-
const output = await Bun.$`git config user.name`.nothrow().text()
|
|
40
|
-
const name = output.trim()
|
|
41
|
-
if (name === '') return null
|
|
42
|
-
return name
|
|
43
|
-
} catch (e) {
|
|
44
|
-
return null
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Guess user email from git config
|
|
49
|
-
export async function guessUserEmail(): Promise<string | null> {
|
|
50
|
-
try {
|
|
51
|
-
const output = await Bun.$`git config user.email`.nothrow().text()
|
|
52
|
-
const email = output.trim()
|
|
53
|
-
if (email === '') return null
|
|
54
|
-
return email
|
|
55
|
-
} catch (e) {
|
|
56
|
-
return null
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function nanoid16(): string {
|
|
61
|
-
const alphabet = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
62
|
-
const nanoid = customAlphabet(alphabet, 16)
|
|
63
|
-
return nanoid()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function nanoid12(): string {
|
|
67
|
-
const alphabet = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
68
|
-
const nanoid = customAlphabet(alphabet, 12)
|
|
69
|
-
return nanoid()
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export function nanoid8(): string {
|
|
73
|
-
const alphabet = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
|
74
|
-
const nanoid = customAlphabet(alphabet, 8)
|
|
75
|
-
return nanoid()
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export function humanid(): string {
|
|
79
|
-
return humanId({
|
|
80
|
-
separator: '-',
|
|
81
|
-
capitalize: false,
|
|
82
|
-
})
|
|
83
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import java.io.*;
|
|
2
|
-
import java.util.*;
|
|
3
|
-
|
|
4
|
-
class Main {
|
|
5
|
-
|
|
6
|
-
public static void main (String[] args) {
|
|
7
|
-
Scanner in = new Scanner(System.in);
|
|
8
|
-
int a = in.nextInt();
|
|
9
|
-
int b = in.nextInt();
|
|
10
|
-
if (a > b) System.out.println(a); else System.out.println(b);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1000000000 500000000
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0 0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-1 -2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
4312 47465
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-12345 -987
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
987654321 -987654321
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
137 0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0 -651
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1000000000 500000000
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<h1 id="màxim-de-dos-enters">Màxim de dos enters</h1>
|
|
2
|
-
<p>Feu un programa que llegeixi dos nombres i que n’escrigui el
|
|
3
|
-
màxim.</p>
|
|
4
|
-
<h2 class="unnumbered" id="entrada">Entrada</h2>
|
|
5
|
-
<p>L’entrada consisteix en dos enters.</p>
|
|
6
|
-
<h2 class="unnumbered" id="sortida">Sortida</h2>
|
|
7
|
-
<p>Cal escriure una línia amb el màxim dels dos nombres.</p>
|
|
8
|
-
<h2 class="unnumbered" id="autor">Autor</h2>
|
|
9
|
-
<p>Jordi Petit</p>
|
|
10
|
-
<h2 class="unnumbered" id="draft">Draft</h2>
|
|
11
|
-
<p>Draft generated with <strong>new-jutge-toolkit</strong>.</p>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Màxim de dos enters
|
|
2
|
-
|
|
3
|
-
Feu un programa que llegeixi dos nombres i que n'escrigui el màxim.
|
|
4
|
-
|
|
5
|
-
## Entrada
|
|
6
|
-
|
|
7
|
-
L'entrada consisteix en dos enters.
|
|
8
|
-
|
|
9
|
-
## Sortida
|
|
10
|
-
|
|
11
|
-
Cal escriure una línia amb el màxim dels dos nombres.
|
|
12
|
-
|
|
13
|
-
## Autor
|
|
14
|
-
|
|
15
|
-
Jordi Petit
|
|
16
|
-
|
|
17
|
-
## Draft
|
|
18
|
-
|
|
19
|
-
Draft generated with **new-jutge-toolkit**.
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
\Problem{Màxim de dos enters}
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
\Statement
|
|
5
|
-
|
|
6
|
-
Feu un programa que llegeixi dos nombres i que n'escrigui el màxim.
|
|
7
|
-
|
|
8
|
-
\Input
|
|
9
|
-
|
|
10
|
-
L'entrada consisteix en dos enters.
|
|
11
|
-
|
|
12
|
-
\Output
|
|
13
|
-
|
|
14
|
-
Cal escriure una línia amb el màxim dels dos nombres.
|
|
15
|
-
|
|
16
|
-
\Sample
|
|
17
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Màxim de dos enters
|
|
2
|
-
|
|
3
|
-
Feu un programa que llegeixi dos nombres i que n’escrigui el màxim.
|
|
4
|
-
|
|
5
|
-
Entrada
|
|
6
|
-
|
|
7
|
-
L’entrada consisteix en dos enters.
|
|
8
|
-
|
|
9
|
-
Sortida
|
|
10
|
-
|
|
11
|
-
Cal escriure una línia amb el màxim dels dos nombres.
|
|
12
|
-
|
|
13
|
-
Autor
|
|
14
|
-
|
|
15
|
-
Jordi Petit
|
|
16
|
-
|
|
17
|
-
Draft
|
|
18
|
-
|
|
19
|
-
Draft generated with new-jutge-toolkit.
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<h1 id="maximum-of-two-integer-numbers">Maximum of two integer
|
|
2
|
-
numbers</h1>
|
|
3
|
-
<p>Write a program that reads two numbers and prints their maximum.</p>
|
|
4
|
-
<h2 class="unnumbered" id="input">Input</h2>
|
|
5
|
-
<p>Input consists of two integer numbers.</p>
|
|
6
|
-
<h2 class="unnumbered" id="output">Output</h2>
|
|
7
|
-
<p>Print a line with the maximum of the two numbers.</p>
|
|
8
|
-
<h2 class="unnumbered" id="author">Author</h2>
|
|
9
|
-
<p>Unknown (en: Carlos Molina)</p>
|
|
10
|
-
<h2 class="unnumbered" id="draft">Draft</h2>
|
|
11
|
-
<p>Draft generated with <strong>new-jutge-toolkit</strong>.</p>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Maximum of two integer numbers
|
|
2
|
-
|
|
3
|
-
Write a program that reads two numbers and prints their maximum.
|
|
4
|
-
|
|
5
|
-
## Input
|
|
6
|
-
|
|
7
|
-
Input consists of two integer numbers.
|
|
8
|
-
|
|
9
|
-
## Output
|
|
10
|
-
|
|
11
|
-
Print a line with the maximum of the two numbers.
|
|
12
|
-
|
|
13
|
-
## Author
|
|
14
|
-
|
|
15
|
-
Unknown (en: Carlos Molina)
|
|
16
|
-
|
|
17
|
-
## Draft
|
|
18
|
-
|
|
19
|
-
Draft generated with **new-jutge-toolkit**.
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
\Problem{Maximum of two integer numbers}
|
|
3
|
-
|
|
4
|
-
\Statement
|
|
5
|
-
|
|
6
|
-
Write a program that reads two numbers and prints their maximum.
|
|
7
|
-
|
|
8
|
-
\Input
|
|
9
|
-
|
|
10
|
-
Input consists of two integer numbers.
|
|
11
|
-
|
|
12
|
-
\Output
|
|
13
|
-
|
|
14
|
-
Print a line with the maximum of the two numbers.
|
|
15
|
-
|
|
16
|
-
\Sample
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Maximum of two integer numbers
|
|
2
|
-
|
|
3
|
-
Write a program that reads two numbers and prints their maximum.
|
|
4
|
-
|
|
5
|
-
Input
|
|
6
|
-
|
|
7
|
-
Input consists of two integer numbers.
|
|
8
|
-
|
|
9
|
-
Output
|
|
10
|
-
|
|
11
|
-
Print a line with the maximum of the two numbers.
|
|
12
|
-
|
|
13
|
-
Author
|
|
14
|
-
|
|
15
|
-
Unknown (en: Carlos Molina)
|
|
16
|
-
|
|
17
|
-
Draft
|
|
18
|
-
|
|
19
|
-
Draft generated with new-jutge-toolkit.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
634 371
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-31 -21
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-5 -5
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import java.io.*;
|
|
2
|
-
import java.util.*;
|
|
3
|
-
|
|
4
|
-
class Main {
|
|
5
|
-
|
|
6
|
-
public static void main (String[] args) {
|
|
7
|
-
Scanner in = new Scanner(System.in);
|
|
8
|
-
int a = in.nextInt();
|
|
9
|
-
int b = in.nextInt();
|
|
10
|
-
if (a > b) System.out.println(a); else System.out.println(b);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-1 -1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-1 -2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-1 0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-1 1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-2 -1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-2 -2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-2 0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
-2 1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0 -1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0 -2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0 0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
0 1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1 -1
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1 -2
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1 0
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
1 1
|
package/test.ts
DELETED
package/toolkit/ai.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { Command } from '@commander-js/extra-typings'
|
|
2
|
-
import { complete, listModels } from '@/lib/ai.ts'
|
|
3
|
-
|
|
4
|
-
export const ai = new Command('ai').description('Query AI models')
|
|
5
|
-
|
|
6
|
-
ai.command('complete')
|
|
7
|
-
.description('Complete a prompt')
|
|
8
|
-
|
|
9
|
-
.argument('prompt', 'the user prompt to complete')
|
|
10
|
-
.option('-s, --system-prompt <system>', 'the system prompt to use', 'You are a helpful assistant.')
|
|
11
|
-
.option(
|
|
12
|
-
'-m, --model <model>',
|
|
13
|
-
'the AI model to use (eg: openai/gpt-5, google/gemini-2.5-pro, ...)',
|
|
14
|
-
'google/gemini-2.5-flash-lite',
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
.action(async (prompt, { model, systemPrompt }) => {
|
|
18
|
-
if (!prompt) prompt = 'Who are you?'
|
|
19
|
-
if (!systemPrompt) systemPrompt = 'You are a helpful assistant.'
|
|
20
|
-
|
|
21
|
-
const answer = await complete(model, systemPrompt, prompt)
|
|
22
|
-
console.log(answer)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
ai.command('models')
|
|
26
|
-
.description('Show available AI models')
|
|
27
|
-
.action(async () => {
|
|
28
|
-
const models = await listModels()
|
|
29
|
-
console.dir(models, { depth: null })
|
|
30
|
-
})
|
package/toolkit/clean.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { cleanFiles } from '@/lib/cleaner'
|
|
2
|
-
import { Command, Option } from '@commander-js/extra-typings'
|
|
3
|
-
import boxen from 'boxen'
|
|
4
|
-
import chalk from 'chalk'
|
|
5
|
-
|
|
6
|
-
export const clean = new Command('clean')
|
|
7
|
-
.description('Clean generated files')
|
|
8
|
-
|
|
9
|
-
.addOption(new Option('-f, --force', 'force removal').conflicts('dryRun'))
|
|
10
|
-
.addOption(new Option('-n, --dry-run', 'show but do not remove files').conflicts('force'))
|
|
11
|
-
.option('-d, --directory <path>', 'problem directory', '.')
|
|
12
|
-
|
|
13
|
-
.action(async (options) => {
|
|
14
|
-
// Default to dry-run if neither option is specified
|
|
15
|
-
console.log(chalk.blue(boxen('Clean files', { padding: { left: 1, right: 1 }, width: process.stdout.columns })))
|
|
16
|
-
console.log()
|
|
17
|
-
const force = options.force || false
|
|
18
|
-
await cleanFiles(force, options.directory)
|
|
19
|
-
})
|
package/toolkit/compilers.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { getAvailableCompilers, getCompilersInfo, getDefinedCompilerIds } from '@/lib/compilers'
|
|
2
|
-
import { Command } from '@commander-js/extra-typings'
|
|
3
|
-
|
|
4
|
-
export const compilers = new Command('compilers')
|
|
5
|
-
.description('Query compiler information')
|
|
6
|
-
// default action is to list all compilers
|
|
7
|
-
|
|
8
|
-
.action(async () => {
|
|
9
|
-
const info = await getCompilersInfo()
|
|
10
|
-
console.dir(info)
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
compilers
|
|
14
|
-
.command('list-defined')
|
|
15
|
-
.description('List all defined compiler names')
|
|
16
|
-
|
|
17
|
-
.action(async () => {
|
|
18
|
-
const items = await getDefinedCompilerIds()
|
|
19
|
-
console.dir(items)
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
compilers
|
|
23
|
-
.command('list-available')
|
|
24
|
-
.description('List all available compiler names')
|
|
25
|
-
|
|
26
|
-
.action(async () => {
|
|
27
|
-
const items = await getAvailableCompilers()
|
|
28
|
-
console.dir(items)
|
|
29
|
-
})
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { generateProblemWithJutgeAI, type ProblemData } from '@/lib/generate'
|
|
2
|
-
import { guessUserEmail, guessUserName } from '@/lib/utils'
|
|
3
|
-
import { checkbox, input, select } from '@inquirer/prompts'
|
|
4
|
-
import * as tui from '@/lib/tui.js'
|
|
5
|
-
import humanId from 'human-id'
|
|
6
|
-
import slug from 'slug'
|
|
7
|
-
|
|
8
|
-
const proglangsChoices = [
|
|
9
|
-
{ name: 'C', value: 'c' },
|
|
10
|
-
{ name: 'C++', value: 'cpp' },
|
|
11
|
-
{ name: 'Python3', value: 'py' },
|
|
12
|
-
{ name: 'Haskell', value: 'hs' },
|
|
13
|
-
{ name: 'Clojure', value: 'clj' },
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
const problemTypesChoices = [
|
|
17
|
-
{ name: 'Standard (read input, write output)', value: 'Standard' },
|
|
18
|
-
{ name: 'Function (use functions)', value: 'Function' },
|
|
19
|
-
{ name: 'Graphic', value: 'Graphic' },
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
const languagesChoices = [
|
|
23
|
-
{ name: 'English', value: 'en' },
|
|
24
|
-
{ name: 'Catalan', value: 'ca' },
|
|
25
|
-
{ name: 'Spanish', value: 'es' },
|
|
26
|
-
{ name: 'French', value: 'fr' },
|
|
27
|
-
{ name: 'German', value: 'de' },
|
|
28
|
-
]
|
|
29
|
-
|
|
30
|
-
const modelsChoices = [
|
|
31
|
-
{ name: 'Google - Gemini 2.5 flash lite', value: 'google/gemini-2.5-flash-lite' },
|
|
32
|
-
{ name: 'Google - Gemini 2.5 flash', value: 'google/gemini-2.5-flash' },
|
|
33
|
-
{ name: 'Google - Gemini 2.5', value: 'google/gemini-2.5' },
|
|
34
|
-
{ name: 'OpenAI - GPT-5 Nano', value: 'openai/gpt-5-nano' },
|
|
35
|
-
{ name: 'OpenAI - GPT-5 Mini', value: 'openai/gpt-5-mini' },
|
|
36
|
-
{ name: 'OpenAI - GPT-5', value: 'openai/gpt-5' },
|
|
37
|
-
{ name: 'Ollama - GPT OSS', value: 'ollama/gpt-oss' },
|
|
38
|
-
]
|
|
39
|
-
|
|
40
|
-
async function getInitialData(outputDir: string): Promise<ProblemData> {
|
|
41
|
-
const author = (await guessUserName()) || 'John Doe'
|
|
42
|
-
const email = (await guessUserEmail()) || 'john.doe@example.com'
|
|
43
|
-
const title = 'The ' + humanId({ separator: ' ', capitalize: false })
|
|
44
|
-
const folder = slug(`The ${title}.pbm`)
|
|
45
|
-
|
|
46
|
-
const data = {
|
|
47
|
-
title,
|
|
48
|
-
description: '',
|
|
49
|
-
author,
|
|
50
|
-
email,
|
|
51
|
-
type: 'std',
|
|
52
|
-
proglangs: ['cpp', 'py'],
|
|
53
|
-
languages: ['en', 'ca', 'es'],
|
|
54
|
-
model: modelsChoices[0]!.value,
|
|
55
|
-
outputDir,
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return data
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function updateDataFromUser(data: ProblemData) {
|
|
62
|
-
data.author = await input({ message: 'Author:', default: data.author })
|
|
63
|
-
data.email = await input({ message: 'Author email:', default: data.email })
|
|
64
|
-
data.title = await input({ message: 'Problem title:', default: data.title })
|
|
65
|
-
data.description = await input({ message: 'Problem description:', default: data.description })
|
|
66
|
-
|
|
67
|
-
const checkedProglangsChoices = proglangsChoices.map((choice) => ({
|
|
68
|
-
...choice,
|
|
69
|
-
checked: data.proglangs.includes(choice.value),
|
|
70
|
-
}))
|
|
71
|
-
data.proglangs = await checkbox({
|
|
72
|
-
message: 'Select programming languages for solutions:',
|
|
73
|
-
choices: checkedProglangsChoices,
|
|
74
|
-
required: true,
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
const checkedLanguagesChoices = languagesChoices.map((choice) => ({
|
|
78
|
-
...choice,
|
|
79
|
-
checked: data.languages.includes(choice.value),
|
|
80
|
-
}))
|
|
81
|
-
data.languages = await checkbox({
|
|
82
|
-
message: 'Select languages for statements:',
|
|
83
|
-
choices: checkedLanguagesChoices,
|
|
84
|
-
required: true,
|
|
85
|
-
})
|
|
86
|
-
|
|
87
|
-
data.model = await select({
|
|
88
|
-
message: 'Select an AI model:',
|
|
89
|
-
choices: modelsChoices,
|
|
90
|
-
default: data.model || modelsChoices[0]!.value,
|
|
91
|
-
})
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export async function createProblemWithJutgeAI(outputDir: string): Promise<void> {
|
|
95
|
-
tui.warning('JutgeAI can only create std problems for now.')
|
|
96
|
-
|
|
97
|
-
const data = await getInitialData(outputDir)
|
|
98
|
-
await updateDataFromUser(data)
|
|
99
|
-
console.log(data)
|
|
100
|
-
await generateProblemWithJutgeAI(data)
|
|
101
|
-
}
|