@xcanwin/manyoyo 3.0.1 → 3.2.0
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/README.md +35 -16
- package/bin/manyoyo.js +66 -8
- package/docker/manyoyo.Dockerfile +1 -1
- package/docs/README_EN.md +35 -16
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -23,19 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
# 使用方法
|
|
25
25
|
|
|
26
|
-
## 1. 安装
|
|
27
|
-
|
|
28
|
-
- 安装 [podman](https://podman.io/docs/installation)
|
|
29
|
-
|
|
30
|
-
## 2. 编译镜像
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
podman pull ubuntu:24.04
|
|
34
|
-
iv=1.4.0-all && podman build -t localhost/xcanwin/manyoyo:$iv -f docker/manyoyo.Dockerfile . --build-arg EXT=all --no-cache
|
|
35
|
-
podman image prune -f
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## 3. 安装 manyoyo(选一种)
|
|
26
|
+
## 1. 安装 manyoyo
|
|
39
27
|
|
|
40
28
|
### 全局安装(推荐)
|
|
41
29
|
|
|
@@ -49,6 +37,32 @@ npm install -g @xcanwin/manyoyo
|
|
|
49
37
|
npm install -g .
|
|
50
38
|
```
|
|
51
39
|
|
|
40
|
+
## 2. 安装 podman
|
|
41
|
+
|
|
42
|
+
- 安装 [podman](https://podman.io/docs/installation)
|
|
43
|
+
|
|
44
|
+
## 3. 编译镜像
|
|
45
|
+
|
|
46
|
+
安装 manyoyo 后,可以使用内置命令构建镜像:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# 拉取基础镜像
|
|
50
|
+
podman pull ubuntu:24.04
|
|
51
|
+
|
|
52
|
+
# 使用 manyoyo 构建镜像(推荐)
|
|
53
|
+
manyoyo --ib all # 构建 all 版本(包含所有工具)
|
|
54
|
+
manyoyo --ib common # 构建 common 版本(基础版本)
|
|
55
|
+
manyoyo --ib go,codex,java,gemini # 构建 go 版本(包含 go,codex,java,gemini 工具)
|
|
56
|
+
|
|
57
|
+
# 自定义镜像名称和版本
|
|
58
|
+
manyoyo --ib all --in myimage --iv 2.0.0
|
|
59
|
+
# 构建:myimage:2.0.0-all
|
|
60
|
+
|
|
61
|
+
# 或手动构建(不推荐)
|
|
62
|
+
iv=1.4.0 && podman build -t localhost/xcanwin/manyoyo:$iv-all -f docker/manyoyo.Dockerfile . --build-arg EXT=all --no-cache
|
|
63
|
+
podman image prune -f
|
|
64
|
+
```
|
|
65
|
+
|
|
52
66
|
## 4. 使用方法
|
|
53
67
|
|
|
54
68
|
### 基础命令
|
|
@@ -159,14 +173,18 @@ manyoyo -n docker-dev -m dind -x /bin/bash
|
|
|
159
173
|
nohup dockerd &
|
|
160
174
|
|
|
161
175
|
# 现在可以在容器内使用 docker 命令
|
|
162
|
-
docker
|
|
176
|
+
docker ps -a
|
|
163
177
|
```
|
|
164
178
|
|
|
165
179
|
#### 挂载 Docker Socket 开发
|
|
166
180
|
|
|
167
181
|
```bash
|
|
168
|
-
# 挂载 Docker Socket
|
|
169
|
-
|
|
182
|
+
# 挂载 Docker Socket(危险的!!!容器可以访问和执行宿主机的一切)
|
|
183
|
+
# 创建挂载 /var/run/docker.sock 的容器
|
|
184
|
+
manyoyo -n socket-dev -m mdsock -x /bin/bash
|
|
185
|
+
|
|
186
|
+
# 现在可以在容器内使用 docker 命令
|
|
187
|
+
docker ps -a
|
|
170
188
|
```
|
|
171
189
|
|
|
172
190
|
### 命令行选项
|
|
@@ -189,6 +207,7 @@ manyoyo -n socket-dev -m mdsock -x docker ps
|
|
|
189
207
|
| `-x CMD` | `--sf`, `--shell-full` | 完整命令(替代 --sp, -s 和 --) |
|
|
190
208
|
| `-y CLI` | `--yolo` | 无需确认运行 AI 智能体 |
|
|
191
209
|
| `-m MODE` | `--cm`, `--cont-mode` | 设置容器模式(common, dind, mdsock) |
|
|
210
|
+
| `--ib EXT` | `--image-build` | 构建镜像,EXT 为镜像变体(all, go, common) |
|
|
192
211
|
| `--install NAME` | | 安装 manyoyo 命令 |
|
|
193
212
|
| `-V` | `--version` | 显示版本 |
|
|
194
213
|
| `-h` | `--help` | 显示帮助 |
|
package/bin/manyoyo.js
CHANGED
|
@@ -8,7 +8,7 @@ const { execSync, spawnSync } = require('child_process');
|
|
|
8
8
|
const fs = require('fs');
|
|
9
9
|
const path = require('path');
|
|
10
10
|
const readline = require('readline');
|
|
11
|
-
const { version: BIN_VERSION } = require('../package.json');
|
|
11
|
+
const { version: BIN_VERSION, imageVersion: IMAGE_VERSION_BASE } = require('../package.json');
|
|
12
12
|
|
|
13
13
|
// Helper function to format date like bash $(date +%m%d-%H%M)
|
|
14
14
|
function formatDate() {
|
|
@@ -25,12 +25,14 @@ let CONTAINER_NAME = `myy-${formatDate()}`;
|
|
|
25
25
|
let HOST_PATH = process.cwd();
|
|
26
26
|
let CONTAINER_PATH = HOST_PATH;
|
|
27
27
|
let IMAGE_NAME = "localhost/xcanwin/manyoyo";
|
|
28
|
-
let IMAGE_VERSION =
|
|
28
|
+
let IMAGE_VERSION = `${IMAGE_VERSION_BASE}-all`;
|
|
29
29
|
let EXEC_COMMAND = "";
|
|
30
30
|
let EXEC_COMMAND_PREFIX = "";
|
|
31
31
|
let EXEC_COMMAND_SUFFIX = "";
|
|
32
32
|
let ENV_FILE = "";
|
|
33
33
|
let SHOULD_REMOVE = false;
|
|
34
|
+
let SHOULD_BUILD_IMAGE = false;
|
|
35
|
+
let BUILD_IMAGE_EXT = "";
|
|
34
36
|
let CONTAINER_ENVS = [];
|
|
35
37
|
let CONTAINER_VOLUMES = [];
|
|
36
38
|
let MANYOYO_NAME = "manyoyo";
|
|
@@ -83,12 +85,15 @@ function showHelp() {
|
|
|
83
85
|
console.log(" 例如 claude / c, gemini / gm, codex / cx, opencode / oc");
|
|
84
86
|
console.log(" -m|--cm|--cont-mode STRING 设置容器嵌套容器模式");
|
|
85
87
|
console.log(" 例如 common, dind, mdsock");
|
|
88
|
+
console.log(" --ib|--image-build EXT 构建镜像,EXT 为镜像变体,逗号分割");
|
|
89
|
+
console.log(" 例如 \"common\" (默认值), \"all\", \"go,codex,java,gemini\" ...");
|
|
86
90
|
console.log(" --install NAME 安装manyoyo命令");
|
|
87
91
|
console.log(" 例如 docker-cli-plugin");
|
|
88
92
|
console.log(" -V|--version 显示版本");
|
|
89
93
|
console.log(" -h|--help 显示帮助");
|
|
90
94
|
console.log("");
|
|
91
95
|
console.log(`${BLUE}Example:${NC}`);
|
|
96
|
+
console.log(` ${MANYOYO_NAME} --ib all 构建 all 版本镜像`);
|
|
92
97
|
console.log(` ${MANYOYO_NAME} -n test --ef ./xxx.env -y c 设置环境变量并运行无需确认的AGENT`);
|
|
93
98
|
console.log(` ${MANYOYO_NAME} -n test -- -c 恢复之前会话`);
|
|
94
99
|
console.log(` ${MANYOYO_NAME} -x echo 123 指定命令执行`);
|
|
@@ -209,7 +214,7 @@ function setContMode(mode) {
|
|
|
209
214
|
case 'mount-docker-socket':
|
|
210
215
|
case 'mdsock':
|
|
211
216
|
case 's':
|
|
212
|
-
CONT_MODE = "--volume /var/run/docker.sock:/var/run/docker.sock";
|
|
217
|
+
CONT_MODE = "--privileged --volume /var/run/docker.sock:/var/run/docker.sock";
|
|
213
218
|
console.log(`${RED}⚠️ 开启危险的容器嵌套容器模式, 危害: 容器可访问宿主机文件${NC}`);
|
|
214
219
|
break;
|
|
215
220
|
default:
|
|
@@ -295,6 +300,46 @@ function getContList() {
|
|
|
295
300
|
}
|
|
296
301
|
}
|
|
297
302
|
|
|
303
|
+
async function buildImage(ext, imageName, imageVersion) {
|
|
304
|
+
// Use package.json imageVersion if not specified
|
|
305
|
+
const version = imageVersion || IMAGE_VERSION_BASE;
|
|
306
|
+
const fullImageTag = `${imageName}:${version}-${ext}`;
|
|
307
|
+
|
|
308
|
+
console.log(`${CYAN}🔨 正在构建镜像: ${YELLOW}${fullImageTag}${NC}`);
|
|
309
|
+
console.log(`${BLUE}构建参数: EXT=${ext}${NC}\n`);
|
|
310
|
+
|
|
311
|
+
// Find Dockerfile path
|
|
312
|
+
const dockerfilePath = path.join(__dirname, '../docker/manyoyo.Dockerfile');
|
|
313
|
+
if (!fs.existsSync(dockerfilePath)) {
|
|
314
|
+
console.error(`${RED}错误: 找不到 Dockerfile: ${dockerfilePath}${NC}`);
|
|
315
|
+
process.exit(1);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// Build command
|
|
319
|
+
const buildCmd = `${DOCKER_CMD} build -t "${fullImageTag}" -f "${dockerfilePath}" "${path.join(__dirname, '..')}" --build-arg EXT=${ext} --no-cache`;
|
|
320
|
+
|
|
321
|
+
console.log(`${BLUE}准备执行命令:${NC}`);
|
|
322
|
+
console.log(`${buildCmd}\n`);
|
|
323
|
+
|
|
324
|
+
const reply = await askQuestion(`❔ 是否继续构建? [ 直接回车=继续, ctrl+c=取消 ]: `);
|
|
325
|
+
console.log("");
|
|
326
|
+
|
|
327
|
+
try {
|
|
328
|
+
execSync(buildCmd, { stdio: 'inherit' });
|
|
329
|
+
console.log(`\n${GREEN}✅ 镜像构建成功: ${fullImageTag}${NC}`);
|
|
330
|
+
console.log(`${BLUE}使用镜像:${NC}`);
|
|
331
|
+
console.log(` manyoyo -n test --in ${imageName} --iv ${version}-${ext} -y c`);
|
|
332
|
+
|
|
333
|
+
// Prune dangling images
|
|
334
|
+
console.log(`\n${YELLOW}清理悬空镜像...${NC}`);
|
|
335
|
+
execSync(`${DOCKER_CMD} image prune -f`, { stdio: 'inherit' });
|
|
336
|
+
console.log(`${GREEN}✅ 清理完成${NC}`);
|
|
337
|
+
} catch (e) {
|
|
338
|
+
console.error(`${RED}错误: 镜像构建失败${NC}`);
|
|
339
|
+
process.exit(1);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
298
343
|
// ==============================================================================
|
|
299
344
|
// Main Function Helpers
|
|
300
345
|
// ==============================================================================
|
|
@@ -439,6 +484,13 @@ function parseArguments(argv) {
|
|
|
439
484
|
i += 2;
|
|
440
485
|
break;
|
|
441
486
|
|
|
487
|
+
case '--ib':
|
|
488
|
+
case '--image-build':
|
|
489
|
+
SHOULD_BUILD_IMAGE = true;
|
|
490
|
+
BUILD_IMAGE_EXT = args[i + 1];
|
|
491
|
+
i += 2;
|
|
492
|
+
break;
|
|
493
|
+
|
|
442
494
|
case '--install':
|
|
443
495
|
installManyoyo(args[i + 1]);
|
|
444
496
|
process.exit(0);
|
|
@@ -633,19 +685,25 @@ async function main() {
|
|
|
633
685
|
// 2. Parse command-line arguments
|
|
634
686
|
parseArguments(process.argv);
|
|
635
687
|
|
|
636
|
-
// 3. Handle
|
|
688
|
+
// 3. Handle image build operation
|
|
689
|
+
if (SHOULD_BUILD_IMAGE) {
|
|
690
|
+
await buildImage(BUILD_IMAGE_EXT, IMAGE_NAME, IMAGE_VERSION.split('-')[0]);
|
|
691
|
+
process.exit(0);
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// 4. Handle remove container operation
|
|
637
695
|
handleRemoveContainer();
|
|
638
696
|
|
|
639
|
-
//
|
|
697
|
+
// 5. Validate host path safety
|
|
640
698
|
validateHostPath();
|
|
641
699
|
|
|
642
|
-
//
|
|
700
|
+
// 6. Setup container (create or connect)
|
|
643
701
|
const defaultCommand = await setupContainer();
|
|
644
702
|
|
|
645
|
-
//
|
|
703
|
+
// 7. Execute command in container
|
|
646
704
|
executeInContainer(defaultCommand);
|
|
647
705
|
|
|
648
|
-
//
|
|
706
|
+
// 8. Handle post-exit interactions
|
|
649
707
|
await handlePostExit(defaultCommand);
|
|
650
708
|
|
|
651
709
|
} catch (e) {
|
package/docs/README_EN.md
CHANGED
|
@@ -23,19 +23,7 @@ Pre-installed with common agents and tools to further save tokens. Freely switch
|
|
|
23
23
|
|
|
24
24
|
# Usage
|
|
25
25
|
|
|
26
|
-
## 1. Install
|
|
27
|
-
|
|
28
|
-
- Install [podman](https://podman.io/docs/installation)
|
|
29
|
-
|
|
30
|
-
## 2. Build Image
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
podman pull ubuntu:24.04
|
|
34
|
-
iv=1.4.0-all && podman build -t localhost/xcanwin/manyoyo:$iv -f docker/manyoyo.Dockerfile . --build-arg EXT=all --no-cache
|
|
35
|
-
podman image prune -f
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## 3. Install manyoyo (Choose One)
|
|
26
|
+
## 1. Install manyoyo
|
|
39
27
|
|
|
40
28
|
### Global Installation (Recommended)
|
|
41
29
|
|
|
@@ -49,6 +37,32 @@ npm install -g @xcanwin/manyoyo
|
|
|
49
37
|
npm install -g .
|
|
50
38
|
```
|
|
51
39
|
|
|
40
|
+
## 2. Install podman
|
|
41
|
+
|
|
42
|
+
- Install [podman](https://podman.io/docs/installation)
|
|
43
|
+
|
|
44
|
+
## 3. Build Image
|
|
45
|
+
|
|
46
|
+
After installing manyoyo, use the built-in command to build images:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
# Pull base image
|
|
50
|
+
podman pull ubuntu:24.04
|
|
51
|
+
|
|
52
|
+
# Build using manyoyo (Recommended)
|
|
53
|
+
manyoyo --ib all # Build all version (includes all tools)
|
|
54
|
+
manyoyo --ib common # Build common version (basic version)
|
|
55
|
+
manyoyo --ib go,codex,java,gemini # Build go version (includes go,codex,java,gemini tools)
|
|
56
|
+
|
|
57
|
+
# Custom image name and version
|
|
58
|
+
manyoyo --ib all --in myimage --iv 2.0.0
|
|
59
|
+
# Builds: myimage:2.0.0-all
|
|
60
|
+
|
|
61
|
+
# Or build manually (Not recommended)
|
|
62
|
+
iv=1.4.0 && podman build -t localhost/xcanwin/manyoyo:$iv-all -f docker/manyoyo.Dockerfile . --build-arg EXT=all --no-cache
|
|
63
|
+
podman image prune -f
|
|
64
|
+
```
|
|
65
|
+
|
|
52
66
|
## 4. Usage
|
|
53
67
|
|
|
54
68
|
### Basic Commands
|
|
@@ -159,14 +173,18 @@ manyoyo -n docker-dev -m dind -x /bin/bash
|
|
|
159
173
|
nohup dockerd &
|
|
160
174
|
|
|
161
175
|
# Now you can use docker commands inside the container
|
|
162
|
-
docker
|
|
176
|
+
docker ps -a
|
|
163
177
|
```
|
|
164
178
|
|
|
165
179
|
#### Mount Docker socket Development
|
|
166
180
|
|
|
167
181
|
```bash
|
|
168
|
-
# Mount Docker socket (dangerous
|
|
169
|
-
|
|
182
|
+
# Mount Docker socket (dangerous!!! containers can access and execute everything on the host)
|
|
183
|
+
# Create a container mounting /var/run/docker.sock
|
|
184
|
+
manyoyo -n socket-dev -m mdsock -x /bin/bash
|
|
185
|
+
|
|
186
|
+
# Now you can use docker commands inside the container
|
|
187
|
+
docker ps -a
|
|
170
188
|
```
|
|
171
189
|
|
|
172
190
|
### Command-Line Options
|
|
@@ -189,6 +207,7 @@ manyoyo -n socket-dev -m mdsock -x docker ps
|
|
|
189
207
|
| `-x CMD` | `--sf`, `--shell-full` | Full command (replaces --sp, -s, and --) |
|
|
190
208
|
| `-y CLI` | `--yolo` | Run AI agent without confirmation |
|
|
191
209
|
| `-m MODE` | `--cm`, `--cont-mode` | Set container mode (common, dind, mdsock) |
|
|
210
|
+
| `--ib EXT` | `--image-build` | Build image, EXT is image variant (all, go, common) |
|
|
192
211
|
| `--install NAME` | | Install manyoyo command |
|
|
193
212
|
| `-V` | `--version` | Show version |
|
|
194
213
|
| `-h` | `--help` | Show help |
|
package/package.json
CHANGED