@kradle/cli 0.2.1 → 0.2.3

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,674 @@
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
+ kradle challenge run <team-name>:<challenge-name>
264
+ ```
265
+
266
+ **Arguments:**
267
+ | Argument | Description | Required |
268
+ |----------|-------------|----------|
269
+ | `challenge-name` | Challenge to run. Can be a short slug (e.g., `my-challenge`) or include a team/user namespace (e.g., `team-name:my-challenge`). The namespace is useful for running public challenges owned by other teams. If no namespace is provided, it defaults to the user's own namespace. | Yes |
270
+
271
+ **Flags:**
272
+ | Flag | Description | Default |
273
+ |------|-------------|---------|
274
+ | `--studio` | Run in local studio environment instead of production | false |
275
+ | `--open` | Open the run URL in the browser | false |
276
+
277
+ **Prerequisites:**
278
+ - `template-run.json` must exist in project root with participant configuration
279
+
280
+ **Example `template-run.json`:**
281
+ ```json
282
+ {
283
+ "participants": [
284
+ {
285
+ "id": "agent-1",
286
+ "type": "agent",
287
+ "agentId": "team-kradle:my-agent"
288
+ },
289
+ {
290
+ "id": "player-1",
291
+ "type": "human"
292
+ }
293
+ ]
294
+ }
295
+ ```
296
+
297
+ **Examples:**
298
+ ```bash
299
+ # Run your own challenge in production
300
+ kradle challenge run my-challenge
301
+
302
+ # Run a public challenge from another team
303
+ kradle challenge run team-kradle:battle-royale
304
+
305
+ # Run in local studio
306
+ kradle challenge run my-challenge --studio
307
+ ```
308
+
309
+ ---
310
+
311
+ ## Experiment Commands
312
+
313
+ Experiments allow batch execution of challenge runs with different configurations for benchmarking and analysis.
314
+
315
+ ### Concepts
316
+
317
+ **Experiment:** A named collection of run configurations in `experiments/<name>/config.ts`.
318
+
319
+ **Version:** A snapshot of experiment execution stored in `experiments/<name>/versions/001/`, `002/`, etc. Contains:
320
+ - Copy of `config.ts` at execution time
321
+ - `manifest.json` - Generated list of runs
322
+ - `progress.json` - Status of each run
323
+ - `recordings/` - Downloaded gameplay recordings (optional)
324
+
325
+ ---
326
+
327
+ ### `kradle experiment create <name>`
328
+
329
+ Creates a new experiment with a template configuration.
330
+
331
+ **Usage:**
332
+ ```bash
333
+ kradle experiment create <experiment-name>
334
+ ```
335
+
336
+ **Arguments:**
337
+ | Argument | Description | Required |
338
+ |----------|-------------|----------|
339
+ | `experiment-name` | Unique name for the experiment | Yes |
340
+
341
+ **Interactive prompts:**
342
+ 1. Select a challenge to use (from available challenges)
343
+
344
+ **Created files:**
345
+ - `experiments/<name>/config.ts` - Experiment configuration template
346
+
347
+ **Example `config.ts` structure:**
348
+ ```typescript
349
+ export async function main() {
350
+ return {
351
+ runs: [
352
+ {
353
+ challenge: "my-challenge",
354
+ participants: [
355
+ { id: "agent-1", type: "agent", agentId: "team-kradle:my-agent" }
356
+ ]
357
+ }
358
+ ],
359
+ tags: ["experiment-tag"]
360
+ };
361
+ }
362
+ ```
363
+
364
+ **Example:**
365
+ ```bash
366
+ kradle experiment create benchmark-v1
367
+ # Select challenge from list
368
+ # Edit experiments/benchmark-v1/config.ts to configure runs
369
+ ```
370
+
371
+ ---
372
+
373
+ ### `kradle experiment run <name>`
374
+
375
+ Executes or resumes an experiment.
376
+
377
+ **Usage:**
378
+ ```bash
379
+ kradle experiment run <name>
380
+ kradle experiment run <name> --new-version
381
+ kradle experiment run <name> --max-concurrent 10
382
+ kradle experiment run <name> --download-recordings
383
+ ```
384
+
385
+ **Arguments:**
386
+ | Argument | Description | Required |
387
+ |----------|-------------|----------|
388
+ | `name` | Experiment name | Yes |
389
+
390
+ **Flags:**
391
+ | Flag | Short | Description | Default |
392
+ |------|-------|-------------|---------|
393
+ | `--new-version` | `-n` | Start a fresh version instead of resuming | false |
394
+ | `--max-concurrent` | `-m` | Maximum parallel runs | 5 |
395
+ | `--download-recordings` | `-d` | Auto-download recordings as runs complete | false |
396
+
397
+ **Behavior:**
398
+ 1. Creates new version or resumes existing incomplete version
399
+ 2. Executes `config.ts` to generate run manifest
400
+ 3. Displays interactive TUI showing run progress
401
+ 4. Saves progress periodically (supports interruption and resume)
402
+ 5. Opens Metabase dashboard when complete
403
+
404
+ **Examples:**
405
+ ```bash
406
+ # Resume or start experiment
407
+ kradle experiment run benchmark-v1
408
+
409
+ # Force new version
410
+ kradle experiment run benchmark-v1 --new-version
411
+
412
+ # Run with higher parallelism
413
+ kradle experiment run benchmark-v1 --max-concurrent 10
414
+
415
+ # Auto-download recordings
416
+ kradle experiment run benchmark-v1 --download-recordings
417
+
418
+ # Combine flags
419
+ kradle experiment run benchmark-v1 -n -m 10 -d
420
+ ```
421
+
422
+ ---
423
+
424
+ ### `kradle experiment recordings <name>`
425
+
426
+ Downloads gameplay recordings from completed experiment runs.
427
+
428
+ **Usage:**
429
+ ```bash
430
+ kradle experiment recordings <name>
431
+ kradle experiment recordings <name> <run-id>
432
+ kradle experiment recordings <name> --all
433
+ kradle experiment recordings <name> --version 2
434
+ kradle experiment recordings <name> <run-id> --all
435
+ ```
436
+
437
+ **Arguments:**
438
+ | Argument | Description | Required |
439
+ |----------|-------------|----------|
440
+ | `name` | Experiment name | Yes |
441
+ | `run-id` | Specific run ID to download | No |
442
+
443
+ **Flags:**
444
+ | Flag | Description | Default |
445
+ |------|-------------|---------|
446
+ | `--all` | Download all runs/participants (skips interactive selection) | false |
447
+ | `--version` | Specific experiment version number | Latest version |
448
+
449
+ **Interactive mode (no flags):**
450
+ 1. Select a run from completed runs list
451
+ 2. Select participant(s) to download
452
+
453
+ **Output location:**
454
+ ```
455
+ experiments/<name>/versions/<version>/recordings/<run-id>/<participant-id>/
456
+ ```
457
+
458
+ **Recording format:** `.mcpr` files (Minecraft replay format)
459
+
460
+ **Examples:**
461
+ ```bash
462
+ # Interactive selection
463
+ kradle experiment recordings benchmark-v1
464
+
465
+ # Download specific run (interactive participant selection)
466
+ kradle experiment recordings benchmark-v1 abc123-run-id
467
+
468
+ # Download all recordings from all runs
469
+ kradle experiment recordings benchmark-v1 --all
470
+
471
+ # Download from specific version
472
+ kradle experiment recordings benchmark-v1 --version 1
473
+
474
+ # Download all participants for a specific run
475
+ kradle experiment recordings benchmark-v1 abc123-run-id --all
476
+
477
+ # Combine version and all flags
478
+ kradle experiment recordings benchmark-v1 --version 2 --all
479
+ ```
480
+
481
+ ---
482
+
483
+ ### `kradle experiment list`
484
+
485
+ Lists all local experiments.
486
+
487
+ **Usage:**
488
+ ```bash
489
+ kradle experiment list
490
+ ```
491
+
492
+ **Output format:**
493
+ ```
494
+ Experiments:
495
+ - benchmark-v1 (3 versions)
496
+ - agent-comparison (1 version)
497
+ - difficulty-test (2 versions)
498
+ ```
499
+
500
+ **Example:**
501
+ ```bash
502
+ kradle experiment list
503
+ ```
504
+
505
+ ---
506
+
507
+ ## Agent Commands
508
+
509
+ ### `kradle agent list`
510
+
511
+ Lists all agents registered in the Kradle system.
512
+
513
+ **Usage:**
514
+ ```bash
515
+ kradle agent list
516
+ ```
517
+
518
+ **Output format:**
519
+ ```
520
+ Agents:
521
+ - team-kradle:baseline-agent
522
+ - team-kradle:advanced-agent
523
+ - my-username:custom-agent
524
+ ```
525
+
526
+ **Example:**
527
+ ```bash
528
+ kradle agent list
529
+ ```
530
+
531
+ ---
532
+
533
+ ## AI Docs Commands
534
+
535
+ These commands output LLM-focused documentation to stdout. Use them to get comprehensive reference material about the Kradle CLI and API.
536
+
537
+ ### `kradle ai-docs cli`
538
+
539
+ Outputs the CLI reference documentation (this document).
540
+
541
+ **Usage:**
542
+ ```bash
543
+ kradle ai-docs cli
544
+ ```
545
+
546
+ **Output:** The full CLI reference in Markdown format.
547
+
548
+ **Example:**
549
+ ```bash
550
+ # Pipe to an LLM or save to a file
551
+ kradle ai-docs cli > cli-reference.md
552
+ ```
553
+
554
+ ---
555
+
556
+ ### `kradle ai-docs api`
557
+
558
+ Outputs the API reference documentation for the `@kradle/challenges` package.
559
+
560
+ **Usage:**
561
+ ```bash
562
+ kradle ai-docs api
563
+ ```
564
+
565
+ **Output:** The full API reference in Markdown format, including:
566
+ - `createChallenge` API
567
+ - Variables system
568
+ - Events system
569
+ - Actions library
570
+ - Sandstone integration
571
+ - Complete examples
572
+
573
+ **Example:**
574
+ ```bash
575
+ # Pipe to an LLM or save to a file
576
+ kradle ai-docs api > api-reference.md
577
+ ```
578
+
579
+ ---
580
+
581
+ ## Common Workflows
582
+
583
+ ### Creating and Testing a New Challenge
584
+
585
+ ```bash
586
+ # 1. Create the challenge
587
+ kradle challenge create my-new-challenge
588
+
589
+ # 2. Edit the challenge files
590
+ # - challenges/my-new-challenge/challenge.ts (behavior)
591
+ # - challenges/my-new-challenge/config.ts (metadata)
592
+
593
+ # 3. Build and upload
594
+ kradle challenge build my-new-challenge
595
+
596
+ # 4. Test with watch mode during development
597
+ kradle challenge watch my-new-challenge
598
+
599
+ # 5. Run a test game
600
+ kradle challenge run my-new-challenge
601
+ ```
602
+
603
+ ### Running a Benchmark Experiment
604
+
605
+ ```bash
606
+ # 1. Create experiment
607
+ kradle experiment create agent-benchmark
608
+
609
+ # 2. Configure runs in experiments/agent-benchmark/config.ts
610
+ # Define which agents to test, how many runs, etc.
611
+
612
+ # 3. Run the experiment
613
+ kradle experiment run agent-benchmark --max-concurrent 10
614
+
615
+ # 4. If interrupted, resume with same command
616
+ kradle experiment run agent-benchmark
617
+
618
+ # 5. Download recordings for analysis
619
+ kradle experiment recordings agent-benchmark --all
620
+ ```
621
+
622
+ ### Making a Challenge Public
623
+
624
+ ```bash
625
+ # Build with public visibility
626
+ kradle challenge build my-challenge --visibility public
627
+
628
+ # Or build all challenges as public
629
+ kradle challenge build --all --visibility public
630
+ ```
631
+
632
+ ---
633
+
634
+ ## Error Handling
635
+
636
+ ### Common Errors and Solutions
637
+
638
+ | Error | Cause | Solution |
639
+ |-------|-------|----------|
640
+ | `API call failed: 401` | Invalid or missing API key | Check `KRADLE_API_KEY` in `.env` |
641
+ | `Challenge not found` | Challenge doesn't exist locally or in cloud | Run `kradle challenge create <name>` first |
642
+ | `Experiment does not exist` | Experiment not created | Run `kradle experiment create <name>` first |
643
+ | `Config file not found` | Missing `config.ts` | Ensure challenge/experiment has config file |
644
+ | `No completed runs found` | Trying to download recordings before runs finish | Wait for runs to complete |
645
+
646
+ ### Exit Codes
647
+
648
+ | Code | Meaning |
649
+ |------|---------|
650
+ | 0 | Success |
651
+ | 1 | General error (check error message) |
652
+ | 2 | Invalid arguments or flags |
653
+
654
+ ---
655
+
656
+ ## Quick Reference
657
+
658
+ | Command | Description |
659
+ |---------|-------------|
660
+ | `kradle init` | Initialize new project |
661
+ | `kradle challenge create <name>` | Create new challenge |
662
+ | `kradle challenge build <name>` | Build and upload challenge |
663
+ | `kradle challenge build --all` | Build all challenges |
664
+ | `kradle challenge delete <name>` | Delete challenge |
665
+ | `kradle challenge list` | List all challenges |
666
+ | `kradle challenge watch <name>` | Watch and auto-rebuild |
667
+ | `kradle challenge run <name>` | Run challenge |
668
+ | `kradle experiment create <name>` | Create new experiment |
669
+ | `kradle experiment run <name>` | Run/resume experiment |
670
+ | `kradle experiment recordings <name>` | Download recordings |
671
+ | `kradle experiment list` | List experiments |
672
+ | `kradle agent list` | List available agents |
673
+ | `kradle ai-docs cli` | Output CLI reference for LLMs |
674
+ | `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