@lark-apaas/openclaw-scripts-diagnose-cli 0.1.6-alpha.1 → 0.1.6-alpha.10
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 +133 -285
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -23,12 +23,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
//#endregion
|
|
24
24
|
let node_process = require("node:process");
|
|
25
25
|
node_process = __toESM(node_process);
|
|
26
|
+
let node_fs = require("node:fs");
|
|
27
|
+
node_fs = __toESM(node_fs);
|
|
26
28
|
let node_path = require("node:path");
|
|
27
29
|
node_path = __toESM(node_path);
|
|
28
30
|
let json5 = require("json5");
|
|
29
31
|
json5 = __toESM(json5);
|
|
30
|
-
let node_fs = require("node:fs");
|
|
31
|
-
node_fs = __toESM(node_fs);
|
|
32
32
|
let node_child_process = require("node:child_process");
|
|
33
33
|
let node_crypto = require("node:crypto");
|
|
34
34
|
node_crypto = __toESM(node_crypto);
|
|
@@ -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.6-alpha.
|
|
56
|
+
return "0.1.6-alpha.10";
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region src/rule-engine/base.ts
|
|
@@ -108,6 +108,14 @@ function topoSort(rules) {
|
|
|
108
108
|
function getExtensionsDir(configPath) {
|
|
109
109
|
return node_path.default.join(node_path.default.dirname(configPath), "extensions");
|
|
110
110
|
}
|
|
111
|
+
/** 判断 `<extDir>/<name>/package.json` 是否存在,即插件是否已安装到磁盘。 */
|
|
112
|
+
function isPluginInstalledOnDisk(extDir, name) {
|
|
113
|
+
try {
|
|
114
|
+
return node_fs.default.existsSync(node_path.default.join(extDir, name, "package.json"));
|
|
115
|
+
} catch {
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
111
119
|
/**
|
|
112
120
|
* Canonical provider-ref for the feishu app secret. Both
|
|
113
121
|
* `feishu_default_account` (multi-agent path) and `feishu_channel`
|
|
@@ -1381,11 +1389,11 @@ OldMiaodaPluginsCleanupRule = __decorate([Rule({
|
|
|
1381
1389
|
//#region src/rules/lark-plugin-allow.ts
|
|
1382
1390
|
const LARK_PLUGIN = "openclaw-lark";
|
|
1383
1391
|
const LEGACY_LARK_PLUGIN = "feishu-openclaw-plugin";
|
|
1384
|
-
const LARK_PLUGIN_NAMES
|
|
1392
|
+
const LARK_PLUGIN_NAMES = [LARK_PLUGIN, LEGACY_LARK_PLUGIN];
|
|
1385
1393
|
let LarkPluginAllowRule = class LarkPluginAllowRule extends DiagnoseRule {
|
|
1386
1394
|
validate(ctx) {
|
|
1387
|
-
const allow = getAllow(ctx.config);
|
|
1388
|
-
if (LARK_PLUGIN_NAMES
|
|
1395
|
+
const allow = getAllow$1(ctx.config);
|
|
1396
|
+
if (LARK_PLUGIN_NAMES.some((name) => allow.includes(name))) return { pass: true };
|
|
1389
1397
|
const installed = detectInstalledLarkPlugin(getExtensionsDir(ctx.configPath));
|
|
1390
1398
|
if (installed == null) return { pass: true };
|
|
1391
1399
|
return {
|
|
@@ -1404,7 +1412,7 @@ let LarkPluginAllowRule = class LarkPluginAllowRule extends DiagnoseRule {
|
|
|
1404
1412
|
const rawAllow = pluginsMap.allow;
|
|
1405
1413
|
const original = Array.isArray(rawAllow) ? rawAllow : [];
|
|
1406
1414
|
const stringAllow = original.filter((e) => typeof e === "string");
|
|
1407
|
-
if (LARK_PLUGIN_NAMES
|
|
1415
|
+
if (LARK_PLUGIN_NAMES.some((name) => stringAllow.includes(name))) return;
|
|
1408
1416
|
original.push(installed);
|
|
1409
1417
|
pluginsMap.allow = original;
|
|
1410
1418
|
}
|
|
@@ -1414,7 +1422,7 @@ LarkPluginAllowRule = __decorate([Rule({
|
|
|
1414
1422
|
dependsOn: ["config_syntax_check"],
|
|
1415
1423
|
repairMode: "standard"
|
|
1416
1424
|
})], LarkPluginAllowRule);
|
|
1417
|
-
function getAllow(config) {
|
|
1425
|
+
function getAllow$1(config) {
|
|
1418
1426
|
const plugins = config.plugins;
|
|
1419
1427
|
if (plugins == null || typeof plugins !== "object" || Array.isArray(plugins)) return [];
|
|
1420
1428
|
const allow = plugins.allow;
|
|
@@ -1438,6 +1446,122 @@ function pluginPackageJsonExists(extDir, pluginDir) {
|
|
|
1438
1446
|
}
|
|
1439
1447
|
}
|
|
1440
1448
|
//#endregion
|
|
1449
|
+
//#region src/rules/miaoda-plugin-allow.ts
|
|
1450
|
+
const MIAODA_PLUGIN = "openclaw-extension-miaoda";
|
|
1451
|
+
let MiaodaPluginAllowRule = class MiaodaPluginAllowRule extends DiagnoseRule {
|
|
1452
|
+
validate(ctx) {
|
|
1453
|
+
if (!isPluginInstalledOnDisk(getExtensionsDir(ctx.configPath), MIAODA_PLUGIN)) return { pass: true };
|
|
1454
|
+
if (getAllow(ctx.config).includes(MIAODA_PLUGIN)) return { pass: true };
|
|
1455
|
+
return {
|
|
1456
|
+
pass: false,
|
|
1457
|
+
message: `plugins.allow 缺少 ${MIAODA_PLUGIN}(已在 extensions/ 下装但未启用)`
|
|
1458
|
+
};
|
|
1459
|
+
}
|
|
1460
|
+
repair(ctx) {
|
|
1461
|
+
if (!isPluginInstalledOnDisk(getExtensionsDir(ctx.configPath), MIAODA_PLUGIN)) return;
|
|
1462
|
+
const plugins = ctx.config.plugins;
|
|
1463
|
+
if (plugins == null || typeof plugins !== "object" || Array.isArray(plugins)) {
|
|
1464
|
+
ctx.config.plugins = { allow: [MIAODA_PLUGIN] };
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
const pluginsMap = plugins;
|
|
1468
|
+
const rawAllow = pluginsMap.allow;
|
|
1469
|
+
const allow = Array.isArray(rawAllow) ? rawAllow : [];
|
|
1470
|
+
if (allow.includes(MIAODA_PLUGIN)) return;
|
|
1471
|
+
allow.push(MIAODA_PLUGIN);
|
|
1472
|
+
pluginsMap.allow = allow;
|
|
1473
|
+
}
|
|
1474
|
+
};
|
|
1475
|
+
MiaodaPluginAllowRule = __decorate([Rule({
|
|
1476
|
+
key: "miaoda_plugin_allow",
|
|
1477
|
+
dependsOn: ["config_syntax_check"],
|
|
1478
|
+
repairMode: "standard",
|
|
1479
|
+
profile: "experimental"
|
|
1480
|
+
})], MiaodaPluginAllowRule);
|
|
1481
|
+
function getAllow(config) {
|
|
1482
|
+
const plugins = config.plugins;
|
|
1483
|
+
if (plugins == null || typeof plugins !== "object" || Array.isArray(plugins)) return [];
|
|
1484
|
+
const allow = plugins.allow;
|
|
1485
|
+
if (!Array.isArray(allow)) return [];
|
|
1486
|
+
return allow.filter((e) => typeof e === "string");
|
|
1487
|
+
}
|
|
1488
|
+
//#endregion
|
|
1489
|
+
//#region src/rules/builtin-plugin-missing.ts
|
|
1490
|
+
/**
|
|
1491
|
+
* install-extension --all 安装的内置扩展插件列表(manifest role=extension)。
|
|
1492
|
+
* 与 miaoda-official-plugins-install-spec-unlock.ts 中的 OFFICIAL_PLUGIN_NAMES 保持一致。
|
|
1493
|
+
*/
|
|
1494
|
+
const BUILTIN_EXTENSION_PLUGINS = new Set([
|
|
1495
|
+
"openclaw-lark",
|
|
1496
|
+
"openclaw-extension-miaoda",
|
|
1497
|
+
"openclaw-extension-miaoda-coding",
|
|
1498
|
+
"openclaw-guardian-plugin",
|
|
1499
|
+
"openclaw-mem0-plugin"
|
|
1500
|
+
]);
|
|
1501
|
+
function findMissingBuiltinPlugins(ctx) {
|
|
1502
|
+
const extDir = getExtensionsDir(ctx.configPath);
|
|
1503
|
+
return [...BUILTIN_EXTENSION_PLUGINS].filter((name) => !isPluginInstalledOnDisk(extDir, name)).sort();
|
|
1504
|
+
}
|
|
1505
|
+
let BuiltinPluginMissingRule = class BuiltinPluginMissingRule extends DiagnoseRule {
|
|
1506
|
+
validate(ctx) {
|
|
1507
|
+
const missing = findMissingBuiltinPlugins(ctx);
|
|
1508
|
+
if (missing.length === 0) return { pass: true };
|
|
1509
|
+
return {
|
|
1510
|
+
pass: false,
|
|
1511
|
+
action: "upgrade_lark",
|
|
1512
|
+
message: `内置插件缺失,请重新安装: ${missing.join(",")}`
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
};
|
|
1516
|
+
BuiltinPluginMissingRule = __decorate([Rule({
|
|
1517
|
+
key: "builtin_plugin_missing",
|
|
1518
|
+
dependsOn: ["config_syntax_check"],
|
|
1519
|
+
repairMode: "user-confirm",
|
|
1520
|
+
profile: "experimental"
|
|
1521
|
+
})], BuiltinPluginMissingRule);
|
|
1522
|
+
//#endregion
|
|
1523
|
+
//#region src/rules/builtin-plugin-installs-cleanup.ts
|
|
1524
|
+
/**
|
|
1525
|
+
* 在内置插件不缺失的前提下(builtin_plugin_missing 通过),
|
|
1526
|
+
* 将 plugins.installs 中磁盘不存在的条目及对应 allow 配置移除。
|
|
1527
|
+
*/
|
|
1528
|
+
function findOrphanedInstalls(ctx) {
|
|
1529
|
+
const extDir = getExtensionsDir(ctx.configPath);
|
|
1530
|
+
const installs = getNestedMap(ctx.config, "plugins", "installs");
|
|
1531
|
+
if (!installs) return [];
|
|
1532
|
+
return Object.keys(installs).filter((name) => !isPluginInstalledOnDisk(extDir, name)).sort();
|
|
1533
|
+
}
|
|
1534
|
+
let BuiltinPluginInstallsCleanupRule = class BuiltinPluginInstallsCleanupRule extends DiagnoseRule {
|
|
1535
|
+
validate(ctx) {
|
|
1536
|
+
const orphaned = findOrphanedInstalls(ctx);
|
|
1537
|
+
if (orphaned.length === 0) return { pass: true };
|
|
1538
|
+
return {
|
|
1539
|
+
pass: false,
|
|
1540
|
+
message: `plugins.installs 存在磁盘缺失的插件: ${orphaned.join(",")}`
|
|
1541
|
+
};
|
|
1542
|
+
}
|
|
1543
|
+
repair(ctx) {
|
|
1544
|
+
const orphaned = findOrphanedInstalls(ctx);
|
|
1545
|
+
if (orphaned.length === 0) return;
|
|
1546
|
+
const orphanSet = new Set(orphaned);
|
|
1547
|
+
const plugins = asRecord(ctx.config.plugins);
|
|
1548
|
+
if (!plugins) return;
|
|
1549
|
+
const installs = asRecord(plugins.installs);
|
|
1550
|
+
if (installs) for (const name of orphaned) delete installs[name];
|
|
1551
|
+
const rawAllow = plugins.allow;
|
|
1552
|
+
if (Array.isArray(rawAllow)) for (let i = rawAllow.length - 1; i >= 0; i--) {
|
|
1553
|
+
const v = rawAllow[i];
|
|
1554
|
+
if (typeof v === "string" && orphanSet.has(v)) rawAllow.splice(i, 1);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
};
|
|
1558
|
+
BuiltinPluginInstallsCleanupRule = __decorate([Rule({
|
|
1559
|
+
key: "builtin_plugin_installs_cleanup",
|
|
1560
|
+
dependsOn: ["builtin_plugin_missing"],
|
|
1561
|
+
repairMode: "standard",
|
|
1562
|
+
profile: "experimental"
|
|
1563
|
+
})], BuiltinPluginInstallsCleanupRule);
|
|
1564
|
+
//#endregion
|
|
1441
1565
|
//#region src/fs-utils.ts
|
|
1442
1566
|
/**
|
|
1443
1567
|
* Rename src → dst, falling back to `mv` (which handles cross-device copy)
|
|
@@ -4210,210 +4334,6 @@ function finalize(results, aborted) {
|
|
|
4210
4334
|
};
|
|
4211
4335
|
}
|
|
4212
4336
|
//#endregion
|
|
4213
|
-
//#region src/lark-cli-init.ts
|
|
4214
|
-
const LARK_PLUGIN_NAMES = ["openclaw-lark", "feishu-openclaw-plugin"];
|
|
4215
|
-
const PE_XML_TAG = "lark-pe";
|
|
4216
|
-
const PE_PLACEHOLDER = `\n<${PE_XML_TAG}>\n<!-- TODO: replace with actual prompt engineering content -->\n</${PE_XML_TAG}>\n`;
|
|
4217
|
-
function isLarkPluginInstalled(configPath) {
|
|
4218
|
-
const extDir = getExtensionsDir(configPath);
|
|
4219
|
-
return LARK_PLUGIN_NAMES.some((name) => {
|
|
4220
|
-
try {
|
|
4221
|
-
return node_fs.default.existsSync(node_path.default.join(extDir, name, "package.json"));
|
|
4222
|
-
} catch {
|
|
4223
|
-
return false;
|
|
4224
|
-
}
|
|
4225
|
-
});
|
|
4226
|
-
}
|
|
4227
|
-
function isLarkCliAvailable() {
|
|
4228
|
-
try {
|
|
4229
|
-
return (0, node_child_process.spawnSync)("lark-cli", ["--version"], {
|
|
4230
|
-
encoding: "utf-8",
|
|
4231
|
-
timeout: 5e3,
|
|
4232
|
-
stdio: [
|
|
4233
|
-
"ignore",
|
|
4234
|
-
"pipe",
|
|
4235
|
-
"ignore"
|
|
4236
|
-
]
|
|
4237
|
-
}).status === 0;
|
|
4238
|
-
} catch {
|
|
4239
|
-
return false;
|
|
4240
|
-
}
|
|
4241
|
-
}
|
|
4242
|
-
function readConfig(configPath) {
|
|
4243
|
-
try {
|
|
4244
|
-
const raw = node_fs.default.readFileSync(configPath, "utf-8");
|
|
4245
|
-
const parsed = loadJSON5().parse(raw);
|
|
4246
|
-
return parsed != null && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
4247
|
-
} catch {
|
|
4248
|
-
return null;
|
|
4249
|
-
}
|
|
4250
|
-
}
|
|
4251
|
-
/**
|
|
4252
|
-
* Resolve the feishu app secret for the given appId.
|
|
4253
|
-
*
|
|
4254
|
-
* Lookup order:
|
|
4255
|
-
* 1. channels.feishu.appSecret (single-agent: feishu.appId === appId)
|
|
4256
|
-
* 2. channels.feishu.accounts[key].appSecret (multi-agent: account.appId === appId)
|
|
4257
|
-
*
|
|
4258
|
-
* Value interpretation:
|
|
4259
|
-
* - string → use directly
|
|
4260
|
-
* - object → secret is managed by a provider; use `feishuAppSecret` param instead
|
|
4261
|
-
*
|
|
4262
|
-
* Returns null when the secret cannot be determined.
|
|
4263
|
-
*/
|
|
4264
|
-
function resolveAppSecret(appId, config, feishuAppSecret) {
|
|
4265
|
-
const feishu = getNestedMap(config, "channels", "feishu");
|
|
4266
|
-
if (!feishu) return null;
|
|
4267
|
-
let rawSecret;
|
|
4268
|
-
if (typeof feishu.appId === "string" && feishu.appId === appId) rawSecret = feishu.appSecret;
|
|
4269
|
-
else {
|
|
4270
|
-
const accounts = asRecord(feishu.accounts);
|
|
4271
|
-
if (accounts) for (const [, val] of Object.entries(accounts)) {
|
|
4272
|
-
const account = asRecord(val);
|
|
4273
|
-
if (account?.appId === appId) {
|
|
4274
|
-
rawSecret = account.appSecret;
|
|
4275
|
-
break;
|
|
4276
|
-
}
|
|
4277
|
-
}
|
|
4278
|
-
}
|
|
4279
|
-
if (typeof rawSecret === "string" && rawSecret) return rawSecret;
|
|
4280
|
-
if (rawSecret != null && typeof rawSecret === "object") return feishuAppSecret ?? null;
|
|
4281
|
-
return null;
|
|
4282
|
-
}
|
|
4283
|
-
/**
|
|
4284
|
-
* Resolve the agents.md path for the given appId from the openclaw config.
|
|
4285
|
-
*
|
|
4286
|
-
* Case 1: appId matches channels.feishu.appId (single-agent path)
|
|
4287
|
-
* → WORKSPACE_DIR/AGENTS.md
|
|
4288
|
-
*
|
|
4289
|
-
* Case 2: appId found in channels.feishu.accounts (multi-agent path)
|
|
4290
|
-
* → find account key where account.appId === appId
|
|
4291
|
-
* → find binding where match.channel=feishu && match.accountId=that key
|
|
4292
|
-
* → if agentId === 'main' → WORKSPACE_DIR/agents.md
|
|
4293
|
-
* → else find agent in agents.list by id → agent.workspace/agents.md
|
|
4294
|
-
*
|
|
4295
|
-
* Returns null when the path cannot be determined.
|
|
4296
|
-
*/
|
|
4297
|
-
function resolveAgentsMdPath(appId, config) {
|
|
4298
|
-
const feishu = getNestedMap(config, "channels", "feishu");
|
|
4299
|
-
if (!feishu) return null;
|
|
4300
|
-
if (typeof feishu.appId === "string" && feishu.appId === appId) return node_path.default.join(WORKSPACE_DIR, "AGENTS.md");
|
|
4301
|
-
const accounts = asRecord(feishu.accounts);
|
|
4302
|
-
if (!accounts) return null;
|
|
4303
|
-
let accountId;
|
|
4304
|
-
for (const [key, val] of Object.entries(accounts)) if (asRecord(val)?.appId === appId) {
|
|
4305
|
-
accountId = key;
|
|
4306
|
-
break;
|
|
4307
|
-
}
|
|
4308
|
-
if (!accountId) return null;
|
|
4309
|
-
const bindings = Array.isArray(config.bindings) ? config.bindings : [];
|
|
4310
|
-
let agentId;
|
|
4311
|
-
for (const b of bindings) {
|
|
4312
|
-
const binding = asRecord(b);
|
|
4313
|
-
if (!binding) continue;
|
|
4314
|
-
const match = asRecord(binding.match);
|
|
4315
|
-
if (match?.channel === "feishu" && match?.accountId === accountId) {
|
|
4316
|
-
if (typeof binding.agentId === "string") {
|
|
4317
|
-
agentId = binding.agentId;
|
|
4318
|
-
break;
|
|
4319
|
-
}
|
|
4320
|
-
}
|
|
4321
|
-
}
|
|
4322
|
-
if (!agentId) return null;
|
|
4323
|
-
if (agentId === "main") return node_path.default.join(WORKSPACE_DIR, "agents.md");
|
|
4324
|
-
const agentsObj = asRecord(config.agents);
|
|
4325
|
-
const list = Array.isArray(agentsObj?.list) ? agentsObj.list : [];
|
|
4326
|
-
for (const a of list) {
|
|
4327
|
-
const agent = asRecord(a);
|
|
4328
|
-
if (agent?.id === agentId && typeof agent.workspace === "string") return node_path.default.join(agent.workspace, "agents.md");
|
|
4329
|
-
}
|
|
4330
|
-
return null;
|
|
4331
|
-
}
|
|
4332
|
-
function appendPeToAgentsMd(agentsMdPath) {
|
|
4333
|
-
const dir = node_path.default.dirname(agentsMdPath);
|
|
4334
|
-
if (!node_fs.default.existsSync(dir)) node_fs.default.mkdirSync(dir, { recursive: true });
|
|
4335
|
-
const existing = node_fs.default.existsSync(agentsMdPath) ? node_fs.default.readFileSync(agentsMdPath, "utf-8") : "";
|
|
4336
|
-
if (existing.includes(`<${PE_XML_TAG}>`)) {
|
|
4337
|
-
console.error(`lark-cli-init: <${PE_XML_TAG}> already present in ${agentsMdPath}, skipping`);
|
|
4338
|
-
return;
|
|
4339
|
-
}
|
|
4340
|
-
const sep = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
|
|
4341
|
-
node_fs.default.appendFileSync(agentsMdPath, `${sep}${PE_PLACEHOLDER}`, "utf-8");
|
|
4342
|
-
console.error(`lark-cli-init: appended PE placeholder to ${agentsMdPath}`);
|
|
4343
|
-
}
|
|
4344
|
-
function runLarkCliInit(opts) {
|
|
4345
|
-
const configPath = opts.configPath ?? CONFIG_PATH;
|
|
4346
|
-
if (!isLarkPluginInstalled(configPath)) {
|
|
4347
|
-
console.error("lark-cli-init: skipping — openclaw-lark plugin not installed");
|
|
4348
|
-
return {
|
|
4349
|
-
ok: true,
|
|
4350
|
-
skipped: true,
|
|
4351
|
-
skipReason: "openclaw-lark plugin not installed"
|
|
4352
|
-
};
|
|
4353
|
-
}
|
|
4354
|
-
if (!isLarkCliAvailable()) {
|
|
4355
|
-
console.error("lark-cli-init: skipping — lark-cli command not found");
|
|
4356
|
-
return {
|
|
4357
|
-
ok: true,
|
|
4358
|
-
skipped: true,
|
|
4359
|
-
skipReason: "lark-cli command not found"
|
|
4360
|
-
};
|
|
4361
|
-
}
|
|
4362
|
-
const config = readConfig(configPath);
|
|
4363
|
-
if (!config) return {
|
|
4364
|
-
ok: false,
|
|
4365
|
-
error: `could not read config at ${configPath}`
|
|
4366
|
-
};
|
|
4367
|
-
const agentsMdPath = opts.agentsMdPath ?? resolveAgentsMdPath(opts.appId, config);
|
|
4368
|
-
if (!agentsMdPath) return {
|
|
4369
|
-
ok: false,
|
|
4370
|
-
error: `could not resolve agents.md path for appId=${opts.appId}`
|
|
4371
|
-
};
|
|
4372
|
-
console.error(`lark-cli-init: agents.md path=${agentsMdPath}`);
|
|
4373
|
-
const appSecret = resolveAppSecret(opts.appId, config, opts.feishuAppSecret);
|
|
4374
|
-
if (!appSecret) return {
|
|
4375
|
-
ok: false,
|
|
4376
|
-
error: `could not resolve appSecret for appId=${opts.appId}`
|
|
4377
|
-
};
|
|
4378
|
-
console.error(`lark-cli-init: running lark-cli config init --app-id=${opts.appId}`);
|
|
4379
|
-
const initRes = (0, node_child_process.spawnSync)("lark-cli", [
|
|
4380
|
-
"config",
|
|
4381
|
-
"init",
|
|
4382
|
-
"--name",
|
|
4383
|
-
opts.appId,
|
|
4384
|
-
"--app-id",
|
|
4385
|
-
opts.appId,
|
|
4386
|
-
"--brand",
|
|
4387
|
-
"feishu",
|
|
4388
|
-
"--app-secret-stdin"
|
|
4389
|
-
], {
|
|
4390
|
-
stdio: [
|
|
4391
|
-
"pipe",
|
|
4392
|
-
"pipe",
|
|
4393
|
-
"pipe"
|
|
4394
|
-
],
|
|
4395
|
-
encoding: "utf-8",
|
|
4396
|
-
input: appSecret
|
|
4397
|
-
});
|
|
4398
|
-
if (initRes.stdout?.trim()) console.error(`lark-cli config init stdout: ${initRes.stdout.trim()}`);
|
|
4399
|
-
if (initRes.stderr?.trim()) console.error(`lark-cli config init stderr: ${initRes.stderr.trim()}`);
|
|
4400
|
-
if (initRes.error) return {
|
|
4401
|
-
ok: false,
|
|
4402
|
-
error: `lark-cli config init spawn error: ${initRes.error.message}`
|
|
4403
|
-
};
|
|
4404
|
-
if (initRes.status !== 0) return {
|
|
4405
|
-
ok: false,
|
|
4406
|
-
configInitExitCode: initRes.status ?? void 0,
|
|
4407
|
-
error: `lark-cli config init exited with code ${initRes.status}`
|
|
4408
|
-
};
|
|
4409
|
-
appendPeToAgentsMd(agentsMdPath);
|
|
4410
|
-
return {
|
|
4411
|
-
ok: true,
|
|
4412
|
-
configInitExitCode: 0,
|
|
4413
|
-
agentsMdPath
|
|
4414
|
-
};
|
|
4415
|
-
}
|
|
4416
|
-
//#endregion
|
|
4417
4337
|
//#region src/innerapi/reportCliRun.ts
|
|
4418
4338
|
/**
|
|
4419
4339
|
* CLI-side client for studio_server's `openclaw.report_cli_run` inner
|
|
@@ -4493,7 +4413,7 @@ async function reportCliRun(opts) {
|
|
|
4493
4413
|
//#region src/help.ts
|
|
4494
4414
|
const BIN = "mclaw-diagnose";
|
|
4495
4415
|
function versionBanner() {
|
|
4496
|
-
return `v0.1.6-alpha.
|
|
4416
|
+
return `v0.1.6-alpha.10`;
|
|
4497
4417
|
}
|
|
4498
4418
|
const COMMANDS = [
|
|
4499
4419
|
{
|
|
@@ -4702,58 +4622,6 @@ OPTIONS
|
|
|
4702
4622
|
--skip-config-update Leave plugins.installs in openclaw.json untouched.
|
|
4703
4623
|
--ctx=<base64> Opaque ctx; see install-openclaw for semantics.
|
|
4704
4624
|
--oss_file_map=... Pre-built OSS URL map (base64 JSON).
|
|
4705
|
-
`
|
|
4706
|
-
},
|
|
4707
|
-
{
|
|
4708
|
-
name: "lark-cli-init",
|
|
4709
|
-
hidden: false,
|
|
4710
|
-
summary: "Initialize lark-cli bot config and append PE to agents.md",
|
|
4711
|
-
help: `USAGE
|
|
4712
|
-
${BIN} lark-cli-init --app-id=<app-id> [--feishu-app-secret=<secret>] [--agents-md=<path>]
|
|
4713
|
-
|
|
4714
|
-
DESCRIPTION
|
|
4715
|
-
Two-step initialization for a Lark (Feishu) bot when prerequisites are met:
|
|
4716
|
-
|
|
4717
|
-
Prerequisites (both must be satisfied, otherwise the command exits 0 with
|
|
4718
|
-
skipped=true and no side effects):
|
|
4719
|
-
1. openclaw-lark plugin installed under extensions/.
|
|
4720
|
-
2. lark-cli command available on PATH.
|
|
4721
|
-
|
|
4722
|
-
The app secret is resolved from config before running lark-cli:
|
|
4723
|
-
- channels.feishu.appSecret (single-agent) or
|
|
4724
|
-
channels.feishu.accounts[key].appSecret (multi-agent, matched by appId)
|
|
4725
|
-
- If the value is a plain string → used directly.
|
|
4726
|
-
- If the value is a provider-ref object → --feishu-app-secret must be supplied.
|
|
4727
|
-
|
|
4728
|
-
Step 1 — lark-cli config init:
|
|
4729
|
-
Pipes the resolved secret via stdin and runs:
|
|
4730
|
-
lark-cli config init \\
|
|
4731
|
-
--name <app-id> \\
|
|
4732
|
-
--app-id <app-id> \\
|
|
4733
|
-
--brand feishu \\
|
|
4734
|
-
--app-secret-stdin
|
|
4735
|
-
|
|
4736
|
-
Step 2 — append PE to agents.md:
|
|
4737
|
-
Resolves the target agents.md from config (see path resolution below)
|
|
4738
|
-
and appends a <lark-pe> placeholder block (idempotent: skipped if already present).
|
|
4739
|
-
|
|
4740
|
-
agents.md path resolution:
|
|
4741
|
-
- channels.feishu.appId === appId → WORKSPACE/AGENTS.md (single-agent)
|
|
4742
|
-
- accounts[key].appId === appId → look up binding by accountId:
|
|
4743
|
-
agentId === 'main' → WORKSPACE/agents.md
|
|
4744
|
-
otherwise → agents.list[agentId].workspace/agents.md
|
|
4745
|
-
|
|
4746
|
-
ARGUMENTS
|
|
4747
|
-
--app-id=<app-id> Required. Bot app ID, e.g. cli_a9659e1f0ab89ccd.
|
|
4748
|
-
|
|
4749
|
-
OPTIONS
|
|
4750
|
-
--feishu-app-secret=<secret> Required when config stores appSecret as a
|
|
4751
|
-
provider-ref object (ctx.vars.feishuAppSecret).
|
|
4752
|
-
--agents-md=<path> Override the resolved agents.md path.
|
|
4753
|
-
|
|
4754
|
-
EXIT CODES
|
|
4755
|
-
0 Success or skipped (prerequisites not met).
|
|
4756
|
-
1 Secret/path unresolvable, lark-cli failed, or config unreadable.
|
|
4757
4625
|
`
|
|
4758
4626
|
},
|
|
4759
4627
|
{
|
|
@@ -5233,26 +5101,6 @@ async function main() {
|
|
|
5233
5101
|
if (error) throw error;
|
|
5234
5102
|
break;
|
|
5235
5103
|
}
|
|
5236
|
-
case "lark-cli-init": {
|
|
5237
|
-
const appId = getFlag(args, "app-id");
|
|
5238
|
-
if (!appId) {
|
|
5239
|
-
console.error("Usage: lark-cli-init --app-id=<app-id> [--agents-md=<path>]");
|
|
5240
|
-
node_process.default.exit(1);
|
|
5241
|
-
}
|
|
5242
|
-
const result = runLarkCliInit({
|
|
5243
|
-
appId,
|
|
5244
|
-
agentsMdPath: getFlag(args, "agents-md"),
|
|
5245
|
-
feishuAppSecret: getFlag(args, "feishu-app-secret")
|
|
5246
|
-
});
|
|
5247
|
-
console.error(`lark-cli-init: result=${JSON.stringify(result)}`);
|
|
5248
|
-
await reportRun("lark-cli-init", rc, void 0, args.join(" "), Date.now() - t0, {
|
|
5249
|
-
success: result.ok,
|
|
5250
|
-
result,
|
|
5251
|
-
error: result.ok ? void 0 : new Error(result.error ?? "lark-cli-init failed")
|
|
5252
|
-
});
|
|
5253
|
-
if (!result.ok) node_process.default.exit(1);
|
|
5254
|
-
break;
|
|
5255
|
-
}
|
|
5256
5104
|
default:
|
|
5257
5105
|
node_process.default.stderr.write(`Unknown command: ${mode}\n\n`);
|
|
5258
5106
|
node_process.default.stderr.write(formatTopLevelHelp(helpFlags.expert));
|
package/package.json
CHANGED