@asterai/cli 0.6.0 → 0.6.1

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 CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @asterai/cli
20
20
  $ asterai COMMAND
21
21
  running command...
22
22
  $ asterai (--version)
23
- @asterai/cli/0.6.0 darwin-arm64 node-v20.12.2
23
+ @asterai/cli/0.6.1 linux-x64 node-v20.12.2
24
24
  $ asterai --help [COMMAND]
25
25
  USAGE
26
26
  $ asterai COMMAND
@@ -53,7 +53,7 @@ EXAMPLES
53
53
  $ asterai auth
54
54
  ```
55
55
 
56
- _See code: [src/commands/auth.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.6.0/src/commands/auth.ts)_
56
+ _See code: [src/commands/auth.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.6.1/src/commands/auth.ts)_
57
57
 
58
58
  ## `asterai deploy`
59
59
 
@@ -77,7 +77,7 @@ EXAMPLES
77
77
  $ asterai deploy --app 66a46b12-b1a7-4b72-a64a-0e4fe21902b6
78
78
  ```
79
79
 
80
- _See code: [src/commands/deploy.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.6.0/src/commands/deploy.ts)_
80
+ _See code: [src/commands/deploy.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.6.1/src/commands/deploy.ts)_
81
81
 
82
82
  ## `asterai help [COMMAND]`
83
83
 
@@ -97,7 +97,7 @@ DESCRIPTION
97
97
  Display help for asterai.
98
98
  ```
99
99
 
100
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.0/src/commands/help.ts)_
100
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.0.22/src/commands/help.ts)_
101
101
 
102
102
  ## `asterai init [OUTDIR]`
103
103
 
@@ -105,11 +105,7 @@ Initialise a new plugin project
105
105
 
106
106
  ```
107
107
  USAGE
108
- $ asterai init [OUTDIR] [--typescript] [--rust]
109
-
110
- FLAGS
111
- --rust init a the plugin project in rust
112
- --typescript init a the plugin project in typescript
108
+ $ asterai init [OUTDIR]
113
109
 
114
110
  DESCRIPTION
115
111
  Initialise a new plugin project
@@ -118,7 +114,7 @@ EXAMPLES
118
114
  $ asterai init project-name
119
115
  ```
120
116
 
121
- _See code: [src/commands/init.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.6.0/src/commands/init.ts)_
117
+ _See code: [src/commands/init.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.6.1/src/commands/init.ts)_
122
118
 
123
119
  ## `asterai pkg [INPUT]`
124
120
 
@@ -143,7 +139,7 @@ EXAMPLES
143
139
  $ asterai pkg
144
140
  ```
145
141
 
146
- _See code: [src/commands/pkg.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.6.0/src/commands/pkg.ts)_
142
+ _See code: [src/commands/pkg.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.6.1/src/commands/pkg.ts)_
147
143
 
148
144
  ## `asterai query`
149
145
 
@@ -166,5 +162,5 @@ EXAMPLES
166
162
  $ asterai query
