@jutge.org/toolkit 4.1.0 → 4.2.1

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.
@@ -0,0 +1,526 @@
1
+ # Jutge Toolkit - Getting Started Guide
2
+
3
+ Welcome to the New Jutge Toolkit! This guide will help you install and start using the toolkit to create, manage, and upload programming problems to Jutge.org. Information about problem formats will be provided in a separate document.
4
+
5
+ ## What is Jutge Toolkit?
6
+
7
+ Jutge Toolkit is a command-line application that helps you create and manage programming problems for the Jutge.org platform. It provides tools to:
8
+
9
+ - Create new problems from scratch or using templates
10
+ - Generate problem elements using AI (JutgeAI)
11
+ - Compile and test solutions in multiple programming languages
12
+ - Generate PDF statements and other formats
13
+ - Upload problems to Jutge.org
14
+
15
+ ## Installation
16
+
17
+ Choose the installation instructions for your operating system:
18
+
19
+ ### Linux Installation
20
+
21
+ 1. **Install Bun (JavaScript runtime)**
22
+
23
+ Open a terminal and run:
24
+
25
+ ```bash
26
+ curl -fsSL https://bun.sh/install | bash
27
+ ```
28
+
29
+ After installation, close and reopen your terminal, or run:
30
+
31
+ ```bash
32
+ source ~/.bashrc
33
+ ```
34
+
35
+ 2. **Install Jutge Toolkit**
36
+
37
+ ```bash
38
+ bun install --global "@jutge.org/toolkit"
39
+ ```
40
+
41
+ 3. **Verify installation**
42
+
43
+ ```bash
44
+ jtk --version
45
+ ```
46
+
47
+ You should see the version number displayed.
48
+
49
+ 4. **Check dependencies**
50
+
51
+ ```bash
52
+ jtk doctor
53
+ ```
54
+
55
+ This command will show which tools are installed on your system. Don't worry if some are missing - you only need to install the ones for the programming languages and features you plan to use.
56
+
57
+ 5. **Install recommended dependencies (optional)**
58
+
59
+ Depending on your needs, you may want to install:
60
+ - **LaTeX** (for PDF statements):
61
+
62
+ ```bash
63
+ sudo apt-get install texlive-xetex texlive-fonts-recommended texlive-lang-european
64
+ ```
65
+
66
+ - **Pandoc** (for converting statements to different formats):
67
+
68
+ ```bash
69
+ sudo apt-get install pandoc
70
+ ```
71
+
72
+ - **ImageMagick** (for image processing):
73
+
74
+ ```bash
75
+ sudo apt-get install imagemagick
76
+ ```
77
+
78
+ - **Python 3** (if using Python in your problems):
79
+
80
+ ```bash
81
+ sudo apt-get install python3
82
+ ```
83
+
84
+ - **GCC/G++** (if using C/C++ in your problems):
85
+ ```bash
86
+ sudo apt-get install build-essential
87
+ ```
88
+
89
+ ### macOS Installation
90
+
91
+ 1. **Install Bun (JavaScript runtime)**
92
+
93
+ Open Terminal and run:
94
+
95
+ ```bash
96
+ curl -fsSL https://bun.sh/install | bash
97
+ ```
98
+
99
+ After installation, close and reopen your terminal.
100
+
101
+ 2. **Install Jutge Toolkit**
102
+
103
+ ```bash
104
+ bun install --global "@jutge.org/toolkit"
105
+ ```
106
+
107
+ 3. **Verify installation**
108
+
109
+ ```bash
110
+ jtk --version
111
+ ```
112
+
113
+ You should see the version number displayed.
114
+
115
+ 4. **Check dependencies**
116
+
117
+ ```bash
118
+ jtk doctor
119
+ ```
120
+
121
+ This command will show which tools are installed on your system.
122
+
123
+ 5. **Install recommended dependencies (optional)**
124
+
125
+ We recommend using Homebrew to install additional tools. If you don't have Homebrew, install it first:
126
+
127
+ ```bash
128
+ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
129
+ ```
130
+
131
+ Then install the tools you need:
132
+ - **LaTeX** (for PDF statements):
133
+
134
+ ```bash
135
+ brew install --cask mactex
136
+ ```
137
+
138
+ - **Pandoc** (for converting statements):
139
+
140
+ ```bash
141
+ brew install pandoc
142
+ ```
143
+
144
+ - **ImageMagick** (for image processing):
145
+
146
+ ```bash
147
+ brew install imagemagick
148
+ ```
149
+
150
+ - **Python 3** (if using Python):
151
+
152
+ ```bash
153
+ brew install python3
154
+ ```
155
+
156
+ - **C/C++ Compiler** (if using C/C++):
157
+
158
+ macOS comes with Clang compiler. Install Xcode Command Line Tools:
159
+
160
+ ```bash
161
+ xcode-select --install
162
+ ```
163
+
164
+ ### Windows Installation
165
+
166
+ 1. **Open PowerShell**
167
+
168
+ Press Windows key, type "PowerShell", and open it. Remember to reopen PowerShell after installing each tool.
169
+
170
+ 2. **Install Bun (JavaScript runtime)**
171
+
172
+ Visit https://bun.sh/ and follow the installation instructions for Windows. It is easy!
173
+
174
+ 3. **Install Jutge Toolkit**
175
+
176
+ ```powershell
177
+ bun install --global "@jutge.org/toolkit"
178
+ ```
179
+
180
+ The first installation may take a while. If it fails with a `mkdir` error, try again - it's usually a transient error.
181
+
182
+ 4. **Verify installation**
183
+
184
+ ```powershell
185
+ jtk --version
186
+ ```
187
+
188
+ You should see the version number displayed.
189
+
190
+ 5. **Check dependencies**
191
+
192
+ ```powershell
193
+ jtk doctor
194
+ ```
195
+
196
+ This command will show which tools are installed on your system.
197
+
198
+ 6. **Install recommended dependencies (optional)**
199
+ - **LaTeX** (for PDF statements):
200
+
201
+ Install MiKTeX from https://miktex.org/download. During installation, select the option to install missing packages on-the-fly.
202
+
203
+ - **Pandoc** (for converting statements):
204
+
205
+ ```powershell
206
+ winget install --id JohnMacFarlane.Pandoc
207
+ ```
208
+
209
+ - **ImageMagick** (for image processing):
210
+
211
+ ```powershell
212
+ winget install --id ImageMagick.ImageMagick
213
+ ```
214
+
215
+ - **Python 3** (if using Python):
216
+
217
+ Install from https://www.python.org/downloads/windows/. Make sure to check "Add Python to PATH" during installation.
218
+
219
+ - **C/C++ Compiler** (if using C/C++):
220
+
221
+ We recommend w64devkit:
222
+ 1. Download from https://github.com/skeeto/w64devkit/releases
223
+ 2. Extract to a folder (e.g., `C:\w64devkit`)
224
+ 3. Run `w64devkit.exe` to open a terminal with GCC available
225
+
226
+ ## Getting Started
227
+
228
+ ### Getting Help
229
+
230
+ Before we dive into configuration, it's important to know how to get help:
231
+
232
+ 1. **View general help:**
233
+
234
+ ```bash
235
+ jtk --help
236
+ ```
237
+
238
+ This shows all available commands.
239
+
240
+ 2. **Get help for a specific command:**
241
+
242
+ ```bash
243
+ jtk make --help
244
+ jtk generate --help
245
+ jtk config --help
246
+ ```
247
+
248
+ Add `--help` to any command to see detailed information about its options and usage.
249
+
250
+ 3. **Get help using JutgeAI:**
251
+
252
+ You can ask questions about the toolkit in human language using the `ask` command and get answers generated by JutgeAI and formatted in arkdown:
253
+
254
+ ```bash
255
+ jtk ask "How to create a new problem?"
256
+ jtk ask "Com puc crear un problema nou?" --model "google/gemini-2.5-flash-lite"
257
+ ```
258
+
259
+ For this to work, you need to have set up an AI API key (see "Setting Up AI Features" below).
260
+
261
+ 4. **View information about the toolkit:**
262
+
263
+ ```bash
264
+ jtk about
265
+ ```
266
+
267
+ ### Configuration
268
+
269
+ Before using the toolkit, you should configure it with your preferences:
270
+
271
+ 1. **View current configuration:**
272
+
273
+ ```bash
274
+ jtk config show
275
+ ```
276
+
277
+ 2. **Set a configuration value:**
278
+
279
+ ```bash
280
+ jtk config set defaultModel "google/gemini-2.5-flash"
281
+ ```
282
+
283
+ 3. **Edit configuration interactively:**
284
+
285
+ ```bash
286
+ jtk config edit
287
+ ```
288
+
289
+ This opens your default text editor with the configuration file.
290
+
291
+ ### Setting Up AI Features (Optional)
292
+
293
+ If you want to use JutgeAI features to generate problems and content, you need to set up API keys:
294
+
295
+ **For Google Gemini (Free for UPC users):**
296
+
297
+ 1. Visit https://aistudio.google.com/ and sign in
298
+ 2. Click "Get API key" in the sidebar
299
+ 3. Click "Create API key"
300
+ 4. Copy the generated key
301
+ 5. Set the environment variable:
302
+ - **Linux/macOS:** Add to `~/.bashrc` or `~/.zshrc`:
303
+ ```bash
304
+ export GEMINI_API_KEY="your-key-here"
305
+ ```
306
+ - **Windows PowerShell (permanent):**
307
+ ```powershell
308
+ [System.Environment]::SetEnvironmentVariable('GEMINI_API_KEY', 'your-key-here', 'User')
309
+ ```
310
+
311
+ **For OpenAI (Paid):**
312
+
313
+ 1. Create an account at https://platform.openai.com/
314
+ 2. Navigate to API Keys section
315
+ 3. Create a new secret key
316
+ 4. Set the environment variable:
317
+ - **Linux/macOS:** Add to `~/.bashrc` or `~/.zshrc`:
318
+ ```bash
319
+ export OPENAI_API_KEY="your-key-here"
320
+ ```
321
+ - **Windows PowerShell (permanent):**
322
+ ```powershell
323
+ [System.Environment]::SetEnvironmentVariable('OPENAI_API_KEY', 'your-key-here', 'User')
324
+ ```
325
+
326
+ ### Your First Problem
327
+
328
+ #### Option 1: Create from Template
329
+
330
+ 1. **Clone a template:**
331
+
332
+ ```bash
333
+ jtk clone
334
+ ```
335
+
336
+ This will show you available templates and create a new problem directory.
337
+
338
+ 2. **Or clone a specific template:**
339
+
340
+ ```bash
341
+ jtk clone standard/maximum-of-2-integers.pbm -d my-problem.pbm
342
+ ```
343
+
344
+ #### Option 2: Create with AI
345
+
346
+ 1. **Create a problem using JutgeAI:**
347
+
348
+ ```bash
349
+ jtk generate problem -d factorial.pbm
350
+ ```
351
+
352
+ The toolkit will ask you for:
353
+ - Problem title
354
+ - Problem description
355
+ - Original language
356
+ - Programming language for the solution
357
+
358
+ 2. **Review the generated content** in the `factorial.pbm` directory.
359
+
360
+ ### Building Your Problem
361
+
362
+ Once you have a problem directory, you can generate all necessary files:
363
+
364
+ ```bash
365
+ cd factorial.pbm
366
+ jtk make
367
+ ```
368
+
369
+ This command will:
370
+
371
+ - Compile solutions
372
+ - Generate correct outputs for test cases
373
+ - Create PDF statements
374
+ - Generate HTML and text versions
375
+
376
+ To make only specific elements:
377
+
378
+ ```bash
379
+ jtk make pdf # Only PDF statements
380
+ jtk make exe # Only compile executables
381
+ jtk make cor # Only generate correct outputs
382
+ ```
383
+
384
+ ### Testing Solutions
385
+
386
+ To verify a solution against your golden solution:
387
+
388
+ ```bash
389
+ jtk verify solution.py
390
+ ```
391
+
392
+ This will run the solution against all test cases and compare outputs.
393
+
394
+ ### Generating Additional Content
395
+
396
+ **Add statement translations:**
397
+
398
+ ```bash
399
+ jtk generate translations en es ca
400
+ ```
401
+
402
+ **Add solutions in other languages:**
403
+
404
+ ```bash
405
+ jtk generate solutions python java cpp
406
+ ```
407
+
408
+ **Generate test case generators:**
409
+
410
+ ```bash
411
+ jtk generate generators --all
412
+ ```
413
+
414
+ **Generate award image:**
415
+
416
+ ```bash
417
+ jtk generate award.png "A golden trophy on a blue background"
418
+ ```
419
+
420
+ **Generate award message:**
421
+
422
+ ```bash
423
+ jtk generate award.html
424
+ ```
425
+
426
+ ### Cleaning Up
427
+
428
+ Remove temporary and generated files:
429
+
430
+ ```bash
431
+ jtk clean # Dry run (shows what would be deleted)
432
+ jtk clean --force # Actually delete files
433
+ jtk clean --all # Also delete generated statements and correct files
434
+ ```
435
+
436
+ ### Uploading to Jutge.org
437
+
438
+ When your problem is ready:
439
+
440
+ ```bash
441
+ jtk upload
442
+ ```
443
+
444
+ If this is a new problem, it will be created on Jutge.org and a `problem.yml` file will be generated with the problem ID. For subsequent uploads, the problem will be updated.
445
+
446
+ ## Common Commands Reference
447
+
448
+ Here's a quick reference of the most commonly used commands:
449
+
450
+ ```bash
451
+ jtk --help # Show help
452
+ jtk --version # Show version
453
+ jtk upgrade # Upgrade to latest version
454
+ jtk about # Show information about the toolkit
455
+
456
+ jtk config show # Show configuration
457
+ jtk config set <key> <value> # Set configuration value
458
+ jtk config edit # Edit configuration interactively
459
+
460
+ jtk clone [template] # Clone template
461
+ jtk generate problem # Create problem with AI
462
+ jtk make # Build all problem elements
463
+ jtk verify <program> # Test a solution
464
+ jtk upload # Upload to Jutge.org
465
+ jtk clean # Clean temporary files
466
+
467
+ jtk doctor # Check system dependencies
468
+ ```
469
+
470
+ ## Getting Help
471
+
472
+ - Use `--help` flag with any command to get detailed information:
473
+
474
+ ```bash
475
+ jtk make --help
476
+ jtk generate --help
477
+ ```
478
+
479
+ - Check the documentation at https://github.com/jutge-org/jutge-toolkit
480
+
481
+ - Report issues on GitHub
482
+
483
+ ## Tips for Success
484
+
485
+ 1. **Keep the toolkit updated:** Regularly run `jtk upgrade` to get the latest features and fixes.
486
+
487
+ 2. **Start simple:** Begin with a basic problem and gradually explore more features.
488
+
489
+ 3. **Review AI-generated content:** Always review and validate content generated by JutgeAI before using it in production.
490
+
491
+ 4. **Use version control:** Keep your problem directories in a Git repository to track changes.
492
+
493
+ 5. **Check dependencies:** Run `jtk doctor` periodically to ensure all required tools are installed.
494
+
495
+ 6. **Test thoroughly:** Always use `jtk verify` to test solutions before uploading.
496
+
497
+ ## Troubleshooting
498
+
499
+ **Command not found after installation:**
500
+
501
+ - Close and reopen your terminal
502
+ - Check that Bun is properly installed: `bun --version`
503
+
504
+ **Permission errors on Linux/macOS:**
505
+
506
+ - You may need to add execution permissions to Bun's installation directory
507
+
508
+ **AI features not working:**
509
+
510
+ - Verify your API keys are set correctly
511
+ - Check you have internet connectivity
512
+ - Ensure the model name is correct in your configuration
513
+
514
+ **LaTeX compilation fails:**
515
+
516
+ - Make sure you have a complete LaTeX distribution installed
517
+ - On Windows, ensure MiKTeX can install packages automatically
518
+
519
+ **Problems with specific compilers:**
520
+
521
+ - Run `jtk doctor` to see which compilers are available
522
+ - Install only the compilers you need for your problems
523
+
524
+ ---
525
+
526
+ You're now ready to start creating problems with Jutge Toolkit! If you have questions or need help, don't hesitate to consult the documentation or reach out to the community.
@@ -0,0 +1,82 @@
1
+ # Jutge<sup>AI</sup> features
2
+
3
+ The toolkit offers integration with Jutge<sup>AI</sup>, allowing users to leverage advanced AI models to help preparing problems.
4
+
5
+ In particular, Jutge<sup>AI</sup> features can assist in:
6
+
7
+ - Creating problems from scratch:
8
+ - You first need to provide a title and a brief description of the problem you want to create.
9
+
10
+ An example description could be: "_A problem where the user has to implement a function that calculates the factorial of a number using recursion and a main program that reads all integers from input and prints their factorial. Add a cute short story around it._"
11
+
12
+ Be specific in the description to get better results.
13
+
14
+ - Then, you need to choose the original language of the problem (use English for better results) and the programming language of the golden solution.
15
+
16
+ - After that, you can ask for more statement languages and more programming languages for the solutions.
17
+
18
+ - The AI will generate the problem statement, the golden solution, and a test suite including sample and private test cases.
19
+
20
+ - Moreover, you can also ask to generate test case generators, that is, programs that generate test cases for the problem. There are three types of test case generators:
21
+ - Random test case generators: programs that generate random test cases.
22
+ - Hard case generators: programs that generate test cases that cover edge cases.
23
+ - Efficient case generators: programs that generate large test cases to test the efficiency of the solutions.
24
+
25
+ - Extending existing problems:
26
+ - You can use Jutge<sup>AI</sup> features to add new statement languages from the original language.
27
+
28
+ - You can also generate solutions in other programming languages from the golden solution.
29
+
30
+ - You can create new test case generators to extend the existing test suite.
31
+
32
+ - You can generate `award.png` and `award.html` files for the problem. (Note: `award.png` requires `dall-e-3` model access.)
33
+
34
+ As in any other use of AI and LLMs, it is important to review and validate the generated content to ensure its correctness and quality. Treat the generated content as a first draft that needs to be refined and validated.
35
+
36
+ In order to use the Jutge<sup>AI</sup> features of the toolkit, you need to have API keys for the models you wish to use. You should get the keys from the respective providers and set them as environment variables in your system. Because of the costs associated to the use of these models, the toolkit or Jutge.org cannot provide these keys directly.
37
+
38
+ UPC users can get free access to Gemini models through their institutional Google accounts. These work well with Jutge<sup>AI</sup> features but have usage limits. If you need more capacity, consider using an OpenAI API key.
39
+
40
+ ## How to get Gemini API key
41
+
42
+ 1. Visit Google AI Studio:
43
+
44
+ Go to [aistudio.google.com](https://aistudio.google.com/) and sign in with your Google Account.
45
+
46
+ 2. Access the API Section:
47
+
48
+ Click on the **Get API key** button located in the left-hand sidebar menu.
49
+
50
+ 3. Generate the Key:
51
+ - Click the **Create API key** button.
52
+ - You will have two options: **Create API key in new project** (recommended for beginners) or **Create API key in existing project.**
53
+ - Select your preference, and the system will generate a unique key for you.
54
+
55
+ 4. Secure Your Key:
56
+
57
+ Copy the generated key immediately.
58
+
59
+ 5. Set `GEMINI_API_KEY` environment variable with the obtained key to use it in the toolkit. This will make models such as `google/gemini-2.5-flash` or `google/gemini-2.5-flash-lite` available for Jutge<sup>AI</sup> features.
60
+
61
+ ## How to get OpenAI API key
62
+
63
+ 1. Create an OpenAI Account:
64
+
65
+ Go to the OpenAI website and sign up (or log in if you already have an account).
66
+
67
+ 2. Access the API Dashboard:
68
+
69
+ After logging in, open the **API dashboard** from your account menu.
70
+
71
+ 3. Create an API Key:
72
+ - Navigate to **API Keys**.
73
+ - Click **Create new secret key**.
74
+ - Copy the key immediately (it will not be shown again).
75
+
76
+ 4. Secure Your Key: Copy the generated key immediately.
77
+
78
+ 5. Set `OPENAI_API_KEY` environment variable with the obtained key to use it in the toolkit.This will make models such as `openai/gpt-5-mini` or `openai/gpt-5-nano` available for Jutge<sup>AI</sup> features.
79
+
80
+ ## Other models
81
+
82
+ We use `multi-llm-ts` package to interface with different models. If you have access to other models supported by this package, you can set the corresponding environment variables as described in the [multi-llm-ts documentation](https://github.com/nbonamy/multi-llm-ts) to use them with Jutge<sup>AI</sup> features.