deepfish-ai 2.0.8 → 2.0.11
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 +433 -227
- package/dist/serve/pm2-server.js +176 -58
- 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 fs25 = (0, node_1.default)();
|
|
8407
8407
|
const handler = (err, buffer) => {
|
|
8408
8408
|
if (fd) {
|
|
8409
|
-
|
|
8409
|
+
fs25.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 = fs25.openSync(filepath, "r");
|
|
8422
8422
|
let sample = Buffer.allocUnsafe(sampleSize);
|
|
8423
|
-
|
|
8423
|
+
fs25.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
|
+
fs25.readFile(filepath, handler);
|
|
8436
8436
|
});
|
|
8437
8437
|
exports2.detectFile = detectFile;
|
|
8438
8438
|
var detectFileSync = (filepath, opts = {}) => {
|
|
8439
|
-
const
|
|
8439
|
+
const fs25 = (0, node_1.default)();
|
|
8440
8440
|
if (opts && opts.sampleSize) {
|
|
8441
|
-
const fd =
|
|
8441
|
+
const fd = fs25.openSync(filepath, "r");
|
|
8442
8442
|
let sample = Buffer.allocUnsafe(opts.sampleSize);
|
|
8443
|
-
const bytesRead =
|
|
8443
|
+
const bytesRead = fs25.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
|
+
fs25.closeSync(fd);
|
|
8448
8448
|
return (0, exports2.detect)(sample);
|
|
8449
8449
|
}
|
|
8450
|
-
return (0, exports2.detect)(
|
|
8450
|
+
return (0, exports2.detect)(fs25.readFileSync(filepath));
|
|
8451
8451
|
};
|
|
8452
8452
|
exports2.detectFileSync = detectFileSync;
|
|
8453
8453
|
exports2.default = {
|
|
@@ -8631,6 +8631,79 @@ var ADD_MODEL_Config = {
|
|
|
8631
8631
|
// src/cli/cli-utils/getGlobalPath.ts
|
|
8632
8632
|
var import_path2 = __toESM(require("path"));
|
|
8633
8633
|
var import_fs_extra = __toESM(require("fs-extra"));
|
|
8634
|
+
|
|
8635
|
+
// src/cli/cli-utils/node-root.ts
|
|
8636
|
+
var { execSync } = require("child_process");
|
|
8637
|
+
var path2 = require("path");
|
|
8638
|
+
var fs = require("fs");
|
|
8639
|
+
function safeExec(cmd) {
|
|
8640
|
+
try {
|
|
8641
|
+
return execSync(cmd, { encoding: "utf8", stdio: "pipe" }).trim();
|
|
8642
|
+
} catch (err) {
|
|
8643
|
+
return null;
|
|
8644
|
+
}
|
|
8645
|
+
}
|
|
8646
|
+
function resolveValidPath(targetPath) {
|
|
8647
|
+
if (!targetPath) return null;
|
|
8648
|
+
try {
|
|
8649
|
+
const realPath = fs.realpathSync(targetPath);
|
|
8650
|
+
return fs.existsSync(realPath) ? realPath : null;
|
|
8651
|
+
} catch (err) {
|
|
8652
|
+
return null;
|
|
8653
|
+
}
|
|
8654
|
+
}
|
|
8655
|
+
function getNvmGlobalPath() {
|
|
8656
|
+
const nvmDir = process.env["NVM_DIR"] || (process.platform === "win32" ? path2.join(process.env["USERPROFILE"], ".nvm") : path2.join(process.env["HOME"], ".nvm"));
|
|
8657
|
+
const nodeVersion = safeExec("nvm current");
|
|
8658
|
+
if (!nodeVersion || nodeVersion.includes("N/A")) return null;
|
|
8659
|
+
const nvmGlobalPath = path2.join(
|
|
8660
|
+
nvmDir,
|
|
8661
|
+
"versions",
|
|
8662
|
+
"node",
|
|
8663
|
+
nodeVersion,
|
|
8664
|
+
"lib",
|
|
8665
|
+
"node_modules"
|
|
8666
|
+
);
|
|
8667
|
+
return resolveValidPath(nvmGlobalPath);
|
|
8668
|
+
}
|
|
8669
|
+
function getNpmGlobalPath() {
|
|
8670
|
+
const npmPath = safeExec("npm root -g");
|
|
8671
|
+
return resolveValidPath(npmPath);
|
|
8672
|
+
}
|
|
8673
|
+
function getFallbackGlobalPath() {
|
|
8674
|
+
try {
|
|
8675
|
+
const nodeExecPath = process.execPath;
|
|
8676
|
+
let globalPrefix;
|
|
8677
|
+
if (process.platform === "win32") {
|
|
8678
|
+
globalPrefix = path2.dirname(path2.dirname(nodeExecPath));
|
|
8679
|
+
} else {
|
|
8680
|
+
globalPrefix = path2.dirname(path2.dirname(path2.dirname(nodeExecPath)));
|
|
8681
|
+
}
|
|
8682
|
+
const fallbackPath = path2.join(globalPrefix, "lib", "node_modules");
|
|
8683
|
+
return resolveValidPath(fallbackPath);
|
|
8684
|
+
} catch (err) {
|
|
8685
|
+
return null;
|
|
8686
|
+
}
|
|
8687
|
+
}
|
|
8688
|
+
function getGlobalNodeModulesPath() {
|
|
8689
|
+
const nvmPath = getNvmGlobalPath();
|
|
8690
|
+
if (nvmPath) {
|
|
8691
|
+
return nvmPath;
|
|
8692
|
+
}
|
|
8693
|
+
const npmPath = getNpmGlobalPath();
|
|
8694
|
+
if (npmPath) {
|
|
8695
|
+
return npmPath;
|
|
8696
|
+
}
|
|
8697
|
+
const fallbackPath = getFallbackGlobalPath();
|
|
8698
|
+
if (fallbackPath) {
|
|
8699
|
+
return fallbackPath;
|
|
8700
|
+
}
|
|
8701
|
+
console.error("\u65E0\u6CD5\u83B7\u53D6\u5168\u5C40 node_modules \u8DEF\u5F84");
|
|
8702
|
+
return null;
|
|
8703
|
+
}
|
|
8704
|
+
var node_root_default = getGlobalNodeModulesPath;
|
|
8705
|
+
|
|
8706
|
+
// src/cli/cli-utils/getGlobalPath.ts
|
|
8634
8707
|
var getDirname = () => __dirname;
|
|
8635
8708
|
function getHomePath() {
|
|
8636
8709
|
return HOME_DIR;
|
|
@@ -8693,6 +8766,10 @@ function getScanDirPaths() {
|
|
|
8693
8766
|
const paths = /* @__PURE__ */ new Set();
|
|
8694
8767
|
paths.add(import_path2.default.join(workspacePath, ".deepfish-ai"));
|
|
8695
8768
|
paths.add(import_path2.default.join(homePath));
|
|
8769
|
+
const nodeRoot = import_path2.default.join(node_root_default(), "@deepfish-ai");
|
|
8770
|
+
if (import_fs_extra.default.existsSync(nodeRoot)) {
|
|
8771
|
+
paths.add(nodeRoot);
|
|
8772
|
+
}
|
|
8696
8773
|
return Array.from(paths);
|
|
8697
8774
|
}
|
|
8698
8775
|
function getMCPFilePath() {
|
|
@@ -8728,8 +8805,11 @@ function handleConfigView() {
|
|
|
8728
8805
|
}
|
|
8729
8806
|
const content = import_fs_extra2.default.readFileSync(configPath, "utf-8");
|
|
8730
8807
|
const data = import_json5.default.parse(content);
|
|
8808
|
+
data.aiList?.forEach((item) => {
|
|
8809
|
+
item.apiKey = "******";
|
|
8810
|
+
});
|
|
8731
8811
|
logInfo("Current config:");
|
|
8732
|
-
|
|
8812
|
+
logInfo(JSON.stringify(data, null, 2));
|
|
8733
8813
|
}
|
|
8734
8814
|
function handleConfigReset() {
|
|
8735
8815
|
const configPath = getConfigPath();
|
|
@@ -8938,8 +9018,8 @@ function registerModelsCommands(program) {
|
|
|
8938
9018
|
// src/cli/cli-core/skills.ts
|
|
8939
9019
|
var import_crypto6 = require("crypto");
|
|
8940
9020
|
var import_inquirer3 = __toESM(require("inquirer"));
|
|
8941
|
-
var
|
|
8942
|
-
var
|
|
9021
|
+
var import_fs_extra20 = __toESM(require("fs-extra"));
|
|
9022
|
+
var import_path20 = __toESM(require("path"));
|
|
8943
9023
|
|
|
8944
9024
|
// src/cli/cli-utils/init-config.ts
|
|
8945
9025
|
var import_fs_extra4 = __toESM(require("fs-extra"));
|
|
@@ -8966,18 +9046,8 @@ function initConfig() {
|
|
|
8966
9046
|
if (!import_fs_extra4.default.pathExistsSync(skillsRegisterPath)) {
|
|
8967
9047
|
import_fs_extra4.default.writeFileSync(skillsRegisterPath, "[]", "utf-8");
|
|
8968
9048
|
}
|
|
8969
|
-
const dynamicToolsDir = getToolsPath();
|
|
8970
|
-
import_fs_extra4.default.ensureDirSync(dynamicToolsDir);
|
|
8971
|
-
const dynamicToolsRegisterPath = import_path3.default.join(dynamicToolsDir, "register.json");
|
|
8972
|
-
if (!import_fs_extra4.default.pathExistsSync(dynamicToolsRegisterPath)) {
|
|
8973
|
-
import_fs_extra4.default.writeFileSync(dynamicToolsRegisterPath, "[]", "utf-8");
|
|
8974
|
-
}
|
|
8975
9049
|
const toolsDir = getToolsPath();
|
|
8976
9050
|
import_fs_extra4.default.ensureDirSync(toolsDir);
|
|
8977
|
-
const toolsRegisterPath = import_path3.default.join(toolsDir, "register.json");
|
|
8978
|
-
if (!import_fs_extra4.default.pathExistsSync(toolsRegisterPath)) {
|
|
8979
|
-
import_fs_extra4.default.writeFileSync(toolsRegisterPath, "[]", "utf-8");
|
|
8980
|
-
}
|
|
8981
9051
|
const sessionsDir = getSessionsPath();
|
|
8982
9052
|
import_fs_extra4.default.ensureDirSync(sessionsDir);
|
|
8983
9053
|
const sessionsIndexPath = import_path3.default.join(sessionsDir, "sessions.json");
|
|
@@ -8996,12 +9066,12 @@ function getConfig() {
|
|
|
8996
9066
|
}
|
|
8997
9067
|
|
|
8998
9068
|
// src/cli/cli-utils/init-agent.ts
|
|
8999
|
-
var
|
|
9000
|
-
var
|
|
9069
|
+
var import_fs_extra19 = __toESM(require("fs-extra"));
|
|
9070
|
+
var import_path19 = __toESM(require("path"));
|
|
9001
9071
|
var import_crypto5 = require("crypto");
|
|
9002
9072
|
|
|
9003
9073
|
// src/agent/AIAgent/index.ts
|
|
9004
|
-
var
|
|
9074
|
+
var import_langchain19 = require("langchain");
|
|
9005
9075
|
var import_deepagents2 = require("deepagents");
|
|
9006
9076
|
|
|
9007
9077
|
// src/agent/AIAgent/utils/langgraph-checkpoint-filesystem/filesystem-saver.ts
|
|
@@ -10494,10 +10564,10 @@ function mergeDefs(...defs) {
|
|
|
10494
10564
|
function cloneDef(schema) {
|
|
10495
10565
|
return mergeDefs(schema._zod.def);
|
|
10496
10566
|
}
|
|
10497
|
-
function getElementAtPath(obj,
|
|
10498
|
-
if (!
|
|
10567
|
+
function getElementAtPath(obj, path23) {
|
|
10568
|
+
if (!path23)
|
|
10499
10569
|
return obj;
|
|
10500
|
-
return
|
|
10570
|
+
return path23.reduce((acc, key) => acc?.[key], obj);
|
|
10501
10571
|
}
|
|
10502
10572
|
function promiseAllObject(promisesObj) {
|
|
10503
10573
|
const keys = Object.keys(promisesObj);
|
|
@@ -10906,11 +10976,11 @@ function explicitlyAborted(x, startIndex = 0) {
|
|
|
10906
10976
|
}
|
|
10907
10977
|
return false;
|
|
10908
10978
|
}
|
|
10909
|
-
function prefixIssues(
|
|
10979
|
+
function prefixIssues(path23, issues) {
|
|
10910
10980
|
return issues.map((iss) => {
|
|
10911
10981
|
var _a3;
|
|
10912
10982
|
(_a3 = iss).path ?? (_a3.path = []);
|
|
10913
|
-
iss.path.unshift(
|
|
10983
|
+
iss.path.unshift(path23);
|
|
10914
10984
|
return iss;
|
|
10915
10985
|
});
|
|
10916
10986
|
}
|
|
@@ -11057,16 +11127,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
|
|
|
11057
11127
|
}
|
|
11058
11128
|
function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
11059
11129
|
const fieldErrors = { _errors: [] };
|
|
11060
|
-
const processError = (error52,
|
|
11130
|
+
const processError = (error52, path23 = []) => {
|
|
11061
11131
|
for (const issue2 of error52.issues) {
|
|
11062
11132
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
11063
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
11133
|
+
issue2.errors.map((issues) => processError({ issues }, [...path23, ...issue2.path]));
|
|
11064
11134
|
} else if (issue2.code === "invalid_key") {
|
|
11065
|
-
processError({ issues: issue2.issues }, [...
|
|
11135
|
+
processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
|
|
11066
11136
|
} else if (issue2.code === "invalid_element") {
|
|
11067
|
-
processError({ issues: issue2.issues }, [...
|
|
11137
|
+
processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
|
|
11068
11138
|
} else {
|
|
11069
|
-
const fullpath = [...
|
|
11139
|
+
const fullpath = [...path23, ...issue2.path];
|
|
11070
11140
|
if (fullpath.length === 0) {
|
|
11071
11141
|
fieldErrors._errors.push(mapper(issue2));
|
|
11072
11142
|
} else {
|
|
@@ -11093,17 +11163,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
|
|
|
11093
11163
|
}
|
|
11094
11164
|
function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
11095
11165
|
const result = { errors: [] };
|
|
11096
|
-
const processError = (error52,
|
|
11166
|
+
const processError = (error52, path23 = []) => {
|
|
11097
11167
|
var _a3, _b;
|
|
11098
11168
|
for (const issue2 of error52.issues) {
|
|
11099
11169
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
11100
|
-
issue2.errors.map((issues) => processError({ issues }, [...
|
|
11170
|
+
issue2.errors.map((issues) => processError({ issues }, [...path23, ...issue2.path]));
|
|
11101
11171
|
} else if (issue2.code === "invalid_key") {
|
|
11102
|
-
processError({ issues: issue2.issues }, [...
|
|
11172
|
+
processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
|
|
11103
11173
|
} else if (issue2.code === "invalid_element") {
|
|
11104
|
-
processError({ issues: issue2.issues }, [...
|
|
11174
|
+
processError({ issues: issue2.issues }, [...path23, ...issue2.path]);
|
|
11105
11175
|
} else {
|
|
11106
|
-
const fullpath = [...
|
|
11176
|
+
const fullpath = [...path23, ...issue2.path];
|
|
11107
11177
|
if (fullpath.length === 0) {
|
|
11108
11178
|
result.errors.push(mapper(issue2));
|
|
11109
11179
|
continue;
|
|
@@ -11135,8 +11205,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
|
|
|
11135
11205
|
}
|
|
11136
11206
|
function toDotPath(_path) {
|
|
11137
11207
|
const segs = [];
|
|
11138
|
-
const
|
|
11139
|
-
for (const seg of
|
|
11208
|
+
const path23 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
11209
|
+
for (const seg of path23) {
|
|
11140
11210
|
if (typeof seg === "number")
|
|
11141
11211
|
segs.push(`[${seg}]`);
|
|
11142
11212
|
else if (typeof seg === "symbol")
|
|
@@ -23828,13 +23898,13 @@ function resolveRef(ref, ctx) {
|
|
|
23828
23898
|
if (!ref.startsWith("#")) {
|
|
23829
23899
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
23830
23900
|
}
|
|
23831
|
-
const
|
|
23832
|
-
if (
|
|
23901
|
+
const path23 = ref.slice(1).split("/").filter(Boolean);
|
|
23902
|
+
if (path23.length === 0) {
|
|
23833
23903
|
return ctx.rootSchema;
|
|
23834
23904
|
}
|
|
23835
23905
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
23836
|
-
if (
|
|
23837
|
-
const key =
|
|
23906
|
+
if (path23[0] === defsKey) {
|
|
23907
|
+
const key = path23[1];
|
|
23838
23908
|
if (!key || !ctx.defs[key]) {
|
|
23839
23909
|
throw new Error(`Reference not found: ${ref}`);
|
|
23840
23910
|
}
|
|
@@ -24247,6 +24317,7 @@ var import_eventemitter_super2 = require("eventemitter-super");
|
|
|
24247
24317
|
|
|
24248
24318
|
// src/agent/AIAgent/middleware/eventEmitMiddleware.ts
|
|
24249
24319
|
var import_langchain = require("langchain");
|
|
24320
|
+
var import_messages = require("@langchain/core/messages");
|
|
24250
24321
|
function createAgentEventMiddleware(emitter) {
|
|
24251
24322
|
return (0, import_langchain.createMiddleware)({
|
|
24252
24323
|
name: "AgentEventMiddleware",
|
|
@@ -24276,7 +24347,7 @@ function createAgentEventMiddleware(emitter) {
|
|
|
24276
24347
|
return await handler(request);
|
|
24277
24348
|
} catch (error51) {
|
|
24278
24349
|
emitter.emit("MODEL_ERROR" /* MODEL_ERROR */, error51);
|
|
24279
|
-
|
|
24350
|
+
return new import_messages.AIMessage(error51.message);
|
|
24280
24351
|
}
|
|
24281
24352
|
},
|
|
24282
24353
|
// Around each tool call
|
|
@@ -24291,7 +24362,7 @@ function createAgentEventMiddleware(emitter) {
|
|
|
24291
24362
|
} catch (err) {
|
|
24292
24363
|
emitter.emit("USE_TOOL_ERROR" /* USE_TOOL_ERROR */, toolCall.id, toolCall.name, err);
|
|
24293
24364
|
emitter.emit("USE_TOOL_AFTER" /* USE_TOOL_AFTER */, toolCall.id, toolCall.name, toolCall.args);
|
|
24294
|
-
|
|
24365
|
+
return new import_langchain.ToolMessage(err.message);
|
|
24295
24366
|
}
|
|
24296
24367
|
}
|
|
24297
24368
|
});
|
|
@@ -24317,8 +24388,8 @@ var Thinking = class {
|
|
|
24317
24388
|
};
|
|
24318
24389
|
|
|
24319
24390
|
// src/agent/AIAgent/utils/skill-parser.ts
|
|
24320
|
-
var
|
|
24321
|
-
var
|
|
24391
|
+
var fs6 = require("fs-extra");
|
|
24392
|
+
var path5 = require("path");
|
|
24322
24393
|
var yaml = require_js_yaml();
|
|
24323
24394
|
function extractFrontmatter(content, skillPath) {
|
|
24324
24395
|
const normalizedContent = content.replace(/^\uFEFF/, "");
|
|
@@ -24329,14 +24400,14 @@ function extractFrontmatter(content, skillPath) {
|
|
|
24329
24400
|
return frontmatterMatch[1];
|
|
24330
24401
|
}
|
|
24331
24402
|
function parseSkillMetadataYaml(skillPath) {
|
|
24332
|
-
const content =
|
|
24403
|
+
const content = fs6.readFileSync(skillPath, "utf-8");
|
|
24333
24404
|
const frontmatterContent = extractFrontmatter(content, skillPath);
|
|
24334
24405
|
const frontmatter = yaml.load(frontmatterContent);
|
|
24335
24406
|
return {
|
|
24336
24407
|
name: frontmatter.name,
|
|
24337
24408
|
description: frontmatter.description,
|
|
24338
24409
|
homepage: frontmatter.homepage,
|
|
24339
|
-
location:
|
|
24410
|
+
location: path5.dirname(skillPath),
|
|
24340
24411
|
metadata: frontmatter.metadata || {},
|
|
24341
24412
|
skillFilePath: skillPath
|
|
24342
24413
|
};
|
|
@@ -24403,12 +24474,12 @@ ${params.systemPrompt || `\u8FD9\u662FDeepfish Cli\u7CFB\u7EDF,\u4F60\u662F\u7CF
|
|
|
24403
24474
|
# \u6CE8\u610F\u6CE8\u610F\u4E8B\u9879:
|
|
24404
24475
|
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
24476
|
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
|
|
24477
|
+
3.\u5C3D\u91CF\u4F7F\u7528"execute_command"\u3001"execute_js_code"\u5DE5\u5177\u5B8C\u6210\u4EFB\u52A1
|
|
24478
|
+
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
24479
|
|
|
24408
24480
|
# \u57FA\u7840\u73AF\u5883\u4FE1\u606F
|
|
24409
24481
|
\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1A${params.workspace}
|
|
24410
24482
|
\u64CD\u4F5C\u7CFB\u7EDF\u7C7B\u578B\uFF1A${params.osType}
|
|
24411
|
-
\u8BED\u8A00\u7C7B\u578B: \u4E0E\u7528\u6237\u8F93\u5165\u8BED\u8A00\u4E00\u81F4
|
|
24412
24483
|
|
|
24413
24484
|
${skillPrompt}
|
|
24414
24485
|
${memoryPrompt}
|
|
@@ -24422,12 +24493,12 @@ var subSystemPrompt = (workspace, osType, skills, excludeSkills) => {
|
|
|
24422
24493
|
### \u57FA\u7840\u73AF\u5883\u4FE1\u606F
|
|
24423
24494
|
\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\uFF1A${workspace}
|
|
24424
24495
|
\u64CD\u4F5C\u7CFB\u7EDF\u7C7B\u578B\uFF1A${osType}
|
|
24425
|
-
\u8BED\u8A00\u7C7B\u578B: \u4E0E\u7528\u6237\u8F93\u5165\u8BED\u8A00\u4E00\u81F4
|
|
24426
24496
|
|
|
24427
24497
|
\u6CE8\u610F:
|
|
24428
24498
|
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
24499
|
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
24500
|
3.\u5C3D\u91CF\u4F7F\u7528"execute_command"\u3001"execute_js_code"\u5DE5\u5177\u5B8C\u6210\u4EFB\u52A1
|
|
24501
|
+
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
24502
|
|
|
24432
24503
|
${skillPrompt}
|
|
24433
24504
|
`;
|
|
@@ -24688,10 +24759,47 @@ function toLangChainTool(func, description) {
|
|
|
24688
24759
|
});
|
|
24689
24760
|
}
|
|
24690
24761
|
function scanUserTools(excludeTools) {
|
|
24762
|
+
const files = _scanUserToolsFile();
|
|
24691
24763
|
const tools = [];
|
|
24764
|
+
files.forEach((toolFile) => {
|
|
24765
|
+
_loadToolsFromFile(toolFile.filePath, tools, excludeTools);
|
|
24766
|
+
});
|
|
24767
|
+
return tools;
|
|
24768
|
+
}
|
|
24769
|
+
function getUserToolList() {
|
|
24770
|
+
const files = _scanUserToolsFile();
|
|
24771
|
+
const toolOpts = [];
|
|
24772
|
+
files.forEach((toolFile) => {
|
|
24773
|
+
const toolModule = require(toolFile.filePath);
|
|
24774
|
+
const { functions, descriptions } = toolModule;
|
|
24775
|
+
descriptions.forEach((desc) => {
|
|
24776
|
+
if (!desc.type) {
|
|
24777
|
+
desc = {
|
|
24778
|
+
type: "function",
|
|
24779
|
+
function: desc
|
|
24780
|
+
};
|
|
24781
|
+
}
|
|
24782
|
+
const func = functions[desc.function.name];
|
|
24783
|
+
if (typeof func !== "function") {
|
|
24784
|
+
return;
|
|
24785
|
+
}
|
|
24786
|
+
toolOpts.push({
|
|
24787
|
+
name: desc.function.name,
|
|
24788
|
+
path: toolFile.filePath,
|
|
24789
|
+
dir: toolFile.dir
|
|
24790
|
+
});
|
|
24791
|
+
});
|
|
24792
|
+
});
|
|
24793
|
+
return toolOpts;
|
|
24794
|
+
}
|
|
24795
|
+
function _scanUserToolsFile() {
|
|
24796
|
+
const toolFiles = [];
|
|
24692
24797
|
const scanPaths = getScanDirPaths();
|
|
24693
24798
|
scanPaths.forEach((scanPath) => {
|
|
24694
|
-
|
|
24799
|
+
let toolsDir = scanPath;
|
|
24800
|
+
if (!scanPath.endsWith("@deepfish-ai")) {
|
|
24801
|
+
toolsDir = import_path8.default.resolve(scanPath, "tools");
|
|
24802
|
+
}
|
|
24695
24803
|
if (import_fs_extra8.default.pathExistsSync(toolsDir)) {
|
|
24696
24804
|
const files = import_fs_extra8.default.readdirSync(toolsDir);
|
|
24697
24805
|
files.forEach((file2) => {
|
|
@@ -24702,26 +24810,35 @@ function scanUserTools(excludeTools) {
|
|
|
24702
24810
|
if (indexFile) {
|
|
24703
24811
|
const filePath = _scanDeepFishJsFile(import_path8.default.resolve(subDirPath, indexFile), indexFile);
|
|
24704
24812
|
if (filePath) {
|
|
24705
|
-
|
|
24813
|
+
toolFiles.push({
|
|
24814
|
+
filePath,
|
|
24815
|
+
dir: subDirPath
|
|
24816
|
+
});
|
|
24706
24817
|
}
|
|
24707
24818
|
} else {
|
|
24708
24819
|
subFiles.forEach((subFile) => {
|
|
24709
24820
|
const filePath = _scanDeepFishJsFile(import_path8.default.resolve(subDirPath, subFile), subFile);
|
|
24710
24821
|
if (filePath) {
|
|
24711
|
-
|
|
24822
|
+
toolFiles.push({
|
|
24823
|
+
filePath,
|
|
24824
|
+
dir: subDirPath
|
|
24825
|
+
});
|
|
24712
24826
|
}
|
|
24713
24827
|
});
|
|
24714
24828
|
}
|
|
24715
24829
|
} else {
|
|
24716
24830
|
const filePath = _scanDeepFishJsFile(toolsDir, file2);
|
|
24717
24831
|
if (filePath) {
|
|
24718
|
-
|
|
24832
|
+
toolFiles.push({
|
|
24833
|
+
filePath,
|
|
24834
|
+
dir: null
|
|
24835
|
+
});
|
|
24719
24836
|
}
|
|
24720
24837
|
}
|
|
24721
24838
|
});
|
|
24722
24839
|
}
|
|
24723
24840
|
});
|
|
24724
|
-
return
|
|
24841
|
+
return toolFiles;
|
|
24725
24842
|
}
|
|
24726
24843
|
function _scanDeepFishJsFile(filePath, fileName) {
|
|
24727
24844
|
if (fileName.endsWith(".js") || fileName.endsWith(".cjs")) {
|
|
@@ -25268,15 +25385,15 @@ async function grepFiles(query, cwd, includePattern = "**/*", isRegexp = false,
|
|
|
25268
25385
|
}
|
|
25269
25386
|
var grepTool = (0, import_langchain10.tool)(
|
|
25270
25387
|
async ({ query, pattern, cwd, includePattern, isRegexp, maxResults, includeHidden }) => safeTool(() => {
|
|
25271
|
-
const searchQuery = query
|
|
25388
|
+
const searchQuery = (query ?? pattern ?? "").trim();
|
|
25272
25389
|
if (!searchQuery) {
|
|
25273
|
-
|
|
25390
|
+
return '\u8BF7\u63D0\u4F9B query \u6216 pattern \u4E4B\u4E00\uFF1B\u4F8B\u5982 query: "foo" \u6216 pattern: "foo"';
|
|
25274
25391
|
}
|
|
25275
25392
|
return grepFiles(searchQuery, cwd, includePattern, isRegexp, maxResults, includeHidden);
|
|
25276
25393
|
}),
|
|
25277
25394
|
{
|
|
25278
25395
|
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",
|
|
25396
|
+
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
25397
|
schema: external_exports.object({
|
|
25281
25398
|
query: external_exports.string().optional().describe("\u8981\u641C\u7D22\u7684\u5B57\u7B26\u4E32\u6216\u6B63\u5219\u8868\u8FBE\u5F0F"),
|
|
25282
25399
|
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 +25402,6 @@ var grepTool = (0, import_langchain10.tool)(
|
|
|
25285
25402
|
isRegexp: external_exports.boolean().default(false).describe("query/pattern \u662F\u5426\u4E3A\u6B63\u5219\u8868\u8FBE\u5F0F"),
|
|
25286
25403
|
maxResults: external_exports.number().default(100).describe("\u6700\u5927\u8FD4\u56DE\u5339\u914D\u6570\u91CF"),
|
|
25287
25404
|
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
25405
|
})
|
|
25292
25406
|
}
|
|
25293
25407
|
);
|
|
@@ -25584,6 +25698,124 @@ var writeFileTool = (0, import_langchain16.tool)(async ({ filePath, content, mod
|
|
|
25584
25698
|
})
|
|
25585
25699
|
});
|
|
25586
25700
|
|
|
25701
|
+
// src/agent/tools/getFishInfo.ts
|
|
25702
|
+
var import_langchain17 = require("langchain");
|
|
25703
|
+
|
|
25704
|
+
// src/cli/cli-help.ts
|
|
25705
|
+
var import_commander = require("commander");
|
|
25706
|
+
function helpInformation() {
|
|
25707
|
+
return `Usage: ai [options] [command]
|
|
25708
|
+
|
|
25709
|
+
Commands:
|
|
25710
|
+
ai "xxx" \u76F4\u63A5\u5411 AI \u53D1\u8D77\u4E00\u6B21\u4EFB\u52A1\u6216\u5BF9\u8BDD
|
|
25711
|
+
|
|
25712
|
+
# Configuration commands
|
|
25713
|
+
ai config edit \u6253\u5F00\u5168\u5C40\u914D\u7F6E\u6587\u4EF6\u8FDB\u884C\u7F16\u8F91
|
|
25714
|
+
ai config view \u67E5\u770B\u5F53\u524D\u5168\u5C40\u914D\u7F6E\u5185\u5BB9
|
|
25715
|
+
ai config reset \u91CD\u7F6E\u5168\u5C40\u914D\u7F6E\u4E3A\u9ED8\u8BA4\u503C
|
|
25716
|
+
ai config dir \u6253\u5F00\u6216\u8F93\u51FA\u5168\u5C40\u914D\u7F6E\u76EE\u5F55
|
|
25717
|
+
|
|
25718
|
+
# Model commands
|
|
25719
|
+
ai models add \u6DFB\u52A0\u4E00\u4E2A\u65B0\u7684\u6A21\u578B\u914D\u7F6E
|
|
25720
|
+
ai models ls \u67E5\u770B\u5DF2\u914D\u7F6E\u7684\u6A21\u578B\u5217\u8868
|
|
25721
|
+
ai models use <name> \u5207\u6362\u5F53\u524D\u9ED8\u8BA4\u4F7F\u7528\u7684\u6A21\u578B
|
|
25722
|
+
ai models del <name> \u5220\u9664\u6307\u5B9A\u540D\u79F0\u7684\u6A21\u578B\u914D\u7F6E
|
|
25723
|
+
|
|
25724
|
+
# Skill commands
|
|
25725
|
+
ai skills ls \u67E5\u770B\u5DF2\u5B89\u88C5\u6216\u5DF2\u914D\u7F6E\u7684\u6280\u80FD\u5217\u8868
|
|
25726
|
+
ai skills add <name> \u6DFB\u52A0\u6307\u5B9A\u540D\u79F0\u7684\u6280\u80FD
|
|
25727
|
+
ai skills del <index> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u6280\u80FD
|
|
25728
|
+
ai skills enable <name|index> \u542F\u7528\u6307\u5B9A\u540D\u79F0\u6216\u5E8F\u53F7\u7684\u6280\u80FD
|
|
25729
|
+
ai skills disable <name|index> \u7981\u7528\u6307\u5B9A\u540D\u79F0\u6216\u5E8F\u53F7\u7684\u6280\u80FD
|
|
25730
|
+
ai skills dir \u6253\u5F00\u6216\u8F93\u51FA\u6280\u80FD\u76EE\u5F55
|
|
25731
|
+
ai skills generate xxx \u6839\u636E\u63CF\u8FF0\u751F\u6210\u4E00\u4E2A\u65B0\u7684\u6280\u80FD\u6A21\u677F
|
|
25732
|
+
|
|
25733
|
+
# Tools commands
|
|
25734
|
+
ai tools dir \u6253\u5F00\u6216\u8F93\u51FA\u7528\u6237\u81EA\u5B9A\u4E49\u5DE5\u5177\u76EE\u5F55
|
|
25735
|
+
ai tools generate xxx \u6839\u636E\u63CF\u8FF0\u751F\u6210\u4E00\u4E2A\u65B0\u7684\u5DE5\u5177\u6A21\u677F
|
|
25736
|
+
|
|
25737
|
+
# Session commands
|
|
25738
|
+
ai session clear \u6E05\u7A7A\u5F53\u524D\u4F1A\u8BDD\u8BB0\u5F55
|
|
25739
|
+
ai session dir \u6253\u5F00\u6216\u8F93\u51FA\u4F1A\u8BDD\u6570\u636E\u76EE\u5F55
|
|
25740
|
+
|
|
25741
|
+
# Task commands
|
|
25742
|
+
ai task ls \u67E5\u770B\u5F53\u524D\u4EFB\u52A1\u961F\u5217
|
|
25743
|
+
ai task add <task> \u5411\u4EFB\u52A1\u961F\u5217\u6DFB\u52A0\u4E00\u4E2A\u540E\u7EED\u4EFB\u52A1
|
|
25744
|
+
ai task del <index> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u4EFB\u52A1
|
|
25745
|
+
ai task clear \u6E05\u7A7A\u5F53\u524D\u4EFB\u52A1\u961F\u5217
|
|
25746
|
+
|
|
25747
|
+
# MCP commands
|
|
25748
|
+
ai mcp edit \u6253\u5F00 MCP \u914D\u7F6E\u6587\u4EF6\u8FDB\u884C\u7F16\u8F91
|
|
25749
|
+
|
|
25750
|
+
# Serve commands
|
|
25751
|
+
ai serve \u542F\u52A8\u670D\u52A1\u6216\u8FDB\u5165\u670D\u52A1\u7BA1\u7406\u5165\u53E3
|
|
25752
|
+
ai serve start \u542F\u52A8\u540E\u53F0\u670D\u52A1
|
|
25753
|
+
ai serve stop \u505C\u6B62\u540E\u53F0\u670D\u52A1
|
|
25754
|
+
ai serve restart \u91CD\u542F\u540E\u53F0\u670D\u52A1
|
|
25755
|
+
|
|
25756
|
+
# Cache commands
|
|
25757
|
+
ai cache ls \u67E5\u770B\u5DF2\u7F13\u5B58\u7684\u5B66\u4E60\u5185\u5BB9\u5217\u8868
|
|
25758
|
+
ai cache edit <index|id> \u7F16\u8F91\u6307\u5B9A\u5E8F\u53F7\u6216 ID \u7684\u7F13\u5B58\u5185\u5BB9
|
|
25759
|
+
ai cache del <index|id> \u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u6216 ID \u7684\u7F13\u5B58\u5185\u5BB9
|
|
25760
|
+
`;
|
|
25761
|
+
}
|
|
25762
|
+
function registerHelpCommand(program) {
|
|
25763
|
+
program.helpInformation = helpInformation;
|
|
25764
|
+
program.command("help").description("Displaying help information").action(() => {
|
|
25765
|
+
logInfo(helpInformation());
|
|
25766
|
+
});
|
|
25767
|
+
}
|
|
25768
|
+
|
|
25769
|
+
// src/agent/tools/getFishInfo.ts
|
|
25770
|
+
var import_path16 = __toESM(require("path"));
|
|
25771
|
+
var import_fs_extra18 = __toESM(require("fs-extra"));
|
|
25772
|
+
var getFishCodePathTool = (0, import_langchain17.tool)(
|
|
25773
|
+
async () => safeTool(() => {
|
|
25774
|
+
const codePath = getCodePath();
|
|
25775
|
+
return { codePath };
|
|
25776
|
+
}),
|
|
25777
|
+
{
|
|
25778
|
+
name: "get_fish_code_path",
|
|
25779
|
+
description: "\u83B7\u53D6 Deepfish CLI \u7CFB\u7EDF\u7684\u4EE3\u7801\u6839\u76EE\u5F55\u8DEF\u5F84",
|
|
25780
|
+
schema: external_exports.object({})
|
|
25781
|
+
}
|
|
25782
|
+
);
|
|
25783
|
+
var getFishReadmeTool = (0, import_langchain17.tool)(
|
|
25784
|
+
async ({ lang }) => safeTool(() => {
|
|
25785
|
+
const codePath = getCodePath();
|
|
25786
|
+
const readmePath = lang === "en" ? import_path16.default.join(codePath, "README_EN.md") : import_path16.default.join(codePath, "README.md");
|
|
25787
|
+
const fallbackPath = lang === "en" ? import_path16.default.join(codePath, "README.md") : import_path16.default.join(codePath, "README_EN.md");
|
|
25788
|
+
let targetPath = readmePath;
|
|
25789
|
+
if (!import_fs_extra18.default.existsSync(targetPath)) {
|
|
25790
|
+
targetPath = fallbackPath;
|
|
25791
|
+
}
|
|
25792
|
+
if (!import_fs_extra18.default.existsSync(targetPath)) {
|
|
25793
|
+
return { error: "\u672A\u627E\u5230 README \u6587\u4EF6", readmePath: targetPath };
|
|
25794
|
+
}
|
|
25795
|
+
const content = import_fs_extra18.default.readFileSync(targetPath, "utf-8");
|
|
25796
|
+
return { readmePath: targetPath, content };
|
|
25797
|
+
}),
|
|
25798
|
+
{
|
|
25799
|
+
name: "get_fish_readme",
|
|
25800
|
+
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",
|
|
25801
|
+
schema: external_exports.object({
|
|
25802
|
+
lang: external_exports.string().optional().default("zh").describe("\u8BED\u8A00\uFF0Czh \u4E3A\u4E2D\u6587 README\uFF0Cen \u4E3A\u82F1\u6587 README")
|
|
25803
|
+
})
|
|
25804
|
+
}
|
|
25805
|
+
);
|
|
25806
|
+
var getFishHelpTool = (0, import_langchain17.tool)(
|
|
25807
|
+
async () => safeTool(() => {
|
|
25808
|
+
const help = helpInformation();
|
|
25809
|
+
return { help };
|
|
25810
|
+
}),
|
|
25811
|
+
{
|
|
25812
|
+
name: "get_fish_help",
|
|
25813
|
+
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",
|
|
25814
|
+
schema: external_exports.object({})
|
|
25815
|
+
}
|
|
25816
|
+
);
|
|
25817
|
+
var fishInfoTools = [getFishCodePathTool, getFishReadmeTool, getFishHelpTool];
|
|
25818
|
+
|
|
25587
25819
|
// src/agent/tools/index.ts
|
|
25588
25820
|
var builtinTools = [
|
|
25589
25821
|
taskTool,
|
|
@@ -25598,23 +25830,24 @@ var builtinTools = [
|
|
|
25598
25830
|
webFetchTool,
|
|
25599
25831
|
...packageTools,
|
|
25600
25832
|
...semanticMemoryTools,
|
|
25601
|
-
...learnTools
|
|
25833
|
+
...learnTools,
|
|
25834
|
+
...fishInfoTools
|
|
25602
25835
|
];
|
|
25603
25836
|
async function getTools(excludeTools, excludeMCP) {
|
|
25604
25837
|
return [...builtinTools, ...await scanUserTools(excludeTools), ...await scanUserMcp(excludeMCP)];
|
|
25605
25838
|
}
|
|
25606
25839
|
|
|
25607
25840
|
// src/agent/skills/index.ts
|
|
25608
|
-
var
|
|
25841
|
+
var import_path17 = __toESM(require("path"));
|
|
25609
25842
|
function getSkills() {
|
|
25610
|
-
return [...getRegisteredSkills(),
|
|
25843
|
+
return [...getRegisteredSkills(), import_path17.default.join(__dirname, "./view-learn-cache.md")];
|
|
25611
25844
|
}
|
|
25612
25845
|
|
|
25613
25846
|
// src/agent/AIAgent/index.ts
|
|
25614
25847
|
var import_os4 = __toESM(require("os"));
|
|
25615
25848
|
|
|
25616
25849
|
// src/agent/AIAgent/SubAgents/SubAIAgent.ts
|
|
25617
|
-
var
|
|
25850
|
+
var import_langchain18 = require("langchain");
|
|
25618
25851
|
var import_deepagents = require("deepagents");
|
|
25619
25852
|
var import_eventemitter_super = require("eventemitter-super");
|
|
25620
25853
|
var import_os3 = __toESM(require("os"));
|
|
@@ -25687,19 +25920,19 @@ var SubAIAgent = class _SubAIAgent extends import_eventemitter_super.EventEmitte
|
|
|
25687
25920
|
agentRulesPath: this.agentRulesPath,
|
|
25688
25921
|
excludeSkills: this.excludeSkills
|
|
25689
25922
|
}) : subSystemPrompt(this.workspace, import_os3.default.platform(), this.skills, this.excludeSkills);
|
|
25690
|
-
const agent = (0,
|
|
25923
|
+
const agent = (0, import_langchain18.createAgent)({
|
|
25691
25924
|
model,
|
|
25692
25925
|
checkpointer,
|
|
25693
25926
|
tools: this.tools,
|
|
25694
25927
|
contextSchema,
|
|
25695
25928
|
middleware: [
|
|
25696
25929
|
createAgentEventMiddleware(this),
|
|
25697
|
-
(0,
|
|
25930
|
+
(0, import_langchain18.summarizationMiddleware)({
|
|
25698
25931
|
model,
|
|
25699
25932
|
trigger: { tokens: this.opt.modelOpt.maxContextLength || 1e5 },
|
|
25700
25933
|
keep: { messages: 50 }
|
|
25701
25934
|
}),
|
|
25702
|
-
(0,
|
|
25935
|
+
(0, import_langchain18.humanInTheLoopMiddleware)({
|
|
25703
25936
|
interruptOn: {
|
|
25704
25937
|
install_package: {
|
|
25705
25938
|
allowedDecisions: ["approve", "reject"]
|
|
@@ -25707,7 +25940,7 @@ var SubAIAgent = class _SubAIAgent extends import_eventemitter_super.EventEmitte
|
|
|
25707
25940
|
readEmailTool: false
|
|
25708
25941
|
}
|
|
25709
25942
|
}),
|
|
25710
|
-
(0,
|
|
25943
|
+
(0, import_langchain18.todoListMiddleware)(),
|
|
25711
25944
|
(0, import_deepagents.createPatchToolCallsMiddleware)()
|
|
25712
25945
|
],
|
|
25713
25946
|
systemPrompt
|
|
@@ -25717,7 +25950,7 @@ var SubAIAgent = class _SubAIAgent extends import_eventemitter_super.EventEmitte
|
|
|
25717
25950
|
this.initEvents();
|
|
25718
25951
|
}
|
|
25719
25952
|
async execute(input) {
|
|
25720
|
-
const humanMessage = new
|
|
25953
|
+
const humanMessage = new import_langchain18.HumanMessage(input);
|
|
25721
25954
|
this.messages.push(humanMessage);
|
|
25722
25955
|
const stream = await this.agent.stream(
|
|
25723
25956
|
{ messages: this.messages },
|
|
@@ -25870,19 +26103,19 @@ var AIAgent = class extends import_eventemitter_super2.EventEmitterSuper {
|
|
|
25870
26103
|
agentId: external_exports.string().optional(),
|
|
25871
26104
|
curAgent: external_exports.object().optional()
|
|
25872
26105
|
});
|
|
25873
|
-
const agent = (0,
|
|
26106
|
+
const agent = (0, import_langchain19.createAgent)({
|
|
25874
26107
|
model,
|
|
25875
26108
|
checkpointer,
|
|
25876
26109
|
tools: this.tools,
|
|
25877
26110
|
contextSchema,
|
|
25878
26111
|
middleware: [
|
|
25879
26112
|
createAgentEventMiddleware(this),
|
|
25880
|
-
(0,
|
|
26113
|
+
(0, import_langchain19.summarizationMiddleware)({
|
|
25881
26114
|
model,
|
|
25882
26115
|
trigger: { tokens: this.opt.modelOpt.maxContextLength || 1e5 },
|
|
25883
26116
|
keep: { messages: 50 }
|
|
25884
26117
|
}),
|
|
25885
|
-
(0,
|
|
26118
|
+
(0, import_langchain19.humanInTheLoopMiddleware)({
|
|
25886
26119
|
interruptOn: {
|
|
25887
26120
|
install_package: {
|
|
25888
26121
|
allowedDecisions: ["approve", "reject"]
|
|
@@ -25890,7 +26123,7 @@ var AIAgent = class extends import_eventemitter_super2.EventEmitterSuper {
|
|
|
25890
26123
|
readEmailTool: false
|
|
25891
26124
|
}
|
|
25892
26125
|
}),
|
|
25893
|
-
(0,
|
|
26126
|
+
(0, import_langchain19.todoListMiddleware)(),
|
|
25894
26127
|
(0, import_deepagents2.createPatchToolCallsMiddleware)()
|
|
25895
26128
|
],
|
|
25896
26129
|
systemPrompt: getSystemPrompt({
|
|
@@ -25909,7 +26142,7 @@ var AIAgent = class extends import_eventemitter_super2.EventEmitterSuper {
|
|
|
25909
26142
|
this.initEvents();
|
|
25910
26143
|
}
|
|
25911
26144
|
async execute(input) {
|
|
25912
|
-
const humanMessage = new
|
|
26145
|
+
const humanMessage = new import_langchain19.HumanMessage(input);
|
|
25913
26146
|
this.messages.push(humanMessage);
|
|
25914
26147
|
const stream = await this.agent.stream(
|
|
25915
26148
|
{ messages: this.messages },
|
|
@@ -26094,12 +26327,12 @@ var AgentRoomClient = class {
|
|
|
26094
26327
|
};
|
|
26095
26328
|
|
|
26096
26329
|
// src/cli/cli-core/serve.ts
|
|
26097
|
-
var
|
|
26330
|
+
var import_path18 = __toESM(require("path"));
|
|
26098
26331
|
var import_pm2 = __toESM(require("pm2"));
|
|
26099
26332
|
var PM2_APP_NAME = "deepfish-ai-server";
|
|
26100
26333
|
function getPm2Config() {
|
|
26101
26334
|
const port = getServePort();
|
|
26102
|
-
const serverScript =
|
|
26335
|
+
const serverScript = import_path18.default.join(getCodePath(), "dist/serve/pm2-server");
|
|
26103
26336
|
return {
|
|
26104
26337
|
name: PM2_APP_NAME,
|
|
26105
26338
|
script: serverScript,
|
|
@@ -26111,8 +26344,8 @@ function getPm2Config() {
|
|
|
26111
26344
|
autorestart: true,
|
|
26112
26345
|
watch: false,
|
|
26113
26346
|
max_memory_restart: "1G",
|
|
26114
|
-
error_file:
|
|
26115
|
-
out_file:
|
|
26347
|
+
error_file: import_path18.default.join(getCodePath(), "logs", "pm2-error.log"),
|
|
26348
|
+
out_file: import_path18.default.join(getCodePath(), "logs", "pm2-out.log"),
|
|
26116
26349
|
log_date_format: "YYYY-MM-DD HH:mm:ss Z"
|
|
26117
26350
|
};
|
|
26118
26351
|
}
|
|
@@ -26344,20 +26577,20 @@ function removeSessionById(agentId) {
|
|
|
26344
26577
|
return;
|
|
26345
26578
|
}
|
|
26346
26579
|
const sessionDir = getSessionPath(agentId);
|
|
26347
|
-
|
|
26580
|
+
import_fs_extra19.default.removeSync(sessionDir);
|
|
26348
26581
|
const sessionsPath = getSessionsPath();
|
|
26349
|
-
const sessionsFilePath =
|
|
26350
|
-
if (!
|
|
26582
|
+
const sessionsFilePath = import_path19.default.join(sessionsPath, "sessions.json");
|
|
26583
|
+
if (!import_fs_extra19.default.pathExistsSync(sessionsFilePath)) {
|
|
26351
26584
|
logSuccess("Current session history cleared");
|
|
26352
26585
|
return;
|
|
26353
26586
|
}
|
|
26354
|
-
const content =
|
|
26587
|
+
const content = import_fs_extra19.default.readFileSync(sessionsFilePath, "utf-8");
|
|
26355
26588
|
const parsed = JSON.parse(content);
|
|
26356
26589
|
const sessions = Array.isArray(parsed) ? parsed : [];
|
|
26357
26590
|
const existingSessionIndex = sessions.findIndex((s) => s.id === agentId);
|
|
26358
26591
|
if (existingSessionIndex !== -1) {
|
|
26359
26592
|
sessions.splice(existingSessionIndex, 1);
|
|
26360
|
-
|
|
26593
|
+
import_fs_extra19.default.writeFileSync(sessionsFilePath, JSON.stringify(sessions, null, 2), "utf-8");
|
|
26361
26594
|
}
|
|
26362
26595
|
logSuccess("Current session history cleared");
|
|
26363
26596
|
}
|
|
@@ -26373,15 +26606,15 @@ function openSessionDir() {
|
|
|
26373
26606
|
}
|
|
26374
26607
|
function initSession() {
|
|
26375
26608
|
const sessionsPath = getSessionsPath();
|
|
26376
|
-
const sessionsFilePath =
|
|
26609
|
+
const sessionsFilePath = import_path19.default.join(sessionsPath, "sessions.json");
|
|
26377
26610
|
let sessions = [];
|
|
26378
|
-
if (
|
|
26379
|
-
const content =
|
|
26611
|
+
if (import_fs_extra19.default.pathExistsSync(sessionsFilePath)) {
|
|
26612
|
+
const content = import_fs_extra19.default.readFileSync(sessionsFilePath, "utf-8");
|
|
26380
26613
|
const parsed = JSON.parse(content);
|
|
26381
26614
|
sessions = Array.isArray(parsed) ? parsed : [];
|
|
26382
26615
|
} else {
|
|
26383
|
-
|
|
26384
|
-
|
|
26616
|
+
import_fs_extra19.default.ensureDirSync(sessionsPath);
|
|
26617
|
+
import_fs_extra19.default.writeFileSync(sessionsFilePath, "[]", "utf-8");
|
|
26385
26618
|
}
|
|
26386
26619
|
const workspace = getWorkspacePath();
|
|
26387
26620
|
const existingSession = sessions.find((s) => s.workspace === workspace);
|
|
@@ -26392,23 +26625,23 @@ function initSession() {
|
|
|
26392
26625
|
const agentId = (0, import_crypto5.randomUUID)();
|
|
26393
26626
|
const newSession = {
|
|
26394
26627
|
id: agentId,
|
|
26395
|
-
name:
|
|
26628
|
+
name: import_path19.default.basename(workspace),
|
|
26396
26629
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
26397
26630
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
26398
26631
|
workspace
|
|
26399
26632
|
};
|
|
26400
26633
|
sessions.push(newSession);
|
|
26401
|
-
|
|
26634
|
+
import_fs_extra19.default.writeFileSync(sessionsFilePath, JSON.stringify(sessions, null, 2), "utf-8");
|
|
26402
26635
|
initSessionDir(newSession.id);
|
|
26403
26636
|
return newSession;
|
|
26404
26637
|
}
|
|
26405
26638
|
function initSessionDir(agentId) {
|
|
26406
26639
|
const sessionDir = getSessionPath(agentId);
|
|
26407
|
-
|
|
26640
|
+
import_fs_extra19.default.ensureDirSync(sessionDir);
|
|
26408
26641
|
const mainSessionPath = `${sessionDir}/main-session/`;
|
|
26409
26642
|
const mainMsgQueuePath = `${sessionDir}/main-msg-queue.json`;
|
|
26410
|
-
|
|
26411
|
-
|
|
26643
|
+
import_fs_extra19.default.ensureDirSync(mainSessionPath);
|
|
26644
|
+
import_fs_extra19.default.ensureFileSync(mainMsgQueuePath);
|
|
26412
26645
|
}
|
|
26413
26646
|
function _getCurrentAIConfig(config2) {
|
|
26414
26647
|
const currentModelName = config2.currentModel;
|
|
@@ -26423,11 +26656,11 @@ function _getCurrentAIConfig(config2) {
|
|
|
26423
26656
|
}
|
|
26424
26657
|
function getAgentId() {
|
|
26425
26658
|
const sessionsPath = getSessionsPath();
|
|
26426
|
-
const sessionsFilePath =
|
|
26427
|
-
if (!
|
|
26659
|
+
const sessionsFilePath = import_path19.default.join(sessionsPath, "sessions.json");
|
|
26660
|
+
if (!import_fs_extra19.default.pathExistsSync(sessionsFilePath)) {
|
|
26428
26661
|
return;
|
|
26429
26662
|
}
|
|
26430
|
-
const content =
|
|
26663
|
+
const content = import_fs_extra19.default.readFileSync(sessionsFilePath, "utf-8");
|
|
26431
26664
|
const parsed = JSON.parse(content);
|
|
26432
26665
|
const sessions = Array.isArray(parsed) ? parsed : [];
|
|
26433
26666
|
const workspace = getWorkspacePath();
|
|
@@ -26455,8 +26688,8 @@ function handleSkillsLs() {
|
|
|
26455
26688
|
async function handleSkillsAdd(name) {
|
|
26456
26689
|
logInfo(`Adding skill: ${name}`);
|
|
26457
26690
|
const workspace = getWorkspacePath();
|
|
26458
|
-
const skillDir =
|
|
26459
|
-
if (!
|
|
26691
|
+
const skillDir = import_path20.default.join(workspace, name);
|
|
26692
|
+
if (!import_fs_extra20.default.existsSync(skillDir)) {
|
|
26460
26693
|
logError(`Skill directory does not exist: ${skillDir}`);
|
|
26461
26694
|
return;
|
|
26462
26695
|
}
|
|
@@ -26472,16 +26705,16 @@ async function handleSkillsAdd(name) {
|
|
|
26472
26705
|
}
|
|
26473
26706
|
]);
|
|
26474
26707
|
const homePath = getHomePath();
|
|
26475
|
-
const globalSkillDir =
|
|
26476
|
-
const localSkillDir =
|
|
26708
|
+
const globalSkillDir = import_path20.default.join(homePath, "skills");
|
|
26709
|
+
const localSkillDir = import_path20.default.join(workspace, ".deepfish-ai", "skills");
|
|
26477
26710
|
if (scope === "local") {
|
|
26478
|
-
|
|
26711
|
+
import_fs_extra20.default.ensureDirSync(localSkillDir);
|
|
26479
26712
|
} else {
|
|
26480
|
-
|
|
26713
|
+
import_fs_extra20.default.ensureDirSync(globalSkillDir);
|
|
26481
26714
|
}
|
|
26482
26715
|
const targetDir = scope === "local" ? localSkillDir : globalSkillDir;
|
|
26483
|
-
const targetPath =
|
|
26484
|
-
if (
|
|
26716
|
+
const targetPath = import_path20.default.join(targetDir, name);
|
|
26717
|
+
if (import_fs_extra20.default.existsSync(targetPath)) {
|
|
26485
26718
|
const { overwrite } = await import_inquirer3.default.prompt([
|
|
26486
26719
|
{
|
|
26487
26720
|
type: "confirm",
|
|
@@ -26494,9 +26727,9 @@ async function handleSkillsAdd(name) {
|
|
|
26494
26727
|
logWarning("Add cancelled");
|
|
26495
26728
|
return;
|
|
26496
26729
|
}
|
|
26497
|
-
|
|
26730
|
+
import_fs_extra20.default.removeSync(targetPath);
|
|
26498
26731
|
}
|
|
26499
|
-
|
|
26732
|
+
import_fs_extra20.default.moveSync(skillDir, targetPath, { overwrite: true });
|
|
26500
26733
|
logSuccess(`Skill ${scope === "local" ? "locally" : "globally"} added: ${targetPath}`);
|
|
26501
26734
|
_updateRegister(targetDir);
|
|
26502
26735
|
}
|
|
@@ -26508,13 +26741,13 @@ function handleSkillsDel(index) {
|
|
|
26508
26741
|
return;
|
|
26509
26742
|
}
|
|
26510
26743
|
const skill = skills[skillIndex];
|
|
26511
|
-
|
|
26744
|
+
import_fs_extra20.default.removeSync(skill.skillPath);
|
|
26512
26745
|
const skillDir = skill.skillDir;
|
|
26513
|
-
const registerPath =
|
|
26514
|
-
if (
|
|
26515
|
-
let register =
|
|
26746
|
+
const registerPath = _getRegisterPath(skillDir);
|
|
26747
|
+
if (import_fs_extra20.default.existsSync(registerPath)) {
|
|
26748
|
+
let register = import_fs_extra20.default.readJSONSync(registerPath);
|
|
26516
26749
|
register = register.filter((item) => item.skillPath !== skill.skillPath);
|
|
26517
|
-
|
|
26750
|
+
import_fs_extra20.default.writeJSONSync(registerPath, register, { spaces: 2 });
|
|
26518
26751
|
}
|
|
26519
26752
|
logSuccess(`Skill deleted: ${skill.name}`);
|
|
26520
26753
|
}
|
|
@@ -26528,8 +26761,8 @@ function handleSkillsEnable(index) {
|
|
|
26528
26761
|
const skill = skills[skillIndex];
|
|
26529
26762
|
skill.isEnabled = true;
|
|
26530
26763
|
const skillDir = skill.skillDir;
|
|
26531
|
-
const registerPath =
|
|
26532
|
-
|
|
26764
|
+
const registerPath = _getRegisterPath(skillDir);
|
|
26765
|
+
import_fs_extra20.default.writeJSONSync(
|
|
26533
26766
|
registerPath,
|
|
26534
26767
|
skills.filter((item) => item.skillDir === skillDir),
|
|
26535
26768
|
{ spaces: 2 }
|
|
@@ -26546,8 +26779,8 @@ function handleSkillsDisable(index) {
|
|
|
26546
26779
|
const skill = skills[skillIndex];
|
|
26547
26780
|
skill.isEnabled = false;
|
|
26548
26781
|
const skillDir = skill.skillDir;
|
|
26549
|
-
const registerPath =
|
|
26550
|
-
|
|
26782
|
+
const registerPath = _getRegisterPath(skillDir);
|
|
26783
|
+
import_fs_extra20.default.writeJSONSync(
|
|
26551
26784
|
registerPath,
|
|
26552
26785
|
skills.filter((item) => item.skillDir === skillDir),
|
|
26553
26786
|
{ spaces: 2 }
|
|
@@ -26557,7 +26790,7 @@ function handleSkillsDisable(index) {
|
|
|
26557
26790
|
function handleSkillsDir() {
|
|
26558
26791
|
logInfo("Opening skills directory");
|
|
26559
26792
|
const homePath = getHomePath();
|
|
26560
|
-
const globalSkillDir =
|
|
26793
|
+
const globalSkillDir = import_path20.default.join(homePath, "skills");
|
|
26561
26794
|
openDirectory(globalSkillDir);
|
|
26562
26795
|
}
|
|
26563
26796
|
async function handleSkillsGenerate(target) {
|
|
@@ -26581,7 +26814,7 @@ async function handleSkillsGenerate(target) {
|
|
|
26581
26814
|
logError("Failed to start service, please check config or port availability");
|
|
26582
26815
|
return;
|
|
26583
26816
|
}
|
|
26584
|
-
const generateSkillPath =
|
|
26817
|
+
const generateSkillPath = import_path20.default.join(__dirname, "./generate-skill.md");
|
|
26585
26818
|
const agent = await initAgent(config2, [generateSkillPath]);
|
|
26586
26819
|
const prompt = `\u8BF7\u6839\u636E\u4EE5\u4E0B\u9700\u6C42\u751F\u6210\u4E00\u4E2ASkill\u6A21\u5757\uFF1A${target}
|
|
26587
26820
|
|
|
@@ -26599,13 +26832,13 @@ async function handleSkillsGenerate(target) {
|
|
|
26599
26832
|
}
|
|
26600
26833
|
function _scanSkills(skillsDir) {
|
|
26601
26834
|
const skills = [];
|
|
26602
|
-
if (
|
|
26603
|
-
const files =
|
|
26835
|
+
if (import_fs_extra20.default.existsSync(skillsDir)) {
|
|
26836
|
+
const files = import_fs_extra20.default.readdirSync(skillsDir);
|
|
26604
26837
|
files.forEach((file2) => {
|
|
26605
|
-
const filePath =
|
|
26606
|
-
if (
|
|
26607
|
-
const skillMdPath =
|
|
26608
|
-
if (
|
|
26838
|
+
const filePath = import_path20.default.resolve(skillsDir, file2);
|
|
26839
|
+
if (import_fs_extra20.default.statSync(filePath).isDirectory()) {
|
|
26840
|
+
const skillMdPath = import_path20.default.resolve(filePath, "SKILL.md");
|
|
26841
|
+
if (import_fs_extra20.default.existsSync(skillMdPath)) {
|
|
26609
26842
|
skills.push(filePath);
|
|
26610
26843
|
}
|
|
26611
26844
|
}
|
|
@@ -26614,17 +26847,17 @@ function _scanSkills(skillsDir) {
|
|
|
26614
26847
|
return skills;
|
|
26615
26848
|
}
|
|
26616
26849
|
function _updateRegister(skillsDir) {
|
|
26617
|
-
const registerPath =
|
|
26618
|
-
if (
|
|
26619
|
-
|
|
26620
|
-
} else if (!
|
|
26850
|
+
const registerPath = _getRegisterPath(skillsDir);
|
|
26851
|
+
if (import_fs_extra20.default.existsSync(skillsDir) && !import_fs_extra20.default.existsSync(registerPath)) {
|
|
26852
|
+
import_fs_extra20.default.writeJSONSync(registerPath, [], { spaces: 2 });
|
|
26853
|
+
} else if (!import_fs_extra20.default.existsSync(skillsDir)) {
|
|
26621
26854
|
return;
|
|
26622
26855
|
}
|
|
26623
26856
|
const skills = _scanSkills(skillsDir);
|
|
26624
|
-
let register =
|
|
26857
|
+
let register = import_fs_extra20.default.readJSONSync(registerPath);
|
|
26625
26858
|
const newRegister = [];
|
|
26626
26859
|
skills.forEach((skillPath) => {
|
|
26627
|
-
const skillName =
|
|
26860
|
+
const skillName = import_path20.default.basename(skillPath);
|
|
26628
26861
|
const existItem = register.find((item) => item.skillPath === skillPath);
|
|
26629
26862
|
if (!existItem) {
|
|
26630
26863
|
newRegister.push({
|
|
@@ -26637,16 +26870,16 @@ function _updateRegister(skillsDir) {
|
|
|
26637
26870
|
});
|
|
26638
26871
|
register = register.filter((item) => skills.includes(item.skillPath));
|
|
26639
26872
|
register.push(...newRegister);
|
|
26640
|
-
|
|
26873
|
+
import_fs_extra20.default.writeJSONSync(registerPath, register, { spaces: 2 });
|
|
26641
26874
|
}
|
|
26642
26875
|
function getRegisteredSkills() {
|
|
26643
26876
|
const scanPaths = getScanDirPaths();
|
|
26644
26877
|
const skills = [];
|
|
26645
26878
|
scanPaths.forEach((scanPath) => {
|
|
26646
26879
|
_updateRegister(scanPath);
|
|
26647
|
-
const registerPath =
|
|
26648
|
-
if (
|
|
26649
|
-
const register =
|
|
26880
|
+
const registerPath = _getRegisterPath(scanPath);
|
|
26881
|
+
if (import_fs_extra20.default.existsSync(registerPath)) {
|
|
26882
|
+
const register = import_fs_extra20.default.readJSONSync(registerPath);
|
|
26650
26883
|
register.forEach((item) => {
|
|
26651
26884
|
if (item.isEnabled) {
|
|
26652
26885
|
skills.push(item.skillPath);
|
|
@@ -26658,10 +26891,10 @@ function getRegisteredSkills() {
|
|
|
26658
26891
|
}
|
|
26659
26892
|
function _getSkillList(skillsDir) {
|
|
26660
26893
|
let allSkills = [];
|
|
26661
|
-
const registerPath =
|
|
26662
|
-
if (
|
|
26894
|
+
const registerPath = _getRegisterPath(skillsDir);
|
|
26895
|
+
if (import_fs_extra20.default.existsSync(registerPath)) {
|
|
26663
26896
|
_updateRegister(skillsDir);
|
|
26664
|
-
const register =
|
|
26897
|
+
const register = import_fs_extra20.default.readJSONSync(registerPath);
|
|
26665
26898
|
allSkills = allSkills.concat(register);
|
|
26666
26899
|
}
|
|
26667
26900
|
return allSkills;
|
|
@@ -26679,6 +26912,12 @@ function _getAllSkills() {
|
|
|
26679
26912
|
});
|
|
26680
26913
|
return allSkills;
|
|
26681
26914
|
}
|
|
26915
|
+
function _getRegisterPath(skillsDir) {
|
|
26916
|
+
if (skillsDir.endsWith("@deepfish-ai")) {
|
|
26917
|
+
return import_path20.default.join(skillsDir, "register.json");
|
|
26918
|
+
}
|
|
26919
|
+
return import_path20.default.join(skillsDir, "skills", "register.json");
|
|
26920
|
+
}
|
|
26682
26921
|
|
|
26683
26922
|
// src/cli/cli-skills.ts
|
|
26684
26923
|
function registerSkillsCommands(program) {
|
|
@@ -26694,8 +26933,38 @@ function registerSkillsCommands(program) {
|
|
|
26694
26933
|
|
|
26695
26934
|
// src/cli/cli-core/tools.ts
|
|
26696
26935
|
var import_inquirer4 = __toESM(require("inquirer"));
|
|
26697
|
-
var
|
|
26698
|
-
var
|
|
26936
|
+
var import_fs_extra21 = __toESM(require("fs-extra"));
|
|
26937
|
+
var import_path21 = __toESM(require("path"));
|
|
26938
|
+
function handleToolsLs() {
|
|
26939
|
+
const toolNames = getUserToolList().map((tool17) => {
|
|
26940
|
+
return tool17.name;
|
|
26941
|
+
});
|
|
26942
|
+
logInfo("=".repeat(50));
|
|
26943
|
+
if (toolNames.length === 0) {
|
|
26944
|
+
logInfo("No tools registered yet");
|
|
26945
|
+
} else {
|
|
26946
|
+
toolNames.forEach((name, index) => {
|
|
26947
|
+
logInfo(`[${index}] ${name}`);
|
|
26948
|
+
});
|
|
26949
|
+
}
|
|
26950
|
+
logInfo("=".repeat(50));
|
|
26951
|
+
}
|
|
26952
|
+
function handleToolsDel(index) {
|
|
26953
|
+
const toolList = getUserToolList();
|
|
26954
|
+
const toolIndex = parseInt(index, 10);
|
|
26955
|
+
if (isNaN(toolIndex) || toolIndex < 0 || toolIndex >= toolList.length) {
|
|
26956
|
+
logError("Invalid tool index");
|
|
26957
|
+
return;
|
|
26958
|
+
}
|
|
26959
|
+
const tool17 = toolList[toolIndex];
|
|
26960
|
+
if (tool17.dir) {
|
|
26961
|
+
import_fs_extra21.default.removeSync(tool17.dir);
|
|
26962
|
+
logSuccess(`Tool directory deleted: ${tool17.dir}`);
|
|
26963
|
+
} else {
|
|
26964
|
+
import_fs_extra21.default.removeSync(tool17.path);
|
|
26965
|
+
logSuccess(`Tool file deleted: ${tool17.path}`);
|
|
26966
|
+
}
|
|
26967
|
+
}
|
|
26699
26968
|
function handleToolsDir() {
|
|
26700
26969
|
const toolsPath = getToolsPath();
|
|
26701
26970
|
openDirectory(toolsPath);
|
|
@@ -26704,8 +26973,8 @@ function handleToolsDir() {
|
|
|
26704
26973
|
async function handleToolsAdd(name) {
|
|
26705
26974
|
logInfo(`Adding tool: ${name}`);
|
|
26706
26975
|
const workspace = getWorkspacePath();
|
|
26707
|
-
const toolDir =
|
|
26708
|
-
if (!
|
|
26976
|
+
const toolDir = import_path21.default.join(workspace, name);
|
|
26977
|
+
if (!import_fs_extra21.default.existsSync(toolDir)) {
|
|
26709
26978
|
logError(`Tool directory does not exist: ${toolDir}`);
|
|
26710
26979
|
return;
|
|
26711
26980
|
}
|
|
@@ -26721,12 +26990,12 @@ async function handleToolsAdd(name) {
|
|
|
26721
26990
|
}
|
|
26722
26991
|
]);
|
|
26723
26992
|
const homePath = getHomePath();
|
|
26724
|
-
const globalToolDir =
|
|
26725
|
-
const localToolDir =
|
|
26993
|
+
const globalToolDir = import_path21.default.join(homePath, "tools");
|
|
26994
|
+
const localToolDir = import_path21.default.join(workspace, ".deepfish-ai", "tools");
|
|
26726
26995
|
const targetDir = scope === "local" ? localToolDir : globalToolDir;
|
|
26727
|
-
const targetPath =
|
|
26728
|
-
|
|
26729
|
-
if (
|
|
26996
|
+
const targetPath = import_path21.default.join(targetDir, name);
|
|
26997
|
+
import_fs_extra21.default.ensureDirSync(targetDir);
|
|
26998
|
+
if (import_fs_extra21.default.existsSync(targetPath)) {
|
|
26730
26999
|
const { overwrite } = await import_inquirer4.default.prompt([
|
|
26731
27000
|
{
|
|
26732
27001
|
type: "confirm",
|
|
@@ -26739,9 +27008,9 @@ async function handleToolsAdd(name) {
|
|
|
26739
27008
|
logWarning("Add cancelled");
|
|
26740
27009
|
return;
|
|
26741
27010
|
}
|
|
26742
|
-
|
|
27011
|
+
import_fs_extra21.default.removeSync(targetPath);
|
|
26743
27012
|
}
|
|
26744
|
-
|
|
27013
|
+
import_fs_extra21.default.moveSync(toolDir, targetPath, { overwrite: true });
|
|
26745
27014
|
logSuccess(`Tool ${scope === "local" ? "locally" : "globally"} added: ${targetPath}`);
|
|
26746
27015
|
}
|
|
26747
27016
|
async function handleToolsGenerate(target) {
|
|
@@ -26765,7 +27034,7 @@ async function handleToolsGenerate(target) {
|
|
|
26765
27034
|
logError("Failed to start service, please check config or port availability");
|
|
26766
27035
|
return;
|
|
26767
27036
|
}
|
|
26768
|
-
const generateSkillPath =
|
|
27037
|
+
const generateSkillPath = import_path21.default.join(__dirname, "./generate-tool.md");
|
|
26769
27038
|
const agent = await initAgent(config2, [generateSkillPath]);
|
|
26770
27039
|
const prompt = `Please use the "generate-tool" SKILL to generate a tool module according to the following requirements: ${target}
|
|
26771
27040
|
|
|
@@ -26784,8 +27053,10 @@ async function handleToolsGenerate(target) {
|
|
|
26784
27053
|
// src/cli/cli-tools.ts
|
|
26785
27054
|
function registerToolsCommands(program) {
|
|
26786
27055
|
const tools = program.command("tools");
|
|
27056
|
+
tools.command("ls").description("\u5217\u51FA\u6240\u6709\u5DE5\u5177").action(handleToolsLs);
|
|
26787
27057
|
tools.command("dir").description("\u6253\u5F00\u5DE5\u5177\u76EE\u5F55").action(handleToolsDir);
|
|
26788
27058
|
tools.command("add <name>").description("\u6DFB\u52A0\u672C\u5730\u5DE5\u5177\u76EE\u5F55").action(handleToolsAdd);
|
|
27059
|
+
tools.command("del <index>").description("\u6309\u7D22\u5F15\u5220\u9664\u5DE5\u5177").action(handleToolsDel);
|
|
26789
27060
|
tools.command("generate <target>").description("\u751F\u6210\u5DE5\u5177").action(handleToolsGenerate);
|
|
26790
27061
|
}
|
|
26791
27062
|
|
|
@@ -26891,10 +27162,10 @@ function handleTaskClear() {
|
|
|
26891
27162
|
|
|
26892
27163
|
// src/cli/cli-task.ts
|
|
26893
27164
|
function registerTaskCommands(program) {
|
|
26894
|
-
const task = program.command("
|
|
27165
|
+
const task = program.command("tasks");
|
|
26895
27166
|
task.command("ls").description("\u5217\u51FA\u6240\u6709\u4EFB\u52A1").action(handleTaskLs);
|
|
26896
27167
|
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\
|
|
27168
|
+
task.command("del <index>").description("\u5220\u9664\u6307\u5B9A\u5E8F\u53F7\u7684\u4EFB\u52A1").action(handleTaskDel);
|
|
26898
27169
|
task.command("clear").description("\u6E05\u9664\u6240\u6709\u4EFB\u52A1").action(handleTaskClear);
|
|
26899
27170
|
}
|
|
26900
27171
|
|
|
@@ -26911,7 +27182,7 @@ function registerMcpCommands(program) {
|
|
|
26911
27182
|
}
|
|
26912
27183
|
|
|
26913
27184
|
// src/cli/cli-core/input.ts
|
|
26914
|
-
var
|
|
27185
|
+
var import_fs_extra22 = __toESM(require("fs-extra"));
|
|
26915
27186
|
var readline = __toESM(require("readline"));
|
|
26916
27187
|
async function handleInput(args) {
|
|
26917
27188
|
const input = args.join(" ");
|
|
@@ -26921,7 +27192,7 @@ async function handleInput(args) {
|
|
|
26921
27192
|
}
|
|
26922
27193
|
try {
|
|
26923
27194
|
const configPath = getConfigPath();
|
|
26924
|
-
if (!
|
|
27195
|
+
if (!import_fs_extra22.default.pathExistsSync(configPath)) {
|
|
26925
27196
|
logError("Config file not found, please run init first");
|
|
26926
27197
|
return;
|
|
26927
27198
|
}
|
|
@@ -26958,7 +27229,7 @@ async function handleInput(args) {
|
|
|
26958
27229
|
async function multiInput() {
|
|
26959
27230
|
try {
|
|
26960
27231
|
const configPath = getConfigPath();
|
|
26961
|
-
if (!
|
|
27232
|
+
if (!import_fs_extra22.default.pathExistsSync(configPath)) {
|
|
26962
27233
|
logError("Config file not found, please run init first");
|
|
26963
27234
|
return;
|
|
26964
27235
|
}
|
|
@@ -27028,7 +27299,7 @@ function registerInputCommand(program) {
|
|
|
27028
27299
|
}
|
|
27029
27300
|
|
|
27030
27301
|
// src/cli/cli-core/cache.ts
|
|
27031
|
-
var
|
|
27302
|
+
var import_path22 = __toESM(require("path"));
|
|
27032
27303
|
var userCache2 = new UserCache();
|
|
27033
27304
|
function resolveId(input) {
|
|
27034
27305
|
const index = Number(input);
|
|
@@ -27062,7 +27333,7 @@ function handleCacheList() {
|
|
|
27062
27333
|
function handleCacheEdit(input) {
|
|
27063
27334
|
const id = resolveId(input);
|
|
27064
27335
|
if (!id) return;
|
|
27065
|
-
const filePath =
|
|
27336
|
+
const filePath = import_path22.default.join(getUserStorePath(), `${id}.md`);
|
|
27066
27337
|
editFile(filePath);
|
|
27067
27338
|
}
|
|
27068
27339
|
function handleCacheDel(input) {
|
|
@@ -27094,71 +27365,6 @@ function registerCommonFlags(program) {
|
|
|
27094
27365
|
program.version(handleVersion(), "-v, --version", "Show version");
|
|
27095
27366
|
}
|
|
27096
27367
|
|
|
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
27368
|
// src/cli/index.ts
|
|
27163
27369
|
function main() {
|
|
27164
27370
|
initConfig();
|