@receptron/graphai_cli 0.4.7 → 0.5.0

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,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const docs_1 = require("./docs");
9
+ const main = async () => {
10
+ const path = process.cwd();
11
+ const packageJson = JSON.parse(fs_1.default.readFileSync(path + "/package.json", "utf8"));
12
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
13
+ const agents = require(path + "/lib/index");
14
+ const agentAttribute = (key) => {
15
+ if (key === "packageName") {
16
+ return packageJson.name;
17
+ }
18
+ if (key === "description") {
19
+ return packageJson.description;
20
+ }
21
+ if (key === "agents") {
22
+ return Object.keys(agents).join(", ");
23
+ }
24
+ };
25
+ const temp = (0, docs_1.readTemplate)("readme.md");
26
+ const md = ["packageName", "description", "agents"].reduce((tmp, key) => {
27
+ tmp = tmp.replaceAll("{" + key + "}", agentAttribute(key));
28
+ return tmp;
29
+ }, temp);
30
+ fs_1.default.writeFileSync(path + "/README.md", md);
31
+ };
32
+ main();
package/lib/docs.d.ts CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export declare const readTemplate: (file: string) => string;
package/lib/docs.js CHANGED
@@ -26,6 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.readTemplate = void 0;
29
30
  const utils_1 = require("graphai/lib/utils/utils");
30
31
  const json_schema_generator_1 = __importDefault(require("json-schema-generator"));
31
32
  const packages = __importStar(require("@graphai/agents"));
@@ -33,9 +34,11 @@ const fs_1 = __importDefault(require("fs"));
33
34
  const path_1 = __importDefault(require("path"));
