@aidejs/tools 0.1.0-alpha.2 → 0.1.0-beta.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.
- package/README.md +32 -11
- package/package.json +1 -1
- package/src/browser/open.js +6 -5
- package/src/disk/copyDisk.js +2 -1
- package/src/disk/deleteDisk.js +2 -1
- package/src/disk/index.js +4 -0
- package/src/disk/linkDisk.js +2 -1
- package/src/disk/moveDisk.js +2 -1
- package/src/disk/newDisk.js +37 -0
- package/src/disk/pathValue.js +34 -0
- package/src/disk/readFolder.js +24 -0
- package/src/disk/typeDisk.js +24 -0
- package/src/disk/writePlain.js +2 -1
- package/src/index.js +1 -1
- package/types/index.d.ts +4 -4
package/README.md
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
<img src="
|
|
1
|
+
<img src="https://NN-Studio.github.io/Aidejs/images/logo.png" />
|
|
2
2
|
|
|
3
3
|
# [Aidejs](https://github.com/NN-Studio/Aidejs)
|
|
4
4
|
一个用于构建人工智能代理的JavaScript框架,它提供了一组工具和库,使创建智能应用程序变得轻松和高效
|
|
5
5
|
|
|
6
|
-
## 功能列表
|
|
7
|
-
|
|
8
|
-
通过类似拼积木的方式,你可以轻松地组合各个模块完成个性化的 AI 应用开发。
|
|
9
|
-
|
|
10
|
-
下面是可用模块:
|
|
11
|
-
|
|
12
6
|
<p>
|
|
13
7
|
<a href="https://github.com/NN-Studio/Aidejs/issues">
|
|
14
8
|
<img src="https://img.shields.io/github/issues/NN-Studio/Aidejs" alt="issue">
|
|
@@ -19,29 +13,56 @@
|
|
|
19
13
|
<a href="https://github.com/NN-Studio/Aidejs">
|
|
20
14
|
<img src="https://img.shields.io/github/forks/NN-Studio/Aidejs" alt="forks">
|
|
21
15
|
</a>
|
|
16
|
+
<a href="https://gitee.com/NN-Studio/Aidejs" target='_blank'>
|
|
17
|
+
<img alt="Gitee repo stars" src="https://gitee.com/NN-Studio/Aidejs/badge/star.svg">
|
|
18
|
+
</a>
|
|
19
|
+
<a href="https://gitee.com/NN-Studio/Aidejs">
|
|
20
|
+
<img src="https://gitee.com/NN-Studio/Aidejs/badge/fork.svg" alt="forks">
|
|
21
|
+
</a>
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
|
+
## 功能列表
|
|
25
|
+
|
|
26
|
+
通过类似拼积木的方式,你可以轻松地组合各个模块完成个性化的 AI 应用开发。
|
|
27
|
+
|
|
28
|
+
下面是可用模块:
|
|
29
|
+
|
|
24
30
|
<table>
|
|
25
31
|
<thead>
|
|
26
32
|
<tr>
|
|
27
33
|
<td>名称</td>
|
|
28
34
|
<td>简介</td>
|
|
29
|
-
<td
|
|
35
|
+
<td>下周统计</td>
|
|
36
|
+
<td>最新版本</td>
|
|
30
37
|
</tr>
|
|
31
38
|
</thead>
|
|
32
39
|
<tbody>
|
|
33
40
|
<tr>
|
|
34
41
|
<td>@aidejs/core</td>
|
|
35
|
-
<td
|
|
42
|
+
<td>必选项,核心库,提供了最核心的LLM交互功能和插件系统</td>
|
|
36
43
|
<td>
|
|
37
|
-
<a href="https://
|
|
44
|
+
<a href="https://zxl20070701.github.io/toolbox/#/npm-download?packages=@aidejs/core&interval=7">
|
|
45
|
+
<img src="https://img.shields.io/npm/dm/@aidejs/core.svg" alt="downloads">
|
|
46
|
+
</a>
|
|
47
|
+
</td>
|
|
48
|
+
<td>
|
|
49
|
+
<a href="https://www.npmjs.com/package/@aidejs/core">
|
|
50
|
+
<img src="https://img.shields.io/npm/v/@aidejs/core.svg" alt="npm">
|
|
51
|
+
</a>
|
|
38
52
|
</td>
|
|
39
53
|
</tr>
|
|
40
54
|
<tr>
|
|
41
55
|
<td>@aidejs/tools</td>
|
|
42
56
|
<td>非必选,工具库,提供了各种实用的工具函数</td>
|
|
43
57
|
<td>
|
|
44
|
-
<a href="https://
|
|
58
|
+
<a href="https://zxl20070701.github.io/toolbox/#/npm-download?packages=@aidejs/tools&interval=7">
|
|
59
|
+
<img src="https://img.shields.io/npm/dm/@aidejs/tools.svg" alt="downloads">
|
|
60
|
+
</a>
|
|
61
|
+
</td>
|
|
62
|
+
<td>
|
|
63
|
+
<a href="https://www.npmjs.com/package/@aidejs/tools">
|
|
64
|
+
<img src="https://img.shields.io/npm/v/@aidejs/tools.svg" alt="npm">
|
|
65
|
+
</a>
|
|
45
66
|
</td>
|
|
46
67
|
</tr>
|
|
47
68
|
</tbody>
|
package/package.json
CHANGED
package/src/browser/open.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const { exec } = require('child_process');
|
|
2
|
-
const
|
|
2
|
+
const { platform } = require('os');
|
|
3
3
|
|
|
4
4
|
module.exports = {
|
|
5
5
|
"description": {
|
|
@@ -20,10 +20,10 @@ module.exports = {
|
|
|
20
20
|
},
|
|
21
21
|
},
|
|
22
22
|
"valueOf": function (args) {
|
|
23
|
-
const
|
|
23
|
+
const platformValue = platform();
|
|
24
24
|
let command;
|
|
25
25
|
|
|
26
|
-
switch (
|
|
26
|
+
switch (platformValue) {
|
|
27
27
|
case 'win32': // Windows
|
|
28
28
|
command = `start ${args.url}`;
|
|
29
29
|
break;
|
|
@@ -37,9 +37,10 @@ module.exports = {
|
|
|
37
37
|
return new Promise(function (resolve, reject) {
|
|
38
38
|
exec(command, (error) => {
|
|
39
39
|
if (error) {
|
|
40
|
-
|
|
40
|
+
console.log(error);
|
|
41
|
+
reject(`fail`);
|
|
41
42
|
} else {
|
|
42
|
-
resolve("
|
|
43
|
+
resolve("success");
|
|
43
44
|
}
|
|
44
45
|
});
|
|
45
46
|
});
|
package/src/disk/copyDisk.js
CHANGED
|
@@ -21,6 +21,7 @@ module.exports = {
|
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
"valueOf": function (args) {
|
|
24
|
-
|
|
24
|
+
require("oipage/nodejs/disk/index.js").copyDisk(args.sourcePath, args.targetPath, true);
|
|
25
|
+
return "success";
|
|
25
26
|
}
|
|
26
27
|
};
|
package/src/disk/deleteDisk.js
CHANGED
package/src/disk/index.js
CHANGED
package/src/disk/linkDisk.js
CHANGED
|
@@ -21,6 +21,7 @@ module.exports = {
|
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
"valueOf": function (args) {
|
|
24
|
-
|
|
24
|
+
require("oipage/nodejs/disk/index.js").linkDisk(args.sourcePath, args.targetPath, true);
|
|
25
|
+
return "success";
|
|
25
26
|
}
|
|
26
27
|
};
|
package/src/disk/moveDisk.js
CHANGED
|
@@ -21,6 +21,7 @@ module.exports = {
|
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
"valueOf": function (args) {
|
|
24
|
-
|
|
24
|
+
require("oipage/nodejs/disk/index.js").moveDisk(args.sourcePath, args.targetPath, true);
|
|
25
|
+
return "success";
|
|
25
26
|
}
|
|
26
27
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const { mkdirSync } = require("fs");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
"description": {
|
|
5
|
+
"type": "function",
|
|
6
|
+
"function": {
|
|
7
|
+
"name": "newDisk",
|
|
8
|
+
"description": "新建文件或文件夹",
|
|
9
|
+
"parameters": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"type": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "目录类型,file=文件、folder=文件夹",
|
|
15
|
+
"enum": ["file", "folder"]
|
|
16
|
+
},
|
|
17
|
+
"diskPath": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "需要创建的文件或文件夹的路径",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
"required": ["type", "diskPath"],
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
"valueOf": function (args) {
|
|
27
|
+
if (args.type === "folder") {
|
|
28
|
+
mkdirSync(args.diskPath, { recursive: true });
|
|
29
|
+
return "success";
|
|
30
|
+
} else if (args.type === "file") {
|
|
31
|
+
require("oipage/nodejs/disk/index.js").writePlain(args.diskPath, "");
|
|
32
|
+
return "success";
|
|
33
|
+
} else {
|
|
34
|
+
return "fail";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const { homedir } = require("os");
|
|
2
|
+
const { join } = require("path");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
"description": {
|
|
6
|
+
"type": "function",
|
|
7
|
+
"function": {
|
|
8
|
+
"name": "pathValue",
|
|
9
|
+
"description": "获取指定的路径",
|
|
10
|
+
"parameters": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"properties": {
|
|
13
|
+
"type": {
|
|
14
|
+
"type": "string",
|
|
15
|
+
"description": "目录类型,current=当前路径、desktop=桌面路径、home=用户根路径",
|
|
16
|
+
"enum": ["desktop", "home"]
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"required": ["type"],
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
"valueOf": function (args) {
|
|
24
|
+
if (args.type === "current") {
|
|
25
|
+
return process.cwd();
|
|
26
|
+
} else if (args.type === "home") {
|
|
27
|
+
return homedir();
|
|
28
|
+
} else if (args.type === "desktop") {
|
|
29
|
+
return join(homedir(), "./Desktop");
|
|
30
|
+
} else {
|
|
31
|
+
return "fail";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const { readdirSync } = require("fs");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
"description": {
|
|
5
|
+
"type": "function",
|
|
6
|
+
"function": {
|
|
7
|
+
"name": "readFolder",
|
|
8
|
+
"description": "获取文件夹的子文件和文件夹列表",
|
|
9
|
+
"parameters": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"folderPath": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "需要获取的文件夹路径",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
"required": ["folderPath"],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
"valueOf": function (args) {
|
|
22
|
+
return readdirSync(args.folderPath).join("、");
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const { lstatSync } = require("fs");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
"description": {
|
|
5
|
+
"type": "function",
|
|
6
|
+
"function": {
|
|
7
|
+
"name": "typeDisk",
|
|
8
|
+
"description": "判断路径类型,返回值如果是file表示文件、folder表示文件夹",
|
|
9
|
+
"parameters": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"properties": {
|
|
12
|
+
"diskPath": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "需要判断的路径",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
"required": ["diskPath"],
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
"valueOf": function (args) {
|
|
22
|
+
return lstatSync(args.diskPath).isDirectory() ? "folder" : "file";
|
|
23
|
+
}
|
|
24
|
+
};
|
package/src/disk/writePlain.js
CHANGED
|
@@ -21,6 +21,7 @@ module.exports = {
|
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
"valueOf": function (args) {
|
|
24
|
-
|
|
24
|
+
require("oipage/nodejs/disk/index.js").writePlain(args.filepath, args.content);
|
|
25
|
+
return "success";
|
|
25
26
|
}
|
|
26
27
|
};
|
package/src/index.js
CHANGED
|
@@ -11,7 +11,7 @@ module.exports = {
|
|
|
11
11
|
for (let toolType in tools) {
|
|
12
12
|
for (let toolItem of tools[toolType]) {
|
|
13
13
|
let functionName = toolItem.description.function.name;
|
|
14
|
-
if (!options.
|
|
14
|
+
if (!options.filter || options.filter(toolType, functionName)) {
|
|
15
15
|
let toolName = `aidejs_${toolType}_` + functionName;
|
|
16
16
|
toolItem.description.function.name = toolName;
|
|
17
17
|
Aidejs.registerTool(toolName, toolItem);
|
package/types/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type Aidejs from "@aidejs/core"
|
|
2
2
|
|
|
3
|
-
export default {
|
|
4
|
-
install(Aidejs: Aidejs, options?: {
|
|
3
|
+
export default class Tools {
|
|
4
|
+
static install(Aidejs: Aidejs, options?: {
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* 过滤若干不希望安装的工具
|
|
8
8
|
* @param toolType <string> 工具类型
|
|
9
9
|
* @param toolName <string> 工具名称
|
|
10
|
-
* @returns boolean 如果返回
|
|
10
|
+
* @returns boolean 如果返回false,就表示当前工具不希望安装
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
filter?: (toolType: string, toolName: string) => boolean
|
|
13
13
|
}): void
|
|
14
14
|
}
|