@aigne/core 1.71.0-beta.4 → 1.71.0-beta.6

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/lib/cjs/agents/agent.d.ts +3 -1
  3. package/lib/cjs/agents/agent.js +7 -1
  4. package/lib/cjs/agents/user-agent.js +1 -1
  5. package/lib/cjs/memory/recorder.js +1 -1
  6. package/lib/cjs/memory/retriever.js +1 -1
  7. package/lib/cjs/prompt/prompt-builder.js +3 -3
  8. package/lib/cjs/prompt/skills/afs/delete.d.ts +18 -0
  9. package/lib/cjs/prompt/skills/afs/delete.js +42 -0
  10. package/lib/cjs/prompt/skills/afs/edit.d.ts +26 -0
  11. package/lib/cjs/prompt/skills/afs/edit.js +98 -0
  12. package/lib/cjs/prompt/skills/afs/exec.d.ts +15 -0
  13. package/lib/cjs/prompt/skills/afs/exec.js +27 -0
  14. package/lib/cjs/prompt/skills/{afs.d.ts → afs/index.d.ts} +1 -1
  15. package/lib/cjs/prompt/skills/afs/index.js +23 -0
  16. package/lib/cjs/prompt/skills/afs/list.d.ts +22 -0
  17. package/lib/cjs/prompt/skills/afs/list.js +90 -0
  18. package/lib/cjs/prompt/skills/afs/read.d.ts +21 -0
  19. package/lib/cjs/prompt/skills/afs/read.js +53 -0
  20. package/lib/cjs/prompt/skills/afs/rename.d.ts +20 -0
  21. package/lib/cjs/prompt/skills/afs/rename.js +45 -0
  22. package/lib/cjs/prompt/skills/afs/search.d.ts +23 -0
  23. package/lib/cjs/prompt/skills/afs/search.js +55 -0
  24. package/lib/cjs/prompt/skills/afs/write.d.ts +19 -0
  25. package/lib/cjs/prompt/skills/afs/write.js +45 -0
  26. package/lib/cjs/utils/json-schema.d.ts +1 -0
  27. package/lib/cjs/utils/json-schema.js +6 -0
  28. package/lib/dts/agents/agent.d.ts +3 -1
  29. package/lib/dts/prompt/skills/afs/delete.d.ts +18 -0
  30. package/lib/dts/prompt/skills/afs/edit.d.ts +26 -0
  31. package/lib/dts/prompt/skills/afs/exec.d.ts +15 -0
  32. package/lib/dts/prompt/skills/{afs.d.ts → afs/index.d.ts} +1 -1
  33. package/lib/dts/prompt/skills/afs/list.d.ts +22 -0
  34. package/lib/dts/prompt/skills/afs/read.d.ts +21 -0
  35. package/lib/dts/prompt/skills/afs/rename.d.ts +20 -0
  36. package/lib/dts/prompt/skills/afs/search.d.ts +23 -0
  37. package/lib/dts/prompt/skills/afs/write.d.ts +19 -0
  38. package/lib/dts/utils/json-schema.d.ts +1 -0
  39. package/lib/esm/agents/agent.d.ts +3 -1
  40. package/lib/esm/agents/agent.js +8 -2
  41. package/lib/esm/agents/user-agent.js +1 -1
  42. package/lib/esm/memory/recorder.js +1 -1
  43. package/lib/esm/memory/retriever.js +1 -1
  44. package/lib/esm/prompt/prompt-builder.js +1 -1
  45. package/lib/esm/prompt/skills/afs/delete.d.ts +18 -0
  46. package/lib/esm/prompt/skills/afs/delete.js +38 -0
  47. package/lib/esm/prompt/skills/afs/edit.d.ts +26 -0
  48. package/lib/esm/prompt/skills/afs/edit.js +94 -0
  49. package/lib/esm/prompt/skills/afs/exec.d.ts +15 -0
  50. package/lib/esm/prompt/skills/afs/exec.js +23 -0
  51. package/lib/esm/prompt/skills/{afs.d.ts → afs/index.d.ts} +1 -1
  52. package/lib/esm/prompt/skills/afs/index.js +20 -0
  53. package/lib/esm/prompt/skills/afs/list.d.ts +22 -0
  54. package/lib/esm/prompt/skills/afs/list.js +86 -0
  55. package/lib/esm/prompt/skills/afs/read.d.ts +21 -0
  56. package/lib/esm/prompt/skills/afs/read.js +49 -0
  57. package/lib/esm/prompt/skills/afs/rename.d.ts +20 -0
  58. package/lib/esm/prompt/skills/afs/rename.js +41 -0
  59. package/lib/esm/prompt/skills/afs/search.d.ts +23 -0
  60. package/lib/esm/prompt/skills/afs/search.js +51 -0
  61. package/lib/esm/prompt/skills/afs/write.d.ts +19 -0
  62. package/lib/esm/prompt/skills/afs/write.js +41 -0
  63. package/lib/esm/utils/json-schema.d.ts +1 -0
  64. package/lib/esm/utils/json-schema.js +5 -0
  65. package/package.json +3 -3
  66. package/lib/cjs/prompt/skills/afs.js +0 -177
  67. package/lib/esm/prompt/skills/afs.js +0 -174
