@aiyiran/myclaw 1.1.57 → 1.1.59

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.
Files changed (2) hide show
  1. package/index.js +49 -0
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1353,6 +1353,53 @@ function runUpdate() {
1353
1353
  console.log('');
1354
1354
  }
1355
1355
 
1356
+ // ============================================================================
1357
+ // mc main — 确保 agents.list 中存在 id=main 且排在第一位
1358
+ // ============================================================================
1359
+
1360
+ function runMain() {
1361
+ const { readConfig, writeConfig } = require('./find-config');
1362
+ const os = require('os');
1363
+ const bar = '----------------------------------------';
1364
+ console.log('');
1365
+ console.log('[mc main] 检查 main agent 配置...');
1366
+ console.log(bar);
1367
+
1368
+ let config, configPath;
1369
+ try {
1370
+ ({ config, configPath } = readConfig());
1371
+ } catch (err) {
1372
+ console.error('[错误] 无法读取 openclaw.json: ' + err.message);
1373
+ process.exit(1);
1374
+ }
1375
+
1376
+ if (!config.agents) config.agents = {};
1377
+ if (!Array.isArray(config.agents.list)) config.agents.list = [];
1378
+
1379
+ const defaultAgentDir = (os.platform() === 'linux' ? '/root' : os.homedir())
1380
+ + '/.openclaw/agents/main/agent';
1381
+
1382
+ const idx = config.agents.list.findIndex(function (a) { return a.id === 'main'; });
1383
+
1384
+ if (idx === -1) {
1385
+ // 不存在,插入到最前面
1386
+ config.agents.list.unshift({ id: 'main', agentDir: defaultAgentDir });
1387
+ console.log(' ✅ 已添加 main agent: ' + defaultAgentDir);
1388
+ } else if (idx !== 0) {
1389
+ // 存在但不在第一位,移到最前面
1390
+ const entry = config.agents.list.splice(idx, 1)[0];
1391
+ config.agents.list.unshift(entry);
1392
+ console.log(' ✅ main agent 已移至第一位');
1393
+ } else {
1394
+ console.log(' ✅ main agent 已在第一位,无需修改');
1395
+ }
1396
+
1397
+ writeConfig(config, configPath);
1398
+ console.log('');
1399
+ console.log('[mc main] 完成');
1400
+ console.log('');
1401
+ }
1402
+
1356
1403
  // ============================================================================
1357
1404
  // 资源管理列表
1358
1405
  // ============================================================================
@@ -2481,6 +2528,8 @@ if (!command) {
2481
2528
  runSync(args[1]); // args[1] 是可选的 workspace 名称
2482
2529
  } else if (command === 'init') {
2483
2530
  console.log('init 还没实现,后续添加钩子');
2531
+ } else if (command === 'main') {
2532
+ runMain();
2484
2533
  } else {
2485
2534
  console.error('[' + colors.red + '错误' + colors.nc + '] 未知命令: ' + command);
2486
2535
  showHelp();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiyiran/myclaw",
3
- "version": "1.1.57",
3
+ "version": "1.1.59",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {