@xcanwin/manyoyo 5.8.9 → 5.8.11

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/bin/manyoyo.js CHANGED
@@ -19,7 +19,6 @@ const { buildManyoyoLogPath } = require('../lib/log-path');
19
19
  const { resolveRuntimeConfig } = require('../lib/runtime-resolver');
20
20
  const {
21
21
  parseEnvEntry: parseEnvEntryOrThrow,
22
- expandHomeAliasPath,
23
22
  normalizeVolume
24
23
  } = require('../lib/runtime-normalizers');
25
24
  const {
@@ -964,7 +963,11 @@ function validateShellSuffixPassThroughArgs(command) {
964
963
  }
965
964
  }
966
965
 
967
- function applyContainerBaseOptions(command) {
966
+ function applyRunStyleOptions(command, options = {}) {
967
+ const includeRmOnExit = options.includeRmOnExit !== false;
968
+ const includeServePreview = options.includeServePreview === true;
969
+ const includeWebAuthOptions = options.includeWebAuthOptions === true;
970
+
968
971
  command
969
972
  .option('-r, --run <name>', '加载运行配置 (从 ~/.manyoyo/manyoyo.json 的 runs.<name> 读取)')
970
973
  .option('--hp, --host-path <path>', '设置宿主机工作目录 (默认: 当前路径)')
@@ -979,69 +982,35 @@ function applyContainerBaseOptions(command) {
979
982
  appendArrayOption(command, '-v, --volume <volume>', '绑定挂载卷 XXX:YYY (可多次使用)');
980
983
  appendArrayOption(command, '-p, --port <port>', '设置端口映射 XXX:YYY (可多次使用)');
981
984
 
982
- return command;
983
- }
984
-
985
- function applyExecOptions(command) {
986
985
  command
987
986
  .option('--sp, --shell-prefix <command>', '主命令前缀 (常用于临时环境变量)')
988
987
  .option('-s, --shell <command>', '主命令')
989
988
  .option('--ss, --shell-suffix <command>', '主命令后缀 (追加到 -s 之后,等价于 -- <args>)')
990
- .option('-x, --shell-full <command...>', '完整命令 (与 --sp/-s/--ss/-- 互斥)')
991
- .option('-y, --yolo <cli>', '使 AGENT 无需确认 (claude(c), gemini(gm), codex(cx), opencode(oc))');
992
-
993
- return command;
994
- }
995
-
996
- function applyFirstExecOptions(command) {
997
- command
998
989
  .option('--first-shell-prefix <command>', '首次预执行命令前缀 (仅新建容器生效; 容器已存在时忽略)')
999
990
  .option('--first-shell <command>', '首次预执行命令 (仅新建容器生效; 容器已存在时忽略)')
1000
- .option('--first-shell-suffix <command>', '首次预执行命令后缀 (仅新建容器生效; 容器已存在时忽略)');
991
+ .option('--first-shell-suffix <command>', '首次预执行命令后缀 (仅新建容器生效; 容器已存在时忽略)')
992
+ .option('-x, --shell-full <command...>', '完整命令 (与 --sp/-s/--ss/-- 互斥)')
993
+ .option('-y, --yolo <cli>', '使 AGENT 无需确认 (claude(c), gemini(gm), codex(cx), opencode(oc))');
1001
994
  appendArrayOption(command, '--first-env <env>', '首次预执行环境变量 XXX=YYY (可多次使用)');
1002
995
  appendArrayOption(command, '--first-env-file <file>', '首次预执行环境变量文件 (仅支持绝对路径,如 /abs/path.env)');
1003
996
 
1004
- return command;
1005
- }
1006
-
1007
- function applyQuietOptions(command) {
1008
- appendArrayOption(command, '-q, --quiet <item>', '静默输出 (可多次使用: cnew, crm, tip, cmd, full)');
1009
- return command;
1010
- }
1011
-
1012
- function applyServeAuthOptions(command) {
1013
- command
1014
- .option('-U, --user <username>', '网页服务登录用户名 (默认 admin)')
1015
- .option('-P, --pass <password>', '网页服务登录密码 (默认自动生成随机密码)');
1016
- return command;
1017
- }
1018
-
1019
- function applyRunStyleOptions(command, options = {}) {
1020
- const includeRmOnExit = options.includeRmOnExit !== false;
1021
- const includeServePreview = options.includeServePreview === true;
1022
- const includeWebAuthOptions = options.includeWebAuthOptions === true;
1023
- const includeFirstExecOptions = options.includeFirstExecOptions !== false;
1024
-
1025
- applyContainerBaseOptions(command);
1026
- applyExecOptions(command);
1027
- if (includeFirstExecOptions) {
1028
- applyFirstExecOptions(command);
1029
- }
1030
-
1031
997
  if (includeRmOnExit) {
1032
998
  command.option('--rm-on-exit', '退出后自动删除容器 (一次性模式)');
1033
999
  }
1034
1000
 
1035
- applyQuietOptions(command);
1001
+ appendArrayOption(command, '-q, --quiet <item>', '静默输出 (可多次使用: cnew, crm, tip, cmd, full)');
1036
1002
 
1037
1003
  if (includeServePreview) {
1038
1004
  command
1039
- .option('--serve [listen]', '按 serve 模式解析配置 (仅支持 <ip:port>)');
1040
- applyServeAuthOptions(command);
1005
+ .option('--serve [listen]', '按 serve 模式解析配置 (仅支持 <ip:port>)')
1006
+ .option('-U, --user <username>', '网页服务登录用户名 (默认 admin)')
1007
+ .option('-P, --pass <password>', '网页服务登录密码 (默认自动生成随机密码)');
1041
1008
  }
1042
1009
 
1043
1010
  if (includeWebAuthOptions) {
1044
- applyServeAuthOptions(command);
1011
+ command
1012
+ .option('-U, --user <username>', '网页服务登录用户名 (默认 admin)')
1013
+ .option('-P, --pass <password>', '网页服务登录密码 (默认自动生成随机密码)');
1045
1014
  }
1046
1015
 
1047
1016
  return command;
@@ -1204,11 +1173,7 @@ Notes:
1204
1173
  .action(() => selectAction('images', { imageList: true }));
1205
1174
 
1206
1175
  const serveCommand = program.command('serve [listen]').description('启动网页交互服务 (默认 127.0.0.1:3000)');
1207
- applyRunStyleOptions(serveCommand, {
1208
- includeRmOnExit: false,
1209
- includeWebAuthOptions: true,
1210
- includeFirstExecOptions: false
1211
- });
1176
+ applyRunStyleOptions(serveCommand, { includeRmOnExit: false, includeWebAuthOptions: true });
1212
1177
  serveCommand.option('-d, --detach', '后台启动网页服务并立即返回');
1213
1178
  serveCommand.option('--stop', '停止后台网页服务;必须显式传入 listen');
1214
1179
  serveCommand.action((listen, options) => {
@@ -1254,10 +1219,7 @@ Notes:
1254
1219
  });
1255
1220
 
1256
1221
  const configRunCommand = configCommand.command('command').description('显示将执行的 docker run 命令并退出');
1257
- applyRunStyleOptions(configRunCommand, {
1258
- includeRmOnExit: false,
1259
- includeFirstExecOptions: false
1260
- });
1222
+ applyRunStyleOptions(configRunCommand, { includeRmOnExit: false });
1261
1223
  enableShellSuffixPassThrough(configRunCommand);
1262
1224
  configRunCommand.action((options, command) => {
1263
1225
  validateShellSuffixPassThroughArgs(command);
@@ -1408,10 +1370,10 @@ Notes:
1408
1370
  validateName('imageName', IMAGE_NAME, /^[A-Za-z0-9][A-Za-z0-9._/:-]*$/);
1409
1371
  validateImageVersion(IMAGE_VERSION);
1410
1372
 
1373
+ // Merge mode (array values): concatenate all sources
1411
1374
  const envFileList = resolvedRuntime.envFile;
1412
1375
  envFileList.forEach(ef => addEnvFile(ef));
1413
1376
 
1414
- // env in JSON config uses map type, and is merged by key with CLI priority.
1415
1377
  const envMap = resolvedRuntime.env;
1416
1378
  Object.entries(envMap).forEach(([key, value]) => addEnv(`${key}=${value}`));
1417
1379
 
@@ -1432,7 +1394,6 @@ Notes:
1432
1394
  const buildArgList = resolvedRuntime.imageBuildArgs;
1433
1395
  buildArgList.forEach(arg => addImageBuildArg(arg));
1434
1396
 
1435
- // Override mode for special options
1436
1397
  const yoloValue = resolvedRuntime.yolo;
1437
1398
  if (yoloValue) setYolo(yoloValue);
1438
1399
 
@@ -1446,14 +1407,11 @@ Notes:
1446
1407
  RM_ON_EXIT = true;
1447
1408
  }
1448
1409
 
1449
- if (isServerMode) {
1450
- SERVER_HOST = resolvedRuntime.serverHost;
1451
- SERVER_PORT = resolvedRuntime.serverPort;
1452
- }
1453
-
1410
+ SERVER_HOST = resolvedRuntime.serverHost || SERVER_HOST;
1411
+ SERVER_PORT = resolvedRuntime.serverPort || SERVER_PORT;
1454
1412
  SERVER_AUTH_USER = resolvedRuntime.serverUser || '';
1455
1413
  SERVER_AUTH_PASS = resolvedRuntime.serverPass || '';
1456
- SERVER_AUTH_PASS_AUTO = resolvedRuntime.serverPassAuto === true;
1414
+ SERVER_AUTH_PASS_AUTO = Boolean(resolvedRuntime.serverPassAuto);
1457
1415
 
1458
1416
  if (isShowConfigMode) {
1459
1417
  const finalConfig = {
@@ -1473,9 +1431,9 @@ Notes:
1473
1431
  shellSuffix: EXEC_COMMAND_SUFFIX || "",
1474
1432
  yolo: yoloValue || "",
1475
1433
  quiet: quietValue || [],
1476
- server: resolvedRuntime.server,
1477
- serverHost: resolvedRuntime.server ? SERVER_HOST : null,
1478
- serverPort: resolvedRuntime.server ? SERVER_PORT : null,
1434
+ server: isServerMode,
1435
+ serverHost: isServerMode ? SERVER_HOST : null,
1436
+ serverPort: isServerMode ? SERVER_PORT : null,
1479
1437
  serverUser: SERVER_AUTH_USER || "",
1480
1438
  serverPass: SERVER_AUTH_PASS || "",
1481
1439
  exec: {