deepfish-ai 2.0.8 → 2.0.9
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 +6 -4
- package/dist/generate-tool.md +120 -0
- package/dist/index.js +338 -211
- package/dist/serve/pm2-server.js +167 -56
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8403,10 +8403,10 @@ var require_lib = __commonJS({
|
|
|
8403
8403
|
exports2.analyse = analyse;
|
|
8404
8404
|
var detectFile = (filepath, opts = {}) => new Promise((resolve, reject) => {
|
|
8405
8405
|
let fd;
|
|
8406
|
-
const
|
|
8406
|
+
const fs24 = (0, node_1.default)();
|
|
8407
8407
|
const handler = (err, buffer) => {
|
|
8408
8408
|
if (fd) {
|
|
8409
|
-
|
|
8409
|
+
fs24.closeSync(fd);
|
|
8410
8410
|
}
|
|
8411
8411
|
if (err) {
|
|
8412
8412
|
reject(err);
|
|
@@ -8418,9 +8418,9 @@ var require_lib = __commonJS({
|
|
|
8418
8418
|
};
|
|
8419
8419
|
const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
|
|
8420
8420
|
if (sampleSize > 0) {
|
|
8421
|
-
fd =
|
|
8421
|
+
fd = fs24.openSync(filepath, "r");
|
|
8422
8422
|
let sample = Buffer.allocUnsafe(sampleSize);
|
|
8423
|
-
|
|
8423
|
+
fs24.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
|
|
8424
8424
|
if (err) {
|
|
8425
8425
|
handler(err, null);
|
|
8426
8426
|
} else {
|
|
@@ -8432,22 +8432,22 @@ var require_lib = __commonJS({
|
|
|
8432
8432
|
});
|
|
8433
8433
|
return;
|
|
8434
8434
|
}
|
|
8435
|
-
|
|
8435
|
+
fs24.readFile(filepath, handler);
|
|
8436
8436
|
});
|
|
8437
8437
|
exports2.detectFile = detectFile;
|
|
8438
8438
|
var detectFileSync = (filepath, opts = {}) => {
|
|
8439
|
-
const
|
|
8439
|
+
const fs24 = (0, node_1.default)();
|
|
8440
8440
|
if (opts && opts.sampleSize) {
|
|
8441
|
-
const fd =
|
|
8441
|
+
const fd = fs24.openSync(filepath, "r");
|
|
8442
8442
|
let sample = Buffer.allocUnsafe(opts.sampleSize);
|
|
8443
|
-
const bytesRead =
|
|
8443
|
+
const bytesRead = fs24.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
|
|
8444
8444
|
if (bytesRead < opts.sampleSize) {
|
|
8445
8445
|
sample = sample.subarray(0, bytesRead);
|
|
8446
8446
|
}
|
|
8447
|
-
|
|
8447
|
+
fs24.closeSync(fd);
|
|
8448
8448
|
return (0, exports2.detect)(sample);
|
|
8449
8449
|
}
|
|
8450
|
-
return (0, exports2.detect)(
|
|
8450
|
+
return (0, exports2.detect)(fs24.readFileSync(filepath));
|
|
8451
8451
|
};
|
|
8452
8452
|
exports2.detectFileSync = detectFileSync;
|
|
8453
8453
|
exports2.default = {
|
|
@@ -8938,8 +8938,8 @@ function registerModelsCommands(program) {
|
|
|
8938
8938
|
// src/cli/cli-core/skills.ts
|
|
8939
8939
|
var import_crypto6 = require("crypto");
|
|
8940
8940
|
var import_inquirer3 = __toESM(require("inquirer"));
|
|
8941
|
-
var
|
|
8942
|
-
var
|
|
8941
|
+
var import_fs_extra20 = __toESM(require("fs-extra"));
|
|
8942
|
+
var import_path20 = __toESM(require("path"));
|
|
8943
8943
|
|
|
8944
8944
|
// src/cli/cli-utils/init-config.ts
|
|
8945
8945
|
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
@@ -8996,12 +8996,12 @@ function getConfig() {
|
|
|
8996
8996
|
}
|
|
8997
8997
|
|
|
8998
8998
|
// src/cli/cli-utils/init-agent.ts
|
|
8999
|
-
var
|
|
9000
|
-
var
|
|
8999
|
+
var import_fs_extra19 = __toESM(require("fs-extra"));
|
|
9000
|
+
var import_path19 = __toESM(require("path"));
|
|
9001
9001
|
var import_crypto5 = require("crypto");
|
|
9002
9002
|
|
|
9003
9003
|
// src/agent/AIAgent/index.ts
|
|
9004
|
-
var
|
|
9004
|
+
var import_langchain19 = require("langchain");
|
|
9005
9005
|
var import_deepagents2 = require("deepagents");
|
|
9006
9006
|
|
|
9007
9007
|
// src/agent/AIAgent/utils/langgraph-checkpoint-filesystem/filesystem-saver.ts
|
|
@@ -10494,10 +10494,10 @@ function mergeDefs(...defs) {
|
|
|
10494
10494
|
function cloneDef(schema) {
|
|
10495
10495
|
return mergeDefs(schema._zod.def);
|
|
10496
10496
|
}
|
|
10497
|
-
function getElementAtPath(obj,
|
|
10498
|
-
if (!
|
|
10497
|
+
function getElementAtPath(obj, path22) {
|
|
10498
|
+
if (!path22)
|
|
10499
10499
|
return obj;
|
|
10500
|
-
return
|
|
10500
|
+
return path22.reduce((acc, key) => acc?.[key], obj);
|
|
10501
10501
|
}
|
|
10502
10502
|
function promiseAllObject(promisesObj) {
|
|
10503
10503
|
const keys = Object.keys(promisesObj);
|
|
@@ -10906,11 +10906,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
10906
10906
|
}
|
|
10907
10907
|
return false;
|
|
10908
10908
|
}
|
|
10909
|
-
function prefixIssues(
|
|
10909
|
+
function prefixIssues(path22, issues) {
|
|
10910
10910
|
return issues.map((iss) => {
|
|
10911
10911
|
var _a3;
|
|
10912
10912
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
10913
|
-
iss.path.unshift(
|
|
10913
|
+
iss.path.unshift(path22);
|
|
10914
10914
|
return iss;
|
|
10915
10915
|
});
|
|
10916
10916
|
}
|
|
@@ -11057,16 +11057,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
11057
11057
|
}
|
|
11058
11058
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
11059
11059
|
const fieldErrors = { _errors: [] };
|
|
11060
|
-
const processError = (error52,
|
|
11060
|
+
const processError = (error52, path22 = []) => {
|
|
11061
11061
|
for (const issue2 of error52.issues) {
|
|
11062
11062
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
11063
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
11063
|
+
issue2.errors.map((issues) => processError({ issues }, [...path22, ...issue2.path]));
|
|
11064
11064
|
} else if (issue2.code === "invalid_key") {
|
|
11065
|
-
processError({ issues: issue2.issues }, [...
|
|
11065
|
+
processError({ issues: issue2.issues }, [...path22, ...issue2.path]);
|
|
11066
11066
|
} else if (issue2.code === "invalid_element") {
|
|
11067
|
-
processError({ issues: issue2.issues }, [...
|
|
11067
|
+
processError({ issues: issue2.issues }, [...path22, ...issue2.path]);
|
|
11068
11068
|
} else {
|
|
11069
|
-
const fullpath = [...
|
|
11069
|
+
const fullpath = [...path22, ...issue2.path];
|
|
11070
11070
|
if (fullpath.length === 0) {
|
|
11071
11071
|
fieldErrors._errors.push(mapper(issue2));
|
|
11072
11072
|
} else {
|
|
@@ -11093,17 +11093,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
11093
11093
|
}
|
|
11094
11094
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
11095
11095
|
const result = { errors: [] };
|
|
11096
|
-
const processError = (error52,
|
|
11096
|
+
const processError = (error52, path22 = []) => {
|
|
11097
11097
|
var _a3, _b;
|
|
11098
11098
|
for (const issue2 of error52.issues) {
|
|
11099
11099
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
11100
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
11100
|
+
issue2.errors.map((issues) => processError({ issues }, [...path22, ...issue2.path]));
|
|
11101
11101
|
} else if (issue2.code === "invalid_key") {
|
|
11102
|
-
processError({ issues: issue2.issues }, [...
|
|
11102
|
+
processError({ issues: issue2.issues }, [...path22, ...issue2.path]);
|
|
11103
11103
|
} else if (issue2.code === "invalid_element") {
|
|
11104
|
-
processError({ issues: issue2.issues }, [...
|
|
11104
|
+
processError({ issues: issue2.issues }, [...path22, ...issue2.path]);
|
|
11105
11105
|
} else {
|
|
11106
|
-
const fullpath = [...
|
|
11106
|
+
const fullpath = [...path22, ...issue2.path];
|
|
11107
11107
|
if (fullpath.length === 0) {
|
|
11108
11108
|
result.errors.push(mapper(issue2));
|
|
11109
11109
|
continue;
|
|
@@ -11135,8 +11135,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
11135
11135
|
}
|
|
11136
11136
|
function toDotPath(_path) {
|
|
11137
11137
|
const segs = [];
|
|
11138
|
-
const
|
|
11139
|
-
for (const seg of
|
|
11138
|
+
const path22 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
11139
|
+
for (const seg of path22) {
|
|
11140
11140
|
if (typeof seg === "number")
|
|
11141
11141
|
segs.push(`[${seg}]`);
|
|
11142
11142
|
else if (typeof seg === "symbol")
|
|
@@ -23828,13 +23828,13 @@ function resolveRef(ref, ctx) {
|
|
|
23828
23828
|
if (!ref.startsWith("#")) {
|
|
23829
23829
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
23830
23830
|
}
|
|
23831
|
-
const
|
|
23832
|
-
if (
|
|
23831
|
+
const path22 = ref.slice(1).split("/").filter(Boolean);
|
|
23832
|
+
if (path22.length === 0) {
|
|
23833
23833
|
return ctx.rootSchema;
|
|
23834
23834
|
}
|
|
23835
23835
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
23836
|
-
if (
|
|
23837
|
-
const key =
|
|
23836
|
+
if (path22[0] === defsKey) {
|
|
23837
|
+
const key = path22[1];
|
|
23838
23838
|
if (!key || !ctx.defs[key]) {
|
|
23839
23839
|
throw new Error(`Reference not found: ${ref}`);
|
|
23840
23840
|
}
|
|
@@ -24247,6 +24247,7 @@ var import_eventemitter_super2 = require("eventemitter-super");
|
|
|
24247
24247
|
|
|
24248
24248
|
// src/agent/AIAgent/middleware/eventEmitMiddleware.ts
|
|
24249
24249
|
var import_langchain = require("langchain");
|
|
24250
|
+
var import_messages = require("@langchain/core/messages");
|
|
24250
24251
|
function createAgentEventMiddleware(emitter) {
|
|
24251
24252
|
return (0, import_langchain.createMiddleware)({
|
|
24252
24253
|
name: "AgentEventMiddleware",
|
|
@@ -24276,7 +24277,7 @@ function createAgentEventMiddleware(emitter) {
|
|
|
24276
24277
|
return await handler(request);
|
|
24277
24278
|
} catch (error51) {
|
|
24278
24279
|
emitter.emit("MODEL_ERROR" /* MODEL_ERROR */, error51);
|
|
24279
|
-
|
|
24280
|
+
return new import_messages.AIMessage(error51.message);
|
|
24280
24281
|
}
|
|
24281
24282
|
},
|
|
24282
24283
|
// Around each tool call
|
|
@@ -24291,7 +24292,7 @@ function createAgentEventMiddleware(emitter) {
|
|
|
24291
24292
|
} catch (err) {
|
|
24292
24293
|
emitter.emit("USE_TOOL_ERROR" /* USE_TOOL_ERROR */, toolCall.id, toolCall.name, err);
|
|
24293
24294
|
emitter.emit("USE_TOOL_AFTER" /* USE_TOOL_AFTER */, toolCall.id, toolCall.name, toolCall.args);
|
|
24294
|
-
|
|
24295
|
+
return new import_langchain.ToolMessage(err.message);
|
|
24295
24296
|
}
|
|
24296
24297
|
}
|
|
24297
24298
|
});
|
|
@@ -24403,12 +24404,12 @@ ${params.systemPrompt || `\u8FD9\u662FDeepfish Cli\u7CFB\u7EDF,\u4F60\u662F\u7CF
|
|
|
24403
24404
|
# \u6CE8\u610F\u6CE8\u610F\u4E8B\u9879:
|
|
24404
24405
|
1.\u5982\u679C\u4EFB\u52A1\u6BD4\u8F83\u590D\u6742\uFF0C\u5E94\u8BE5\u5148\u8FDB\u884C\u62C6\u5206\uFF0C\u5206\u89E3\u6210\u591A\u4E2A\u6B65\u9AA4\uFF0C\u521B\u5EFA\u5B50\u667A\u80FD\u4F53\u6765\u9010\u6B65\u5B8C\u6210\u3002
|
|
24405
24406
|
2.\u4E34\u65F6\u6587\u4EF6\u5FC5\u987B\u4F7F\u7528"tmp_"\u4F5C\u4E3A\u524D\u7F00\u547D\u540D\uFF0C\u5E76\u5728\u4EFB\u52A1\u7ED3\u675F\u540E\u5220\u9664\uFF0C\u4E0D\u80FD\u5728\u5DE5\u4F5C\u76EE\u5F55\u4E2D\u7559\u4E0B\u4EFB\u4F55\u4E34\u65F6\u6587\u4EF6\u3002
|
|
24406
|
-
3.\u5C3D\u91CF\u4F7F\u7528"execute_command"\u3001"execute_js_code"\u5DE5\u5177\u5B8C\u6210\u4EFB\u52A1
|
|
24407
|
+
3.\u5C3D\u91CF\u4F7F\u7528"execute_command"\u3001"execute_js_code"\u5DE5\u5177\u5B8C\u6210\u4EFB\u52A1
|
|
24408
|
+
4.\u786C\u6027\u89C4\u5219\uFF1A\u65E0\u8BBA\u6846\u67B6\u5185\u7F6E\u82F1\u6587\u6A21\u677F\uFF0C\u4F60\u7684\u6BCF\u4E00\u6B65\u601D\u8003\uFF08Thought\uFF09\u3001\u89C2\u5BDF\u5206\u6790\u3001\u7ED3\u8BBA\u56DE\u7B54\uFF0C**\u4E25\u683C\u4F7F\u7528\u7B80\u4F53\u4E2D\u6587**\uFF0C\u7981\u6B62\u82F1\u6587\u3002`}
|
|
24407
24409
|
|
|
24408
24410
|
# \u57FA\u7840\u73AF\u5883\u4FE1\u606F
|
|
24409
24411
|
\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1A${params.workspace}
|
|
24410
24412
|
\u64CD\u4F5C\u7CFB\u7EDF\u7C7B\u578B\uFF1A${params.osType}
|
|
24411
|
-
\u8BED\u8A00\u7C7B\u578B: \u4E0E\u7528\u6237\u8F93\u5165\u8BED\u8A00\u4E00\u81F4
|
|
24412
24413
|
|
|
24413
24414
|
${skillPrompt}
|
|
24414
24415
|
${memoryPrompt}
|
|
@@ -24422,12 +24423,12 @@ var subSystemPrompt = (workspace, osType, skills, excludeSkills) => {
|
|
|
24422
24423
|
### \u57FA\u7840\u73AF\u5883\u4FE1\u606F
|
|
24423
24424
|
\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1A${workspace}
|
|
24424
24425
|
\u64CD\u4F5C\u7CFB\u7EDF\u7C7B\u578B\uFF1A${osType}
|
|
24425
|
-
\u8BED\u8A00\u7C7B\u578B: \u4E0E\u7528\u6237\u8F93\u5165\u8BED\u8A00\u4E00\u81F4
|
|
24426
24426
|
|
|
24427
24427
|
\u6CE8\u610F:
|
|
24428
24428
|
1.\u5B50\u667A\u80FD\u4F53\u53EA\u80FD\u5B8C\u6210\u5355\u4E2A\u4EFB\u52A1,\u4E0D\u80FD\u521B\u5EFA\u65B0\u7684\u5B50\u667A\u80FD\u4F53\u3002
|
|
24429
24429
|
2.\u4E34\u65F6\u6587\u4EF6\u5FC5\u987B\u4F7F\u7528"tmp_"\u4F5C\u4E3A\u524D\u7F00\u547D\u540D\uFF0C\u5E76\u5728\u4EFB\u52A1\u7ED3\u675F\u540E\u5220\u9664\uFF0C\u4E0D\u80FD\u5728\u5DE5\u4F5C\u76EE\u5F55\u4E2D\u7559\u4E0B\u4EFB\u4F55\u4E34\u65F6\u6587\u4EF6\u3002
|
|
24430
24430
|
3.\u5C3D\u91CF\u4F7F\u7528"execute_command"\u3001"execute_js_code"\u5DE5\u5177\u5B8C\u6210\u4EFB\u52A1
|
|
24431
|
+
4.\u786C\u6027\u89C4\u5219\uFF1A\u65E0\u8BBA\u6846\u67B6\u5185\u7F6E\u82F1\u6587\u6A21\u677F\uFF0C\u4F60\u7684\u6BCF\u4E00\u6B65\u601D\u8003\uFF08Thought\uFF09\u3001\u89C2\u5BDF\u5206\u6790\u3001\u7ED3\u8BBA\u56DE\u7B54\uFF0C**\u4E25\u683C\u4F7F\u7528\u7B80\u4F53\u4E2D\u6587**\uFF0C\u7981\u6B62\u82F1\u6587\u3002
|
|
24431
24432
|
|
|
24432
24433
|
${skillPrompt}
|
|
24433
24434
|
`;
|
|
@@ -24688,7 +24689,41 @@ function toLangChainTool(func, description) {
|
|
|
24688
24689
|
});
|
|
24689
24690
|
}
|
|
24690
24691
|
function scanUserTools(excludeTools) {
|
|
24692
|
+
const files = _scanUserToolsFile();
|
|
24691
24693
|
const tools = [];
|
|
24694
|
+
files.forEach((toolFile) => {
|
|
24695
|
+
_loadToolsFromFile(toolFile.filePath, tools, excludeTools);
|
|
24696
|
+
});
|
|
24697
|
+
return tools;
|
|
24698
|
+
}
|
|
24699
|
+
function getUserToolList() {
|
|
24700
|
+
const files = _scanUserToolsFile();
|
|
24701
|
+
const toolOpts = [];
|
|
24702
|
+
files.forEach((toolFile) => {
|
|
24703
|
+
const toolModule = require(toolFile.filePath);
|
|
24704
|
+
const { functions, descriptions } = toolModule;
|
|
24705
|
+
descriptions.forEach((desc) => {
|
|
24706
|
+
if (!desc.type) {
|
|
24707
|
+
desc = {
|
|
24708
|
+
type: "function",
|
|
24709
|
+
function: desc
|
|
24710
|
+
};
|
|
24711
|
+
}
|
|
24712
|
+
const func = functions[desc.function.name];
|
|
24713
|
+
if (typeof func !== "function") {
|
|
24714
|
+
return;
|
|
24715
|
+
}
|
|
24716
|
+
toolOpts.push({
|
|
24717
|
+
name: desc.function.name,
|
|
24718
|
+
path: toolFile.filePath,
|
|
24719
|
+
dir: toolFile.dir
|
|
24720
|
+
});
|
|
24721
|
+
});
|
|
24722
|
+
});
|
|
24723
|
+
return toolOpts;
|
|
24724
|
+
}
|
|
24725
|
+
function _scanUserToolsFile() {
|
|
24726
|
+
const toolFiles = [];
|
|
24692
24727
|
const scanPaths = getScanDirPaths();
|
|
24693
24728
|
scanPaths.forEach((scanPath) => {
|
|
24694
24729
|
const toolsDir = import_path8.default.resolve(scanPath, "tools");
|
|
@@ -24702,26 +24737,35 @@ function scanUserTools(excludeTools) {
|
|
|
24702
24737
|
if (indexFile) {
|
|
24703
24738
|
const filePath = _scanDeepFishJsFile(import_path8.default.resolve(subDirPath, indexFile), indexFile);
|
|
24704
24739
|
if (filePath) {
|
|
24705
|
-
|
|
24740
|
+
toolFiles.push({
|
|
24741
|
+
filePath,
|
|
24742
|
+
dir: subDirPath
|
|
24743
|
+
});
|
|
24706
24744
|
}
|
|
24707
24745
|
} else {
|
|
24708
24746
|
subFiles.forEach((subFile) => {
|
|
24709
24747
|
const filePath = _scanDeepFishJsFile(import_path8.default.resolve(subDirPath, subFile), subFile);
|
|
24710
24748
|
if (filePath) {
|
|
24711
|
-
|
|
24749
|
+
toolFiles.push({
|
|
24750
|
+
filePath,
|
|
24751
|
+
dir: subDirPath
|
|
24752
|
+
});
|
|
24712
24753
|
}
|
|
24713
24754
|
});
|
|
24714
24755
|
}
|
|
24715
24756
|
} else {
|
|
24716
24757
|
const filePath = _scanDeepFishJsFile(toolsDir, file2);
|
|
24717
24758
|
if (filePath) {
|
|
24718
|
-
|
|
24759
|
+
toolFiles.push({
|
|
24760
|
+
filePath,
|
|
24761
|
+
dir: null
|
|
24762
|
+
});
|
|
24719
24763
|
}
|
|
24720
24764
|
}
|
|
24721
24765
|
});
|
|
24722
24766
|
}
|
|
24723
24767
|
});
|
|
24724
|
-
return
|
|
24768
|
+
return toolFiles;
|
|
24725
24769
|
}
|
|
24726
24770
|
function _scanDeepFishJsFile(filePath, fileName) {
|
|
24727
24771
|
if (fileName.endsWith(".js") || fileName.endsWith(".cjs")) {
|
|
@@ -25268,15 +25312,15 @@ async function grepFiles(query, cwd, includePattern = "**/*", isRegexp = false,
|
|
|
25268
25312
|
}
|
|
25269
25313
|
var grepTool = (0, import_langchain10.tool)(
|
|
25270
25314
|
async ({ query, pattern, cwd, includePattern, isRegexp, maxResults, includeHidden }) => safeTool(() => {
|
|
25271
|
-
const searchQuery = query
|
|
25315
|
+
const searchQuery = (query ?? pattern ?? "").trim();
|
|
25272
25316
|
if (!searchQuery) {
|
|
25273
|
-
|
|
25317
|
+
return '\u8BF7\u63D0\u4F9B query \u6216 pattern \u4E4B\u4E00\uFF1B\u4F8B\u5982 query: "foo" \u6216 pattern: "foo"';
|
|
25274
25318
|
}
|
|
25275
25319
|
return grepFiles(searchQuery, cwd, includePattern, isRegexp, maxResults, includeHidden);
|
|
25276
25320
|
}),
|
|
25277
25321
|
{
|
|
25278
25322
|
name: "grep_files",
|
|
25279
|
-
description: "\u5728\u6587\u672C\u6587\u4EF6\u4E2D\u641C\u7D22\u5185\u5BB9\uFF0C\u652F\u6301\u666E\u901A\u5B57\u7B26\u4E32\u6216\u6B63\u5219\u8868\u8FBE\u5F0F\uFF0C\u53EF\u7528 includePattern \u9650\u5B9A\u6587\u4EF6\u8303\u56F4\u3002query \u4E3A\u641C\u7D22\u5185\u5BB9\uFF1B\u517C\u5BB9 pattern \u4F5C\u4E3A query \u7684\u522B\u540D\u3002",
|
|
25323
|
+
description: "\u5728\u6587\u672C\u6587\u4EF6\u4E2D\u641C\u7D22\u5185\u5BB9\uFF0C\u652F\u6301\u666E\u901A\u5B57\u7B26\u4E32\u6216\u6B63\u5219\u8868\u8FBE\u5F0F\uFF0C\u53EF\u7528 includePattern \u9650\u5B9A\u6587\u4EF6\u8303\u56F4\u3002query \u4E3A\u641C\u7D22\u5185\u5BB9\uFF1B\u517C\u5BB9 pattern \u4F5C\u4E3A query \u7684\u522B\u540D\uFF1B\u5982\u679C\u672A\u63D0\u4F9B\u641C\u7D22\u8BCD\uFF0C\u4F1A\u8FD4\u56DE\u63D0\u793A\u3002",
|
|
25280
25324
|
schema: external_exports.object({
|
|
25281
25325
|
query: external_exports.string().optional().describe("\u8981\u641C\u7D22\u7684\u5B57\u7B26\u4E32\u6216\u6B63\u5219\u8868\u8FBE\u5F0F"),
|
|
25282
25326
|
pattern: external_exports.string().optional().describe("query \u7684\u517C\u5BB9\u522B\u540D\uFF0C\u8981\u641C\u7D22\u7684\u5B57\u7B26\u4E32\u6216\u6B63\u5219\u8868\u8FBE\u5F0F"),
|
|
@@ -25285,9 +25329,6 @@ var grepTool = (0, import_langchain10.tool)(
|
|
|
25285
25329
|
isRegexp: external_exports.boolean().default(false).describe("query/pattern \u662F\u5426\u4E3A\u6B63\u5219\u8868\u8FBE\u5F0F"),
|
|
25286
25330
|
maxResults: external_exports.number().default(100).describe("\u6700\u5927\u8FD4\u56DE\u5339\u914D\u6570\u91CF"),
|
|
25287
25331
|
includeHidden: external_exports.boolean().default(false).describe("\u662F\u5426\u5305\u542B\u9690\u85CF\u6587\u4EF6\u6216\u9690\u85CF\u76EE\u5F55")
|
|
25288
|
-
}).refine((input) => input.query || input.pattern, {
|
|
25289
|
-
message: "query \u6216 pattern \u81F3\u5C11\u9700\u8981\u63D0\u4F9B\u4E00\u4E2A",
|
|
25290
|
-
path: ["query"]
|
|
25291
25332
|
})
|
|
25292
25333
|
}
|
|
25293
25334
|
);
|
|
@@ -25584,6 +25625,124 @@ var writeFileTool = (0, import_langchain16.tool)(async ({ filePath, content, mod
|
|
|
25584
25625
|
})
|
|
25585
25626
|
});
|
|
25586
25627
|
|
|
25628
|
+
// src/agent/tools/getFishInfo.ts
|
|
25629
|
+
var import_langchain17 = require("langchain");
|
|
25630
|
+
|
|
25631
|
+
// src/cli/cli-help.ts
|
|
25632
|
+
var import_commander = require("commander");
|
|
25633
|
+
function helpInformation() {
|
|
25634
|
+
return `Usage: ai [options] [command]
|
|
25635
|
+
|
|
25636
|
+
Commands:
|
|
25637
|
+
ai "xxx" \u76F4\u63A5\u5411 AI \u53D1\u8D77\u4E00\u6B21\u4EFB\u52A1\u6216\u5BF9\u8BDD
|
|
25638
|
+
|
|
25639
|
+
# Configuration commands
|
|
25640
|
+
ai config edit \u6253\u5F00\u5168\u5C40\u914D\u7F6E\u6587\u4EF6\u8FDB\u884C\u7F16\u8F91
|
|
25641
|
+
ai config view \u67E5\u770B\u5F53\u524D\u5168\u5C40\u914D\u7F6E\u5185\u5BB9
|
|
25642
|
+
ai config reset \u91CD\u7F6E\u5168\u5C40\u914D\u7F6E\u4E3A\u9ED8\u8BA4\u503C
|
|
25643
|
+
ai config dir \u6253\u5F00\u6216\u8F93\u51FA\u5168\u5C40\u914D\u7F6E\u76EE\u5F55
|
|
25644
|
+
|
|
25645
|
+
# Model commands
|
|
25646
|
+
ai models add \u6DFB\u52A0\u4E00\u4E2A\u65B0\u7684\u6A21\u578B\u914D\u7F6E
|
|
25647
|
+
ai models ls \u67E5\u770B\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u5217\u8868
|
|
25648
|
+
ai models use <name> \u5207\u6362\u5F53\u524D\u9ED8\u8BA4\u4F7F\u7528\u7684\u6A21\u578B
|
|
25649
|
+
ai models del <name> \u5220\u9664\u6307\u5B9A\u540D\u79F0\u7684\u6A21\u578B\u914D\u7F6E
|
|
25650
|
+
|
|
25651
|
+
# Skill commands
|
|
25652
|
+
ai skills ls \u67E5\u770B\u5DF2\u5B89\u88C5\u6216\u5DF2\u914D\u7F6E\u7684\u6280\u80FD\u5217\u8868
|
|
25653
|
+
ai skills add <name> \u6DFB\u52A0\u6307\u5B9A\u540D\u79F0\u7684\u6280\u80FD
|
|
25654
|
+
ai skills del <index> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u6280\u80FD
|
|
25655
|
+
ai skills enable <name|index> \u542F\u7528\u6307\u5B9A\u540D\u79F0\u6216\u5E8F\u53F7\u7684\u6280\u80FD
|
|
25656
|
+
ai skills disable <name|index> \u7981\u7528\u6307\u5B9A\u540D\u79F0\u6216\u5E8F\u53F7\u7684\u6280\u80FD
|
|
25657
|
+
ai skills dir \u6253\u5F00\u6216\u8F93\u51FA\u6280\u80FD\u76EE\u5F55
|
|
25658
|
+
ai skills generate xxx \u6839\u636E\u63CF\u8FF0\u751F\u6210\u4E00\u4E2A\u65B0\u7684\u6280\u80FD\u6A21\u677F
|
|
25659
|
+
|
|
25660
|
+
# Tools commands
|
|
25661
|
+
ai tools dir \u6253\u5F00\u6216\u8F93\u51FA\u7528\u6237\u81EA\u5B9A\u4E49\u5DE5\u5177\u76EE\u5F55
|
|
25662
|
+
ai tools generate xxx \u6839\u636E\u63CF\u8FF0\u751F\u6210\u4E00\u4E2A\u65B0\u7684\u5DE5\u5177\u6A21\u677F
|
|
25663
|
+
|
|
25664
|
+
# Session commands
|
|
25665
|
+
ai session clear \u6E05\u7A7A\u5F53\u524D\u4F1A\u8BDD\u8BB0\u5F55
|
|
25666
|
+
ai session dir \u6253\u5F00\u6216\u8F93\u51FA\u4F1A\u8BDD\u6570\u636E\u76EE\u5F55
|
|
25667
|
+
|
|
25668
|
+
# Task commands
|
|
25669
|
+
ai task ls \u67E5\u770B\u5F53\u524D\u4EFB\u52A1\u961F\u5217
|
|
25670
|
+
ai task add <task> \u5411\u4EFB\u52A1\u961F\u5217\u6DFB\u52A0\u4E00\u4E2A\u540E\u7EED\u4EFB\u52A1
|
|
25671
|
+
ai task del <index> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u4EFB\u52A1
|
|
25672
|
+
ai task clear \u6E05\u7A7A\u5F53\u524D\u4EFB\u52A1\u961F\u5217
|
|
25673
|
+
|
|
25674
|
+
# MCP commands
|
|
25675
|
+
ai mcp edit \u6253\u5F00 MCP \u914D\u7F6E\u6587\u4EF6\u8FDB\u884C\u7F16\u8F91
|
|
25676
|
+
|
|
25677
|
+
# Serve commands
|
|
25678
|
+
ai serve \u542F\u52A8\u670D\u52A1\u6216\u8FDB\u5165\u670D\u52A1\u7BA1\u7406\u5165\u53E3
|
|
25679
|
+
ai serve start \u542F\u52A8\u540E\u53F0\u670D\u52A1
|
|
25680
|
+
ai serve stop \u505C\u6B62\u540E\u53F0\u670D\u52A1
|
|
25681
|
+
ai serve restart \u91CD\u542F\u540E\u53F0\u670D\u52A1
|
|
25682
|
+
|
|
25683
|
+
# Cache commands
|
|
25684
|
+
ai cache ls \u67E5\u770B\u5DF2\u7F13\u5B58\u7684\u5B66\u4E60\u5185\u5BB9\u5217\u8868
|
|
25685
|
+
ai cache edit <index|id> \u7F16\u8F91\u6307\u5B9A\u5E8F\u53F7\u6216 ID \u7684\u7F13\u5B58\u5185\u5BB9
|
|
25686
|
+
ai cache del <index|id> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u6216 ID \u7684\u7F13\u5B58\u5185\u5BB9
|
|
25687
|
+
`;
|
|
25688
|
+
}
|
|
25689
|
+
function registerHelpCommand(program) {
|
|
25690
|
+
program.helpInformation = helpInformation;
|
|
25691
|
+
program.command("help").description("Displaying help information").action(() => {
|
|
25692
|
+
logInfo(helpInformation());
|
|
25693
|
+
});
|
|
25694
|
+
}
|
|
25695
|
+
|
|
25696
|
+
// src/agent/tools/getFishInfo.ts
|
|
25697
|
+
var import_path16 = __toESM(require("path"));
|
|
25698
|
+
var import_fs_extra18 = __toESM(require("fs-extra"));
|
|
25699
|
+
var getFishCodePathTool = (0, import_langchain17.tool)(
|
|
25700
|
+
async () => safeTool(() => {
|
|
25701
|
+
const codePath = getCodePath();
|
|
25702
|
+
return { codePath };
|
|
25703
|
+
}),
|
|
25704
|
+
{
|
|
25705
|
+
name: "get_fish_code_path",
|
|
25706
|
+
description: "\u83B7\u53D6 Deepfish CLI \u7CFB\u7EDF\u7684\u4EE3\u7801\u6839\u76EE\u5F55\u8DEF\u5F84",
|
|
25707
|
+
schema: external_exports.object({})
|
|
25708
|
+
}
|
|
25709
|
+
);
|
|
25710
|
+
var getFishReadmeTool = (0, import_langchain17.tool)(
|
|
25711
|
+
async ({ lang }) => safeTool(() => {
|
|
25712
|
+
const codePath = getCodePath();
|
|
25713
|
+
const readmePath = lang === "en" ? import_path16.default.join(codePath, "README_EN.md") : import_path16.default.join(codePath, "README.md");
|
|
25714
|
+
const fallbackPath = lang === "en" ? import_path16.default.join(codePath, "README.md") : import_path16.default.join(codePath, "README_EN.md");
|
|
25715
|
+
let targetPath = readmePath;
|
|
25716
|
+
if (!import_fs_extra18.default.existsSync(targetPath)) {
|
|
25717
|
+
targetPath = fallbackPath;
|
|
25718
|
+
}
|
|
25719
|
+
if (!import_fs_extra18.default.existsSync(targetPath)) {
|
|
25720
|
+
return { error: "\u672A\u627E\u5230 README \u6587\u4EF6", readmePath: targetPath };
|
|
25721
|
+
}
|
|
25722
|
+
const content = import_fs_extra18.default.readFileSync(targetPath, "utf-8");
|
|
25723
|
+
return { readmePath: targetPath, content };
|
|
25724
|
+
}),
|
|
25725
|
+
{
|
|
25726
|
+
name: "get_fish_readme",
|
|
25727
|
+
description: "\u83B7\u53D6 Deepfish CLI \u7CFB\u7EDF\u7684 README \u6587\u4EF6\u5185\u5BB9\uFF0C\u7528\u4E8E\u4E86\u89E3\u7CFB\u7EDF\u7684\u529F\u80FD\u3001\u7528\u6CD5\u548C\u7279\u6027\u3002\u53EF\u9009\u53C2\u6570 lang \u6307\u5B9A\u8BED\u8A00\uFF08zh \u6216 en\uFF09\uFF0C\u9ED8\u8BA4\u4E2D\u6587\u3002",
|
|
25728
|
+
schema: external_exports.object({
|
|
25729
|
+
lang: external_exports.string().optional().default("zh").describe("\u8BED\u8A00\uFF0Czh \u4E3A\u4E2D\u6587 README\uFF0Cen \u4E3A\u82F1\u6587 README")
|
|
25730
|
+
})
|
|
25731
|
+
}
|
|
25732
|
+
);
|
|
25733
|
+
var getFishHelpTool = (0, import_langchain17.tool)(
|
|
25734
|
+
async () => safeTool(() => {
|
|
25735
|
+
const help = helpInformation();
|
|
25736
|
+
return { help };
|
|
25737
|
+
}),
|
|
25738
|
+
{
|
|
25739
|
+
name: "get_fish_help",
|
|
25740
|
+
description: "\u83B7\u53D6 Deepfish CLI \u7CFB\u7EDF\u7684\u6240\u6709\u53EF\u7528\u547D\u4EE4\u53CA\u4F7F\u7528\u8BF4\u660E\uFF0C\u5305\u62EC\u914D\u7F6E\u3001\u6A21\u578B\u3001\u6280\u80FD\u3001\u5DE5\u5177\u3001\u4F1A\u8BDD\u3001\u4EFB\u52A1\u3001MCP\u3001\u670D\u52A1\u3001\u7F13\u5B58\u7B49\u5B50\u547D\u4EE4\u7684\u8BE6\u7EC6\u7528\u6CD5",
|
|
25741
|
+
schema: external_exports.object({})
|
|
25742
|
+
}
|
|
25743
|
+
);
|
|
25744
|
+
var fishInfoTools = [getFishCodePathTool, getFishReadmeTool, getFishHelpTool];
|
|
25745
|
+
|
|
25587
25746
|
// src/agent/tools/index.ts
|
|
25588
25747
|
var builtinTools = [
|
|
25589
25748
|
taskTool,
|
|
@@ -25598,23 +25757,24 @@ var builtinTools = [
|
|
|
25598
25757
|
webFetchTool,
|
|
25599
25758
|
...packageTools,
|
|
25600
25759
|
...semanticMemoryTools,
|
|
25601
|
-
...learnTools
|
|
25760
|
+
...learnTools,
|
|
25761
|
+
...fishInfoTools
|
|
25602
25762
|
];
|
|
25603
25763
|
async function getTools(excludeTools, excludeMCP) {
|
|
25604
25764
|
return [...builtinTools, ...await scanUserTools(excludeTools), ...await scanUserMcp(excludeMCP)];
|
|
25605
25765
|
}
|
|
25606
25766
|
|
|
25607
25767
|
// src/agent/skills/index.ts
|
|
25608
|
-
var
|
|
25768
|
+
var import_path17 = __toESM(require("path"));
|
|
25609
25769
|
function getSkills() {
|
|
25610
|
-
return [...getRegisteredSkills(),
|
|
25770
|
+
return [...getRegisteredSkills(), import_path17.default.join(__dirname, "./view-learn-cache.md")];
|
|
25611
25771
|
}
|
|
25612
25772
|
|
|
25613
25773
|
// src/agent/AIAgent/index.ts
|
|
25614
25774
|
var import_os4 = __toESM(require("os"));
|
|
25615
25775
|
|
|
25616
25776
|
// src/agent/AIAgent/SubAgents/SubAIAgent.ts
|
|
25617
|
-
var
|
|
25777
|
+
var import_langchain18 = require("langchain");
|
|
25618
25778
|
var import_deepagents = require("deepagents");
|
|
25619
25779
|
var import_eventemitter_super = require("eventemitter-super");
|
|
25620
25780
|
var import_os3 = __toESM(require("os"));
|
|
@@ -25687,19 +25847,19 @@ var SubAIAgent = class _SubAIAgent extends import_eventemitter_super.EventEmitte
|
|
|
25687
25847
|
agentRulesPath: this.agentRulesPath,
|
|
25688
25848
|
excludeSkills: this.excludeSkills
|
|
25689
25849
|
}) : subSystemPrompt(this.workspace, import_os3.default.platform(), this.skills, this.excludeSkills);
|
|
25690
|
-
const agent = (0,
|
|
25850
|
+
const agent = (0, import_langchain18.createAgent)({
|
|
25691
25851
|
model,
|
|
25692
25852
|
checkpointer,
|
|
25693
25853
|
tools: this.tools,
|
|
25694
25854
|
contextSchema,
|
|
25695
25855
|
middleware: [
|
|
25696
25856
|
createAgentEventMiddleware(this),
|
|
25697
|
-
(0,
|
|
25857
|
+
(0, import_langchain18.summarizationMiddleware)({
|
|
25698
25858
|
model,
|
|
25699
25859
|
trigger: { tokens: this.opt.modelOpt.maxContextLength || 1e5 },
|
|
25700
25860
|
keep: { messages: 50 }
|
|
25701
25861
|
}),
|
|
25702
|
-
(0,
|
|
25862
|
+
(0, import_langchain18.humanInTheLoopMiddleware)({
|
|
25703
25863
|
interruptOn: {
|
|
25704
25864
|
install_package: {
|
|
25705
25865
|
allowedDecisions: ["approve", "reject"]
|
|
@@ -25707,7 +25867,7 @@ var SubAIAgent = class _SubAIAgent extends import_eventemitter_super.EventEmitte
|
|
|
25707
25867
|
readEmailTool: false
|
|
25708
25868
|
}
|
|
25709
25869
|
}),
|
|
25710
|
-
(0,
|
|
25870
|
+
(0, import_langchain18.todoListMiddleware)(),
|
|
25711
25871
|
(0, import_deepagents.createPatchToolCallsMiddleware)()
|
|
25712
25872
|
],
|
|
25713
25873
|
systemPrompt
|
|
@@ -25717,7 +25877,7 @@ var SubAIAgent = class _SubAIAgent extends import_eventemitter_super.EventEmitte
|
|
|
25717
25877
|
this.initEvents();
|
|
25718
25878
|
}
|
|
25719
25879
|
async execute(input) {
|
|
25720
|
-
const humanMessage = new
|
|
25880
|
+
const humanMessage = new import_langchain18.HumanMessage(input);
|
|
25721
25881
|
this.messages.push(humanMessage);
|
|
25722
25882
|
const stream = await this.agent.stream(
|
|
25723
25883
|
{ messages: this.messages },
|
|
@@ -25870,19 +26030,19 @@ var AIAgent = class extends import_eventemitter_super2.EventEmitterSuper {
|
|
|
25870
26030
|
agentId: external_exports.string().optional(),
|
|
25871
26031
|
curAgent: external_exports.object().optional()
|
|
25872
26032
|
});
|
|
25873
|
-
const agent = (0,
|
|
26033
|
+
const agent = (0, import_langchain19.createAgent)({
|
|
25874
26034
|
model,
|
|
25875
26035
|
checkpointer,
|
|
25876
26036
|
tools: this.tools,
|
|
25877
26037
|
contextSchema,
|
|
25878
26038
|
middleware: [
|
|
25879
26039
|
createAgentEventMiddleware(this),
|
|
25880
|
-
(0,
|
|
26040
|
+
(0, import_langchain19.summarizationMiddleware)({
|
|
25881
26041
|
model,
|
|
25882
26042
|
trigger: { tokens: this.opt.modelOpt.maxContextLength || 1e5 },
|
|
25883
26043
|
keep: { messages: 50 }
|
|
25884
26044
|
}),
|
|
25885
|
-
(0,
|
|
26045
|
+
(0, import_langchain19.humanInTheLoopMiddleware)({
|
|
25886
26046
|
interruptOn: {
|
|
25887
26047
|
install_package: {
|
|
25888
26048
|
allowedDecisions: ["approve", "reject"]
|
|
@@ -25890,7 +26050,7 @@ var AIAgent = class extends import_eventemitter_super2.EventEmitterSuper {
|
|
|
25890
26050
|
readEmailTool: false
|
|
25891
26051
|
}
|
|
25892
26052
|
}),
|
|
25893
|
-
(0,
|
|
26053
|
+
(0, import_langchain19.todoListMiddleware)(),
|
|
25894
26054
|
(0, import_deepagents2.createPatchToolCallsMiddleware)()
|
|
25895
26055
|
],
|
|
25896
26056
|
systemPrompt: getSystemPrompt({
|
|
@@ -25909,7 +26069,7 @@ var AIAgent = class extends import_eventemitter_super2.EventEmitterSuper {
|
|
|
25909
26069
|
this.initEvents();
|
|
25910
26070
|
}
|
|
25911
26071
|
async execute(input) {
|
|
25912
|
-
const humanMessage = new
|
|
26072
|
+
const humanMessage = new import_langchain19.HumanMessage(input);
|
|
25913
26073
|
this.messages.push(humanMessage);
|
|
25914
26074
|
const stream = await this.agent.stream(
|
|
25915
26075
|
{ messages: this.messages },
|
|
@@ -26094,12 +26254,12 @@ var AgentRoomClient = class {
|
|
|
26094
26254
|
};
|
|
26095
26255
|
|
|
26096
26256
|
// src/cli/cli-core/serve.ts
|
|
26097
|
-
var
|
|
26257
|
+
var import_path18 = __toESM(require("path"));
|
|
26098
26258
|
var import_pm2 = __toESM(require("pm2"));
|
|
26099
26259
|
var PM2_APP_NAME = "deepfish-ai-server";
|
|
26100
26260
|
function getPm2Config() {
|
|
26101
26261
|
const port = getServePort();
|
|
26102
|
-
const serverScript =
|
|
26262
|
+
const serverScript = import_path18.default.join(getCodePath(), "dist/serve/pm2-server");
|
|
26103
26263
|
return {
|
|
26104
26264
|
name: PM2_APP_NAME,
|
|
26105
26265
|
script: serverScript,
|
|
@@ -26111,8 +26271,8 @@ function getPm2Config() {
|
|
|
26111
26271
|
autorestart: true,
|
|
26112
26272
|
watch: false,
|
|
26113
26273
|
max_memory_restart: "1G",
|
|
26114
|
-
error_file:
|
|
26115
|
-
out_file:
|
|
26274
|
+
error_file: import_path18.default.join(getCodePath(), "logs", "pm2-error.log"),
|
|
26275
|
+
out_file: import_path18.default.join(getCodePath(), "logs", "pm2-out.log"),
|
|
26116
26276
|
log_date_format: "YYYY-MM-DD HH:mm:ss Z"
|
|
26117
26277
|
};
|
|
26118
26278
|
}
|
|
@@ -26344,20 +26504,20 @@ function removeSessionById(agentId) {
|
|
|
26344
26504
|
return;
|
|
26345
26505
|
}
|
|
26346
26506
|
const sessionDir = getSessionPath(agentId);
|
|
26347
|
-
|
|
26507
|
+
import_fs_extra19.default.removeSync(sessionDir);
|
|
26348
26508
|
const sessionsPath = getSessionsPath();
|
|
26349
|
-
const sessionsFilePath =
|
|
26350
|
-
if (!
|
|
26509
|
+
const sessionsFilePath = import_path19.default.join(sessionsPath, "sessions.json");
|
|
26510
|
+
if (!import_fs_extra19.default.pathExistsSync(sessionsFilePath)) {
|
|
26351
26511
|
logSuccess("Current session history cleared");
|
|
26352
26512
|
return;
|
|
26353
26513
|
}
|
|
26354
|
-
const content =
|
|
26514
|
+
const content = import_fs_extra19.default.readFileSync(sessionsFilePath, "utf-8");
|
|
26355
26515
|
const parsed = JSON.parse(content);
|
|
26356
26516
|
const sessions = Array.isArray(parsed) ? parsed : [];
|
|
26357
26517
|
const existingSessionIndex = sessions.findIndex((s) => s.id === agentId);
|
|
26358
26518
|
if (existingSessionIndex !== -1) {
|
|
26359
26519
|
sessions.splice(existingSessionIndex, 1);
|
|
26360
|
-
|
|
26520
|
+
import_fs_extra19.default.writeFileSync(sessionsFilePath, JSON.stringify(sessions, null, 2), "utf-8");
|
|
26361
26521
|
}
|
|
26362
26522
|
logSuccess("Current session history cleared");
|
|
26363
26523
|
}
|
|
@@ -26373,15 +26533,15 @@ function openSessionDir() {
|
|
|
26373
26533
|
}
|
|
26374
26534
|
function initSession() {
|
|
26375
26535
|
const sessionsPath = getSessionsPath();
|
|
26376
|
-
const sessionsFilePath =
|
|
26536
|
+
const sessionsFilePath = import_path19.default.join(sessionsPath, "sessions.json");
|
|
26377
26537
|
let sessions = [];
|
|
26378
|
-
if (
|
|
26379
|
-
const content =
|
|
26538
|
+
if (import_fs_extra19.default.pathExistsSync(sessionsFilePath)) {
|
|
26539
|
+
const content = import_fs_extra19.default.readFileSync(sessionsFilePath, "utf-8");
|
|
26380
26540
|
const parsed = JSON.parse(content);
|
|
26381
26541
|
sessions = Array.isArray(parsed) ? parsed : [];
|
|
26382
26542
|
} else {
|
|
26383
|
-
|
|
26384
|
-
|
|
26543
|
+
import_fs_extra19.default.ensureDirSync(sessionsPath);
|
|
26544
|
+
import_fs_extra19.default.writeFileSync(sessionsFilePath, "[]", "utf-8");
|
|
26385
26545
|
}
|
|
26386
26546
|
const workspace = getWorkspacePath();
|
|
26387
26547
|
const existingSession = sessions.find((s) => s.workspace === workspace);
|
|
@@ -26392,23 +26552,23 @@ function initSession() {
|
|
|
26392
26552
|
const agentId = (0, import_crypto5.randomUUID)();
|
|
26393
26553
|
const newSession = {
|
|
26394
26554
|
id: agentId,
|
|
26395
|
-
name:
|
|
26555
|
+
name: import_path19.default.basename(workspace),
|
|
26396
26556
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
26397
26557
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
26398
26558
|
workspace
|
|
26399
26559
|
};
|
|
26400
26560
|
sessions.push(newSession);
|
|
26401
|
-
|
|
26561
|
+
import_fs_extra19.default.writeFileSync(sessionsFilePath, JSON.stringify(sessions, null, 2), "utf-8");
|
|
26402
26562
|
initSessionDir(newSession.id);
|
|
26403
26563
|
return newSession;
|
|
26404
26564
|
}
|
|
26405
26565
|
function initSessionDir(agentId) {
|
|
26406
26566
|
const sessionDir = getSessionPath(agentId);
|
|
26407
|
-
|
|
26567
|
+
import_fs_extra19.default.ensureDirSync(sessionDir);
|
|
26408
26568
|
const mainSessionPath = `${sessionDir}/main-session/`;
|
|
26409
26569
|
const mainMsgQueuePath = `${sessionDir}/main-msg-queue.json`;
|
|
26410
|
-
|
|
26411
|
-
|
|
26570
|
+
import_fs_extra19.default.ensureDirSync(mainSessionPath);
|
|
26571
|
+
import_fs_extra19.default.ensureFileSync(mainMsgQueuePath);
|
|
26412
26572
|
}
|
|
26413
26573
|
function _getCurrentAIConfig(config2) {
|
|
26414
26574
|
const currentModelName = config2.currentModel;
|
|
@@ -26423,11 +26583,11 @@ function _getCurrentAIConfig(config2) {
|
|
|
26423
26583
|
}
|
|
26424
26584
|
function getAgentId() {
|
|
26425
26585
|
const sessionsPath = getSessionsPath();
|
|
26426
|
-
const sessionsFilePath =
|
|
26427
|
-
if (!
|
|
26586
|
+
const sessionsFilePath = import_path19.default.join(sessionsPath, "sessions.json");
|
|
26587
|
+
if (!import_fs_extra19.default.pathExistsSync(sessionsFilePath)) {
|
|
26428
26588
|
return;
|
|
26429
26589
|
}
|
|
26430
|
-
const content =
|
|
26590
|
+
const content = import_fs_extra19.default.readFileSync(sessionsFilePath, "utf-8");
|
|
26431
26591
|
const parsed = JSON.parse(content);
|
|
26432
26592
|
const sessions = Array.isArray(parsed) ? parsed : [];
|
|
26433
26593
|
const workspace = getWorkspacePath();
|
|
@@ -26455,8 +26615,8 @@ function handleSkillsLs() {
|
|
|
26455
26615
|
async function handleSkillsAdd(name) {
|
|
26456
26616
|
logInfo(`Adding skill: ${name}`);
|
|
26457
26617
|
const workspace = getWorkspacePath();
|
|
26458
|
-
const skillDir =
|
|
26459
|
-
if (!
|
|
26618
|
+
const skillDir = import_path20.default.join(workspace, name);
|
|
26619
|
+
if (!import_fs_extra20.default.existsSync(skillDir)) {
|
|
26460
26620
|
logError(`Skill directory does not exist: ${skillDir}`);
|
|
26461
26621
|
return;
|
|
26462
26622
|
}
|
|
@@ -26472,16 +26632,16 @@ async function handleSkillsAdd(name) {
|
|
|
26472
26632
|
}
|
|
26473
26633
|
]);
|
|
26474
26634
|
const homePath = getHomePath();
|
|
26475
|
-
const globalSkillDir =
|
|
26476
|
-
const localSkillDir =
|
|
26635
|
+
const globalSkillDir = import_path20.default.join(homePath, "skills");
|
|
26636
|
+
const localSkillDir = import_path20.default.join(workspace, ".deepfish-ai", "skills");
|
|
26477
26637
|
if (scope === "local") {
|
|
26478
|
-
|
|
26638
|
+
import_fs_extra20.default.ensureDirSync(localSkillDir);
|
|
26479
26639
|
} else {
|
|
26480
|
-
|
|
26640
|
+
import_fs_extra20.default.ensureDirSync(globalSkillDir);
|
|
26481
26641
|
}
|
|
26482
26642
|
const targetDir = scope === "local" ? localSkillDir : globalSkillDir;
|
|
26483
|
-
const targetPath =
|
|
26484
|
-
if (
|
|
26643
|
+
const targetPath = import_path20.default.join(targetDir, name);
|
|
26644
|
+
if (import_fs_extra20.default.existsSync(targetPath)) {
|
|
26485
26645
|
const { overwrite } = await import_inquirer3.default.prompt([
|
|
26486
26646
|
{
|
|
26487
26647
|
type: "confirm",
|
|
@@ -26494,9 +26654,9 @@ async function handleSkillsAdd(name) {
|
|
|
26494
26654
|
logWarning("Add cancelled");
|
|
26495
26655
|
return;
|
|
26496
26656
|
}
|
|
26497
|
-
|
|
26657
|
+
import_fs_extra20.default.removeSync(targetPath);
|
|
26498
26658
|
}
|
|
26499
|
-
|
|
26659
|
+
import_fs_extra20.default.moveSync(skillDir, targetPath, { overwrite: true });
|
|
26500
26660
|
logSuccess(`Skill ${scope === "local" ? "locally" : "globally"} added: ${targetPath}`);
|
|
26501
26661
|
_updateRegister(targetDir);
|
|
26502
26662
|
}
|
|
@@ -26508,13 +26668,13 @@ function handleSkillsDel(index) {
|
|
|
26508
26668
|
return;
|
|
26509
26669
|
}
|
|
26510
26670
|
const skill = skills[skillIndex];
|
|
26511
|
-
|
|
26671
|
+
import_fs_extra20.default.removeSync(skill.skillPath);
|
|
26512
26672
|
const skillDir = skill.skillDir;
|
|
26513
|
-
const registerPath =
|
|
26514
|
-
if (
|
|
26515
|
-
let register =
|
|
26673
|
+
const registerPath = import_path20.default.join(skillDir, "skills", "register.json");
|
|
26674
|
+
if (import_fs_extra20.default.existsSync(registerPath)) {
|
|
26675
|
+
let register = import_fs_extra20.default.readJSONSync(registerPath);
|
|
26516
26676
|
register = register.filter((item) => item.skillPath !== skill.skillPath);
|
|
26517
|
-
|
|
26677
|
+
import_fs_extra20.default.writeJSONSync(registerPath, register, { spaces: 2 });
|
|
26518
26678
|
}
|
|
26519
26679
|
logSuccess(`Skill deleted: ${skill.name}`);
|
|
26520
26680
|
}
|
|
@@ -26528,8 +26688,8 @@ function handleSkillsEnable(index) {
|
|
|
26528
26688
|
const skill = skills[skillIndex];
|
|
26529
26689
|
skill.isEnabled = true;
|
|
26530
26690
|
const skillDir = skill.skillDir;
|
|
26531
|
-
const registerPath =
|
|
26532
|
-
|
|
26691
|
+
const registerPath = import_path20.default.join(skillDir, "skills", "register.json");
|
|
26692
|
+
import_fs_extra20.default.writeJSONSync(
|
|
26533
26693
|
registerPath,
|
|
26534
26694
|
skills.filter((item) => item.skillDir === skillDir),
|
|
26535
26695
|
{ spaces: 2 }
|
|
@@ -26546,8 +26706,8 @@ function handleSkillsDisable(index) {
|
|
|
26546
26706
|
const skill = skills[skillIndex];
|
|
26547
26707
|
skill.isEnabled = false;
|
|
26548
26708
|
const skillDir = skill.skillDir;
|
|
26549
|
-
const registerPath =
|
|
26550
|
-
|
|
26709
|
+
const registerPath = import_path20.default.join(skillDir, "skills", "register.json");
|
|
26710
|
+
import_fs_extra20.default.writeJSONSync(
|
|
26551
26711
|
registerPath,
|
|
26552
26712
|
skills.filter((item) => item.skillDir === skillDir),
|
|
26553
26713
|
{ spaces: 2 }
|
|
@@ -26557,7 +26717,7 @@ function handleSkillsDisable(index) {
|
|
|
26557
26717
|
function handleSkillsDir() {
|
|
26558
26718
|
logInfo("Opening skills directory");
|
|
26559
26719
|
const homePath = getHomePath();
|
|
26560
|
-
const globalSkillDir =
|
|
26720
|
+
const globalSkillDir = import_path20.default.join(homePath, "skills");
|
|
26561
26721
|
openDirectory(globalSkillDir);
|
|
26562
26722
|
}
|
|
26563
26723
|
async function handleSkillsGenerate(target) {
|
|
@@ -26581,7 +26741,7 @@ async function handleSkillsGenerate(target) {
|
|
|
26581
26741
|
logError("Failed to start service, please check config or port availability");
|
|
26582
26742
|
return;
|
|
26583
26743
|
}
|
|
26584
|
-
const generateSkillPath =
|
|
26744
|
+
const generateSkillPath = import_path20.default.join(__dirname, "./generate-skill.md");
|
|
26585
26745
|
const agent = await initAgent(config2, [generateSkillPath]);
|
|
26586
26746
|
const prompt = `\u8BF7\u6839\u636E\u4EE5\u4E0B\u9700\u6C42\u751F\u6210\u4E00\u4E2ASkill\u6A21\u5757\uFF1A${target}
|
|
26587
26747
|
|
|
@@ -26599,13 +26759,13 @@ async function handleSkillsGenerate(target) {
|
|
|
26599
26759
|
}
|
|
26600
26760
|
function _scanSkills(skillsDir) {
|
|
26601
26761
|
const skills = [];
|
|
26602
|
-
if (
|
|
26603
|
-
const files =
|
|
26762
|
+
if (import_fs_extra20.default.existsSync(skillsDir)) {
|
|
26763
|
+
const files = import_fs_extra20.default.readdirSync(skillsDir);
|
|
26604
26764
|
files.forEach((file2) => {
|
|
26605
|
-
const filePath =
|
|
26606
|
-
if (
|
|
26607
|
-
const skillMdPath =
|
|
26608
|
-
if (
|
|
26765
|
+
const filePath = import_path20.default.resolve(skillsDir, file2);
|
|
26766
|
+
if (import_fs_extra20.default.statSync(filePath).isDirectory()) {
|
|
26767
|
+
const skillMdPath = import_path20.default.resolve(filePath, "SKILL.md");
|
|
26768
|
+
if (import_fs_extra20.default.existsSync(skillMdPath)) {
|
|
26609
26769
|
skills.push(filePath);
|
|
26610
26770
|
}
|
|
26611
26771
|
}
|
|
@@ -26614,17 +26774,17 @@ function _scanSkills(skillsDir) {
|
|
|
26614
26774
|
return skills;
|
|
26615
26775
|
}
|
|
26616
26776
|
function _updateRegister(skillsDir) {
|
|
26617
|
-
const registerPath =
|
|
26618
|
-
if (
|
|
26619
|
-
|
|
26620
|
-
} else if (!
|
|
26777
|
+
const registerPath = import_path20.default.resolve(skillsDir, "register.json");
|
|
26778
|
+
if (import_fs_extra20.default.existsSync(skillsDir) && !import_fs_extra20.default.existsSync(registerPath)) {
|
|
26779
|
+
import_fs_extra20.default.writeJSONSync(registerPath, [], { spaces: 2 });
|
|
26780
|
+
} else if (!import_fs_extra20.default.existsSync(skillsDir)) {
|
|
26621
26781
|
return;
|
|
26622
26782
|
}
|
|
26623
26783
|
const skills = _scanSkills(skillsDir);
|
|
26624
|
-
let register =
|
|
26784
|
+
let register = import_fs_extra20.default.readJSONSync(registerPath);
|
|
26625
26785
|
const newRegister = [];
|
|
26626
26786
|
skills.forEach((skillPath) => {
|
|
26627
|
-
const skillName =
|
|
26787
|
+
const skillName = import_path20.default.basename(skillPath);
|
|
26628
26788
|
const existItem = register.find((item) => item.skillPath === skillPath);
|
|
26629
26789
|
if (!existItem) {
|
|
26630
26790
|
newRegister.push({
|
|
@@ -26637,16 +26797,16 @@ function _updateRegister(skillsDir) {
|
|
|
26637
26797
|
});
|
|
26638
26798
|
register = register.filter((item) => skills.includes(item.skillPath));
|
|
26639
26799
|
register.push(...newRegister);
|
|
26640
|
-
|
|
26800
|
+
import_fs_extra20.default.writeJSONSync(registerPath, register, { spaces: 2 });
|
|
26641
26801
|
}
|
|
26642
26802
|
function getRegisteredSkills() {
|
|
26643
26803
|
const scanPaths = getScanDirPaths();
|
|
26644
26804
|
const skills = [];
|
|
26645
26805
|
scanPaths.forEach((scanPath) => {
|
|
26646
26806
|
_updateRegister(scanPath);
|
|
26647
|
-
const registerPath =
|
|
26648
|
-
if (
|
|
26649
|
-
const register =
|
|
26807
|
+
const registerPath = import_path20.default.join(scanPath, "skills", "register.json");
|
|
26808
|
+
if (import_fs_extra20.default.existsSync(registerPath)) {
|
|
26809
|
+
const register = import_fs_extra20.default.readJSONSync(registerPath);
|
|
26650
26810
|
register.forEach((item) => {
|
|
26651
26811
|
if (item.isEnabled) {
|
|
26652
26812
|
skills.push(item.skillPath);
|
|
@@ -26658,10 +26818,10 @@ function getRegisteredSkills() {
|
|
|
26658
26818
|
}
|
|
26659
26819
|
function _getSkillList(skillsDir) {
|
|
26660
26820
|
let allSkills = [];
|
|
26661
|
-
const registerPath =
|
|
26662
|
-
if (
|
|
26821
|
+
const registerPath = import_path20.default.join(skillsDir, "skills", "register.json");
|
|
26822
|
+
if (import_fs_extra20.default.existsSync(registerPath)) {
|
|
26663
26823
|
_updateRegister(skillsDir);
|
|
26664
|
-
const register =
|
|
26824
|
+
const register = import_fs_extra20.default.readJSONSync(registerPath);
|
|
26665
26825
|
allSkills = allSkills.concat(register);
|
|
26666
26826
|
}
|
|
26667
26827
|
return allSkills;
|
|
@@ -26694,8 +26854,38 @@ function registerSkillsCommands(program) {
|
|
|
26694
26854
|
|
|
26695
26855
|
// src/cli/cli-core/tools.ts
|
|
26696
26856
|
var import_inquirer4 = __toESM(require("inquirer"));
|
|
26697
|
-
var
|
|
26698
|
-
var
|
|
26857
|
+
var import_fs_extra21 = __toESM(require("fs-extra"));
|
|
26858
|
+
var import_path21 = __toESM(require("path"));
|
|
26859
|
+
function handleToolsLs() {
|
|
26860
|
+
const toolNames = getUserToolList().map((tool17) => {
|
|
26861
|
+
return tool17.name;
|
|
26862
|
+
});
|
|
26863
|
+
logInfo("=".repeat(50));
|
|
26864
|
+
if (toolNames.length === 0) {
|
|
26865
|
+
logInfo("No tools registered yet");
|
|
26866
|
+
} else {
|
|
26867
|
+
toolNames.forEach((name, index) => {
|
|
26868
|
+
logInfo(`[${index}] ${name}`);
|
|
26869
|
+
});
|
|
26870
|
+
}
|
|
26871
|
+
logInfo("=".repeat(50));
|
|
26872
|
+
}
|
|
26873
|
+
function handleToolsDel(index) {
|
|
26874
|
+
const toolList = getUserToolList();
|
|
26875
|
+
const toolIndex = parseInt(index, 10);
|
|
26876
|
+
if (isNaN(toolIndex) || toolIndex < 0 || toolIndex >= toolList.length) {
|
|
26877
|
+
logError("Invalid tool index");
|
|
26878
|
+
return;
|
|
26879
|
+
}
|
|
26880
|
+
const tool17 = toolList[toolIndex];
|
|
26881
|
+
if (tool17.dir) {
|
|
26882
|
+
import_fs_extra21.default.removeSync(tool17.dir);
|
|
26883
|
+
logSuccess(`Tool directory deleted: ${tool17.dir}`);
|
|
26884
|
+
} else {
|
|
26885
|
+
import_fs_extra21.default.removeSync(tool17.path);
|
|
26886
|
+
logSuccess(`Tool file deleted: ${tool17.path}`);
|
|
26887
|
+
}
|
|
26888
|
+
}
|
|
26699
26889
|
function handleToolsDir() {
|
|
26700
26890
|
const toolsPath = getToolsPath();
|
|
26701
26891
|
openDirectory(toolsPath);
|
|
@@ -26704,8 +26894,8 @@ function handleToolsDir() {
|
|
|
26704
26894
|
async function handleToolsAdd(name) {
|
|
26705
26895
|
logInfo(`Adding tool: ${name}`);
|
|
26706
26896
|
const workspace = getWorkspacePath();
|
|
26707
|
-
const toolDir =
|
|
26708
|
-
if (!
|
|
26897
|
+
const toolDir = import_path21.default.join(workspace, name);
|
|
26898
|
+
if (!import_fs_extra21.default.existsSync(toolDir)) {
|
|
26709
26899
|
logError(`Tool directory does not exist: ${toolDir}`);
|
|
26710
26900
|
return;
|
|
26711
26901
|
}
|
|
@@ -26721,12 +26911,12 @@ async function handleToolsAdd(name) {
|
|
|
26721
26911
|
}
|
|
26722
26912
|
]);
|
|
26723
26913
|
const homePath = getHomePath();
|
|
26724
|
-
const globalToolDir =
|
|
26725
|
-
const localToolDir =
|
|
26914
|
+
const globalToolDir = import_path21.default.join(homePath, "tools");
|
|
26915
|
+
const localToolDir = import_path21.default.join(workspace, ".deepfish-ai", "tools");
|
|
26726
26916
|
const targetDir = scope === "local" ? localToolDir : globalToolDir;
|
|
26727
|
-
const targetPath =
|
|
26728
|
-
|
|
26729
|
-
if (
|
|
26917
|
+
const targetPath = import_path21.default.join(targetDir, name);
|
|
26918
|
+
import_fs_extra21.default.ensureDirSync(targetDir);
|
|
26919
|
+
if (import_fs_extra21.default.existsSync(targetPath)) {
|
|
26730
26920
|
const { overwrite } = await import_inquirer4.default.prompt([
|
|
26731
26921
|
{
|
|
26732
26922
|
type: "confirm",
|
|
@@ -26739,9 +26929,9 @@ async function handleToolsAdd(name) {
|
|
|
26739
26929
|
logWarning("Add cancelled");
|
|
26740
26930
|
return;
|
|
26741
26931
|
}
|
|
26742
|
-
|
|
26932
|
+
import_fs_extra21.default.removeSync(targetPath);
|
|
26743
26933
|
}
|
|
26744
|
-
|
|
26934
|
+
import_fs_extra21.default.moveSync(toolDir, targetPath, { overwrite: true });
|
|
26745
26935
|
logSuccess(`Tool ${scope === "local" ? "locally" : "globally"} added: ${targetPath}`);
|
|
26746
26936
|
}
|
|
26747
26937
|
async function handleToolsGenerate(target) {
|
|
@@ -26765,7 +26955,7 @@ async function handleToolsGenerate(target) {
|
|
|
26765
26955
|
logError("Failed to start service, please check config or port availability");
|
|
26766
26956
|
return;
|
|
26767
26957
|
}
|
|
26768
|
-
const generateSkillPath =
|
|
26958
|
+
const generateSkillPath = import_path21.default.join(__dirname, "./generate-tool.md");
|
|
26769
26959
|
const agent = await initAgent(config2, [generateSkillPath]);
|
|
26770
26960
|
const prompt = `Please use the "generate-tool" SKILL to generate a tool module according to the following requirements: ${target}
|
|
26771
26961
|
|
|
@@ -26784,8 +26974,10 @@ async function handleToolsGenerate(target) {
|
|
|
26784
26974
|
// src/cli/cli-tools.ts
|
|
26785
26975
|
function registerToolsCommands(program) {
|
|
26786
26976
|
const tools = program.command("tools");
|
|
26977
|
+
tools.command("ls").description("\u5217\u51FA\u6240\u6709\u5DE5\u5177").action(handleToolsLs);
|
|
26787
26978
|
tools.command("dir").description("\u6253\u5F00\u5DE5\u5177\u76EE\u5F55").action(handleToolsDir);
|
|
26788
26979
|
tools.command("add <name>").description("\u6DFB\u52A0\u672C\u5730\u5DE5\u5177\u76EE\u5F55").action(handleToolsAdd);
|
|
26980
|
+
tools.command("del <index>").description("\u6309\u7D22\u5F15\u5220\u9664\u5DE5\u5177").action(handleToolsDel);
|
|
26789
26981
|
tools.command("generate <target>").description("\u751F\u6210\u5DE5\u5177").action(handleToolsGenerate);
|
|
26790
26982
|
}
|
|
26791
26983
|
|
|
@@ -26891,10 +27083,10 @@ function handleTaskClear() {
|
|
|
26891
27083
|
|
|
26892
27084
|
// src/cli/cli-task.ts
|
|
26893
27085
|
function registerTaskCommands(program) {
|
|
26894
|
-
const task = program.command("
|
|
27086
|
+
const task = program.command("tasks");
|
|
26895
27087
|
task.command("ls").description("\u5217\u51FA\u6240\u6709\u4EFB\u52A1").action(handleTaskLs);
|
|
26896
27088
|
task.command("add <task>").description("\u6DFB\u52A0\u4EFB\u52A1").action(handleTaskAdd);
|
|
26897
|
-
task.command("del <index>").description("\u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u4EFB\
|
|
27089
|
+
task.command("del <index>").description("\u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u4EFB\u52A1").action(handleTaskDel);
|
|
26898
27090
|
task.command("clear").description("\u6E05\u9664\u6240\u6709\u4EFB\u52A1").action(handleTaskClear);
|
|
26899
27091
|
}
|
|
26900
27092
|
|
|
@@ -26911,7 +27103,7 @@ function registerMcpCommands(program) {
|
|
|
26911
27103
|
}
|
|
26912
27104
|
|
|
26913
27105
|
// src/cli/cli-core/input.ts
|
|
26914
|
-
var
|
|
27106
|
+
var import_fs_extra22 = __toESM(require("fs-extra"));
|
|
26915
27107
|
var readline = __toESM(require("readline"));
|
|
26916
27108
|
async function handleInput(args) {
|
|
26917
27109
|
const input = args.join(" ");
|
|
@@ -26921,7 +27113,7 @@ async function handleInput(args) {
|
|
|
26921
27113
|
}
|
|
26922
27114
|
try {
|
|
26923
27115
|
const configPath = getConfigPath();
|
|
26924
|
-
if (!
|
|
27116
|
+
if (!import_fs_extra22.default.pathExistsSync(configPath)) {
|
|
26925
27117
|
logError("Config file not found, please run init first");
|
|
26926
27118
|
return;
|
|
26927
27119
|
}
|
|
@@ -26958,7 +27150,7 @@ async function handleInput(args) {
|
|
|
26958
27150
|
async function multiInput() {
|
|
26959
27151
|
try {
|
|
26960
27152
|
const configPath = getConfigPath();
|
|
26961
|
-
if (!
|
|
27153
|
+
if (!import_fs_extra22.default.pathExistsSync(configPath)) {
|
|
26962
27154
|
logError("Config file not found, please run init first");
|
|
26963
27155
|
return;
|
|
26964
27156
|
}
|
|
@@ -27028,7 +27220,7 @@ function registerInputCommand(program) {
|
|
|
27028
27220
|
}
|
|
27029
27221
|
|
|
27030
27222
|
// src/cli/cli-core/cache.ts
|
|
27031
|
-
var
|
|
27223
|
+
var import_path22 = __toESM(require("path"));
|
|
27032
27224
|
var userCache2 = new UserCache();
|
|
27033
27225
|
function resolveId(input) {
|
|
27034
27226
|
const index = Number(input);
|
|
@@ -27062,7 +27254,7 @@ function handleCacheList() {
|
|
|
27062
27254
|
function handleCacheEdit(input) {
|
|
27063
27255
|
const id = resolveId(input);
|
|
27064
27256
|
if (!id) return;
|
|
27065
|
-
const filePath =
|
|
27257
|
+
const filePath = import_path22.default.join(getUserStorePath(), `${id}.md`);
|
|
27066
27258
|
editFile(filePath);
|
|
27067
27259
|
}
|
|
27068
27260
|
function handleCacheDel(input) {
|
|
@@ -27094,71 +27286,6 @@ function registerCommonFlags(program) {
|
|
|
27094
27286
|
program.version(handleVersion(), "-v, --version", "Show version");
|
|
27095
27287
|
}
|
|
27096
27288
|
|
|
27097
|
-
// src/cli/cli-help.ts
|
|
27098
|
-
var import_commander = require("commander");
|
|
27099
|
-
function helpInformation() {
|
|
27100
|
-
return `Usage: ai [options] [command]
|
|
27101
|
-
|
|
27102
|
-
Commands:
|
|
27103
|
-
ai "xxx" \u76F4\u63A5\u5411 AI \u53D1\u8D77\u4E00\u6B21\u4EFB\u52A1\u6216\u5BF9\u8BDD
|
|
27104
|
-
|
|
27105
|
-
# Configuration commands
|
|
27106
|
-
ai config edit \u6253\u5F00\u5168\u5C40\u914D\u7F6E\u6587\u4EF6\u8FDB\u884C\u7F16\u8F91
|
|
27107
|
-
ai config view \u67E5\u770B\u5F53\u524D\u5168\u5C40\u914D\u7F6E\u5185\u5BB9
|
|
27108
|
-
ai config reset \u91CD\u7F6E\u5168\u5C40\u914D\u7F6E\u4E3A\u9ED8\u8BA4\u503C
|
|
27109
|
-
ai config dir \u6253\u5F00\u6216\u8F93\u51FA\u5168\u5C40\u914D\u7F6E\u76EE\u5F55
|
|
27110
|
-
|
|
27111
|
-
# Model commands
|
|
27112
|
-
ai models add \u6DFB\u52A0\u4E00\u4E2A\u65B0\u7684\u6A21\u578B\u914D\u7F6E
|
|
27113
|
-
ai models ls \u67E5\u770B\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u5217\u8868
|
|
27114
|
-
ai models use <name> \u5207\u6362\u5F53\u524D\u9ED8\u8BA4\u4F7F\u7528\u7684\u6A21\u578B
|
|
27115
|
-
ai models del <name> \u5220\u9664\u6307\u5B9A\u540D\u79F0\u7684\u6A21\u578B\u914D\u7F6E
|
|
27116
|
-
|
|
27117
|
-
# Skill commands
|
|
27118
|
-
ai skills ls \u67E5\u770B\u5DF2\u5B89\u88C5\u6216\u5DF2\u914D\u7F6E\u7684\u6280\u80FD\u5217\u8868
|
|
27119
|
-
ai skills add <name> \u6DFB\u52A0\u6307\u5B9A\u540D\u79F0\u7684\u6280\u80FD
|
|
27120
|
-
ai skills del <index> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u6280\u80FD
|
|
27121
|
-
ai skills enable <name|index> \u542F\u7528\u6307\u5B9A\u540D\u79F0\u6216\u5E8F\u53F7\u7684\u6280\u80FD
|
|
27122
|
-
ai skills disable <name|index> \u7981\u7528\u6307\u5B9A\u540D\u79F0\u6216\u5E8F\u53F7\u7684\u6280\u80FD
|
|
27123
|
-
ai skills dir \u6253\u5F00\u6216\u8F93\u51FA\u6280\u80FD\u76EE\u5F55
|
|
27124
|
-
ai skills generate xxx \u6839\u636E\u63CF\u8FF0\u751F\u6210\u4E00\u4E2A\u65B0\u7684\u6280\u80FD\u6A21\u677F
|
|
27125
|
-
|
|
27126
|
-
# Tools commands
|
|
27127
|
-
ai tools dir \u6253\u5F00\u6216\u8F93\u51FA\u7528\u6237\u81EA\u5B9A\u4E49\u5DE5\u5177\u76EE\u5F55
|
|
27128
|
-
ai tools generate xxx \u6839\u636E\u63CF\u8FF0\u751F\u6210\u4E00\u4E2A\u65B0\u7684\u5DE5\u5177\u6A21\u677F
|
|
27129
|
-
|
|
27130
|
-
# Session commands
|
|
27131
|
-
ai session clear \u6E05\u7A7A\u5F53\u524D\u4F1A\u8BDD\u8BB0\u5F55
|
|
27132
|
-
ai session dir \u6253\u5F00\u6216\u8F93\u51FA\u4F1A\u8BDD\u6570\u636E\u76EE\u5F55
|
|
27133
|
-
|
|
27134
|
-
# Task commands
|
|
27135
|
-
ai task ls \u67E5\u770B\u5F53\u524D\u4EFB\u52A1\u961F\u5217
|
|
27136
|
-
ai task add <task> \u5411\u4EFB\u52A1\u961F\u5217\u6DFB\u52A0\u4E00\u4E2A\u540E\u7EED\u4EFB\u52A1
|
|
27137
|
-
ai task del <index> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u4EFB\u52A1
|
|
27138
|
-
ai task clear \u6E05\u7A7A\u5F53\u524D\u4EFB\u52A1\u961F\u5217
|
|
27139
|
-
|
|
27140
|
-
# MCP commands
|
|
27141
|
-
ai mcp edit \u6253\u5F00 MCP \u914D\u7F6E\u6587\u4EF6\u8FDB\u884C\u7F16\u8F91
|
|
27142
|
-
|
|
27143
|
-
# Serve commands
|
|
27144
|
-
ai serve \u542F\u52A8\u670D\u52A1\u6216\u8FDB\u5165\u670D\u52A1\u7BA1\u7406\u5165\u53E3
|
|
27145
|
-
ai serve start \u542F\u52A8\u540E\u53F0\u670D\u52A1
|
|
27146
|
-
ai serve stop \u505C\u6B62\u540E\u53F0\u670D\u52A1
|
|
27147
|
-
ai serve restart \u91CD\u542F\u540E\u53F0\u670D\u52A1
|
|
27148
|
-
|
|
27149
|
-
# Cache commands
|
|
27150
|
-
ai cache ls \u67E5\u770B\u5DF2\u7F13\u5B58\u7684\u5B66\u4E60\u5185\u5BB9\u5217\u8868
|
|
27151
|
-
ai cache edit <index|id> \u7F16\u8F91\u6307\u5B9A\u5E8F\u53F7\u6216 ID \u7684\u7F13\u5B58\u5185\u5BB9
|
|
27152
|
-
ai cache del <index|id> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u6216 ID \u7684\u7F13\u5B58\u5185\u5BB9
|
|
27153
|
-
`;
|
|
27154
|
-
}
|
|
27155
|
-
function registerHelpCommand(program) {
|
|
27156
|
-
program.helpInformation = helpInformation;
|
|
27157
|
-
program.command("help").description("Displaying help information").action(() => {
|
|
27158
|
-
logInfo(helpInformation());
|
|
27159
|
-
});
|
|
27160
|
-
}
|
|
27161
|
-
|
|
27162
27289
|
// src/cli/index.ts
|
|
27163
27290
|
function main() {
|
|
27164
27291
|
initConfig();
|