@lark-apaas/openclaw-scripts-diagnose-cli 0.1.4-beta.1 → 0.1.5-alpha.0
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/index.cjs +44 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -53,7 +53,7 @@ let json_diff = require("json-diff");
|
|
|
53
53
|
* it terse and parseable.
|
|
54
54
|
*/
|
|
55
55
|
function getVersion() {
|
|
56
|
-
return "0.1.
|
|
56
|
+
return "0.1.5-alpha.0";
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region src/rule-engine/base.ts
|
|
@@ -1420,19 +1420,24 @@ OldMiaodaPluginsCleanupRule = __decorate([Rule({
|
|
|
1420
1420
|
//#endregion
|
|
1421
1421
|
//#region src/rules/lark-plugin-allow.ts
|
|
1422
1422
|
const LARK_PLUGIN = "openclaw-lark";
|
|
1423
|
-
const
|
|
1423
|
+
const LEGACY_LARK_PLUGIN = "feishu-openclaw-plugin";
|
|
1424
|
+
const LARK_PLUGIN_NAMES = [LARK_PLUGIN, LEGACY_LARK_PLUGIN];
|
|
1424
1425
|
let LarkPluginAllowRule = class LarkPluginAllowRule extends DiagnoseRule {
|
|
1425
1426
|
validate(ctx) {
|
|
1426
1427
|
const allow = getAllow(ctx.config);
|
|
1427
1428
|
if (LARK_PLUGIN_NAMES.some((name) => allow.includes(name))) return { pass: true };
|
|
1429
|
+
const installed = detectInstalledLarkPlugin(getExtensionsDir(ctx.configPath));
|
|
1430
|
+
if (installed == null) return { pass: true };
|
|
1428
1431
|
return {
|
|
1429
1432
|
pass: false,
|
|
1430
|
-
message: `plugins.allow 缺少飞书插件
|
|
1433
|
+
message: `plugins.allow 缺少飞书插件 ${installed}(已在 extensions/ 下装但未启用)`
|
|
1431
1434
|
};
|
|
1432
1435
|
}
|
|
1433
1436
|
repair(ctx) {
|
|
1437
|
+
const installed = detectInstalledLarkPlugin(getExtensionsDir(ctx.configPath));
|
|
1438
|
+
if (installed == null) return;
|
|
1434
1439
|
if (ctx.config.plugins == null || typeof ctx.config.plugins !== "object" || Array.isArray(ctx.config.plugins)) {
|
|
1435
|
-
ctx.config.plugins = { allow: [
|
|
1440
|
+
ctx.config.plugins = { allow: [installed] };
|
|
1436
1441
|
return;
|
|
1437
1442
|
}
|
|
1438
1443
|
const pluginsMap = ctx.config.plugins;
|
|
@@ -1440,7 +1445,7 @@ let LarkPluginAllowRule = class LarkPluginAllowRule extends DiagnoseRule {
|
|
|
1440
1445
|
const original = Array.isArray(rawAllow) ? rawAllow : [];
|
|
1441
1446
|
const stringAllow = original.filter((e) => typeof e === "string");
|
|
1442
1447
|
if (LARK_PLUGIN_NAMES.some((name) => stringAllow.includes(name))) return;
|
|
1443
|
-
original.push(
|
|
1448
|
+
original.push(installed);
|
|
1444
1449
|
pluginsMap.allow = original;
|
|
1445
1450
|
}
|
|
1446
1451
|
};
|
|
@@ -1456,6 +1461,22 @@ function getAllow(config) {
|
|
|
1456
1461
|
if (!Array.isArray(allow)) return [];
|
|
1457
1462
|
return allow.filter((e) => typeof e === "string");
|
|
1458
1463
|
}
|
|
1464
|
+
/**
|
|
1465
|
+
* fs-only 检测:`<extDir>/<name>/package.json` 存在即视为已装。
|
|
1466
|
+
* 优先级 openclaw-lark(新版)> feishu-openclaw-plugin(legacy)。
|
|
1467
|
+
* 不读 package.json 内容,只判存在性,避开 JSON 损坏。
|
|
1468
|
+
*/
|
|
1469
|
+
function detectInstalledLarkPlugin(extDir) {
|
|
1470
|
+
for (const name of [LARK_PLUGIN, LEGACY_LARK_PLUGIN]) if (pluginPackageJsonExists(extDir, name)) return name;
|
|
1471
|
+
return null;
|
|
1472
|
+
}
|
|
1473
|
+
function pluginPackageJsonExists(extDir, pluginDir) {
|
|
1474
|
+
try {
|
|
1475
|
+
return node_fs.default.existsSync(node_path.default.join(extDir, pluginDir, "package.json"));
|
|
1476
|
+
} catch {
|
|
1477
|
+
return false;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1459
1480
|
//#endregion
|
|
1460
1481
|
//#region src/fs-utils.ts
|
|
1461
1482
|
/**
|
|
@@ -2974,6 +2995,7 @@ async function installExtension(tag, ossFileMap, opts = {}) {
|
|
|
2974
2995
|
else console.error(`[install-extension] skipConfigUpdate=true — not touching openclaw.json`);
|
|
2975
2996
|
console.error(`[install-extension] done ${targets.length}/${targets.length} in ${Date.now() - t0}ms`);
|
|
2976
2997
|
}
|
|
2998
|
+
const MEM0_PLUGIN_NAME = "openclaw-mem0-plugin";
|
|
2977
2999
|
/**
|
|
2978
3000
|
* Merge each installed extension's installMetadata into openclaw.json's
|
|
2979
3001
|
* plugins.installs[<pkg.name>]. Atomic write via tmp + rename.
|
|
@@ -2981,6 +3003,11 @@ async function installExtension(tag, ossFileMap, opts = {}) {
|
|
|
2981
3003
|
* - No openclaw.json → log + return (not an error; some install contexts don't have it yet)
|
|
2982
3004
|
* - Extension without installMetadata in manifest → skip that entry (log)
|
|
2983
3005
|
* - Existing plugins.installs entries for other extensions left untouched
|
|
3006
|
+
*
|
|
3007
|
+
* Special-case for mem0: when openclaw-mem0-plugin is among the installed
|
|
3008
|
+
* targets, also append it to plugins.allow (idempotent) and seed
|
|
3009
|
+
* plugins.entries.openclaw-mem0-plugin = { enabled: false } when the key
|
|
3010
|
+
* is absent. Existing values are preserved (user toggles survive).
|
|
2984
3011
|
*/
|
|
2985
3012
|
function updatePluginInstalls(configPath, installedPkgs) {
|
|
2986
3013
|
if (!node_fs.default.existsSync(configPath)) {
|
|
@@ -3000,10 +3027,20 @@ function updatePluginInstalls(configPath, installedPkgs) {
|
|
|
3000
3027
|
installs[pkg.name] = pkg.installMetadata;
|
|
3001
3028
|
updated++;
|
|
3002
3029
|
} else skipped++;
|
|
3030
|
+
const installedMem0 = installedPkgs.some((p) => p.name === MEM0_PLUGIN_NAME);
|
|
3031
|
+
if (installedMem0) {
|
|
3032
|
+
const allowRaw = plugins.allow;
|
|
3033
|
+
const allow = Array.isArray(allowRaw) ? allowRaw : [];
|
|
3034
|
+
if (!allow.filter((e) => typeof e === "string").includes(MEM0_PLUGIN_NAME)) allow.push(MEM0_PLUGIN_NAME);
|
|
3035
|
+
plugins.allow = allow;
|
|
3036
|
+
if (!plugins.entries || typeof plugins.entries !== "object" || Array.isArray(plugins.entries)) plugins.entries = {};
|
|
3037
|
+
const entries = plugins.entries;
|
|
3038
|
+
if (!(MEM0_PLUGIN_NAME in entries)) entries[MEM0_PLUGIN_NAME] = { enabled: false };
|
|
3039
|
+
}
|
|
3003
3040
|
const tmpPath = configPath + ".installs-tmp";
|
|
3004
3041
|
node_fs.default.writeFileSync(tmpPath, JSON.stringify(config, null, 2), "utf-8");
|
|
3005
3042
|
moveSafe(tmpPath, configPath);
|
|
3006
|
-
console.error(`[install-extension] plugins.installs updated: ${updated} entry(ies) in ${configPath}` + (skipped > 0 ? ` (${skipped} package(s) without installMetadata skipped)` : ""));
|
|
3043
|
+
console.error(`[install-extension] plugins.installs updated: ${updated} entry(ies) in ${configPath}` + (skipped > 0 ? ` (${skipped} package(s) without installMetadata skipped)` : "") + (installedMem0 ? " [mem0: allow+entries seeded]" : ""));
|
|
3007
3044
|
}
|
|
3008
3045
|
function installOne(pkg, tarball, homeBase) {
|
|
3009
3046
|
const destDir = node_path.default.join(homeBase, pkg.installPath);
|
|
@@ -4276,7 +4313,7 @@ async function reportCliRun(opts) {
|
|
|
4276
4313
|
//#region src/help.ts
|
|
4277
4314
|
const BIN = "mclaw-diagnose";
|
|
4278
4315
|
function versionBanner() {
|
|
4279
|
-
return `v0.1.
|
|
4316
|
+
return `v0.1.5-alpha.0`;
|
|
4280
4317
|
}
|
|
4281
4318
|
const COMMANDS = [
|
|
4282
4319
|
{
|