bfi-cli 0.1.82 → 0.1.84
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/bin/bfi-codesearch-mcp.js +0 -0
- package/bin/bfi-db-mcp.js +0 -0
- package/dist/cli.mjs +71 -3
- package/dist/mcp-codesearch/main.mjs +1 -1
- package/package.json +2 -2
|
File without changes
|
package/bin/bfi-db-mcp.js
CHANGED
|
File without changes
|
package/dist/cli.mjs
CHANGED
|
@@ -828,6 +828,40 @@ var SkillHubAPI = class {
|
|
|
828
828
|
async getDoc(id) {
|
|
829
829
|
return (await this.request("GET", `/process-docs/${id}`)).body;
|
|
830
830
|
}
|
|
831
|
+
async downloadDoc(id) {
|
|
832
|
+
const url = new URL(this.buildUrl(`/process-docs/${id}/download`));
|
|
833
|
+
const isHttps = url.protocol === "https:";
|
|
834
|
+
const client = isHttps ? https : http;
|
|
835
|
+
const requestOptions = {
|
|
836
|
+
method: "GET",
|
|
837
|
+
headers: this.getHeaders()
|
|
838
|
+
};
|
|
839
|
+
if (isHttps) requestOptions.rejectUnauthorized = this.rejectUnauthorized;
|
|
840
|
+
return new Promise((resolve, reject) => {
|
|
841
|
+
const req = client.request(url, requestOptions, (res) => {
|
|
842
|
+
const chunks = [];
|
|
843
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
844
|
+
res.on("end", () => {
|
|
845
|
+
const statusCode = res.statusCode || 500;
|
|
846
|
+
if (statusCode < 200 || statusCode >= 300) {
|
|
847
|
+
const error = /* @__PURE__ */ new Error(`HTTP ${statusCode}`);
|
|
848
|
+
error.status = statusCode;
|
|
849
|
+
reject(error);
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
const disposition = String(res.headers["content-disposition"] || "");
|
|
853
|
+
const utf8Match = disposition.match(/filename\*=UTF-8''([^;]+)/i);
|
|
854
|
+
const plainMatch = disposition.match(/filename="?([^";]+)"?/i);
|
|
855
|
+
resolve({
|
|
856
|
+
fileName: utf8Match ? decodeURIComponent(utf8Match[1]) : plainMatch ? plainMatch[1] : `process-doc-${id}`,
|
|
857
|
+
buffer: Buffer.concat(chunks)
|
|
858
|
+
});
|
|
859
|
+
});
|
|
860
|
+
});
|
|
861
|
+
req.on("error", reject);
|
|
862
|
+
req.end();
|
|
863
|
+
});
|
|
864
|
+
}
|
|
831
865
|
async logSkillUsage(skillName, contentSummary = "") {
|
|
832
866
|
return (await this.request("POST", "/public/skill-usage", { body: {
|
|
833
867
|
skillName,
|
|
@@ -6359,19 +6393,25 @@ async function runDocs(args, globalOpts) {
|
|
|
6359
6393
|
case "info":
|
|
6360
6394
|
await handleInfo(args.slice(1), globalOpts);
|
|
6361
6395
|
break;
|
|
6396
|
+
case "download":
|
|
6397
|
+
await handleDownload(args.slice(1), globalOpts);
|
|
6398
|
+
break;
|
|
6362
6399
|
default: printDocsHelp();
|
|
6363
6400
|
}
|
|
6364
6401
|
}
|
|
6365
6402
|
function printDocsHelp() {
|
|
6366
6403
|
console.log("文档命令:");
|
|
6367
|
-
console.log(" bfi docs upload <file>
|
|
6404
|
+
console.log(" bfi docs upload <file> 上传文档(.md/.txt/.html ≤5MB,.zip ≤50MB)");
|
|
6368
6405
|
console.log(" bfi docs list 列出已上传文档");
|
|
6369
|
-
console.log(" bfi docs info <id>
|
|
6406
|
+
console.log(" bfi docs info <id> 查看文档信息与内容");
|
|
6407
|
+
console.log(" bfi docs download <id> 下载原始文档文件");
|
|
6370
6408
|
console.log();
|
|
6371
6409
|
console.log("示例:");
|
|
6372
|
-
console.log(` ${DIM$7}$ ${RESET$7}bfi docs upload
|
|
6410
|
+
console.log(` ${DIM$7}$ ${RESET$7}bfi docs upload notes.md`);
|
|
6411
|
+
console.log(` ${DIM$7}$ ${RESET$7}bfi docs upload bundle.zip`);
|
|
6373
6412
|
console.log(` ${DIM$7}$ ${RESET$7}bfi docs list`);
|
|
6374
6413
|
console.log(` ${DIM$7}$ ${RESET$7}bfi docs info 42`);
|
|
6414
|
+
console.log(` ${DIM$7}$ ${RESET$7}bfi docs download 42`);
|
|
6375
6415
|
}
|
|
6376
6416
|
async function handleUpload(args, globalOpts) {
|
|
6377
6417
|
const filePath = args[0];
|
|
@@ -6503,6 +6543,9 @@ async function handleInfo(args, globalOpts) {
|
|
|
6503
6543
|
console.log(`${DIM$7}${"─".repeat(48)}${RESET$7}`);
|
|
6504
6544
|
for (const line of content.split("\n")) console.log(` ${TEXT$6}${line}${RESET$7}`);
|
|
6505
6545
|
console.log(`${DIM$7}${"─".repeat(48)}${RESET$7}`);
|
|
6546
|
+
} else if (doc.content === null || doc.content === void 0) {
|
|
6547
|
+
console.log();
|
|
6548
|
+
console.log(` ${DIM$7}该文件类型不支持内容预览,可用 bfi docs download ${doc.id} 获取原始文件${RESET$7}`);
|
|
6506
6549
|
}
|
|
6507
6550
|
console.log();
|
|
6508
6551
|
} catch (error) {
|
|
@@ -6511,6 +6554,31 @@ async function handleInfo(args, globalOpts) {
|
|
|
6511
6554
|
process.exit(1);
|
|
6512
6555
|
}
|
|
6513
6556
|
}
|
|
6557
|
+
async function handleDownload(args, globalOpts) {
|
|
6558
|
+
const docId = args[0];
|
|
6559
|
+
if (!docId) {
|
|
6560
|
+
console.error("用法:bfi docs download <id>");
|
|
6561
|
+
process.exit(1);
|
|
6562
|
+
}
|
|
6563
|
+
const id = parseInt(docId, 10);
|
|
6564
|
+
if (isNaN(id)) {
|
|
6565
|
+
console.error(`无效的文档 ID:${docId}`);
|
|
6566
|
+
process.exit(1);
|
|
6567
|
+
}
|
|
6568
|
+
const { registry, token } = resolveConfig(globalOpts);
|
|
6569
|
+
const api = new SkillHubAPI(registry, token);
|
|
6570
|
+
try {
|
|
6571
|
+
const { fileName, buffer } = await api.downloadDoc(id);
|
|
6572
|
+
const safeName = path$1.basename(fileName);
|
|
6573
|
+
const targetPath = path$1.resolve(safeName);
|
|
6574
|
+
fs.writeFileSync(targetPath, buffer);
|
|
6575
|
+
console.log(`${TEXT$6}✓ 已保存 ${safeName} (${formatFileSize(buffer.length)})${RESET$7}`);
|
|
6576
|
+
} catch (error) {
|
|
6577
|
+
if (error.status === 404) console.error(`未找到文档:${id}`);
|
|
6578
|
+
else console.error(`下载失败:${error.message}`);
|
|
6579
|
+
process.exit(1);
|
|
6580
|
+
}
|
|
6581
|
+
}
|
|
6514
6582
|
const RESET$6 = "\x1B[0m";
|
|
6515
6583
|
const BOLD$4 = "\x1B[1m";
|
|
6516
6584
|
const DIM$6 = "\x1B[38;5;102m";
|
|
@@ -104,7 +104,7 @@ function textResult(payload, isError = false) {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
function buildServer(remote) {
|
|
107
|
-
const bcs = remote ?? new BcsRemote(process.env.BFI_BCS_URL || "https://bfi.yyuap.com
|
|
107
|
+
const bcs = remote ?? new BcsRemote(process.env.BFI_BCS_URL || "https://bfi.yyuap.com/bcs/mcp", resolveToken);
|
|
108
108
|
const server = new Server({
|
|
109
109
|
name: "bfi-code-search",
|
|
110
110
|
version: "0.1.0"
|
package/package.json
CHANGED