@@ -1,174 +0,0 @@
1
- import { z } from "zod";
2
- import { FunctionAgent } from "../../agents/agent.js";
3
- export async function getAFSSkills(afs) {
4
- return [
5
- FunctionAgent.from({
6
- name: "afs_list",
7
- description: "Get a tree view of directory contents in the AFS - shows hierarchical structure of files and folders",
8
- inputSchema: z.object({
9
- path: z.string().describe("The directory path to browse (e.g., '/', '/docs', '/src')"),
10
- options: z
11
- .object({
12
- maxDepth: z.number().optional().describe("Maximum depth to display in the tree view"),
13
- })
14
- .optional(),
15
- }),
16
- process: async (input) => {
17
- const { list, message } = await afs.list(input.path, input.options);
18
- const result = buildTreeView(list);
19
- return {
20
- status: "success",
21
- tool: "afs_list",
22
- path: input.path,
23
- options: input.options,
24
- message,
25
- result,
26
- };
27
- },
28
- }),
29
- FunctionAgent.from({
30
- name: "afs_search",
31
- description: "Find files by searching content using keywords - returns matching files with their paths",
32
- inputSchema: z.object({
33
- path: z.string().describe("The directory path to search in (e.g., '/', '/docs')"),
34
- query: z
35
- .string()
36
- .describe("Keywords to search for in file contents (e.g., 'function authentication', 'database config')"),
37
- options: z
38
- .object({
39
- limit: z.number().optional().describe("Maximum number of entries to return"),
40
- caseSensitive: z
41
- .boolean()
42
- .optional()
43
- .describe("Whether the search is case sensitive, default is false"),
44
- })
45
- .optional(),
46
- }),
47
- process: async (input) => {
48
- const result = await afs.search(input.path, input.query, input.options);
49
- return {
50
- status: "success",
51
- tool: "afs_search",
52
- path: input.path,
53
- query: input.query,
54
- options: input.options,
55
- ...result,
56
- };
57
- },
58
- }),
59
- FunctionAgent.from({
60
- name: "afs_read",
61
- description: `\
62
- Read file contents from the AFS - path must be an exact file path from list or search results
63
-
64
- Usage:
65
- - Use withLineNumbers=true to get line numbers for code reviews or edits
66
- `,
67
- inputSchema: z.object({
68
- path: z
69
- .string()
70
- .describe("Exact file path from list or search results (e.g., '/docs/api.md', '/src/utils/helper.js')"),
71
- withLineNumbers: z
72
- .boolean()
73
- .optional()
74
- .describe(`Whether to include line numbers in the returned content, default is false`),
75
- }),
76
- process: async (input) => {
77
- const result = await afs.read(input.path);
78
- let content = result.result?.content;
79
- if (input.withLineNumbers && typeof content === "string") {
80
- content = content
81
- .split("\n")
82
- .map((line, idx) => `${idx + 1}| ${line}`)
83
- .join("\n");
84
- }
85
- return {
86
- status: "success",
87
- tool: "afs_read",
88
- path: input.path,
89
- withLineNumbers: input.withLineNumbers,
90
- ...result,
91
- result: {
92
- ...result.result,
93
- content,
94
- },
95
- };
96
- },
97
- }),
98
- FunctionAgent.from({
99
- name: "afs_write",
100
- description: "Create or update a file in the AFS with new content - overwrites existing files",
101
- inputSchema: z.object({
102
- path: z
103
- .string()
104
- .describe("Full file path where to write content (e.g., '/docs/new-file.md', '/src/component.js')"),
105
- content: z.string().describe("The text content to write to the file"),
106
- }),
107
- process: async (input) => {
108
- const result = await afs.write(input.path, {
109
- content: input.content,
110
- });
111
- return {
112
- status: "success",
113
- tool: "afs_write",
114
- path: input.path,
115
- ...result,
116
- };
117
- },
118
- }),
119
- FunctionAgent.from({
120
- name: "afs_exec",
121
- description: "Execute a function or command available in the AFS modules",
122
- inputSchema: z.object({
123
- path: z.string().describe("The exact path to the executable entry in AFS"),
124
- args: z
125
- .string()
126
- .describe("JSON stringified arguments to pass to the executable, must be an object matching the input schema of the executable"),
127
- }),
128
- process: async ({ path, args }, options) => {
129
- return await afs.exec(path, JSON.parse(args), options);
130
- },
131
- }),
132
- ];
133
- }
134
- function buildTreeView(entries) {
135
- const tree = {};
136
- const entryMap = new Map();
137
- for (const entry of entries) {
138
- entryMap.set(entry.path, entry);
139
- const parts = entry.path.split("/").filter(Boolean);
140
- let current = tree;
141
- for (const part of parts) {
142
- if (!current[part]) {
143
- current[part] = {};
144
- }
145
- current = current[part];
146
- }
147
- }
148
- function renderTree(node, prefix = "", currentPath = "") {
149
- let result = "";
150
- const keys = Object.keys(node);
151
- keys.forEach((key, index) => {
152
- const isLast = index === keys.length - 1;
153
- const fullPath = currentPath ? `${currentPath}/${key}` : `/${key}`;
154
- const entry = entryMap.get(fullPath);
155
- // Build metadata suffix
156
- const metadataParts = [];
157
- // Children count
158
- const childrenCount = entry?.metadata?.childrenCount;
159
- if (childrenCount !== undefined && childrenCount > 0) {
160
- metadataParts.push(`${childrenCount} items`);
161
- }
162
- // Executable
163
- if (entry?.metadata?.execute) {
164
- metadataParts.push("executable");
165
- }
166
- const metadataSuffix = metadataParts.length > 0 ? ` [${metadataParts.join(", ")}]` : "";
167
- result += `${prefix}${isLast ? "└── " : "├── "}${key}${metadataSuffix}`;
168
- result += `\n`;
169
- result += renderTree(node[key], `${prefix}${isLast ? " " : "│ "}`, fullPath);
170
- });
171
- return result;
172
- }
173
- return renderTree(tree);
174
- }