@kradle/cli 0.0.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.
- package/README.md +224 -0
- package/bin/dev.cmd +3 -0
- package/bin/dev.js +14 -0
- package/bin/run.cmd +3 -0
- package/bin/run.js +14 -0
- package/dist/commands/agent/list.d.ts +6 -0
- package/dist/commands/agent/list.js +20 -0
- package/dist/commands/challenge/build.d.ts +9 -0
- package/dist/commands/challenge/build.js +25 -0
- package/dist/commands/challenge/create.d.ts +12 -0
- package/dist/commands/challenge/create.js +87 -0
- package/dist/commands/challenge/delete.d.ts +12 -0
- package/dist/commands/challenge/delete.js +99 -0
- package/dist/commands/challenge/list.d.ts +6 -0
- package/dist/commands/challenge/list.js +48 -0
- package/dist/commands/challenge/multi-upload.d.ts +6 -0
- package/dist/commands/challenge/multi-upload.js +80 -0
- package/dist/commands/challenge/run.d.ts +12 -0
- package/dist/commands/challenge/run.js +47 -0
- package/dist/commands/challenge/watch.d.ts +12 -0
- package/dist/commands/challenge/watch.js +113 -0
- package/dist/commands/init.d.ts +11 -0
- package/dist/commands/init.js +161 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lib/api-client.d.ts +55 -0
- package/dist/lib/api-client.js +162 -0
- package/dist/lib/arguments.d.ts +7 -0
- package/dist/lib/arguments.js +17 -0
- package/dist/lib/challenge.d.ts +67 -0
- package/dist/lib/challenge.js +203 -0
- package/dist/lib/config.d.ts +13 -0
- package/dist/lib/config.js +51 -0
- package/dist/lib/schemas.d.ts +127 -0
- package/dist/lib/schemas.js +55 -0
- package/dist/lib/utils.d.ts +89 -0
- package/dist/lib/utils.js +170 -0
- package/oclif.manifest.json +310 -0
- package/package.json +78 -0
- package/static/challenge.ts +32 -0
- package/static/project_template/dev.env +6 -0
- package/static/project_template/package.json +17 -0
- package/static/project_template/prod.env +6 -0
- package/static/project_template/template-run.json +10 -0
- package/static/project_template/tsconfig.json +17 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { fork, spawn } from "node:child_process";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
export async function loadTemplateRun() {
|
|
7
|
+
const templatePath = path.resolve(process.cwd(), "template-run.json");
|
|
8
|
+
const content = await fs.readFile(templatePath, "utf-8");
|
|
9
|
+
return JSON.parse(content);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Resolve tildes in a path to the home directory
|
|
13
|
+
*/
|
|
14
|
+
export function untildify(filePath) {
|
|
15
|
+
if (filePath.startsWith("~/")) {
|
|
16
|
+
return path.join(os.homedir(), filePath.slice(2));
|
|
17
|
+
}
|
|
18
|
+
return filePath;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns a debounced function that will only be called after the delay has passed since the last call.
|
|
22
|
+
*
|
|
23
|
+
* @param fn The function to debounce.
|
|
24
|
+
* @param delay The delay in milliseconds.
|
|
25
|
+
* @returns A debounced function.
|
|
26
|
+
*/
|
|
27
|
+
export function debounced(fn, delay) {
|
|
28
|
+
let timeoutId = null;
|
|
29
|
+
return () => {
|
|
30
|
+
if (timeoutId) {
|
|
31
|
+
clearTimeout(timeoutId);
|
|
32
|
+
}
|
|
33
|
+
timeoutId = setTimeout(() => fn(), delay);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Clear the screen.
|
|
38
|
+
*
|
|
39
|
+
* @see https://stackoverflow.com/a/26373971
|
|
40
|
+
*/
|
|
41
|
+
export function clearScreen() {
|
|
42
|
+
process.stdout.write("\x1Bc");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Returns the directory name of the current module.
|
|
46
|
+
*
|
|
47
|
+
* @returns The directory name of the current module.
|
|
48
|
+
*/
|
|
49
|
+
function getDirName() {
|
|
50
|
+
// In NodeJS, __dirname is the directory of the current module - but if we use ESM, __dirname is undefined and we should
|
|
51
|
+
// instead use the import.meta.url to get the directory of the current module.
|
|
52
|
+
try {
|
|
53
|
+
return __dirname;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return path.dirname(fileURLToPath(import.meta.url));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get the path to a static resource (located in the `static` folder).
|
|
61
|
+
*
|
|
62
|
+
* @param name The name of the resource.
|
|
63
|
+
* @returns The absolute path to the resource.
|
|
64
|
+
*/
|
|
65
|
+
export function getStaticResourcePath(name) {
|
|
66
|
+
return path.resolve(getDirName(), "..", "..", "static", name);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Reads a directory and returns a sorted list of files, with their types.
|
|
70
|
+
* @param dir The directory to read.
|
|
71
|
+
* @returns A sorted list of files, with their types (Dirent).
|
|
72
|
+
*/
|
|
73
|
+
export async function readDirSorted(dir) {
|
|
74
|
+
const files = await fs.readdir(dir, { recursive: true, withFileTypes: true });
|
|
75
|
+
return files.sort((a, b) => a.name.localeCompare(b.name));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Runs a NodeJS module. The module is executed in the current working directory, and the environment is set to the given config.
|
|
79
|
+
* stdout & stdout are piped to the parent process.
|
|
80
|
+
*
|
|
81
|
+
* Returns a promise that resolves when the module completes.
|
|
82
|
+
*
|
|
83
|
+
* @param file The file to execute.
|
|
84
|
+
* @param config The configuration to use.
|
|
85
|
+
* @param options The options to use.
|
|
86
|
+
* @param options.silent Whether to suppress stdout.
|
|
87
|
+
* @returns A promise that resolves when the command completes.
|
|
88
|
+
*/
|
|
89
|
+
export function runNodeModule(file, config, options = {}) {
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
const child = fork(file, {
|
|
92
|
+
cwd: path.resolve(process.cwd()),
|
|
93
|
+
env: { ...process.env, ...config },
|
|
94
|
+
silent: options.silent,
|
|
95
|
+
});
|
|
96
|
+
child.on("close", (code) => {
|
|
97
|
+
if (code !== 0) {
|
|
98
|
+
reject(new Error(`Command failed with code ${code}`));
|
|
99
|
+
}
|
|
100
|
+
resolve(undefined);
|
|
101
|
+
});
|
|
102
|
+
child.on("error", (error) => {
|
|
103
|
+
reject(error);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Execute a TypeScript file using NodeJS's built-in TS support.
|
|
109
|
+
*
|
|
110
|
+
* @param filePath The path to the TypeScript file.
|
|
111
|
+
* @param config The configuration to use.
|
|
112
|
+
* @param options The options to use.
|
|
113
|
+
* @param options.silent Whether to suppress stdout.
|
|
114
|
+
* @returns The result of the execution.
|
|
115
|
+
*/
|
|
116
|
+
export async function executeTypescriptFile(filePath, config, options = {}) {
|
|
117
|
+
return await runNodeModule(filePath, config, options);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Executes an arbitrary command. The command is spawned in the current working directory, and the environment is set to the given config.
|
|
121
|
+
*
|
|
122
|
+
* stdout will be returned as a string.
|
|
123
|
+
* if stderr is not empty, an error will be thrown.
|
|
124
|
+
*
|
|
125
|
+
* @param args The arguments to pass to the command.
|
|
126
|
+
* @param options The options to use.
|
|
127
|
+
* @param options.env The environment variables to set.
|
|
128
|
+
* @param options.cwd The current working directory.
|
|
129
|
+
* @returns A promise that resolves with the stdout of the command.
|
|
130
|
+
*/
|
|
131
|
+
export async function executeCommand(command, args, options) {
|
|
132
|
+
return new Promise((resolve, reject) => {
|
|
133
|
+
const child = spawn(command, args, {
|
|
134
|
+
cwd: path.resolve(options?.cwd ?? process.cwd()),
|
|
135
|
+
env: { ...process.env, ...(options?.env ?? {}) },
|
|
136
|
+
});
|
|
137
|
+
// Accumulate stdout and stderr
|
|
138
|
+
let stdout = "";
|
|
139
|
+
child.stdout?.on("data", (data) => {
|
|
140
|
+
stdout += data;
|
|
141
|
+
});
|
|
142
|
+
let stderr = "";
|
|
143
|
+
child.stderr?.on("data", (data) => {
|
|
144
|
+
stderr += data;
|
|
145
|
+
});
|
|
146
|
+
child.on("close", (code) => {
|
|
147
|
+
if (code !== 0 || stderr.length > 0) {
|
|
148
|
+
reject(new Error(`Command failed with code ${code} and stderr: ${stderr}`));
|
|
149
|
+
}
|
|
150
|
+
resolve(stdout);
|
|
151
|
+
});
|
|
152
|
+
child.on("error", (error) => {
|
|
153
|
+
reject(error);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Executes an arbitrary NodeJS command. The command is spawned in the current working directory, and the environment is set to the given config.
|
|
159
|
+
* It will use the process.execPath of the current process to find the NodeJS executable.
|
|
160
|
+
*
|
|
161
|
+
* stdout will be returned as a string.
|
|
162
|
+
* if stderr is not empty, an error will be thrown.
|
|
163
|
+
*
|
|
164
|
+
* @param args The arguments to pass to the command.
|
|
165
|
+
* @param config The configuration to use.
|
|
166
|
+
* @returns A promise that resolves with the stdout of the command.
|
|
167
|
+
*/
|
|
168
|
+
export async function executeNodeCommand(args, config) {
|
|
169
|
+
return executeCommand(process.execPath, args, { env: config });
|
|
170
|
+
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
{
|
|
2
|
+
"commands": {
|
|
3
|
+
"init": {
|
|
4
|
+
"aliases": [],
|
|
5
|
+
"args": {},
|
|
6
|
+
"description": "Initialize a new Kradle project. If the current directory is not empty, it will create a subdirectory for the project. Else, the current directory will be used.",
|
|
7
|
+
"examples": [
|
|
8
|
+
"<%= config.bin %> <%= command.id %>"
|
|
9
|
+
],
|
|
10
|
+
"flags": {
|
|
11
|
+
"name": {
|
|
12
|
+
"char": "n",
|
|
13
|
+
"description": "Project name",
|
|
14
|
+
"name": "name",
|
|
15
|
+
"required": false,
|
|
16
|
+
"hasDynamicHelp": false,
|
|
17
|
+
"multiple": false,
|
|
18
|
+
"type": "option"
|
|
19
|
+
},
|
|
20
|
+
"dev": {
|
|
21
|
+
"char": "d",
|
|
22
|
+
"description": "Use Kradle's development environment instead of production",
|
|
23
|
+
"name": "dev",
|
|
24
|
+
"required": false,
|
|
25
|
+
"allowNo": false,
|
|
26
|
+
"type": "boolean"
|
|
27
|
+
},
|
|
28
|
+
"api-key": {
|
|
29
|
+
"char": "k",
|
|
30
|
+
"description": "Kradle API key",
|
|
31
|
+
"name": "api-key",
|
|
32
|
+
"required": false,
|
|
33
|
+
"hasDynamicHelp": false,
|
|
34
|
+
"multiple": false,
|
|
35
|
+
"type": "option"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
"hasDynamicHelp": false,
|
|
39
|
+
"hiddenAliases": [],
|
|
40
|
+
"id": "init",
|
|
41
|
+
"pluginAlias": "@kradle/cli",
|
|
42
|
+
"pluginName": "@kradle/cli",
|
|
43
|
+
"pluginType": "core",
|
|
44
|
+
"strict": true,
|
|
45
|
+
"enableJsonFlag": false,
|
|
46
|
+
"isESM": true,
|
|
47
|
+
"relativePath": [
|
|
48
|
+
"dist",
|
|
49
|
+
"commands",
|
|
50
|
+
"init.js"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"agent:list": {
|
|
54
|
+
"aliases": [],
|
|
55
|
+
"args": {},
|
|
56
|
+
"description": "List all agents",
|
|
57
|
+
"examples": [
|
|
58
|
+
"<%= config.bin %> <%= command.id %>"
|
|
59
|
+
],
|
|
60
|
+
"flags": {},
|
|
61
|
+
"hasDynamicHelp": false,
|
|
62
|
+
"hiddenAliases": [],
|
|
63
|
+
"id": "agent:list",
|
|
64
|
+
"pluginAlias": "@kradle/cli",
|
|
65
|
+
"pluginName": "@kradle/cli",
|
|
66
|
+
"pluginType": "core",
|
|
67
|
+
"strict": true,
|
|
68
|
+
"enableJsonFlag": false,
|
|
69
|
+
"isESM": true,
|
|
70
|
+
"relativePath": [
|
|
71
|
+
"dist",
|
|
72
|
+
"commands",
|
|
73
|
+
"agent",
|
|
74
|
+
"list.js"
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
"challenge:build": {
|
|
78
|
+
"aliases": [],
|
|
79
|
+
"args": {
|
|
80
|
+
"challenge": {
|
|
81
|
+
"description": "Challenge slug to build",
|
|
82
|
+
"name": "challenge",
|
|
83
|
+
"required": true
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
"description": "Build and upload challenge datapack and config",
|
|
87
|
+
"examples": [
|
|
88
|
+
"<%= config.bin %> <%= command.id %> my-challenge"
|
|
89
|
+
],
|
|
90
|
+
"flags": {},
|
|
91
|
+
"hasDynamicHelp": false,
|
|
92
|
+
"hiddenAliases": [],
|
|
93
|
+
"id": "challenge:build",
|
|
94
|
+
"pluginAlias": "@kradle/cli",
|
|
95
|
+
"pluginName": "@kradle/cli",
|
|
96
|
+
"pluginType": "core",
|
|
97
|
+
"strict": true,
|
|
98
|
+
"enableJsonFlag": false,
|
|
99
|
+
"isESM": true,
|
|
100
|
+
"relativePath": [
|
|
101
|
+
"dist",
|
|
102
|
+
"commands",
|
|
103
|
+
"challenge",
|
|
104
|
+
"build.js"
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"challenge:create": {
|
|
108
|
+
"aliases": [],
|
|
109
|
+
"args": {
|
|
110
|
+
"challenge": {
|
|
111
|
+
"description": "Challenge slug to create",
|
|
112
|
+
"name": "challenge",
|
|
113
|
+
"required": true
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
"description": "Create a new challenge locally and in the cloud",
|
|
117
|
+
"examples": [
|
|
118
|
+
"<%= config.bin %> <%= command.id %> my-challenge"
|
|
119
|
+
],
|
|
120
|
+
"flags": {
|
|
121
|
+
"verbose": {
|
|
122
|
+
"char": "v",
|
|
123
|
+
"description": "Verbose output",
|
|
124
|
+
"name": "verbose",
|
|
125
|
+
"allowNo": false,
|
|
126
|
+
"type": "boolean"
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
"hasDynamicHelp": false,
|
|
130
|
+
"hiddenAliases": [],
|
|
131
|
+
"id": "challenge:create",
|
|
132
|
+
"pluginAlias": "@kradle/cli",
|
|
133
|
+
"pluginName": "@kradle/cli",
|
|
134
|
+
"pluginType": "core",
|
|
135
|
+
"strict": true,
|
|
136
|
+
"enableJsonFlag": false,
|
|
137
|
+
"isESM": true,
|
|
138
|
+
"relativePath": [
|
|
139
|
+
"dist",
|
|
140
|
+
"commands",
|
|
141
|
+
"challenge",
|
|
142
|
+
"create.js"
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
"challenge:delete": {
|
|
146
|
+
"aliases": [],
|
|
147
|
+
"args": {
|
|
148
|
+
"challenge": {
|
|
149
|
+
"description": "Challenge slug to delete",
|
|
150
|
+
"name": "challenge",
|
|
151
|
+
"required": true
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"description": "Delete a challenge locally and from the cloud",
|
|
155
|
+
"examples": [
|
|
156
|
+
"<%= config.bin %> <%= command.id %> my-challenge",
|
|
157
|
+
"<%= config.bin %> <%= command.id %> my-challenge --yes"
|
|
158
|
+
],
|
|
159
|
+
"flags": {
|
|
160
|
+
"yes": {
|
|
161
|
+
"char": "y",
|
|
162
|
+
"description": "Skip confirmation prompts",
|
|
163
|
+
"name": "yes",
|
|
164
|
+
"allowNo": false,
|
|
165
|
+
"type": "boolean"
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
"hasDynamicHelp": false,
|
|
169
|
+
"hiddenAliases": [],
|
|
170
|
+
"id": "challenge:delete",
|
|
171
|
+
"pluginAlias": "@kradle/cli",
|
|
172
|
+
"pluginName": "@kradle/cli",
|
|
173
|
+
"pluginType": "core",
|
|
174
|
+
"strict": true,
|
|
175
|
+
"enableJsonFlag": false,
|
|
176
|
+
"isESM": true,
|
|
177
|
+
"relativePath": [
|
|
178
|
+
"dist",
|
|
179
|
+
"commands",
|
|
180
|
+
"challenge",
|
|
181
|
+
"delete.js"
|
|
182
|
+
]
|
|
183
|
+
},
|
|
184
|
+
"challenge:list": {
|
|
185
|
+
"aliases": [],
|
|
186
|
+
"args": {},
|
|
187
|
+
"description": "List all challenges (local and cloud)",
|
|
188
|
+
"examples": [
|
|
189
|
+
"<%= config.bin %> <%= command.id %>"
|
|
190
|
+
],
|
|
191
|
+
"flags": {},
|
|
192
|
+
"hasDynamicHelp": false,
|
|
193
|
+
"hiddenAliases": [],
|
|
194
|
+
"id": "challenge:list",
|
|
195
|
+
"pluginAlias": "@kradle/cli",
|
|
196
|
+
"pluginName": "@kradle/cli",
|
|
197
|
+
"pluginType": "core",
|
|
198
|
+
"strict": true,
|
|
199
|
+
"enableJsonFlag": false,
|
|
200
|
+
"isESM": true,
|
|
201
|
+
"relativePath": [
|
|
202
|
+
"dist",
|
|
203
|
+
"commands",
|
|
204
|
+
"challenge",
|
|
205
|
+
"list.js"
|
|
206
|
+
]
|
|
207
|
+
},
|
|
208
|
+
"challenge:multi-upload": {
|
|
209
|
+
"aliases": [],
|
|
210
|
+
"args": {},
|
|
211
|
+
"description": "Interactively select and upload multiple challenges",
|
|
212
|
+
"examples": [
|
|
213
|
+
"<%= config.bin %> <%= command.id %>"
|
|
214
|
+
],
|
|
215
|
+
"flags": {},
|
|
216
|
+
"hasDynamicHelp": false,
|
|
217
|
+
"hiddenAliases": [],
|
|
218
|
+
"id": "challenge:multi-upload",
|
|
219
|
+
"pluginAlias": "@kradle/cli",
|
|
220
|
+
"pluginName": "@kradle/cli",
|
|
221
|
+
"pluginType": "core",
|
|
222
|
+
"strict": true,
|
|
223
|
+
"enableJsonFlag": false,
|
|
224
|
+
"isESM": true,
|
|
225
|
+
"relativePath": [
|
|
226
|
+
"dist",
|
|
227
|
+
"commands",
|
|
228
|
+
"challenge",
|
|
229
|
+
"multi-upload.js"
|
|
230
|
+
]
|
|
231
|
+
},
|
|
232
|
+
"challenge:run": {
|
|
233
|
+
"aliases": [],
|
|
234
|
+
"args": {
|
|
235
|
+
"challenge": {
|
|
236
|
+
"description": "Challenge slug to run",
|
|
237
|
+
"name": "challenge",
|
|
238
|
+
"required": true
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
"description": "Run a challenge",
|
|
242
|
+
"examples": [
|
|
243
|
+
"<%= config.bin %> <%= command.id %> my-challenge",
|
|
244
|
+
"<%= config.bin %> <%= command.id %> my-challenge --studio"
|
|
245
|
+
],
|
|
246
|
+
"flags": {
|
|
247
|
+
"studio": {
|
|
248
|
+
"char": "s",
|
|
249
|
+
"description": "Run in studio environment",
|
|
250
|
+
"name": "studio",
|
|
251
|
+
"allowNo": false,
|
|
252
|
+
"type": "boolean"
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
"hasDynamicHelp": false,
|
|
256
|
+
"hiddenAliases": [],
|
|
257
|
+
"id": "challenge:run",
|
|
258
|
+
"pluginAlias": "@kradle/cli",
|
|
259
|
+
"pluginName": "@kradle/cli",
|
|
260
|
+
"pluginType": "core",
|
|
261
|
+
"strict": true,
|
|
262
|
+
"enableJsonFlag": false,
|
|
263
|
+
"isESM": true,
|
|
264
|
+
"relativePath": [
|
|
265
|
+
"dist",
|
|
266
|
+
"commands",
|
|
267
|
+
"challenge",
|
|
268
|
+
"run.js"
|
|
269
|
+
]
|
|
270
|
+
},
|
|
271
|
+
"challenge:watch": {
|
|
272
|
+
"aliases": [],
|
|
273
|
+
"args": {
|
|
274
|
+
"challenge": {
|
|
275
|
+
"description": "Challenge slug to watch",
|
|
276
|
+
"name": "challenge",
|
|
277
|
+
"required": true
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
"description": "Watch a challenge for changes and auto-rebuild/upload",
|
|
281
|
+
"examples": [
|
|
282
|
+
"<%= config.bin %> <%= command.id %> my-challenge"
|
|
283
|
+
],
|
|
284
|
+
"flags": {
|
|
285
|
+
"verbose": {
|
|
286
|
+
"description": "Enable verbose output",
|
|
287
|
+
"name": "verbose",
|
|
288
|
+
"allowNo": false,
|
|
289
|
+
"type": "boolean"
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
"hasDynamicHelp": false,
|
|
293
|
+
"hiddenAliases": [],
|
|
294
|
+
"id": "challenge:watch",
|
|
295
|
+
"pluginAlias": "@kradle/cli",
|
|
296
|
+
"pluginName": "@kradle/cli",
|
|
297
|
+
"pluginType": "core",
|
|
298
|
+
"strict": true,
|
|
299
|
+
"enableJsonFlag": false,
|
|
300
|
+
"isESM": true,
|
|
301
|
+
"relativePath": [
|
|
302
|
+
"dist",
|
|
303
|
+
"commands",
|
|
304
|
+
"challenge",
|
|
305
|
+
"watch.js"
|
|
306
|
+
]
|
|
307
|
+
}
|
|
308
|
+
},
|
|
309
|
+
"version": "0.0.2"
|
|
310
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kradle/cli",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Kradle's CLI. Manage challenges, evaluations, agents and more!",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli"
|
|
7
|
+
],
|
|
8
|
+
"license": "AGPL-3.0",
|
|
9
|
+
"author": "Kradle",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/index.js",
|
|
12
|
+
"types": "dist/index.d.ts",
|
|
13
|
+
"bin": {
|
|
14
|
+
"kradle": "bin/run.js"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"./bin",
|
|
18
|
+
"./dist",
|
|
19
|
+
"./oclif.manifest.json",
|
|
20
|
+
"./static",
|
|
21
|
+
"./README.md"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "rm -rf dist && tsc",
|
|
25
|
+
"watch": "rm -rf dist && tsc --watch",
|
|
26
|
+
"lint": "biome check .",
|
|
27
|
+
"lint:fix": "biome check --write .",
|
|
28
|
+
"format": "biome format --write .",
|
|
29
|
+
"prepack": "cp package.json package.json.bak && npm pkg delete bin.kradle-dev && npm run build && oclif manifest && oclif readme",
|
|
30
|
+
"postpack": "mv -f package.json.bak package.json && rm -f oclif.manifest.json",
|
|
31
|
+
"version": "oclif readme && git add README.md"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@google-cloud/storage": "^7.17.3",
|
|
35
|
+
"@oclif/core": "^4.8.0",
|
|
36
|
+
"@oclif/plugin-autocomplete": "^3.2.39",
|
|
37
|
+
"@oclif/plugin-help": "^6.2.35",
|
|
38
|
+
"chokidar": "^4.0.3",
|
|
39
|
+
"dotenv": "^17.2.3",
|
|
40
|
+
"enquirer": "^2.4.1",
|
|
41
|
+
"listr2": "^9.0.5",
|
|
42
|
+
"picocolors": "^1.1.1",
|
|
43
|
+
"tar": "^7.5.2",
|
|
44
|
+
"zod": "^4.1.12"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@biomejs/biome": "^2.3.4",
|
|
48
|
+
"@oclif/test": "^4",
|
|
49
|
+
"@types/chai": "^4",
|
|
50
|
+
"@types/node": "^18",
|
|
51
|
+
"@types/tar": "^6.1.13",
|
|
52
|
+
"chai": "^4",
|
|
53
|
+
"oclif": "^4",
|
|
54
|
+
"tsx": "^4.20.6",
|
|
55
|
+
"typescript": "^5.9.3"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=22.18.0"
|
|
59
|
+
},
|
|
60
|
+
"oclif": {
|
|
61
|
+
"bin": "kradle",
|
|
62
|
+
"dirname": "kradle",
|
|
63
|
+
"commands": "./dist/commands",
|
|
64
|
+
"plugins": [
|
|
65
|
+
"@oclif/plugin-help",
|
|
66
|
+
"@oclif/plugin-autocomplete"
|
|
67
|
+
],
|
|
68
|
+
"topicSeparator": " ",
|
|
69
|
+
"topics": {
|
|
70
|
+
"challenge": {
|
|
71
|
+
"description": "Manage challenges"
|
|
72
|
+
},
|
|
73
|
+
"agent": {
|
|
74
|
+
"description": "Manage agents"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Actions, createChallenge, DEFAULT_CHALLENGE_PATH } from "@kradle/challenges";
|
|
2
|
+
import { config } from "./config.ts";
|
|
3
|
+
|
|
4
|
+
// Extract challenge name from config
|
|
5
|
+
const challenge_name = config.slug.split(":").at(-1)!;
|
|
6
|
+
const GAME_DURATION = 2 * 60 * 20; // 2 minutes
|
|
7
|
+
|
|
8
|
+
createChallenge({
|
|
9
|
+
name: challenge_name,
|
|
10
|
+
kradle_challenge_path: process.env.KRADLE_CHALLENGES_PATH || DEFAULT_CHALLENGE_PATH,
|
|
11
|
+
GAME_DURATION: GAME_DURATION,
|
|
12
|
+
roles: ["all"],
|
|
13
|
+
custom_variables: {},
|
|
14
|
+
})
|
|
15
|
+
.events(() => ({
|
|
16
|
+
start_challenge: {
|
|
17
|
+
actions: [Actions.announce({ message: ["Challenge starting!"] }), Actions.setTime({ time: "day" })],
|
|
18
|
+
},
|
|
19
|
+
init_participants: {
|
|
20
|
+
actions: [
|
|
21
|
+
Actions.clear({ target: "all" }),
|
|
22
|
+
Actions.setAttribute({ attribute_: "minecraft:generic.max_health", value: 20, target: "all" }),
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
end_challenge: {
|
|
26
|
+
actions: [Actions.announce({ message: ["Challenge ended!"] })],
|
|
27
|
+
},
|
|
28
|
+
}))
|
|
29
|
+
.end_condition(({ alive_players }) => alive_players.equalTo(0))
|
|
30
|
+
.win_conditions(({ has_never_died }, { all }) => ({
|
|
31
|
+
[all]: has_never_died.equalTo(1),
|
|
32
|
+
}));
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
WEB_API_URL=https://dev-api.kradle.ai/v0 #https://api.kradle.ai/v0
|
|
2
|
+
WEB_URL=https://dev.kradle.ai #https:/.kradle.ai/workbench
|
|
3
|
+
STUDIO_API_URL=http://localhost:2999/api/v0
|
|
4
|
+
STUDIO_URL=kradle-dev://open #kradle://://open
|
|
5
|
+
GCS_BUCKET=mckradle-3c267.firebasestorage.app #kradle-prod-storage
|
|
6
|
+
KRADLE_CHALLENGES_PATH=~/Documents/kradle-studio/challenges
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-challenge",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "My challenge",
|
|
5
|
+
"dependencies": {
|
|
6
|
+
"@kradle/challenges": "latest",
|
|
7
|
+
"sandstone": "0.14.0-alpha.13"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"devDependencies": {
|
|
11
|
+
"@types/node": "^18.14.0",
|
|
12
|
+
"typescript": "^5.9.3"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=22.18.0"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
WEB_API_URL=https://api.kradle.ai/v0 #https://dev-api.kradle.ai/v0
|
|
2
|
+
WEB_URL=https://kradle.ai #https://dev.kradle.ai
|
|
3
|
+
STUDIO_API_URL=http://localhost:2999/api/v0
|
|
4
|
+
STUDIO_URL=kradle://open #kradle-dev://://open
|
|
5
|
+
GCS_BUCKET=kradle-prod-storage #mckradle-3c267.firebasestorage.app
|
|
6
|
+
KRADLE_CHALLENGES_PATH=~/Documents/kradle-studio/challenges
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "CommonJS",
|
|
5
|
+
"outDir": "build",
|
|
6
|
+
"rootDir": ".",
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"allowJs": true,
|
|
11
|
+
"checkJs": false,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"allowImportingTsExtensions": true,
|
|
14
|
+
"noEmit": true
|
|
15
|
+
},
|
|
16
|
+
"include": ["challenges/**/*"]
|
|
17
|
+
}
|