bfi-cli 0.1.83 → 0.1.85
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/dist/cli.mjs +71 -3
- package/dist/mcp-codesearch/main.mjs +6 -4
- package/package.json +2 -2
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";
|
|
@@ -111,11 +111,13 @@ function buildServer(remote) {
|
|
|
111
111
|
}, {
|
|
112
112
|
capabilities: { tools: {} },
|
|
113
113
|
instructions: [
|
|
114
|
-
"代码图谱/规则链/跨仓检索通道(bfi cli
|
|
114
|
+
"代码图谱/规则链/跨仓检索通道(bfi cli 登录态鉴权,零配置)。",
|
|
115
|
+
"完整工具清单以远端 listTools 动态下发为准,下列为常用入口:",
|
|
115
116
|
"· 结构化查询:query(BM25+语义混合检索)/ context(符号360度)/ trace(最短调用路径)/ impact(影响面)/ cypher(图谱直查)",
|
|
116
|
-
"·
|
|
117
|
-
"· 内容检索:zoekt_search
|
|
118
|
-
"·
|
|
117
|
+
"· 规则链:rule_chain(单据动作有效规则链)/ rule_impact(规则被哪些链使用)/ rule_search(模糊搜规则/单据)",
|
|
118
|
+
"· 内容检索:zoekt_search(跨 309 仓文本/正则/行级,毫秒级——搜字面量/URL/配置值/报错文案);read_file / grep(单仓工作区文件读取与文本检索——定位到仓后取原文片段用)",
|
|
119
|
+
"· 多仓契约组:group_list(组清单)/ group_sync(契约同步);组内可跨仓 trace(repo 传 \"@组名\")",
|
|
120
|
+
"· 佐证纪律:多候选必须让用户确认;trace 结果校验仓库归属;检索结果不是完整源码,结合行号取源码片段引用;跨仓 trace 仅覆盖契约可提取的调用形态,\"无路径\"不等于\"无调用\""
|
|
119
121
|
].join("\n")
|
|
120
122
|
});
|
|
121
123
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
package/package.json
CHANGED