@kradle/cli 0.0.6 → 0.0.7

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,9 @@
1
+ import { Command } from "@oclif/core";
2
+ export default class Create extends Command {
3
+ static description: string;
4
+ static examples: string[];
5
+ static args: {
6
+ name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
7
+ };
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,58 @@
1
+ import { exec } from "node:child_process";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { Args, Command } from "@oclif/core";
5
+ import pc from "picocolors";
6
+ import { loadConfig } from "../../lib/config.js";
7
+ import { getStaticResourcePath } from "../../lib/utils.js";
8
+ export default class Create extends Command {
9
+ static description = "Create a new evaluation";
10
+ static examples = ["<%= config.bin %> <%= command.id %> my-evaluation"];
11
+ static args = {
12
+ name: Args.string({
13
+ description: "Name of the evaluation",
14
+ required: true,
15
+ }),
16
+ };
17
+ async run() {
18
+ const { args } = await this.parse(Create);
19
+ loadConfig(); // Validate config is available
20
+ const evaluationDir = path.resolve(process.cwd(), "evaluations", args.name);
21
+ const configPath = path.join(evaluationDir, "config.ts");
22
+ // Check if evaluation already exists
23
+ try {
24
+ await fs.access(evaluationDir);
25
+ this.error(pc.red(`Evaluation '${args.name}' already exists at ${evaluationDir}`));
26
+ }
27
+ catch {
28
+ // Directory doesn't exist, which is what we want
29
+ }
30
+ // Create evaluation directory
31
+ await fs.mkdir(evaluationDir, { recursive: true });
32
+ // Copy template
33
+ const templatePath = getStaticResourcePath("evaluation_template.ts");
34
+ await fs.copyFile(templatePath, configPath);
35
+ this.log(pc.green(`✓ Created evaluation '${args.name}'`));
36
+ this.log(pc.dim(` Config: ${configPath}`));
37
+ // Offer to open in editor on macOS
38
+ if (process.platform === "darwin") {
39
+ this.log("");
40
+ this.log(pc.blue(">> Opening config.ts in your editor..."));
41
+ // Try Cursor first, then VS Code, then fallback to default
42
+ exec(`cursor "${configPath}" || code "${configPath}" || open "${configPath}"`, (error) => {
43
+ if (error) {
44
+ this.log(pc.dim(` Could not open editor automatically. Please open: ${configPath}`));
45
+ }
46
+ });
47
+ }
48
+ else {
49
+ this.log("");
50
+ this.log(pc.blue(`>> Edit the config file to define your runs:`));
51
+ this.log(pc.dim(` ${configPath}`));
52
+ }
53
+ this.log("");
54
+ this.log(pc.blue(">> Next steps:"));
55
+ this.log(pc.dim(` 1. Edit ${path.basename(configPath)} to define your evaluation runs`));
56
+ this.log(pc.dim(` 2. Run: kradle evaluation run ${args.name}`));
57
+ }
58
+ }
@@ -52,7 +52,7 @@ export default class Init extends Command {
52
52
  }
53
53
  this.log("");
54
54
  this.log(pc.blue(">> Next steps:"));
55
- this.log(pc.dim(` 1. Edit ${path.basename(configPath)} to define your evaluation runs`));
55
+ this.log(pc.dim(` 1. Edit ${path.basename(configPath)} to define your evaluation runs, and `));
56
56
  this.log(pc.dim(` 2. Run: kradle evaluation run ${args.name}`));
57
57
  }
58
58
  }
@@ -4,7 +4,6 @@ export default class Init extends Command {
4
4
  static examples: string[];
5
5
  static flags: {
6
6
  name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
7
- dev: import("@oclif/core/interfaces").BooleanFlag<boolean>;
8
7
  "api-key": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
9
8
  };
10
9
  run(): Promise<void>;
@@ -14,11 +14,11 @@ export default class Init extends Command {
14
14
  description: "Project name",
15
15
  required: false,
16
16
  }),
