@lark-apaas/openclaw-scripts-diagnose-cli 0.1.6-alpha.6 → 0.1.6-alpha.8
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 +104 -6
- 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.6-alpha.
|
|
56
|
+
return "0.1.6-alpha.8";
|
|
57
57
|
}
|
|
58
58
|
//#endregion
|
|
59
59
|
//#region src/rule-engine/base.ts
|
|
@@ -4213,7 +4213,11 @@ function finalize(results, aborted) {
|
|
|
4213
4213
|
//#region src/lark-cli-init.ts
|
|
4214
4214
|
const LARK_PLUGIN_NAMES = ["openclaw-lark", "feishu-openclaw-plugin"];
|
|
4215
4215
|
const PE_XML_TAG = "lark-cli-pe";
|
|
4216
|
-
|
|
4216
|
+
const PE_PLACEHOLDER = `
|
|
4217
|
+
<${PE_XML_TAG}>
|
|
4218
|
+
**【强制要求 - 无例外】飞书所有操作必须先读 feishu-lark-cli skill。未读skill不得调用任何飞书工具,违者视为操作失误。**
|
|
4219
|
+
</${PE_XML_TAG}>
|
|
4220
|
+
`;
|
|
4217
4221
|
function isLarkPluginInstalled(configPath) {
|
|
4218
4222
|
const extDir = getExtensionsDir(configPath);
|
|
4219
4223
|
return LARK_PLUGIN_NAMES.some((name) => {
|
|
@@ -4280,6 +4284,92 @@ function resolveAppSecret(appId, config, feishuAppSecret) {
|
|
|
4280
4284
|
if (rawSecret != null && typeof rawSecret === "object") return feishuAppSecret ?? null;
|
|
4281
4285
|
return null;
|
|
4282
4286
|
}
|
|
4287
|
+
/**
|
|
4288
|
+
* Resolve the agents.md path for the given appId from the openclaw config.
|
|
4289
|
+
*
|
|
4290
|
+
* Case 1: appId matches channels.feishu.appId (single-agent path)
|
|
4291
|
+
* → WORKSPACE_DIR/AGENTS.md
|
|
4292
|
+
*
|
|
4293
|
+
* Case 2: appId found in channels.feishu.accounts (multi-agent path)
|
|
4294
|
+
* → find account key where account.appId === appId
|
|
4295
|
+
* → find binding where match.channel=feishu && match.accountId=that key
|
|
4296
|
+
* → if agentId === 'main' → WORKSPACE_DIR/agents.md
|
|
4297
|
+
* → else find agent in agents.list by id → agent.workspace/agents.md
|
|
4298
|
+
*
|
|
4299
|
+
* Returns null when the path cannot be determined.
|
|
4300
|
+
*/
|
|
4301
|
+
function resolveAgentsMdPath(appId, config) {
|
|
4302
|
+
const feishu = getNestedMap(config, "channels", "feishu");
|
|
4303
|
+
if (!feishu) {
|
|
4304
|
+
console.error("resolveAgentsMdPath: channels.feishu not found");
|
|
4305
|
+
return null;
|
|
4306
|
+
}
|
|
4307
|
+
if (typeof feishu.appId === "string" && feishu.appId === appId) {
|
|
4308
|
+
console.error(`resolveAgentsMdPath: case=single-agent feishu.appId=${feishu.appId}`);
|
|
4309
|
+
return node_path.default.join(WORKSPACE_DIR, "workspace", "AGENTS.md");
|
|
4310
|
+
}
|
|
4311
|
+
const accounts = asRecord(feishu.accounts);
|
|
4312
|
+
if (!accounts) {
|
|
4313
|
+
console.error("resolveAgentsMdPath: feishu.accounts not found");
|
|
4314
|
+
return null;
|
|
4315
|
+
}
|
|
4316
|
+
let accountId;
|
|
4317
|
+
for (const [key, val] of Object.entries(accounts)) if (asRecord(val)?.appId === appId) {
|
|
4318
|
+
accountId = key;
|
|
4319
|
+
break;
|
|
4320
|
+
}
|
|
4321
|
+
if (!accountId) {
|
|
4322
|
+
console.error(`resolveAgentsMdPath: no account found with appId=${appId} in feishu.accounts keys=[${Object.keys(accounts).join(",")}]`);
|
|
4323
|
+
return null;
|
|
4324
|
+
}
|
|
4325
|
+
console.error(`resolveAgentsMdPath: found accountId=${accountId}`);
|
|
4326
|
+
const bindings = Array.isArray(config.bindings) ? config.bindings : [];
|
|
4327
|
+
let agentId;
|
|
4328
|
+
for (const b of bindings) {
|
|
4329
|
+
const binding = asRecord(b);
|
|
4330
|
+
if (!binding) continue;
|
|
4331
|
+
const match = asRecord(binding.match);
|
|
4332
|
+
if (match?.channel === "feishu" && match?.accountId === accountId) {
|
|
4333
|
+
if (typeof binding.agentId === "string") {
|
|
4334
|
+
agentId = binding.agentId;
|
|
4335
|
+
break;
|
|
4336
|
+
}
|
|
4337
|
+
}
|
|
4338
|
+
}
|
|
4339
|
+
if (!agentId) {
|
|
4340
|
+
console.error(`resolveAgentsMdPath: no binding found for accountId=${accountId} in bindings(count=${bindings.length})`);
|
|
4341
|
+
return null;
|
|
4342
|
+
}
|
|
4343
|
+
console.error(`resolveAgentsMdPath: found agentId=${agentId}`);
|
|
4344
|
+
if (agentId === "main") {
|
|
4345
|
+
console.error("resolveAgentsMdPath: case=multi-agent-main");
|
|
4346
|
+
return node_path.default.join(WORKSPACE_DIR, "workspace", "AGENTS.md");
|
|
4347
|
+
}
|
|
4348
|
+
const agentsObj = asRecord(config.agents);
|
|
4349
|
+
const list = Array.isArray(agentsObj?.list) ? agentsObj.list : [];
|
|
4350
|
+
for (const a of list) {
|
|
4351
|
+
const agent = asRecord(a);
|
|
4352
|
+
if (agent?.id === agentId) {
|
|
4353
|
+
const ws = typeof agent.workspace === "string" ? agent.workspace : node_path.default.join(WORKSPACE_DIR, "workspace");
|
|
4354
|
+
console.error(`resolveAgentsMdPath: case=multi-agent-custom agentId=${agentId} workspace=${ws}`);
|
|
4355
|
+
return node_path.default.join(ws, "AGENTS.md");
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
4358
|
+
console.error(`resolveAgentsMdPath: agentId=${agentId} not found in agents.list(count=${list.length})`);
|
|
4359
|
+
return null;
|
|
4360
|
+
}
|
|
4361
|
+
function appendPeToAgentsMd(agentsMdPath) {
|
|
4362
|
+
const dir = node_path.default.dirname(agentsMdPath);
|
|
4363
|
+
if (!node_fs.default.existsSync(dir)) node_fs.default.mkdirSync(dir, { recursive: true });
|
|
4364
|
+
const existing = node_fs.default.existsSync(agentsMdPath) ? node_fs.default.readFileSync(agentsMdPath, "utf-8") : "";
|
|
4365
|
+
if (existing.includes(`<${PE_XML_TAG}>`)) {
|
|
4366
|
+
console.error(`lark-cli-init: <${PE_XML_TAG}> already present in ${agentsMdPath}, skipping`);
|
|
4367
|
+
return;
|
|
4368
|
+
}
|
|
4369
|
+
const sep = existing.length > 0 && !existing.endsWith("\n") ? "\n" : "";
|
|
4370
|
+
node_fs.default.appendFileSync(agentsMdPath, `${sep}${PE_PLACEHOLDER}`, "utf-8");
|
|
4371
|
+
console.error(`lark-cli-init: appended PE placeholder to ${agentsMdPath}`);
|
|
4372
|
+
}
|
|
4283
4373
|
function runLarkCliInit(opts) {
|
|
4284
4374
|
const configPath = opts.configPath ?? CONFIG_PATH;
|
|
4285
4375
|
if (!isLarkPluginInstalled(configPath)) {
|
|
@@ -4303,6 +4393,12 @@ function runLarkCliInit(opts) {
|
|
|
4303
4393
|
ok: false,
|
|
4304
4394
|
error: `could not read config at ${configPath}`
|
|
4305
4395
|
};
|
|
4396
|
+
const agentsMdPath = resolveAgentsMdPath(opts.appId, config);
|
|
4397
|
+
console.error(`lark-cli-init: resolved agents.md path=${agentsMdPath ?? "(null)"}`);
|
|
4398
|
+
if (!agentsMdPath) return {
|
|
4399
|
+
ok: false,
|
|
4400
|
+
error: `could not resolve agents.md path for appId=${opts.appId}`
|
|
4401
|
+
};
|
|
4306
4402
|
const appSecret = resolveAppSecret(opts.appId, config, opts.feishuAppSecret);
|
|
4307
4403
|
if (!appSecret) return {
|
|
4308
4404
|
ok: false,
|
|
@@ -4346,9 +4442,11 @@ function runLarkCliInit(opts) {
|
|
|
4346
4442
|
configInitStderr,
|
|
4347
4443
|
error: `lark-cli config init exited with code ${initRes.status}`
|
|
4348
4444
|
};
|
|
4445
|
+
appendPeToAgentsMd(agentsMdPath);
|
|
4349
4446
|
return {
|
|
4350
4447
|
ok: true,
|
|
4351
|
-
configInitExitCode: 0
|
|
4448
|
+
configInitExitCode: 0,
|
|
4449
|
+
agentsMdPath
|
|
4352
4450
|
};
|
|
4353
4451
|
}
|
|
4354
4452
|
//#endregion
|
|
@@ -4431,7 +4529,7 @@ async function reportCliRun(opts) {
|
|
|
4431
4529
|
//#region src/help.ts
|
|
4432
4530
|
const BIN = "mclaw-diagnose";
|
|
4433
4531
|
function versionBanner() {
|
|
4434
|
-
return `v0.1.6-alpha.
|
|
4532
|
+
return `v0.1.6-alpha.8`;
|
|
4435
4533
|
}
|
|
4436
4534
|
const COMMANDS = [
|
|
4437
4535
|
{
|
|
@@ -4676,9 +4774,9 @@ DESCRIPTION
|
|
|
4676
4774
|
and appends a <lark-pe> placeholder block (idempotent: skipped if already present).
|
|
4677
4775
|
|
|
4678
4776
|
agents.md path resolution:
|
|
4679
|
-
- channels.feishu.appId === appId → WORKSPACE/AGENTS.md (single-agent)
|
|
4777
|
+
- channels.feishu.appId === appId → WORKSPACE/workspace/AGENTS.md (single-agent)
|
|
4680
4778
|
- accounts[key].appId === appId → look up binding by accountId:
|
|
4681
|
-
agentId === 'main' → WORKSPACE/AGENTS.md
|
|
4779
|
+
agentId === 'main' → WORKSPACE/workspace/AGENTS.md
|
|
4682
4780
|
otherwise → agents.list[agentId].workspace/AGENTS.md
|
|
4683
4781
|
|
|
4684
4782
|
ARGUMENTS
|