@xcanwin/manyoyo 5.10.3 → 5.10.4
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 +1 -0
- package/docker/res/update-agents.sh +45 -0
- package/lib/image-build.js +38 -34
- package/package.json +1 -1
package/bin/manyoyo.js
CHANGED
|
@@ -1138,6 +1138,7 @@ async function setupCommander() {
|
|
|
1138
1138
|
示例:
|
|
1139
1139
|
${MANYOYO_NAME} update 更新 MANYOYO 到最新版本
|
|
1140
1140
|
${MANYOYO_NAME} build --iv ${IMAGE_VERSION_HELP_EXAMPLE} --yes 构建镜像
|
|
1141
|
+
${MANYOYO_NAME} build --update-agents --yes 仅更新已有镜像内已存在的 Agent CLI
|
|
1141
1142
|
${MANYOYO_NAME} init all 从本机 Agent 配置初始化 ~/.manyoyo
|
|
1142
1143
|
${MANYOYO_NAME} run -r claude 使用 manyoyo.json 的 runs.claude 快速启动
|
|
1143
1144
|
${MANYOYO_NAME} run -r codex --ss "resume --last" 使用命令后缀
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
TARGETS="${MANYOYO_AGENT_UPDATE_TARGETS:-claude=@anthropic-ai/claude-code@latest codex=@openai/codex@latest}"
|
|
5
|
+
|
|
6
|
+
read -r -a agent_targets <<< "$TARGETS"
|
|
7
|
+
|
|
8
|
+
print_agent_versions() {
|
|
9
|
+
for target in "${agent_targets[@]}"; do
|
|
10
|
+
agent="${target%%=*}"
|
|
11
|
+
if command -v "$agent" >/dev/null 2>&1; then
|
|
12
|
+
printf "%s: " "$agent"
|
|
13
|
+
"$agent" --version || echo "version check failed"
|
|
14
|
+
else
|
|
15
|
+
printf "%s: skipped (command not found)\n" "$agent"
|
|
16
|
+
fi
|
|
17
|
+
done
|
|
18
|
+
printf "npm: "
|
|
19
|
+
npm --version
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
update_packages=()
|
|
23
|
+
for target in "${agent_targets[@]}"; do
|
|
24
|
+
agent="${target%%=*}"
|
|
25
|
+
package_name="${target#*=}"
|
|
26
|
+
if [ -n "$agent" ] && [ -n "$package_name" ] && [ "$agent" != "$package_name" ] && command -v "$agent" >/dev/null 2>&1; then
|
|
27
|
+
update_packages+=("$package_name")
|
|
28
|
+
fi
|
|
29
|
+
done
|
|
30
|
+
|
|
31
|
+
echo "[manyoyo] Agent CLI versions before update:"
|
|
32
|
+
print_agent_versions
|
|
33
|
+
|
|
34
|
+
if [ "${#update_packages[@]}" -gt 0 ]; then
|
|
35
|
+
npm_config_update_notifier=false npm install -g npm@latest "${update_packages[@]}"
|
|
36
|
+
else
|
|
37
|
+
echo "[manyoyo] No existing Agent CLI found; skip npm install."
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
echo "[manyoyo] Agent CLI versions after update:"
|
|
41
|
+
print_agent_versions
|
|
42
|
+
|
|
43
|
+
npm_config_update_notifier=false npm cache clean --force --loglevel=error
|
|
44
|
+
rm -rf /tmp/* /var/tmp/* /var/log/apt /var/log/*.log /var/lib/apt/lists/* ~/.npm ~/.cache/node-gyp ~/.claude/plugins/cache ~/go/pkg/mod/cache
|
|
45
|
+
rm -f /var/log/dpkg.log /var/log/bootstrap.log /var/lib/dpkg/status-old /var/cache/debconf/templates.dat-old
|
package/lib/image-build.js
CHANGED
|
@@ -396,20 +396,22 @@ function runCmdPipeline(leftCmd, leftArgs, rightCmd, rightArgs, options = {}) {
|
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
-
const
|
|
400
|
-
'
|
|
401
|
-
'@
|
|
402
|
-
'@
|
|
403
|
-
'
|
|
404
|
-
'opencode-ai@latest'
|
|
399
|
+
const AGENT_UPDATE_TARGETS = [
|
|
400
|
+
{ name: 'claude', packageName: '@anthropic-ai/claude-code@latest', base: true },
|
|
401
|
+
{ name: 'codex', packageName: '@openai/codex@latest', base: true },
|
|
402
|
+
{ name: 'gemini', packageName: '@google/gemini-cli@latest' },
|
|
403
|
+
{ name: 'opencode', packageName: 'opencode-ai@latest' }
|
|
405
404
|
];
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
405
|
+
|
|
406
|
+
function resolveAgentUpdateTargets(imageTool) {
|
|
407
|
+
const tools = new Set(String(imageTool || 'common').split(',').map(value => value.trim()).filter(Boolean));
|
|
408
|
+
const hasFull = tools.has('full');
|
|
409
|
+
return AGENT_UPDATE_TARGETS.filter(target => target.base || hasFull || tools.has(target.name));
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
function formatAgentUpdateTargets(targets) {
|
|
413
|
+
return targets.map(target => `${target.name}=${target.packageName}`).join(' ');
|
|
414
|
+
}
|
|
413
415
|
|
|
414
416
|
function createAgentUpdateContainerName() {
|
|
415
417
|
return `manyoyo-update-agents-${crypto.randomBytes(6).toString('hex')}`;
|
|
@@ -429,7 +431,7 @@ function parseImageConfig(rawConfig) {
|
|
|
429
431
|
|
|
430
432
|
function isAgentUpdateCommand(cmd) {
|
|
431
433
|
const text = Array.isArray(cmd) ? cmd.join(' ') : String(cmd || '');
|
|
432
|
-
return
|
|
434
|
+
return AGENT_UPDATE_TARGETS.some(target => text.includes(target.packageName));
|
|
433
435
|
}
|
|
434
436
|
|
|
435
437
|
function buildImageImportChangeArgs(config) {
|
|
@@ -475,30 +477,18 @@ function buildImageImportChangeArgs(config) {
|
|
|
475
477
|
async function updateAgentsInExistingImage(ctx, fullImageTag) {
|
|
476
478
|
const { RED, GREEN, YELLOW, BLUE, CYAN, NC } = ctx.colors;
|
|
477
479
|
const containerName = ctx.agentUpdateContainerName || createAgentUpdateContainerName();
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
AGENT_VERSION_CHECK_COMMAND,
|
|
481
|
-
`npm_config_update_notifier=false npm install -g ${AGENT_UPDATE_PACKAGES.map(quoteShellArg).join(' ')}`,
|
|
482
|
-
'echo "[manyoyo] Agent CLI versions after update:"',
|
|
483
|
-
AGENT_VERSION_CHECK_COMMAND,
|
|
484
|
-
'npm_config_update_notifier=false npm cache clean --force --loglevel=error',
|
|
485
|
-
'rm -rf /tmp/* /var/tmp/* /var/log/apt /var/log/*.log /var/lib/apt/lists/* ~/.npm ~/.cache/node-gyp ~/.claude/plugins/cache ~/go/pkg/mod/cache',
|
|
486
|
-
'rm -f /var/log/dpkg.log /var/log/bootstrap.log /var/lib/dpkg/status-old /var/cache/debconf/templates.dat-old'
|
|
487
|
-
].join(' && ');
|
|
488
|
-
const runArgs = [
|
|
489
|
-
'run',
|
|
490
|
-
'--name', containerName,
|
|
491
|
-
'--network', 'host',
|
|
492
|
-
fullImageTag,
|
|
493
|
-
'/bin/bash',
|
|
494
|
-
'-lc',
|
|
495
|
-
updateScript
|
|
496
|
-
];
|
|
480
|
+
let updateTargets = resolveAgentUpdateTargets(ctx.imageTool);
|
|
481
|
+
const updateScriptPath = path.join(ctx.rootDir, 'docker', 'res', 'update-agents.sh');
|
|
497
482
|
const cleanupArgs = ['rm', '-f', containerName];
|
|
498
483
|
let imageConfig = {};
|
|
499
484
|
|
|
500
485
|
ctx.log(`${CYAN}🔄 正在更新已有镜像内 Agent CLI: ${YELLOW}${fullImageTag}${NC}`);
|
|
501
|
-
|
|
486
|
+
|
|
487
|
+
if (!fs.existsSync(updateScriptPath)) {
|
|
488
|
+
ctx.error(`${RED}错误: 找不到 Agent CLI 更新脚本: ${updateScriptPath}${NC}`);
|
|
489
|
+
ctx.exit(1);
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
502
492
|
|
|
503
493
|
try {
|
|
504
494
|
imageConfig = parseImageConfig(ctx.runCmd(ctx.dockerCmd, [
|
|
@@ -515,6 +505,19 @@ async function updateAgentsInExistingImage(ctx, fullImageTag) {
|
|
|
515
505
|
return;
|
|
516
506
|
}
|
|
517
507
|
|
|
508
|
+
ctx.log(`${BLUE}更新范围: 已存在的 ${updateTargets.map(target => target.name).join('/')} CLI -> latest${NC}\n`);
|
|
509
|
+
|
|
510
|
+
const runArgs = [
|
|
511
|
+
'run',
|
|
512
|
+
'--name', containerName,
|
|
513
|
+
'--network', 'host',
|
|
514
|
+
'--volume', `${updateScriptPath}:/usr/local/bin/manyoyo-update-agents.sh:ro`,
|
|
515
|
+
'--env', `MANYOYO_AGENT_UPDATE_TARGETS=${formatAgentUpdateTargets(updateTargets)}`,
|
|
516
|
+
fullImageTag,
|
|
517
|
+
'/bin/bash',
|
|
518
|
+
'/usr/local/bin/manyoyo-update-agents.sh'
|
|
519
|
+
];
|
|
520
|
+
|
|
518
521
|
const importArgs = [
|
|
519
522
|
'import',
|
|
520
523
|
...buildImageImportChangeArgs(imageConfig),
|
|
@@ -593,6 +596,7 @@ async function buildImage(options = {}) {
|
|
|
593
596
|
} else {
|
|
594
597
|
imageTool = toolFromArgs;
|
|
595
598
|
}
|
|
599
|
+
ctx.imageTool = imageTool;
|
|
596
600
|
|
|
597
601
|
const fullImageTag = `${ctx.imageName}:${version}-${imageTool}`;
|
|
598
602
|
if (ctx.updateAgents) {
|