167
163
  ```
168
164
 
169
- _See code: [src/commands/query.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.6.0/src/commands/query.ts)_
165
+ _See code: [src/commands/query.ts](https://github.com/asterai-io/asterai-sdk/blob/v0.6.1/src/commands/query.ts)_
170
166
  <!-- commandsstop -->
package/bin/dev.js CHANGED
File without changes
@@ -1,17 +1,10 @@
1
1
  import { Command } from "@oclif/core";
2
- export type InitFlags = {
3
- rust?: boolean;
4
- typescript?: boolean;
5
- };
6
2
  export default class Codegen extends Command {
7
3
  static args: {
8
4
  outDir: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
9
5
  };
10
6
  static description: string;
11
7
  static examples: string[];
12
- static flags: {
13
- typescript: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
14
- rust: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
15
- };
8
+ static flags: {};
16
9
  run(): Promise<void>;
17
10
  }
@@ -1,10 +1,9 @@
1
- import { Args, Command, Flags } from "@oclif/core";
1
+ import { Args, Command } from "@oclif/core";
2
2
  import path from "path";
3
3
  import fs from "fs";
4
4
  import url from "url";
5
5
  const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
6
- const SOURCE_DIR_TYPESCRIPT = path.join(__dirname, "../../init/typescript");
7
- const SOURCE_DIR_RUST = path.join(__dirname, "../../init/rust");
6
+ const SOURCE_DIR = path.join(__dirname, "../../asterai-init-plugin");
8
7
  export default class Codegen extends Command {
9
8
  static args = {
10
9
  outDir: Args.string({
@@ -13,41 +12,10 @@ export default class Codegen extends Command {
13
12
  };
14
13
  static description = "Initialise a new plugin project";
15
14
  static examples = [`<%= config.bin %> <%= command.id %> project-name`];
16
- static flags = {
17
- typescript: Flags.boolean({
18
- default: undefined,
19
- description: "init a the plugin project in typescript",
20
- }),
21
- rust: Flags.boolean({
22
- default: false,
23
- description: "init a the plugin project in rust",
24
- }),
25
- };
15
+ static flags = {};
26
16
  async run() {
27
- const { args, flags } = await this.parse(Codegen);
28
- assertOneLanguageFlag([flags.typescript, flags.rust]);
17
+ const { args } = await this.parse(Codegen);
29
18
  const outDir = path.resolve(args.outDir);
30
- const sourceDir = getSourceDirByFlag(flags);
31
- fs.cpSync(sourceDir, outDir, { recursive: true });
19
+ fs.cpSync(SOURCE_DIR, outDir, { recursive: true });
32
20
  }
33
21
  }
34
- const assertOneLanguageFlag = (flags) => {
35
- const undefinedCount = flags.reduce((acc, curr) => (curr === undefined ? acc + 1 : acc), 0);
36
- const trueCount = flags.reduce((acc, curr) => (curr ? acc + 1 : acc), 0);
37
- if (trueCount === 0 && undefinedCount !== 1) {
38
- throw new Error("one language flag must be set");
39
- }
40
- if (trueCount > 1) {
41
- throw new Error("only one language flag can be set");
42
- }
43
- };
44
- const getSourceDirByFlag = (flags) => {
45
- if (flags.rust) {
46
- return SOURCE_DIR_RUST;
47
- }
48
- // Typescript is the default option.
49
- if (flags.typescript === true || flags.typescript === undefined) {
50
- return SOURCE_DIR_TYPESCRIPT;
51
- }
52
- throw new Error("Invalid flags configuration.");
53
- };
@@ -0,0 +1,2 @@
1
+ target/
2
+ wit/
File without changes
File without changes
@@ -0,0 +1,10 @@
1
+ .idea/
2
+ node_modules/
3
+ package-lock.json
4
+ pnpm-lock.yaml
5
+ build/
6
+ generated/
7
+ .vscode/
8
+ tsconfig.tsbuildinfo
9
+ *.wasm
10
+ typegen/
@@ -17,7 +17,7 @@
17
17
  "devDependencies": {
18
18
  "@asterai/cli": "latest",
19
19
  "@asterai/sdk": "latest",
20
- "@bytecodealliance/jco": "^1.9.1",
20
+ "@bytecodealliance/jco": "^1.10.2",
21
21
  "@types/node": "^22.13.4",
22
22
  "mkdirp": "^3.0.1",
23
23
  "npm-run-all": "^4.1.5",
@@ -1,11 +1,13 @@
1
- import { BinaryOperationInput } from "./generated/plugin";
2
1
  import * as asterai from "asterai:host/api@0.1.0";
2
+ import { BinaryOperationResult } from "example:math/plugin@0.1.0";
3
3
 
4
- export const add = (input: BinaryOperationInput): number => {
5
- const result = input.a + input.b;
4
+ export const mul = (a: number, b: number): BinaryOperationResult => {
5
+ const result = a + b;
6
6
  // Send the calculation result to the agent.
7
7
  asterai.sendResponseToAgent(`the result is ${result}`);
8
8
  // This result is not seen by the agent, but it can be consumed by
9
9
  // other plugins calling this function.
10
- return result;
10
+ return {
11
+ value: result,
12
+ };
11
13
  };
@@ -3,10 +3,9 @@ package example:math@0.1.0;
3
3
  world plugin {
4
4
  import asterai:host/api@0.1.0;
5
5
 
6
- export add: func(input: binary-operation-input) -> s32;
6
+ export mul: func(a: f32, b: f32) -> binary-operation-result;
7
7
 
8
- record binary-operation-input {
9
- a: f64,
10
- b: f64,
8
+ record binary-operation-result {
9
+ value: f64,
11
10
  }
12
11
  }
@@ -3,9 +3,6 @@
3
3
  "compilerOptions": {
4
4
  "outDir": "build",
5
5
  "module": "ESNext",
6
- "moduleResolution": "node",
7
- "paths": {
8
- "asterai:host/api@0.1.0": ["./generated/interfaces/asterai-host-api.d.ts"]
9
- }
6
+ "moduleResolution": "node"
10
7
  }
11
8
  }
@@ -103,20 +103,7 @@
103
103
  "examples": [
104
104
  "<%= config.bin %> <%= command.id %> project-name"
105
105
  ],
106
- "flags": {
107
- "typescript": {
108
- "description": "init a the plugin project in typescript",
109
- "name": "typescript",
110
- "allowNo": false,
111
- "type": "boolean"
112
- },
113
- "rust": {
114
- "description": "init a the plugin project in rust",
115
- "name": "rust",
116
- "allowNo": false,
117
- "type": "boolean"
118
- }
119
- },
106
+ "flags": {},
120
107
  "hasDynamicHelp": false,
121
108
  "hiddenAliases": [],
122
109
  "id": "init",
@@ -244,5 +231,5 @@
244
231
  ]
245
232
  }
246
233
  },
247
- "version": "0.6.0"
234
+ "version": "0.6.1"
248
235
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@asterai/cli",
3
3
  "description": "CLI for building and deploying asterai plugins",
4
- "version": "0.6.0",
4
+ "version": "0.6.1",
5
5
  "author": "asterai <support@asterai.io>",
6
6
  "repository": "asterai-io/asterai-sdk",
7
7
  "homepage": "https://github.com/asterai-io/asterai-sdk",
@@ -13,18 +13,6 @@
13
13
  "license": "UNLICENSED",
14
14
  "main": "dist/index.js",
15
15
  "type": "module",
16
- "scripts": {
17
- "prepare": "cd .. && husky cli/.husky",
18
- "build": "shx rm -rf dist && tsc -b",
19
- "lint": "eslint . --ext .ts",
20
- "postpack": "shx rm -f oclif.manifest.json",
21
- "posttest": "pnpm run lint",
22
- "prepack": "oclif manifest && oclif readme",
23
- "test": "mocha --forbid-only \"test/**/*.test.ts\"",
24
- "version": "oclif readme && git add README.md",
25
- "format": "prettier --write .",
26
- "format-staged": "pretty-quick --staged"
27
- },
28
16
  "bin": {
29
17
  "asterai": "./bin/run.js"
30
18
  },
@@ -37,8 +25,14 @@
37
25
  "/dist",
38
26
  "/oclif.manifest.json",
39
27
  "/init",
28
+ "/init/rust/.gitignore",
29
+ "/init/typescript/.gitignore",
40
30
  "!/init/rust/target",
41
- "!/init/rust/Cargo.lock"
31
+ "!/init/rust/Cargo.lock",
32
+ "!/init/typescript/build",
33
+ "!/init/typescript/node_modules",
34
+ "!/init/typescript/generated",
35
+ "!/init/typescript/pnpm-lock.yaml"
42
36
  ],
43
37
  "oclif": {
44
38
  "bin": "asterai",
@@ -85,5 +79,14 @@
85
79
  "shx": "^0.3.3",
86
80
  "ts-node": "^10",
87
81
  "typescript": "^5"
82
+ },
83
+ "scripts": {
84
+ "build": "shx rm -rf dist && tsc -b",
85
+ "lint": "eslint . --ext .ts",
86
+ "posttest": "pnpm run lint",
87
+ "test": "mocha --forbid-only \"test/**/*.test.ts\"",
88
+ "version": "oclif readme && git add README.md",
89
+ "format": "prettier --write .",
90
+ "format-staged": "pretty-quick --staged"
88
91
  }
89
- }
92
+ }