@bangdao-ai/acw-tools 1.4.14 → 1.4.15
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/index.js +48 -2
- package/manifest.json +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -727,9 +727,14 @@ let mcpConfig = {
|
|
|
727
727
|
};
|
|
728
728
|
|
|
729
729
|
// 从环境变量读取配置
|
|
730
|
-
|
|
730
|
+
// 自动移除末尾斜杠,避免 URL 拼接时产生双斜杠问题(如 https://xxx.com//api/...)
|
|
731
|
+
const RAW_BASE_URL = process.env.ACW_BASE_URL || "https://acw.bangdao-tech.com";
|
|
732
|
+
const BASE_URL = RAW_BASE_URL.replace(/\/+$/, '');
|
|
731
733
|
const TOKEN = process.env.ACW_TOKEN; // Token认证(必需)
|
|
732
734
|
|
|
735
|
+
// 检查 BASE_URL 是否被修正过(用于日志提示)
|
|
736
|
+
const baseUrlWasCorrected = RAW_BASE_URL !== BASE_URL;
|
|
737
|
+
|
|
733
738
|
// 检查 TOKEN 是否有效(未设置或为占位符值时视为无效)
|
|
734
739
|
const isTokenValid = TOKEN && TOKEN !== 'your_acw_token' && TOKEN.trim() !== '';
|
|
735
740
|
|
|
@@ -766,9 +771,19 @@ logger.info("MCP 配置信息", {
|
|
|
766
771
|
baseUrl: BASE_URL,
|
|
767
772
|
authMethod: 'Token',
|
|
768
773
|
tokenConfigured: isTokenValid,
|
|
769
|
-
cwd: process.cwd()
|
|
774
|
+
cwd: process.cwd(),
|
|
775
|
+
baseUrlCorrected: baseUrlWasCorrected ? `已自动修正(原值: ${RAW_BASE_URL})` : undefined
|
|
770
776
|
});
|
|
771
777
|
|
|
778
|
+
// 如果 BASE_URL 被修正过,记录警告
|
|
779
|
+
if (baseUrlWasCorrected) {
|
|
780
|
+
logger.warn("ACW_BASE_URL 末尾斜杠已自动移除", {
|
|
781
|
+
original: RAW_BASE_URL,
|
|
782
|
+
corrected: BASE_URL,
|
|
783
|
+
hint: '建议修改配置,移除 ACW_BASE_URL 末尾的斜杠'
|
|
784
|
+
});
|
|
785
|
+
}
|
|
786
|
+
|
|
772
787
|
// ==================== 对话抓取功能 ====================
|
|
773
788
|
|
|
774
789
|
/**
|
|
@@ -2594,6 +2609,37 @@ async function downloadAndExtractRule(ruleIdentifier, targetDir) {
|
|
|
2594
2609
|
throw new Error(`请求错误: ${errorData.message || '请求参数错误'}`);
|
|
2595
2610
|
}
|
|
2596
2611
|
|
|
2612
|
+
// HTTP 405 Method Not Allowed - 通常是配置问题
|
|
2613
|
+
if (response.status === 405) {
|
|
2614
|
+
logger.error("HTTP 405 错误 - 请求方法不被允许", {
|
|
2615
|
+
apiUrl,
|
|
2616
|
+
method: "POST",
|
|
2617
|
+
baseUrl: BASE_URL,
|
|
2618
|
+
hint: "可能是 ACW_BASE_URL 配置错误或服务器路由问题"
|
|
2619
|
+
});
|
|
2620
|
+
throw new Error(
|
|
2621
|
+
`HTTP 405 错误:请求方法不被允许。\n\n` +
|
|
2622
|
+
`可能原因:\n` +
|
|
2623
|
+
`1. ACW_BASE_URL 配置错误(当前值: ${BASE_URL})\n` +
|
|
2624
|
+
`2. 服务器接口路径变更\n` +
|
|
2625
|
+
`3. 网络代理/网关拦截了请求\n\n` +
|
|
2626
|
+
`解决方案:\n` +
|
|
2627
|
+
`1. 检查 ~/.cursor/mcp_settings.json 中的 ACW_BASE_URL 配置\n` +
|
|
2628
|
+
`2. 确保 ACW_BASE_URL 设置为 https://acw.bangdao-tech.com(不带末尾斜杠)\n` +
|
|
2629
|
+
`3. 升级 MCP 到最新版本: npx -y @bangdao-ai/acw-tools@latest\n` +
|
|
2630
|
+
`4. 重启 Cursor 后重试`
|
|
2631
|
+
);
|
|
2632
|
+
}
|
|
2633
|
+
|
|
2634
|
+
// HTTP 502/503/504 网关错误
|
|
2635
|
+
if (response.status >= 502 && response.status <= 504) {
|
|
2636
|
+
logger.error("网关错误", { statusCode: response.status, apiUrl });
|
|
2637
|
+
throw new Error(
|
|
2638
|
+
`服务器网关错误 (HTTP ${response.status}),ACW 服务可能暂时不可用。\n` +
|
|
2639
|
+
`请稍后重试,如持续出现请联系管理员。`
|
|
2640
|
+
);
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2597
2643
|
// 检查是否是JSON响应(多个匹配的情况)
|
|
2598
2644
|
const contentType = response.headers.get("content-type");
|
|
2599
2645
|
if (contentType && contentType.includes("application/json")) {
|
package/manifest.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ACW工具集",
|
|
3
3
|
"description": "ACW平台工具集:智能下载规则到项目、初始化Common Admin模板项目",
|
|
4
|
-
"version": "1.4.
|
|
4
|
+
"version": "1.4.15",
|
|
5
5
|
"author": "邦道科技 - 产品技术中心",
|
|
6
6
|
"homepage": "https://www.npmjs.com/package/@bangdao-ai/acw-tools",
|
|
7
7
|
"repository": "https://www.npmjs.com/package/@bangdao-ai/acw-tools?activeTab=readme",
|
package/package.json
CHANGED