34
35
  const agentAttribute = (agentInfo, key) => {
35
36
  if (key === "samples") {
36
- return agentInfo.samples
37
- .map((sample) => {
37
+ return Array.from(agentInfo.samples.keys())
38
+ .map((key) => {
39
+ const sample = agentInfo.samples[key];
38
40
  return [
41
+ `### Sample${key}`,
39
42
  "#### inputs",
40
43
  "```json",
41
44
  JSON.stringify(sample.inputs, null, 2),
@@ -54,12 +57,23 @@ const agentAttribute = (agentInfo, key) => {
54
57
  .join("\n");
55
58
  }
56
59
  if (key === "schemas") {
57
- return agentInfo.samples
58
- .map((sample) => {
60
+ if (agentInfo.inputs && agentInfo.output) {
61
+ return [
62
+ "#### inputs",
63
+ "```json",
64
+ JSON.stringify(agentInfo.inputs, null, 2),
65
+ "````",
66
+ "#### output",
67
+ "```json",
68
+ JSON.stringify(agentInfo.output, null, 2),
69
+ "````",
70
+ ].join("\n\n");
71
+ }
72
+ if (agentInfo.samples && agentInfo.samples[0]) {
73
+ const sample = agentInfo.samples[0];
59
74
  return ["#### inputs", "```json", JSON.stringify((0, json_schema_generator_1.default)(sample.inputs), null, 2), "````"].join("\n\n");
60
- // return JSON.stringify(agentInfo.samples, null, 2);
61
- })
62
- .join("\n");
75
+ }
76
+ return "";
63
77
  }
64
78
  if (key === "resultKey") {
65
79
  return agentInfo.samples
@@ -73,8 +87,9 @@ const agentAttribute = (agentInfo, key) => {
73
87
  const readTemplate = (file) => {
74
88
  return fs_1.default.readFileSync(path_1.default.resolve(__dirname) + "/../templates/" + file, "utf8");
75
89
  };
90
+ exports.readTemplate = readTemplate;
76
91
  const agentMd = (agentInfo) => {
77
- const template = readTemplate("agent.md");
92
+ const template = (0, exports.readTemplate)("agent.md");
78
93
  const md = ["name", "description", "author", "repository", "license", "samples", "schemas", "resultKey"].reduce((tmp, key) => {
79
94
  tmp = tmp.replace("{" + key + "}", agentAttribute(agentInfo, key));
80
95
  return tmp;
@@ -34,7 +34,7 @@ const fs_1 = __importDefault(require("fs"));
34
34
  const path_1 = __importDefault(require("path"));
35
35
  const yaml_1 = __importDefault(require("yaml"));
36
36
  const args_1 = require("./args");
37
- const test_utils_1 = require("@graphai/test_utils");
37
+ const test_utils_1 = require("@receptron/test_utils");
38
38
  const options_1 = require("./options");
39
39
  const mermaid_1 = require("./mermaid");
40
40
  const fileFullPath = (file) => {
package/lib/mermaid.js CHANGED
@@ -9,15 +9,31 @@ const mermaid = (graphData) => {
9
9
  // label / name
10
10
  if ("agent" in node) {
11
11
  if (node.inputs) {
12
- node.inputs.forEach((input) => {
13
- const source = (0, utils_1.parseNodeName)(input, graphData.version ?? 0.2);
14
- if (source.propIds) {
15
- console.log(` ${source.nodeId}(${source.nodeId}) -- ${source.propIds.join(".")} --> ${nodeId}`);
16
- }
17
- else {
18
- console.log(` ${source.nodeId}(${source.nodeId}) --> ${nodeId}`);
19
- }
20
- });
12
+ if (Array.isArray(node.inputs)) {
13
+ node.inputs.forEach((input) => {
14
+ const source = (0, utils_1.parseNodeName)(input, graphData.version ?? 0.2);
15
+ if (source.propIds) {
16
+ console.log(` ${source.nodeId}(${source.nodeId}) -- ${source.propIds.join(".")} --> ${nodeId}`);
17
+ }
18
+ else {
19
+ console.log(` ${source.nodeId}(${source.nodeId}) --> ${nodeId}`);
20
+ }
21
+ });
22
+ }
23
+ else {
24
+ // LATER: Display the inputName as well.
25
+ const inputNames = Object.keys(node.inputs);
26
+ inputNames.forEach((inputName) => {
27
+ const input = node.inputs[inputName];
28
+ const source = (0, utils_1.parseNodeName)(input, graphData.version ?? 0.2);
29
+ if (source.propIds) {
30
+ console.log(` ${source.nodeId}(${source.nodeId}) -- ${source.propIds.join(".")} --> ${nodeId}`);
31
+ }
32
+ else {
33
+ console.log(` ${source.nodeId}(${source.nodeId}) --> ${nodeId}`);
34
+ }
35
+ });
36
+ }
21
37
  }
22
38
  }
23
39
  if ("value" in node) {
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@receptron/graphai_cli",
3
- "version": "0.4.7",
3
+ "version": "0.5.0",
4
4
  "description": "GraphAI command line tools.",
5
5
  "main": "lib/graphai_cli.js",
6
6
  "bin": {
7
- "graphai": "lib/graphai_cli.js"
7
+ "graphai": "lib/graphai_cli.js",
8
+ "agentdoc": "lib/agentdoc.js"
8
9
  },
9
10
  "files": [
10
11
  "./lib"
@@ -35,15 +36,16 @@
35
36
  "@types/yargs": "^17.0.32"
36
37
  },
37
38
  "dependencies": {
38
- "@graphai/agents": "^0.0.3",
39
- "@graphai/test_utils": "^0.0.1",
39
+ "@graphai/agents": "^0.0.6",
40
+ "@receptron/test_utils": "^0.0.2",
40
41
  "dotenv": "^16.4.5",
41
- "graphai": "^0.4.6",
42
+ "graphai": "^0.5.1",
42
43
  "json-schema-generator": "^2.0.6",
43
44
  "yargs": "^17.7.2"
44
45
  },
45
46
  "types": "./lib/graphai_cli.d.ts",
46
47
  "directories": {
47
- "lib": "lib"
48
+ "lib": "lib",
49
+ "template": "template"
48
50
  }
49
51
  }