@kradle/cli 0.2.0 → 0.2.2

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,669 @@
1
+ # Kradle CLI - LLM Reference Guide
2
+
3
+ This document provides exhaustive documentation for LLM agents using the Kradle CLI to manage Minecraft challenges, experiments, and agents.
4
+
5
+ ## Table of Contents
6
+
7
+ - [Prerequisites](#prerequisites)
8
+ - [Configuration](#configuration)
9
+ - [Project Initialization](#project-initialization)
10
+ - [Challenge Commands](#challenge-commands)
11
+ - [Experiment Commands](#experiment-commands)
12
+ - [Agent Commands](#agent-commands)
13
+ - [AI Docs Commands](#ai-docs-commands)
14
+ - [Common Workflows](#common-workflows)
15
+ - [Error Handling](#error-handling)
16
+
17
+ ---
18
+
19
+ ## Prerequisites
20
+
21
+ Before using the CLI, ensure:
22
+ 1. The CLI is installed globally: `npm i -g @kradle/cli`
23
+ 2. You are in an initialized Kradle project directory (has `.env` file with API key)
24
+ 3. You have a valid `KRADLE_API_KEY` from https://kradle.ai/settings#api-keys
25
+
26
+ ---
27
+
28
+ ## Configuration
29
+
30
+ The CLI reads configuration from environment variables or command-line flags. Flags override environment variables.
31
+
32
+ ### Environment Variables
33
+
34
+ | Variable | Description | Required |
35
+ |----------|-------------|----------|
36
+ | `KRADLE_API_KEY` | Your Kradle API key | Yes |
37
+ | `KRADLE_API_URL` | API endpoint (default: `https://api.kradle.ai/v0`) | No |
38
+ | `KRADLE_WEB_URL` | Web URL (default: `https://kradle.ai`) | No |
39
+ | `KRADLE_CHALLENGES_PATH` | Path to built datapacks | No |
40
+ | `NAMESPACE` | Default namespace for challenges | No |
41
+
42
+ ### Global Flags
43
+
44
+ These flags are available on most commands:
45
+
46
+ | Flag | Environment Variable | Description |
47
+ |------|---------------------|-------------|
48
+ | `--api-key` | `KRADLE_API_KEY` | Kradle API key |
49
+ | `--api-url` | `KRADLE_API_URL` | Kradle API URL |
50
+ | `--web-url` | `KRADLE_WEB_URL` | Kradle Web URL |
51
+
52
+ ---
53
+
54
+ ## Project Initialization
55
+
56
+ ### `kradle init`
57
+
58
+ Initializes a new Kradle project in the current directory.
59
+
60
+ **Usage:**
61
+ ```bash
62
+ kradle init
63
+ ```
64
+
65
+ **Interactive Prompts:**
66
+ 1. API key (if not set in environment)
67
+ 2. Environment selection (dev/prod)
68
+
69
+ **Created Files:**
70
+ - `.env` - Environment configuration with API key
71
+ - `package.json` - Node.js package configuration
72
+ - `tsconfig.json` - TypeScript configuration
73
+ - `.gitignore` - Git ignore rules
74
+ - `template-run.json` - Run configuration template
75
+
76
+ **Example:**
77
+ ```bash
78
+ mkdir my-kradle-project
79
+ cd my-kradle-project
80
+ kradle init
81
+ # Follow prompts to enter API key and select environment
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Challenge Commands
87
+
88
+ Challenges are Minecraft scenarios that agents can be tested against. Each challenge consists of:
89
+ - `challenge.ts` - Defines the challenge behavior using the Sandstone API
90
+ - `config.ts` - Metadata (name, roles, objectives, visibility)
91
+
92
+ ### `kradle challenge create <name>`
93
+
94
+ Creates a new challenge locally and in the cloud.
95
+
96
+ **Usage:**
97
+ ```bash
98
+ kradle challenge create <challenge-name>
99
+ ```
100
+
101
+ **Arguments:**
102
+ | Argument | Description | Required |
103
+ |----------|-------------|----------|
104
+ | `challenge-name` | Unique identifier for the challenge (lowercase, hyphens allowed) | Yes |
105
+
106
+ **What it does:**
107
+ 1. Creates `challenges/<name>/challenge.ts` from template
108
+ 2. Registers the challenge in the cloud
109
+ 3. Downloads and creates `challenges/<name>/config.ts` with cloud-generated metadata
110
+
111
+ **Example:**
112
+ ```bash
113
+ kradle challenge create my-first-challenge
114
+ # Creates challenges/my-first-challenge/challenge.ts
115
+ # Creates challenges/my-first-challenge/config.ts
116
+ ```
117
+
118
+ ---
119
+
120
+ ### `kradle challenge build <name>`
121
+
122
+ Builds a challenge datapack and uploads everything to the cloud.
123
+
124
+ **Usage:**
125
+ ```bash
126
+ kradle challenge build <challenge-name>
127
+ kradle challenge build <challenge-name> --visibility public
128
+ kradle challenge build --all
129
+ kradle challenge build --all --visibility public
130
+ ```
131
+
132
+ **Arguments:**
133
+ | Argument | Description | Required |
134
+ |----------|-------------|----------|
135
+ | `challenge-name` | Challenge to build | Yes (unless `--all`) |
136
+
137
+ **Flags:**
138
+ | Flag | Description | Default |
139
+ |------|-------------|---------|
140
+ | `--all` | Build all local challenges | false |
141
+ | `--visibility` | Set visibility (`private` or `public`) | private |
142
+
143
+ **What it does:**
144
+ 1. Creates the challenge in cloud if it doesn't exist
145
+ 2. Uploads `config.ts` metadata to cloud
146
+ 3. Executes `challenge.ts` to generate the datapack
147
+ 4. Compresses and uploads datapack to cloud storage
148
+
149
+ **Examples:**
150
+ ```bash
151
+ # Build single challenge
152
+ kradle challenge build my-challenge
153
+
154
+ # Build and make public
155
+ kradle challenge build my-challenge --visibility public
156
+
157
+ # Build all challenges
158
+ kradle challenge build --all
159
+ ```
160
+
161
+ ---
162
+
163
+ ### `kradle challenge delete <name>`
164
+
165
+ Deletes a challenge locally, from the cloud, or both.
166
+
167
+ **Usage:**
168
+ ```bash
169
+ kradle challenge delete <challenge-name>
170
+ kradle challenge delete <challenge-name> --yes
171
+ ```
172
+
173
+ **Arguments:**
174
+ | Argument | Description | Required |
175
+ |----------|-------------|----------|
176
+ | `challenge-name` | Challenge to delete | Yes |
177
+
178
+ **Flags:**
179
+ | Flag | Description | Default |
180
+ |------|-------------|---------|
181
+ | `--yes`, `-y` | Skip confirmation prompts | false |
182
+
183
+ **Interactive prompts (unless `--yes`):**
184
+ 1. Delete local files? (y/n)
185
+ 2. Delete from cloud? (y/n)
186
+
187
+ **Examples:**
188
+ ```bash
189
+ # Interactive deletion
190
+ kradle challenge delete my-challenge
191
+
192
+ # Force delete without prompts
193
+ kradle challenge delete my-challenge --yes
194
+ ```
195
+
196
+ ---
197
+
198
+ ### `kradle challenge list`
199
+
200
+ Lists all challenges (both local and cloud).
201
+
202
+ **Usage:**
203
+ ```bash
204
+ kradle challenge list
205
+ ```
206
+
207
+ **Output format:**
208
+ ```
209
+ Local challenges:
210
+ - my-challenge
211
+ - another-challenge
212
+
213
+ Cloud challenges:
214
+ - my-challenge (public)
215
+ - team-kradle:example-challenge (public)
216
+ - my-private-challenge (private)
217
+ ```
218
+
219
+ **Example:**
220
+ ```bash
221
+ kradle challenge list
222
+ ```
223
+
224
+ ---
225
+
226
+ ### `kradle challenge watch <name>`
227
+
228
+ Watches a challenge for file changes and automatically rebuilds/uploads.
229
+
230
+ **Usage:**
231
+ ```bash
232
+ kradle challenge watch <challenge-name>
233
+ ```
234
+
235
+ **Arguments:**
236
+ | Argument | Description | Required |
237
+ |----------|-------------|----------|
238
+ | `challenge-name` | Challenge to watch | Yes |
239
+
240
+ **Behavior:**
241
+ - Monitors `challenges/<name>/` directory for changes
242
+ - Debounces rebuilds (300ms delay)
243
+ - Only uploads if datapack hash changed
244
+ - Press Ctrl+C to stop watching
245
+
246
+ **Example:**
247
+ ```bash
248
+ kradle challenge watch my-challenge
249
+ # Now edit challenges/my-challenge/challenge.ts
250
+ # Changes will automatically rebuild and upload
251
+ ```
252
+
253
+ ---
254
+
255
+ ### `kradle challenge run <name>`
256
+
257
+ Runs a challenge with configured participants.
258
+
259
+ **Usage:**
260
+ ```bash
261
+ kradle challenge run <challenge-name>
262
+ kradle challenge run <challenge-name> --studio
263
+ ```
264
+
265
+ **Arguments:**
266
+ | Argument | Description | Required |
267
+ |----------|-------------|----------|
268
+ | `challenge-name` | Challenge to run | Yes |
269
+
270
+ **Flags:**
271
+ | Flag | Description | Default |
272
+ |------|-------------|---------|
273
+ | `--studio` | Run in local studio environment instead of production | false |
274
+
275
+ **Prerequisites:**
276
+ - `template-run.json` must exist in project root with participant configuration
277
+
278
+ **Example `template-run.json`:**
279
+ ```json
280
+ {
281
+ "participants": [
282
+ {
283
+ "id": "agent-1",
284
+ "type": "agent",
285
+ "agentId": "team-kradle:my-agent"
286
+ },
287
+ {
288
+ "id": "player-1",
289
+ "type": "human"
290
+ }
291
+ ]
292
+ }
293
+ ```
294
+
295
+ **Examples:**
296
+ ```bash
297
+ # Run in production
298
+ kradle challenge run my-challenge
299
+
300
+ # Run in local studio
301
+ kradle challenge run my-challenge --studio
302
+ ```
303
+
304
+ ---
305
+
306
+ ## Experiment Commands
307
+
308
+ Experiments allow batch execution of challenge runs with different configurations for benchmarking and analysis.
309
+
310
+ ### Concepts
311
+
312
+ **Experiment:** A named collection of run configurations in `experiments/<name>/config.ts`.
313
+
314
+ **Version:** A snapshot of experiment execution stored in `experiments/<name>/versions/001/`, `002/`, etc. Contains:
315
+ - Copy of `config.ts` at execution time
316
+ - `manifest.json` - Generated list of runs
317
+ - `progress.json` - Status of each run
318
+ - `recordings/` - Downloaded gameplay recordings (optional)
319
+
320
+ ---
321
+
322
+ ### `kradle experiment create <name>`
323
+
324
+ Creates a new experiment with a template configuration.
325
+
326
+ **Usage:**
327
+ ```bash
328
+ kradle experiment create <experiment-name>
329
+ ```
330
+
331
+ **Arguments:**
332
+ | Argument | Description | Required |
333
+ |----------|-------------|----------|
334
+ | `experiment-name` | Unique name for the experiment | Yes |
335
+
336
+ **Interactive prompts:**
337
+ 1. Select a challenge to use (from available challenges)
338
+
339
+ **Created files:**
340
+ - `experiments/<name>/config.ts` - Experiment configuration template
341
+
342
+ **Example `config.ts` structure:**
343
+ ```typescript
344
+ export async function main() {
345
+ return {
346
+ runs: [
347
+ {
348
+ challenge: "my-challenge",
349
+ participants: [
350
+ { id: "agent-1", type: "agent", agentId: "team-kradle:my-agent" }
351
+ ]
352
+ }
353
+ ],
354
+ tags: ["experiment-tag"]
355
+ };
356
+ }
357
+ ```
358
+
359
+ **Example:**
360
+ ```bash
361
+ kradle experiment create benchmark-v1
362
+ # Select challenge from list
363
+ # Edit experiments/benchmark-v1/config.ts to configure runs
364
+ ```
365
+
366
+ ---
367
+
368
+ ### `kradle experiment run <name>`
369
+
370
+ Executes or resumes an experiment.
371
+
372
+ **Usage:**
373
+ ```bash
374
+ kradle experiment run <name>
375
+ kradle experiment run <name> --new-version
376
+ kradle experiment run <name> --max-concurrent 10
377
+ kradle experiment run <name> --download-recordings
378
+ ```
379
+
380
+ **Arguments:**
381
+ | Argument | Description | Required |
382
+ |----------|-------------|----------|
383
+ | `name` | Experiment name | Yes |
384
+
385
+ **Flags:**
386
+ | Flag | Short | Description | Default |
387
+ |------|-------|-------------|---------|
388
+ | `--new-version` | `-n` | Start a fresh version instead of resuming | false |
389
+ | `--max-concurrent` | `-m` | Maximum parallel runs | 5 |
390
+ | `--download-recordings` | `-d` | Auto-download recordings as runs complete | false |
391
+
392
+ **Behavior:**
393
+ 1. Creates new version or resumes existing incomplete version
394
+ 2. Executes `config.ts` to generate run manifest
395
+ 3. Displays interactive TUI showing run progress
396
+ 4. Saves progress periodically (supports interruption and resume)
397
+ 5. Opens Metabase dashboard when complete
398
+
399
+ **Examples:**
400
+ ```bash
401
+ # Resume or start experiment
402
+ kradle experiment run benchmark-v1
403
+
404
+ # Force new version
405
+ kradle experiment run benchmark-v1 --new-version
406
+
407
+ # Run with higher parallelism
408
+ kradle experiment run benchmark-v1 --max-concurrent 10
409
+
410
+ # Auto-download recordings
411
+ kradle experiment run benchmark-v1 --download-recordings
412
+
413
+ # Combine flags
414
+ kradle experiment run benchmark-v1 -n -m 10 -d
415
+ ```
416
+
417
+ ---
418
+
419
+ ### `kradle experiment recordings <name>`
420
+
421
+ Downloads gameplay recordings from completed experiment runs.
422
+
423
+ **Usage:**
424
+ ```bash
425
+ kradle experiment recordings <name>
426
+ kradle experiment recordings <name> <run-id>
427
+ kradle experiment recordings <name> --all
428
+ kradle experiment recordings <name> --version 2
429
+ kradle experiment recordings <name> <run-id> --all
430
+ ```
431
+
432
+ **Arguments:**
433
+ | Argument | Description | Required |
434
+ |----------|-------------|----------|
435
+ | `name` | Experiment name | Yes |
436
+ | `run-id` | Specific run ID to download | No |
437
+
438
+ **Flags:**
439
+ | Flag | Description | Default |
440
+ |------|-------------|---------|
441
+ | `--all` | Download all runs/participants (skips interactive selection) | false |
442
+ | `--version` | Specific experiment version number | Latest version |
443
+
444
+ **Interactive mode (no flags):**
445
+ 1. Select a run from completed runs list
446
+ 2. Select participant(s) to download
447
+
448
+ **Output location:**
449
+ ```
450
+ experiments/<name>/versions/<version>/recordings/<run-id>/<participant-id>/
451
+ ```
452
+
453
+ **Recording format:** `.mcpr` files (Minecraft replay format)
454
+
455
+ **Examples:**
456
+ ```bash
457
+ # Interactive selection
458
+ kradle experiment recordings benchmark-v1
459
+
460
+ # Download specific run (interactive participant selection)
461
+ kradle experiment recordings benchmark-v1 abc123-run-id
462
+
463
+ # Download all recordings from all runs
464
+ kradle experiment recordings benchmark-v1 --all
465
+
466
+ # Download from specific version
467
+ kradle experiment recordings benchmark-v1 --version 1
468
+
469
+ # Download all participants for a specific run
470
+ kradle experiment recordings benchmark-v1 abc123-run-id --all
471
+
472
+ # Combine version and all flags
473
+ kradle experiment recordings benchmark-v1 --version 2 --all
474
+ ```
475
+
476
+ ---
477
+
478
+ ### `kradle experiment list`
479
+
480
+ Lists all local experiments.
481
+
482
+ **Usage:**
483
+ ```bash
484
+ kradle experiment list
485
+ ```
486
+
487
+ **Output format:**
488
+ ```
489
+ Experiments:
490
+ - benchmark-v1 (3 versions)
491
+ - agent-comparison (1 version)
492
+ - difficulty-test (2 versions)
493
+ ```
494
+
495
+ **Example:**
496
+ ```bash
497
+ kradle experiment list
498
+ ```
499
+
500
+ ---
501
+
502
+ ## Agent Commands
503
+
504
+ ### `kradle agent list`
505
+
506
+ Lists all agents registered in the Kradle system.
507
+
508
+ **Usage:**
509
+ ```bash
510
+ kradle agent list
511
+ ```
512
+
513
+ **Output format:**
514
+ ```
515
+ Agents:
516
+ - team-kradle:baseline-agent
517
+ - team-kradle:advanced-agent
518
+ - my-username:custom-agent
519
+ ```
520
+
521
+ **Example:**
522
+ ```bash
523
+ kradle agent list
524
+ ```
525
+
526
+ ---
527
+
528
+ ## AI Docs Commands
529
+
530
+ These commands output LLM-focused documentation to stdout. Use them to get comprehensive reference material about the Kradle CLI and API.
531
+
532
+ ### `kradle ai-docs cli`
533
+
534
+ Outputs the CLI reference documentation (this document).
535
+
536
+ **Usage:**
537
+ ```bash
538
+ kradle ai-docs cli
539
+ ```
540
+
541
+ **Output:** The full CLI reference in Markdown format.
542
+
543
+ **Example:**
544
+ ```bash
545
+ # Pipe to an LLM or save to a file
546
+ kradle ai-docs cli > cli-reference.md
547
+ ```
548
+
549
+ ---
550
+
551
+ ### `kradle ai-docs api`
552
+
553
+ Outputs the API reference documentation for the `@kradle/challenges` package.
554
+
555
+ **Usage:**
556
+ ```bash
557
+ kradle ai-docs api
558
+ ```
559
+
560
+ **Output:** The full API reference in Markdown format, including:
561
+ - `createChallenge` API
562
+ - Variables system
563
+ - Events system
564
+ - Actions library
565
+ - Sandstone integration
566
+ - Complete examples
567
+
568
+ **Example:**
569
+ ```bash
570
+ # Pipe to an LLM or save to a file
571
+ kradle ai-docs api > api-reference.md
572
+ ```
573
+
574
+ ---
575
+
576
+ ## Common Workflows
577
+
578
+ ### Creating and Testing a New Challenge
579
+
580
+ ```bash
581
+ # 1. Create the challenge
582
+ kradle challenge create my-new-challenge
583
+
584
+ # 2. Edit the challenge files
585
+ # - challenges/my-new-challenge/challenge.ts (behavior)
586
+ # - challenges/my-new-challenge/config.ts (metadata)
587
+
588
+ # 3. Build and upload
589
+ kradle challenge build my-new-challenge
590
+
591
+ # 4. Test with watch mode during development
592
+ kradle challenge watch my-new-challenge
593
+
594
+ # 5. Run a test game
595
+ kradle challenge run my-new-challenge
596
+ ```
597
+
598
+ ### Running a Benchmark Experiment
599
+
600
+ ```bash
601
+ # 1. Create experiment
602
+ kradle experiment create agent-benchmark
603
+
604
+ # 2. Configure runs in experiments/agent-benchmark/config.ts
605
+ # Define which agents to test, how many runs, etc.
606
+
607
+ # 3. Run the experiment
608
+ kradle experiment run agent-benchmark --max-concurrent 10
609
+
610
+ # 4. If interrupted, resume with same command
611
+ kradle experiment run agent-benchmark
612
+
613
+ # 5. Download recordings for analysis
614
+ kradle experiment recordings agent-benchmark --all
615
+ ```
616
+
617
+ ### Making a Challenge Public
618
+
619
+ ```bash
620
+ # Build with public visibility
621
+ kradle challenge build my-challenge --visibility public
622
+
623
+ # Or build all challenges as public
624
+ kradle challenge build --all --visibility public
625
+ ```
626
+
627
+ ---
628
+
629
+ ## Error Handling
630
+
631
+ ### Common Errors and Solutions
632
+
633
+ | Error | Cause | Solution |
634
+ |-------|-------|----------|
635
+ | `API call failed: 401` | Invalid or missing API key | Check `KRADLE_API_KEY` in `.env` |
636
+ | `Challenge not found` | Challenge doesn't exist locally or in cloud | Run `kradle challenge create <name>` first |
637
+ | `Experiment does not exist` | Experiment not created | Run `kradle experiment create <name>` first |
638
+ | `Config file not found` | Missing `config.ts` | Ensure challenge/experiment has config file |
639
+ | `No completed runs found` | Trying to download recordings before runs finish | Wait for runs to complete |
640
+
641
+ ### Exit Codes
642
+
643
+ | Code | Meaning |
644
+ |------|---------|
645
+ | 0 | Success |
646
+ | 1 | General error (check error message) |
647
+ | 2 | Invalid arguments or flags |
648
+
649
+ ---
650
+
651
+ ## Quick Reference
652
+
653
+ | Command | Description |
654
+ |---------|-------------|
655
+ | `kradle init` | Initialize new project |
656
+ | `kradle challenge create <name>` | Create new challenge |
657
+ | `kradle challenge build <name>` | Build and upload challenge |
658
+ | `kradle challenge build --all` | Build all challenges |
659
+ | `kradle challenge delete <name>` | Delete challenge |
660
+ | `kradle challenge list` | List all challenges |
661
+ | `kradle challenge watch <name>` | Watch and auto-rebuild |
662
+ | `kradle challenge run <name>` | Run challenge |
663
+ | `kradle experiment create <name>` | Create new experiment |
664
+ | `kradle experiment run <name>` | Run/resume experiment |
665
+ | `kradle experiment recordings <name>` | Download recordings |
666
+ | `kradle experiment list` | List experiments |
667
+ | `kradle agent list` | List available agents |
668
+ | `kradle ai-docs cli` | Output CLI reference for LLMs |
669
+ | `kradle ai-docs api` | Output API reference for LLMs |
@@ -0,0 +1,15 @@
1
+ # API & CLI reference
2
+
3
+ To access Kradle's API & CLI references, use the following commands:
4
+
5
+ ```bash
6
+ # Get CLI reference (commands, flags, workflows)
7
+ kradle ai-docs cli
8
+
9
+ # Get API reference (@kradle/challenges package documentation)
10
+ kradle ai-docs api
11
+ ```
12
+
13
+ These will output comprehensive documentation for working with Kradle challenges and experiments.
14
+
15
+ You should always read both. You should create challenges and experiments with the CLI if possible - avoid creating them from scratch.
@@ -0,0 +1 @@
1
+ @AGENTS.md