@reconcrap/boss-recommend-mcp 1.3.20 → 1.3.21
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/package.json +1 -1
- package/src/cli.js +50 -1
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -45,6 +45,10 @@ const recommendMcpBinaryName = "boss-recommend-mcp";
|
|
|
45
45
|
const autoSyncSkipCommands = new Set(["install", "install-skill", "where", "help", "--help", "-h"]);
|
|
46
46
|
const externalMcpTargetsEnv = "BOSS_RECOMMEND_MCP_CONFIG_TARGETS";
|
|
47
47
|
const externalSkillDirsEnv = "BOSS_RECOMMEND_EXTERNAL_SKILL_DIRS";
|
|
48
|
+
const installConfigDefaults = Object.freeze({
|
|
49
|
+
llmThinkingLevel: "low",
|
|
50
|
+
humanRestEnabled: false
|
|
51
|
+
});
|
|
48
52
|
|
|
49
53
|
function getSkillSourceDir(name = skillName) {
|
|
50
54
|
return path.join(packageRoot, "skills", name);
|
|
@@ -655,6 +659,21 @@ function resolveCliConfigTarget(options = {}) {
|
|
|
655
659
|
};
|
|
656
660
|
}
|
|
657
661
|
|
|
662
|
+
function applyMissingInstallConfigDefaults(config = {}) {
|
|
663
|
+
const nextConfig = { ...config };
|
|
664
|
+
const patchedKeys = [];
|
|
665
|
+
for (const [key, defaultValue] of Object.entries(installConfigDefaults)) {
|
|
666
|
+
if (!Object.prototype.hasOwnProperty.call(nextConfig, key)) {
|
|
667
|
+
nextConfig[key] = defaultValue;
|
|
668
|
+
patchedKeys.push(key);
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
return {
|
|
672
|
+
nextConfig,
|
|
673
|
+
patchedKeys
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
|
|
658
677
|
function ensureUserConfig(options = {}) {
|
|
659
678
|
const { configPath, workspacePreferred } = resolveCliConfigTarget(options);
|
|
660
679
|
const writeTargets = dedupePaths([configPath, workspacePreferred]).filter(Boolean);
|
|
@@ -671,7 +690,27 @@ function ensureUserConfig(options = {}) {
|
|
|
671
690
|
}
|
|
672
691
|
const stat = fs.statSync(targetPath);
|
|
673
692
|
if (stat.isFile()) {
|
|
674
|
-
|
|
693
|
+
try {
|
|
694
|
+
const existingConfig = readJsonObjectFile(targetPath);
|
|
695
|
+
const patched = applyMissingInstallConfigDefaults(existingConfig);
|
|
696
|
+
if (patched.patchedKeys.length > 0) {
|
|
697
|
+
fs.writeFileSync(targetPath, JSON.stringify(patched.nextConfig, null, 2), "utf8");
|
|
698
|
+
}
|
|
699
|
+
return {
|
|
700
|
+
path: targetPath,
|
|
701
|
+
created: false,
|
|
702
|
+
patched: patched.patchedKeys.length > 0,
|
|
703
|
+
patched_keys: patched.patchedKeys
|
|
704
|
+
};
|
|
705
|
+
} catch (error) {
|
|
706
|
+
return {
|
|
707
|
+
path: targetPath,
|
|
708
|
+
created: false,
|
|
709
|
+
patched: false,
|
|
710
|
+
patched_keys: [],
|
|
711
|
+
patch_error: error?.message || "screening-config.json 解析失败,跳过自动补字段。"
|
|
712
|
+
};
|
|
713
|
+
}
|
|
675
714
|
}
|
|
676
715
|
lastError = new Error(`Config target is a directory and cannot be used as file: ${targetPath}`);
|
|
677
716
|
} catch (error) {
|
|
@@ -1286,6 +1325,11 @@ function installAll(options = {}) {
|
|
|
1286
1325
|
? `screening-config.json created: ${configResult.path}`
|
|
1287
1326
|
: `screening-config.json already exists: ${configResult.path}`
|
|
1288
1327
|
);
|
|
1328
|
+
if (Array.isArray(configResult.patched_keys) && configResult.patched_keys.length > 0) {
|
|
1329
|
+
console.log(`screening-config.json patched missing defaults: ${configResult.patched_keys.join(", ")}`);
|
|
1330
|
+
} else if (configResult.patch_error) {
|
|
1331
|
+
console.warn(`screening-config.json skip default patch: ${configResult.patch_error}`);
|
|
1332
|
+
}
|
|
1289
1333
|
console.log(`请在该目录修改 baseUrl/apiKey/model 并替换占位词后再运行:${path.dirname(configResult.path)}`);
|
|
1290
1334
|
console.log(`MCP config templates exported to: ${mcpTemplateResult.outputDir}`);
|
|
1291
1335
|
for (const item of mcpTemplateResult.files) {
|
|
@@ -1482,6 +1526,11 @@ export async function runCli(argv = process.argv) {
|
|
|
1482
1526
|
case "init-config": {
|
|
1483
1527
|
const result = ensureUserConfig(options);
|
|
1484
1528
|
console.log(result.created ? `Config template created at: ${result.path}` : `Config already exists at: ${result.path}`);
|
|
1529
|
+
if (Array.isArray(result.patched_keys) && result.patched_keys.length > 0) {
|
|
1530
|
+
console.log(`Config patched missing defaults: ${result.patched_keys.join(", ")}`);
|
|
1531
|
+
} else if (result.patch_error) {
|
|
1532
|
+
console.warn(`Config skip default patch: ${result.patch_error}`);
|
|
1533
|
+
}
|
|
1485
1534
|
break;
|
|
1486
1535
|
}
|
|
1487
1536
|
case "set-port": {
|