17
- dev: Flags.boolean({
18
- char: "d",
19
- description: "Use Kradle's development environment instead of production",
20
- required: false,
21
- }),
17
+ // dev: Flags.boolean({
18
+ // char: "d",
19
+ // description: "Use Kradle's development environment instead of production",
20
+ // required: false,
21
+ // }),
22
22
  "api-key": Flags.string({
23
23
  char: "k",
24
24
  description: "Kradle API key",
@@ -34,10 +34,10 @@ export default class Init extends Command {
34
34
  const nonHiddenFiles = files.filter((f) => !f.startsWith("."));
35
35
  const useCurrentDir = nonHiddenFiles.length === 0;
36
36
  if (useCurrentDir) {
37
- this.log(pc.yellow("Current directory is empty, it will be used as the project directory."));
37
+ this.log(pc.yellow("Current directory is empty, it will be used to store challenges and evaluations."));
38
38
  }
39
39
  else {
40
- this.log(pc.yellow("Current directory is not empty, a subdirectory will be created for the project."));
40
+ this.log(pc.yellow("Current directory is not empty, a subdirectory will be created to store challenges and evaluations."));
41
41
  }
42
42
  let projectName;
43
43
  if (flags.name) {
@@ -51,34 +51,36 @@ export default class Init extends Command {
51
51
  const { name } = await enquirer.prompt({
52
52
  type: "input",
53
53
  name: "name",
54
- message: "Enter the project name:",
54
+ message: "What should the directory be called?",
55
55
  initial: initial,
56
56
  });
57
57
  projectName = name;
58
58
  }
59
- let useDev = flags.dev;
60
- if (!useDev) {
61
- const { confirm } = await enquirer.prompt({
62
- type: "confirm",
63
- name: "confirm",
64
- message: "Do you want to use Kradle's development environment?",
65
- initial: false,
66
- });
67
- useDev = confirm;
68
- }
69
- if (useDev) {
70
- this.log(pc.yellow("Using Kradle's development environment."));
71
- }
72
- else {
73
- this.log(pc.green("Using Kradle's production environment."));
74
- }
59
+ // let useDev = flags.dev;
60
+ // if (!useDev) {
61
+ // const { confirm } = await enquirer.prompt<{ confirm: boolean }>({
62
+ // type: "confirm",
63
+ // name: "confirm",
64
+ // message: "Do you want to use Kradle's development environment?",
65
+ // initial: false,
66
+ // });
67
+ // useDev = confirm;
68
+ // }
69
+ // if (useDev) {
70
+ // this.log(pc.yellow("Using Kradle's development environment."));
71
+ // } else {
72
+ // this.log(pc.green("Using Kradle's production environment."));
73
+ // }
74
+ this.log();
75
+ this.log(pc.yellow("Cloud Analytics are only available in the development environment for now. Development environment will be used."));
76
+ const useDev = true;
75
77
  const domain = useDev ? "dev.kradle.ai" : "kradle.ai";
76
78
  let apiKey;
77
79
  if (flags["api-key"]) {
78
80
  apiKey = flags["api-key"];
79
81
  }
80
82
  else {
81
- this.log(pc.dim(`\nGet your API key at: https://${domain}/settings#api-keys`));
83
+ this.log(pc.dim(`Get your API key at: https://${domain}/settings#api-keys`));
82
84
  const { key } = await enquirer.prompt({
83
85
  type: "password",
84
86
  name: "key",
@@ -17,14 +17,6 @@
17
17
  "multiple": false,
18
18
  "type": "option"
19
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
20
  "api-key": {
29
21
  "char": "k",
30
22
  "description": "Kradle API key",
@@ -305,6 +297,36 @@
305
297
  "watch.js"
306
298
  ]
307
299
  },
300
+ "evaluation:create": {
301
+ "aliases": [],
302
+ "args": {
303
+ "name": {
304
+ "description": "Name of the evaluation",
305
+ "name": "name",
306
+ "required": true
307
+ }
308
+ },
309
+ "description": "Create a new evaluation",
310
+ "examples": [
311
+ "<%= config.bin %> <%= command.id %> my-evaluation"
312
+ ],
313
+ "flags": {},
314
+ "hasDynamicHelp": false,
315
+ "hiddenAliases": [],
316
+ "id": "evaluation:create",
317
+ "pluginAlias": "@kradle/cli",
318
+ "pluginName": "@kradle/cli",
319
+ "pluginType": "core",
320
+ "strict": true,
321
+ "enableJsonFlag": false,
322
+ "isESM": true,
323
+ "relativePath": [
324
+ "dist",
325
+ "commands",
326
+ "evaluation",
327
+ "create.js"
328
+ ]
329
+ },
308
330
  "evaluation:init": {
309
331
  "aliases": [],
310
332
  "args": {
@@ -409,5 +431,5 @@
409
431
  ]
410
432
  }
411
433
  },
412
- "version": "0.0.6"
434
+ "version": "0.0.7"
413
435
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kradle/cli",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Kradle's CLI. Manage challenges, evaluations, agents and more!",
5
5
  "keywords": [
6
6
  "cli"