@aigne/cli 1.0.0-1 → 1.0.0-11

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/dist/cli.js CHANGED
@@ -1,5 +1,3 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const aigne_js_1 = require("./commands/aigne.js");
5
- (0, aigne_js_1.createAIGNECommand)().parse();
2
+ import { createAIGNECommand } from "./commands/aigne.js";
3
+ createAIGNECommand().parse();
@@ -1,19 +1,16 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAIGNECommand = createAIGNECommand;
4
- const commander_1 = require("commander");
5
- const package_json_1 = require("../../package.json");
6
- const create_js_1 = require("./create.js");
7
- const run_js_1 = require("./run.js");
8
- const test_js_1 = require("./test.js");
9
- function createAIGNECommand() {
10
- return new commander_1.Command()
1
+ import { Command } from "commander";
2
+ import { createCreateCommand } from "./create.js";
3
+ import { createRunCommand } from "./run.js";
4
+ import { createTestCommand } from "./test.js";
5
+ export function createAIGNECommand() {
6
+ const { version } = require("../../package.json");
7
+ return new Command()
11
8
  .name("aigne")
12
9
  .description("CLI for AIGNE framework")
13
- .version(package_json_1.version)
14
- .addCommand((0, run_js_1.createRunCommand)())
15
- .addCommand((0, test_js_1.createTestCommand)())
16
- .addCommand((0, create_js_1.createCreateCommand)())
10
+ .version(version)
11
+ .addCommand(createRunCommand())
12
+ .addCommand(createTestCommand())
13
+ .addCommand(createCreateCommand())
17
14
  .showHelpAfterError(true)
18
15
  .showSuggestionAfterError(true);
19
16
  }
@@ -1,22 +1,16 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.createCreateCommand = createCreateCommand;
7
- const node_fs_1 = require("node:fs");
8
- const promises_1 = require("node:fs/promises");
9
- const node_path_1 = require("node:path");
10
- const commander_1 = require("commander");
11
- const inquirer_1 = __importDefault(require("inquirer"));
12
- function createCreateCommand() {
13
- return new commander_1.Command("create")
1
+ import { existsSync, mkdirSync, readdirSync } from "node:fs";
2
+ import { cp } from "node:fs/promises";
3
+ import { isAbsolute, join, resolve } from "node:path";
4
+ import { Command } from "commander";
5
+ import inquirer from "inquirer";
6
+ export function createCreateCommand() {
7
+ return new Command("create")
14
8
  .description("Create a new aigne project with agent config files")
15
9
  .argument("[path]", "Path to create the project directory", ".")
16
10
  .action(async (path) => {
17
11
  let projectPath = path;
18
12
  if (projectPath === ".") {
19
- const answers = await inquirer_1.default.prompt([
13
+ const answers = await inquirer.prompt([
20
14
  {
21
15
  type: "input",
22
16
  name: "projectName",
@@ -31,10 +25,10 @@ function createCreateCommand() {
31
25
  ]);
32
26
  projectPath = answers.projectName;
33
27
  }
34
- const absolutePath = (0, node_path_1.isAbsolute)(path) ? path : (0, node_path_1.resolve)(process.cwd(), path);
35
- const isPathNotEmpty = (0, node_fs_1.existsSync)(absolutePath) && (0, node_fs_1.readdirSync)(absolutePath).length > 0;
28
+ const absolutePath = isAbsolute(path) ? path : resolve(process.cwd(), path);
29
+ const isPathNotEmpty = existsSync(absolutePath) && readdirSync(absolutePath).length > 0;
36
30
  if (isPathNotEmpty) {
37
- const answers = await inquirer_1.default.prompt([
31
+ const answers = await inquirer.prompt([
38
32
  {
39
33
  type: "confirm",
40
34
  name: "overwrite",
@@ -48,7 +42,7 @@ function createCreateCommand() {
48
42
  }
49
43
  }
50
44
  const templates = [{ name: "default" }];
51
- const { template } = await inquirer_1.default.prompt([
45
+ const { template } = await inquirer.prompt([
52
46
  {
53
47
  type: "list",
54
48
  name: "template",
@@ -57,15 +51,15 @@ function createCreateCommand() {
57
51
  default: "default",
58
52
  },
59
53
  ]);
60
- (0, node_fs_1.mkdirSync)(absolutePath, { recursive: true });
61
- const templatePath = (0, node_path_1.join)(__dirname, "../../templates", template);
62
- if (!(0, node_fs_1.existsSync)(templatePath))
54
+ mkdirSync(absolutePath, { recursive: true });
55
+ const templatePath = join(import.meta.dirname, "../../templates", template);
56
+ if (!existsSync(templatePath))
63
57
  throw new Error(`Template "${template}" not found.`);
64
- const files = (0, node_fs_1.readdirSync)(templatePath);
58
+ const files = readdirSync(templatePath);
65
59
  for (const file of files) {
66
- const source = (0, node_path_1.join)(templatePath, file);
67
- const destination = (0, node_path_1.join)(absolutePath, file);
68
- await (0, promises_1.cp)(source, destination, { recursive: true, force: true });
60
+ const source = join(templatePath, file);
61
+ const destination = join(absolutePath, file);
62
+ await cp(source, destination, { recursive: true, force: true });
69
63
  }
70
64
  console.log("\n✅ Aigne project created successfully!");
71
65
  console.log(`\nTo use your new agent, run:\n cd ${path} && npx -y aigne run`);
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRunCommand = createRunCommand;
4
- const node_path_1 = require("node:path");
5
- const core_1 = require("@aigne/core");
6
- const run_chat_loop_js_1 = require("@aigne/core/utils/run-chat-loop.js");
7
- const commander_1 = require("commander");
8
- function createRunCommand() {
9
- return new commander_1.Command("run")
1
+ import { isAbsolute, resolve } from "node:path";
2
+ import { ExecutionEngine } from "@aigne/core";
3
+ import { runChatLoopInTerminal } from "@aigne/core/utils/run-chat-loop.js";
4
+ import { Command } from "commander";
5
+ export function createRunCommand() {
6
+ return new Command("run")
10
7
  .description("Run a chat loop with the specified agent")
11
8
  .argument("[path]", "Path to the agents directory", ".")
12
9
  .option("--agent <agent>", "Name of the agent to use (defaults to the first agent found)")
13
10
  .action(async (path, options) => {
14
- const absolutePath = (0, node_path_1.isAbsolute)(path) ? path : (0, node_path_1.resolve)(process.cwd(), path);
15
- const engine = await core_1.ExecutionEngine.load({ path: absolutePath });
11
+ const absolutePath = isAbsolute(path) ? path : resolve(process.cwd(), path);
12
+ const engine = await ExecutionEngine.load({ path: absolutePath });
16
13
  let agent;
17
14
  if (options.agent) {
18
15
  agent = engine.agents[options.agent];
@@ -33,7 +30,7 @@ function createRunCommand() {
33
30
  }
34
31
  }
35
32
  const user = engine.call(agent);
36
- await (0, run_chat_loop_js_1.runChatLoopInTerminal)(user, {});
33
+ await runChatLoopInTerminal(user, {});
37
34
  })
38
35
  .showHelpAfterError(true)
39
36
  .showSuggestionAfterError(true);
@@ -1,16 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createTestCommand = createTestCommand;
4
- const node_child_process_1 = require("node:child_process");
5
- const node_path_1 = require("node:path");
6
- const commander_1 = require("commander");
7
- function createTestCommand() {
8
- return new commander_1.Command("test")
1
+ import { spawnSync } from "node:child_process";
2
+ import { isAbsolute, resolve } from "node:path";
3
+ import { Command } from "commander";
4
+ export function createTestCommand() {
5
+ return new Command("test")
9
6
  .description("Run tests in the specified agents directory")
10
7
  .argument("[path]", "Path to the agents directory", ".")
11
8
  .action(async (path) => {
12
- const absolutePath = (0, node_path_1.isAbsolute)(path) ? path : (0, node_path_1.resolve)(process.cwd(), path);
13
- (0, node_child_process_1.spawnSync)("node", ["--test"], { cwd: absolutePath, stdio: "inherit" });
9
+ const absolutePath = isAbsolute(path) ? path : resolve(process.cwd(), path);
10
+ spawnSync("node", ["--test"], { cwd: absolutePath, stdio: "inherit" });
14
11
  })
15
12
  .showHelpAfterError(true)
16
13
  .showSuggestionAfterError(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/cli",
3
- "version": "1.0.0-1",
3
+ "version": "1.0.0-11",
4
4
  "description": "cli for AIGNE framework",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -19,6 +19,7 @@
19
19
  "CHANGELOG.md",
20
20
  "templates"
21
21
  ],
22
+ "type": "module",
22
23
  "bin": {
23
24
  "aigne": "dist/cli.js"
24
25
  },
@@ -35,12 +36,6 @@
35
36
  "rimraf": "^6.0.1",
36
37
  "typescript": "^5.8.2"
37
38
  },
38
- "resolutions": {
39
- "pkce-challenge": "^5.0.0"
40
- },
41
- "overrides": {
42
- "pkce-challenge": "^5.0.0"
43
- },
44
39
  "scripts": {
45
40
  "lint": "tsc --noEmit",
46
41
  "build": "tsc --build tsconfig.build.json",