@xcanwin/manyoyo 2.0.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/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 xcanwin
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,222 @@
1
+ # MANYOYO(慢悠悠)
2
+
3
+ **MANYOYO** 是一款 AI 智能体提效安全沙箱,安全、高效、省 token,专为 Agent YOLO 模式设计,保障宿主机安全。
4
+
5
+ 预装常见 Agent 与工具,进一步节省 token。循环自由切换 Agent 和 /bin/bash,进一步提效。
6
+
7
+ MANYOYO provides an isolated Docker/Podman container environment for running AI agent CLIs safely.
8
+
9
+ ## 功能亮点
10
+
11
+ - **多Agent**:支持 claude code, gemini, codex, opencode
12
+ - **安全隔离**:保护宿主机,支持安全容器嵌套(Docker-in-Docker)
13
+ - **高效启动**:快捷开启常见 Agent YOLO / SOLO 模式(例如 claude --dangerously-skip-permissions)
14
+ - **便捷操作**:快速进入 `/bin/bash`
15
+ - **会话恢复**:安装 Skills Marketplace 可快速恢复会话
16
+ - **自定义灵活**:支持自定义 `BASEURL`、`AUTH_TOKEN` 等变量
17
+ - **配置管理**:快捷导入配置文件
18
+ - **高级模式**:支持危险容器嵌套(mount-docker-socket)、自定义沙箱镜像
19
+
20
+ # 使用方法
21
+
22
+ ## 1. 安装 podman
23
+
24
+ - 安装 [podman](https://podman.io/docs/installation)
25
+
26
+ ## 2. 编译镜像
27
+
28
+ ```
29
+ podman pull ubuntu:24.04
30
+ iv=1.4.0-all && podman build -t localhost/xcanwin/manyoyo:$iv -f docker/manyoyo.Dockerfile . --build-arg EXT=all --no-cache
31
+ podman image prune -f
32
+ ```
33
+
34
+ ## 3. 安装 manyoyo(选一种)
35
+
36
+ ### Global Installation (Recommended)
37
+
38
+ ```bash
39
+ cd ./manyoyo/
40
+ npm install -g .
41
+ ```
42
+
43
+ ### Local Development
44
+
45
+ ```bash
46
+ npm link
47
+ ```
48
+
49
+ ### Direct Symlink Installation
50
+
51
+ ```bash
52
+ node bin/manyoyo.js --install manyoyo
53
+ ```
54
+
55
+ ## 4. 使用方法
56
+
57
+ ### Basic Commands
58
+
59
+ ```bash
60
+ # Show help
61
+ manyoyo -h
62
+
63
+ # Show version
64
+ manyoyo -V
65
+
66
+ # List all containers
67
+ manyoyo -l
68
+
69
+ # Create new container with environment file
70
+ manyoyo -n test --ef .env -y c
71
+
72
+ # Resume existing session
73
+ manyoyo -n test -- -c
74
+
75
+ # Execute command in interactive shell
76
+ manyoyo -n test -x /bin/bash
77
+
78
+ # Execute custom command
79
+ manyoyo -n test -x echo "hello world"
80
+
81
+ # Remove container
82
+ manyoyo -n test --rm
83
+ ```
84
+
85
+ ### Environment Variables
86
+
87
+ #### String Format
88
+
89
+ ```bash
90
+ # Direct
91
+ manyoyo -e "VAR=value" -x env
92
+
93
+ # Multiple
94
+ manyoyo -e "A=1" -e "B=2" -x env
95
+ ```
96
+
97
+ #### File Format
98
+
99
+ ```bash
100
+ # From file
101
+ manyoyo --ef .env -x env
102
+ ```
103
+
104
+ Environment files (`.env`) support the following formats:
105
+
106
+ ```bash
107
+ # With export statement
108
+ export ANTHROPIC_BASE_URL="https://api.anthropic.com"
109
+ # export CLAUDE_CODE_OAUTH_TOKEN="sk-xxxxxxxx"
110
+ export ANTHROPIC_AUTH_TOKEN="sk-xxxxxxxx"
111
+ export API_TIMEOUT_MS=3000000
112
+ export ANTHROPIC_MODEL="claude-sonnet-4-5"
113
+ export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-5"
114
+ export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-5"
115
+ export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"
116
+ export CLAUDE_CODE_SUBAGENT_MODEL="claude-sonnet-4-5"
117
+
118
+ # Simple key=value
119
+ API_KEY=your-api-key-here
120
+
121
+ # Quoted values (quotes will be stripped)
122
+ MESSAGE="Hello World"
123
+ PATH='/usr/local/bin'
124
+ ```
125
+
126
+ ### AI CLI Shortcuts (skip permissions)
127
+
128
+ ```bash
129
+ # Claude Code
130
+ manyoyo -y c # or: claude, cc
131
+
132
+ # Gemini
133
+ manyoyo -y gm # or: gemini, g
134
+
135
+ # Codex
136
+ manyoyo -y cx # or: codex
137
+
138
+ # OpenCode
139
+ manyoyo -y oc # or: opencode
140
+ ```
141
+
142
+ ### Interactive Session Management
143
+
144
+ After exiting a container session, you'll be prompted with options:
145
+
146
+ - `y` - Keep container running in background (default)
147
+ - `n` - Delete the container
148
+ - `1` - Re-enter with the original command
149
+ - `s` - Execute a new command
150
+ - `i` - Enter interactive shell
151
+
152
+ ### Container Modes
153
+
154
+ #### Docker-in-Docker Development
155
+
156
+ ```bash
157
+ # Docker-in-Docker (safe nested containers)
158
+ # Create a container with Docker-in-Docker support
159
+ manyoyo -n docker-dev -m dind -x /bin/bash
160
+
161
+ # Inside the container, start dockerd
162
+ nohup dockerd &
163
+
164
+ # Now you can use docker commands inside the container
165
+ docker run hello-world
166
+ ```
167
+
168
+ #### Mount Docker socket Development
169
+
170
+ ```bash
171
+ # Mount Docker socket (dangerous - container can access host)
172
+ manyoyo -n socket-dev -m mdsock -x docker ps
173
+ ```
174
+
175
+ ### Command-Line Options
176
+
177
+ | Option | Aliases | Description |
178
+ |--------|---------|-------------|
179
+ | `-l` | `--ls`, `--list` | List all manyoyo containers |
180
+ | `--hp PATH` | `--host-path` | Set host working directory (default: current path) |
181
+ | `-n NAME` | `--cn`, `--cont-name` | Set container name |
182
+ | `--cp PATH` | `--cont-path` | Set container working directory |
183
+ | `--in NAME` | `--image-name` | Specify image name |
184
+ | `--iv VERSION` | `--image-ver` | Specify image version |
185
+ | `-e STRING` | `--env` | Set environment variable |
186
+ | `--ef FILE` | `--env-file` | Load environment variables from file |
187
+ | `-v STRING` | `--volume` | Bind mount volume |
188
+ | `--rm` | `--rmc`, `--remove-cont` | Remove container |
189
+ | `--sp CMD` | `--shell-prefix` | Temporary environment variable (prefix for -s) |
190
+ | `-s CMD` | `--shell` | Specify command to execute |
191
+ | `--` | `--ss`, `--shell-suffix` | Command arguments (suffix for -s) |
192
+ | `-x CMD` | `--sf`, `--shell-full` | Full command (replaces --sp, -s, and --) |
193
+ | `-y CLI` | `--yolo` | Run AI agent without confirmation |
194
+ | `-m MODE` | `--cm`, `--cont-mode` | Set container mode (common, dind, mdsock) |
195
+ | `--install NAME` | | Install manyoyo command |
196
+ | `-V` | `--version` | Show version |
197
+ | `-h` | `--help` | Show help |
198
+
199
+ ## 其他说明
200
+
201
+ ### Default Configuration
202
+
203
+ - **Container Name**: `myy-{MMDD-HHMM}` (auto-generated based on current time)
204
+ - **Host Path**: Current working directory
205
+ - **Container Path**: Same as host path
206
+ - **Image**: `localhost/xcanwin/manyoyo:xxx`
207
+
208
+ ### Requirements
209
+
210
+ - Node.js >= 14.0.0
211
+ - Docker or Podman
212
+
213
+ ### remove
214
+
215
+ ```bash
216
+ npm unlink -g manyoyo
217
+ sudo rm -rf /usr/local/bin/manyoyo
218
+ ```
219
+
220
+ ## License
221
+
222
+ MIT
package/bin/manyoyo.js ADDED
@@ -0,0 +1,582 @@
1
+ #!/usr/bin/env node
2
+
3
+ // ==============================================================================
4
+ // MANYOYO - AI Agent CLI Sandbox
5
+ // ==============================================================================
6
+
7
+ const { execSync, spawnSync } = require('child_process');
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const readline = require('readline');
11
+
12
+ // Helper function to format date like bash $(date +%m%d-%H%M)
13
+ function formatDate() {
14
+ const now = new Date();
15
+ const month = String(now.getMonth() + 1).padStart(2, '0');
16
+ const day = String(now.getDate()).padStart(2, '0');
17
+ const hour = String(now.getHours()).padStart(2, '0');
18
+ const minute = String(now.getMinutes()).padStart(2, '0');
19
+ return `${month}${day}-${hour}${minute}`;
20
+ }
21
+
22
+ // Default configuration
23
+ const BIN_VERSION = "2.0.0";
24
+ let CONTAINER_NAME = `myy-${formatDate()}`;
25
+ let HOST_PATH = process.cwd();
26
+ let CONTAINER_PATH = HOST_PATH;
27
+ let IMAGE_NAME = "localhost/xcanwin/manyoyo";
28
+ let IMAGE_VERSION = "1.4.0-all";
29
+ let EXEC_COMMAND = "";
30
+ let EXEC_COMMAND_PREFIX = "";
31
+ let EXEC_COMMAND_SUFFIX = "";
32
+ let ENV_FILE = "";
33
+ let SHOULD_REMOVE = false;
34
+ let CONTAINER_ENVS = [];
35
+ let CONTAINER_VOLUMES = [];
36
+ let MANYOYO_NAME = "manyoyo";
37
+ let CONT_MODE = "";
38
+
39
+ // Color definitions using ANSI codes
40
+ const RED = '\x1b[0;31m';
41
+ const GREEN = '\x1b[0;32m';
42
+ const YELLOW = '\x1b[1;33m';
43
+ const BLUE = '\x1b[0;34m';
44
+ const CYAN = '\x1b[0;36m';
45
+ const NC = '\x1b[0m'; // No Color
46
+
47
+ // Docker command (will be set by ensure_docker)
48
+ let DOCKER_CMD = 'docker';
49
+
50
+ function show_help() {
51
+ console.log(`${BLUE}Usage:${NC}`);
52
+ console.log(` ${MANYOYO_NAME} [OPTIONS]`);
53
+ console.log(` ${MANYOYO_NAME} [--hp HOST_PATH] [-n CONTAINER_NAME] [--cp CONTAINER_PATH] [--ef ENV_FILE] [--sp COMMAND] [-s COMMAND] [-- COMMAND]`);
54
+ console.log("");
55
+ console.log(`${BLUE}Options:${NC}`);
56
+ console.log(" -l|--ls|--list 列举容器");
57
+ console.log(" --hp|--host-path PATH 设置宿主机工作目录 (默认当前路径)");
58
+ console.log(" -n|--cn|--cont-name NAME 设置容器名称");
59
+ console.log(" --cp|--cont-path PATH 设置容器工作目录");
60
+ console.log(" --in|--image-name NAME 指定镜像名称");
61
+ console.log(" --iv|--image-ver VERSION 指定镜像版本");
62
+ console.log(" -e|--env STRING 设置环境变量");
63
+ console.log(" --ef|--env-file ENV_FILE 设置环境变量通过文件");
64
+ console.log(" -v|--volume STRING 绑定挂载卷");
65
+ console.log(" --rm|--remove-cont 删除-n容器");
66
+ console.log(" --sp|--shell-prefix COMMAND 临时环境变量 (作为-s前缀)");
67
+ console.log(" -s|--shell COMMAND 指定命令执行");
68
+ console.log(" --|--shell-suffix COMMAND 指定命令参数, --后面全部直传 (作为-s后缀)");
69
+ console.log(" -x|--shell-full COMMAND 指定完整命令执行, -x后面全部直传 (代替--sp和-s和--命令)");
70
+ console.log(" -y|--yolo CLI 使AGENT无需确认 (代替-s命令)");
71
+ console.log(" 例如 claude / c, gemini / gm, codex / cx, opencode / oc");
72
+ console.log(" -m|--cm|--cont-mode STRING 设置容器嵌套容器模式");
73
+ console.log(" 例如 common, dind, mdsock");
74
+ console.log(" --install NAME 安装manyoyo命令");
75
+ console.log(" 例如 manyoyo, myy, docker-cli-plugin");
76
+ console.log(" -V|--version 显示版本");
77
+ console.log(" -h|--help 显示帮助");
78
+ console.log("");
79
+ console.log(`${BLUE}Example:${NC}`);
80
+ console.log(` ./${MANYOYO_NAME}.sh --install manyoyo 安装manyoyo命令`);
81
+ console.log(` ${MANYOYO_NAME} -n test --ef ./xxx.env -y c 设置环境变量并运行无需确认的AGENT`);
82
+ console.log(` ${MANYOYO_NAME} -n test -- -c 恢复之前会话`);
83
+ console.log(` ${MANYOYO_NAME} -x echo 123 指定命令执行`);
84
+ console.log(` ${MANYOYO_NAME} -n test --ef ./xxx.env -x claude 设置环境变量并运行`);
85
+ console.log(` ${MANYOYO_NAME} -n test -x claude -c 恢复之前会话`);
86
+ }
87
+
88
+ function ensure_docker() {
89
+ try {
90
+ execSync('docker --version', { stdio: 'pipe' });
91
+ DOCKER_CMD = 'docker';
92
+ return true;
93
+ } catch (e) {
94
+ try {
95
+ execSync('podman --version', { stdio: 'pipe' });
96
+ DOCKER_CMD = 'podman';
97
+ return true;
98
+ } catch (e2) {
99
+ console.error("docker/podman not found");
100
+ process.exit(1);
101
+ }
102
+ }
103
+ }
104
+
105
+ function install_manyoyo(name) {
106
+ const MANYOYO_FILE = fs.realpathSync(__filename);
107
+ switch (name) {
108
+ case 'manyoyo':
109
+ execSync(`sudo ln -f -s "${MANYOYO_FILE}" /usr/local/bin/manyoyo`, { stdio: 'inherit' });
110
+ break;
111
+ case 'myy':
112
+ execSync(`sudo ln -f -s "${MANYOYO_FILE}" /usr/local/bin/myy`, { stdio: 'inherit' });
113
+ break;
114
+ case 'docker-cli-plugin':
115
+ execSync(`mkdir -p "$HOME/.docker/cli-plugins/"`, { stdio: 'inherit' });
116
+ execSync(`sudo ln -f -s "${MANYOYO_FILE}" "$HOME/.docker/cli-plugins/docker-manyoyo"`, { stdio: 'inherit' });
117
+ break;
118
+ default:
119
+ console.log("");
120
+ }
121
+ process.exit(0);
122
+ }
123
+
124
+ function show_version() {
125
+ console.log(`manyoyo by xcanwin, ${BIN_VERSION}`);
126
+ }
127
+
128
+ function set_yolo(cli) {
129
+ switch (cli) {
130
+ case 'claude':
131
+ case 'cc':
132
+ case 'c':
133
+ EXEC_COMMAND = "IS_SANDBOX=1 claude --dangerously-skip-permissions";
134
+ break;
135
+ case 'gemini':
136
+ case 'gm':
137
+ case 'g':
138
+ EXEC_COMMAND = "gemini --yolo";
139
+ break;
140
+ case 'codex':
141
+ case 'cx':
142
+ EXEC_COMMAND = "codex";
143
+ break;
144
+ case 'opencode':
145
+ case 'oc':
146
+ EXEC_COMMAND = "opencode";
147
+ break;
148
+ default:
149
+ console.log(`${RED}⚠️ 未知LLM CLI: ${cli}${NC}`);
150
+ process.exit(0);
151
+ }
152
+ }
153
+
154
+ function set_cont_mode(mode) {
155
+ switch (mode) {
156
+ case 'common':
157
+ CONT_MODE = "";
158
+ break;
159
+ case 'docker-in-docker':
160
+ case 'dind':
161
+ case 'd':
162
+ CONT_MODE = "--privileged";
163
+ console.log(`${GREEN}✅ 开启安全的容器嵌套容器模式, 手动在容器内启动服务: nohup dockerd &${NC}`);
164
+ break;
165
+ case 'mount-docker-socket':
166
+ case 'mdsock':
167
+ case 's':
168
+ CONT_MODE = "--volume /var/run/docker.sock:/var/run/docker.sock";
169
+ console.log(`${RED}⚠️ 开启危险的容器嵌套容器模式, 危害: 容器可访问宿主机文件${NC}`);
170
+ break;
171
+ default:
172
+ console.log(`${RED}⚠️ 未知模式: ${mode}${NC}`);
173
+ process.exit(0);
174
+ }
175
+ }
176
+
177
+ function get_cont_list() {
178
+ try {
179
+ const result = execSync(`${DOCKER_CMD} ps -a --size --filter "ancestor=manyoyo" --filter "ancestor=$(${DOCKER_CMD} images -a --format '{{.Repository}}:{{.Tag}}' | grep manyoyo)" --format "table {{.Names}}\\t{{.Status}}\\t{{.Size}}\\t{{.ID}}\\t{{.Image}}\\t{{.Ports}}\\t{{.Networks}}\\t{{.Mounts}}"`,
180
+ { encoding: 'utf-8' });
181
+ console.log(result);
182
+ } catch (e) {
183
+ console.log(e.stdout || '');
184
+ }
185
+ }
186
+
187
+ function add_volume(volume) {
188
+ CONTAINER_VOLUMES.push("--volume", volume);
189
+ }
190
+
191
+ function add_env(env) {
192
+ CONTAINER_ENVS.push("--env", env);
193
+ }
194
+
195
+ function add_env_file(envFile) {
196
+ ENV_FILE = envFile;
197
+ if (ENV_FILE && fs.existsSync(ENV_FILE)) {
198
+ const content = fs.readFileSync(ENV_FILE, 'utf-8');
199
+ const lines = content.split('\n');
200
+
201
+ for (let line of lines) {
202
+ // Match pattern: (export )?(KEY)=(VALUE)
203
+ const match = line.match(/^(?:export\s+)?([a-zA-Z_][a-zA-Z0-9_]*)\s*=\s*(.*)$/);
204
+ if (match) {
205
+ let key = match[1];
206
+ let value = match[2].trim();
207
+
208
+ // Filter malicious characters
209
+ if (/[\$\(\)\`\|\&\*\{\}]/.test(value)) continue;
210
+ if (/^\(/.test(value)) continue;
211
+
212
+ // Remove quotes
213
+ if (/^"(.*)"$/.test(value)) {
214
+ value = value.slice(1, -1);
215
+ } else if (/^'(.*)'$/.test(value)) {
216
+ value = value.slice(1, -1);
217
+ }
218
+
219
+ if (key) {
220
+ CONTAINER_ENVS.push("--env", `${key}=${value}`);
221
+ }
222
+ }
223
+ }
224
+ }
225
+ }
226
+
227
+ function get_hello_tip(containerName, defaultCommand) {
228
+ console.log(`${BLUE}----------------------------------------${NC}`);
229
+ console.log(`📦 首次命令 : ${defaultCommand}`);
230
+ console.log(`⚫ 恢复首次命令会话: ${CYAN}${MANYOYO_NAME} -n ${containerName} -- -c${NC}`);
231
+ console.log(`⚫ 执行首次命令 : ${GREEN}${MANYOYO_NAME} -n ${containerName}${NC}`);
232
+ console.log(`⚫ 执行指定命令 : ${GREEN}${MANYOYO_NAME} -n ${containerName} -x /bin/bash${NC}`);
233
+ console.log(`⚫ 执行指定命令 : ${GREEN}docker exec -it ${containerName} /bin/bash${NC}`);
234
+ console.log(`⚫ 删除容器 : ${MANYOYO_NAME} -n ${containerName} --rm`);
235
+ console.log("");
236
+ }
237
+
238
+ function docker_exec(cmd, options = {}) {
239
+ try {
240
+ return execSync(cmd, { encoding: 'utf-8', ...options });
241
+ } catch (e) {
242
+ if (options.ignoreError) {
243
+ return e.stdout || '';
244
+ }
245
+ throw e;
246
+ }
247
+ }
248
+
249
+ function sleep(ms) {
250
+ return new Promise(resolve => setTimeout(resolve, ms));
251
+ }
252
+
253
+ async function askQuestion(prompt) {
254
+ const rl = readline.createInterface({
255
+ input: process.stdin,
256
+ output: process.stdout
257
+ });
258
+
259
+ return new Promise((resolve) => {
260
+ rl.question(prompt, (answer) => {
261
+ rl.close();
262
+ resolve(answer);
263
+ });
264
+ });
265
+ }
266
+
267
+ async function main() {
268
+ // Check if no arguments provided
269
+ if (process.argv.length <= 2) {
270
+ show_help();
271
+ process.exit(1);
272
+ }
273
+
274
+ // Ensure docker/podman is available
275
+ ensure_docker();
276
+
277
+ // Docker CLI plugin metadata
278
+ if (process.argv[2] === 'docker-cli-plugin-metadata') {
279
+ const metadata = {
280
+ "SchemaVersion": "0.1.0",
281
+ "Vendor": "xcanwin",
282
+ "Version": "v1.0.0",
283
+ "Description": "AI Agent CLI Sandbox"
284
+ };
285
+ console.log(JSON.stringify(metadata, null, 2));
286
+ process.exit(0);
287
+ }
288
+
289
+ // Parse arguments
290
+ let args = process.argv.slice(2);
291
+
292
+ // Docker CLI plugin mode - remove first arg if running as plugin
293
+ const dockerPluginPath = path.join(process.env.HOME || '', '.docker/cli-plugins/docker-manyoyo');
294
+ if (process.argv[1] === dockerPluginPath && args[0] === 'manyoyo') {
295
+ args.shift();
296
+ }
297
+
298
+ // Parse command-line arguments
299
+ let i = 0;
300
+ while (i < args.length) {
301
+ const arg = args[i];
302
+
303
+ switch (arg) {
304
+ case '-l':
305
+ case '--ls':
306
+ case '--list':
307
+ get_cont_list();
308
+ process.exit(0);
309
+
310
+ case '--hp':
311
+ case '--host-path':
312
+ HOST_PATH = args[i + 1];
313
+ i += 2;
314
+ break;
315
+
316
+ case '-n':
317
+ case '--cn':
318
+ case '--cont-name':
319
+ CONTAINER_NAME = args[i + 1];
320
+ i += 2;
321
+ break;
322
+
323
+ case '--cp':
324
+ case '--cont-path':
325
+ CONTAINER_PATH = args[i + 1];
326
+ i += 2;
327
+ break;
328
+
329
+ case '--in':
330
+ case '--image-name':
331
+ IMAGE_NAME = args[i + 1];
332
+ i += 2;
333
+ break;
334
+
335
+ case '--iv':
336
+ case '--image-ver':
337
+ IMAGE_VERSION = args[i + 1];
338
+ i += 2;
339
+ break;
340
+
341
+ case '-e':
342
+ case '--env':
343
+ add_env(args[i + 1]);
344
+ i += 2;
345
+ break;
346
+
347
+ case '--ef':
348
+ case '--env-file':
349
+ add_env_file(args[i + 1]);
350
+ i += 2;
351
+ break;
352
+
353
+ case '-v':
354
+ case '--volume':
355
+ add_volume(args[i + 1]);
356
+ i += 2;
357
+ break;
358
+
359
+ case '--rm':
360
+ case '--rmc':
361
+ case '--remove-cont':
362
+ SHOULD_REMOVE = true;
363
+ i += 1;
364
+ break;
365
+
366
+ case '--sp':
367
+ case '--shell-prefix':
368
+ EXEC_COMMAND_PREFIX = args[i + 1] + " ";
369
+ i += 2;
370
+ break;
371
+
372
+ case '-s':
373
+ case '--shell':
374
+ EXEC_COMMAND = args[i + 1];
375
+ i += 2;
376
+ break;
377
+
378
+ case '--':
379
+ case '--ss':
380
+ case '--shell-suffix':
381
+ EXEC_COMMAND_SUFFIX = " " + args.slice(i + 1).join(' ');
382
+ i = args.length;
383
+ break;
384
+
385
+ case '-x':
386
+ case '--sf':
387
+ case '--shell-full':
388
+ EXEC_COMMAND = args.slice(i + 1).join(' ');
389
+ i = args.length;
390
+ break;
391
+
392
+ case '-y':
393
+ case '--yolo':
394
+ set_yolo(args[i + 1]);
395
+ i += 2;
396
+ break;
397
+
398
+ case '-m':
399
+ case '--cm':
400
+ case '--cont-mode':
401
+ set_cont_mode(args[i + 1]);
402
+ i += 2;
403
+ break;
404
+
405
+ case '--install':
406
+ install_manyoyo(args[i + 1]);
407
+ process.exit(0);
408
+
409
+ case '-V':
410
+ case '--version':
411
+ show_version();
412
+ process.exit(0);
413
+
414
+ case '-h':
415
+ case '--help':
416
+ show_help();
417
+ process.exit(0);
418
+
419
+ default:
420
+ console.log(`${RED}⚠️ 未知参数: ${arg}${NC}`);
421
+ show_help();
422
+ process.exit(1);
423
+ }
424
+ }
425
+
426
+ // Handle remove logic
427
+ if (SHOULD_REMOVE) {
428
+ try {
429
+ const containers = docker_exec(`${DOCKER_CMD} ps -a --format '{{.Names}}'`);
430
+ if (containers.split('\n').some(name => name.trim() === CONTAINER_NAME)) {
431
+ console.log(`${YELLOW}🗑️ 正在删除容器: ${CONTAINER_NAME}...${NC}`);
432
+ docker_exec(`${DOCKER_CMD} rm -f "${CONTAINER_NAME}"`, { stdio: 'pipe' });
433
+ console.log(`${GREEN}✅ 已彻底删除。${NC}`);
434
+ } else {
435
+ console.log(`${RED}⚠️ 错误: 未找到名为 ${CONTAINER_NAME} 的容器。${NC}`);
436
+ }
437
+ } catch (e) {
438
+ console.log(`${RED}⚠️ 错误: 未找到名为 ${CONTAINER_NAME} 的容器。${NC}`);
439
+ }
440
+ process.exit(0);
441
+ }
442
+
443
+ // Safety check
444
+ const realHostPath = fs.realpathSync(HOST_PATH);
445
+ const homeDir = process.env.HOME || '/home';
446
+ if (realHostPath === '/' || realHostPath === '/home' || realHostPath === homeDir) {
447
+ console.log(`${RED}⚠️ 错误: 不允许挂载根目录或home目录。${NC}`);
448
+ process.exit(1);
449
+ }
450
+
451
+ const FULL_IMAGE = `${IMAGE_NAME}:${IMAGE_VERSION}`;
452
+ let DEFAULT_COMMAND = "";
453
+
454
+ // Check if container exists
455
+ try {
456
+ const containers = docker_exec(`${DOCKER_CMD} ps -a --format '{{.Names}}'`);
457
+ const containerExists = containers.split('\n').some(name => name.trim() === CONTAINER_NAME);
458
+
459
+ if (!containerExists) {
460
+ // Create new container
461
+ console.log(`${CYAN}📦 manyoyo by xcanwin 正在创建新容器: ${YELLOW}${CONTAINER_NAME}${NC}\n`);
462
+ EXEC_COMMAND = `${EXEC_COMMAND_PREFIX}${EXEC_COMMAND}${EXEC_COMMAND_SUFFIX}`;
463
+ DEFAULT_COMMAND = EXEC_COMMAND;
464
+
465
+ // Build docker run command
466
+ const envArgs = CONTAINER_ENVS.join(' ');
467
+ const volumeArgs = CONTAINER_VOLUMES.join(' ');
468
+ const contModeArg = CONT_MODE ? CONT_MODE : '';
469
+
470
+ const dockerRunCmd = `${DOCKER_CMD} run -d --name "${CONTAINER_NAME}" --entrypoint "" ${contModeArg} ${envArgs} ${volumeArgs} --volume "${HOST_PATH}:${CONTAINER_PATH}" --workdir "${CONTAINER_PATH}" --label "manyoyo.default_cmd=${EXEC_COMMAND}" "${FULL_IMAGE}" tail -f /dev/null`;
471
+
472
+ docker_exec(dockerRunCmd, { stdio: 'pipe' });
473
+
474
+ // Wait for container to be ready
475
+ const MAX_RETRIES = 50;
476
+ let count = 0;
477
+ while (true) {
478
+ try {
479
+ const status = docker_exec(`${DOCKER_CMD} inspect -f '{{.State.Status}}' "${CONTAINER_NAME}"`).trim();
480
+
481
+ if (status === 'running') {
482
+ break;
483
+ }
484
+
485
+ if (status === 'exited') {
486
+ console.log(`${RED}⚠️ 错误: 容器启动后立即退出。${NC}`);
487
+ docker_exec(`${DOCKER_CMD} logs "${CONTAINER_NAME}"`, { stdio: 'inherit' });
488
+ process.exit(1);
489
+ }
490
+
491
+ await sleep(100);
492
+ count++;
493
+
494
+ if (count >= MAX_RETRIES) {
495
+ console.log(`${RED}⚠️ 错误: 容器启动超时(当前状态: ${status})。${NC}`);
496
+ docker_exec(`${DOCKER_CMD} logs "${CONTAINER_NAME}"`, { stdio: 'inherit' });
497
+ process.exit(1);
498
+ }
499
+ } catch (e) {
500
+ await sleep(100);
501
+ count++;
502
+ if (count >= MAX_RETRIES) {
503
+ console.log(`${RED}⚠️ 错误: 容器启动超时。${NC}`);
504
+ process.exit(1);
505
+ }
506
+ }
507
+ }
508
+ } else {
509
+ // Container exists
510
+ console.log(`${CYAN}🔄 manyoyo by xcanwin 正在连接到现有容器: ${YELLOW}${CONTAINER_NAME}${NC}`);
511
+
512
+ // Start container if stopped
513
+ const status = docker_exec(`${DOCKER_CMD} inspect -f '{{.State.Status}}' "${CONTAINER_NAME}"`).trim();
514
+ if (status !== 'running') {
515
+ docker_exec(`${DOCKER_CMD} start "${CONTAINER_NAME}"`, { stdio: 'pipe' });
516
+ }
517
+
518
+ // Get default command from label
519
+ DEFAULT_COMMAND = docker_exec(`${DOCKER_CMD} inspect -f '{{index .Config.Labels "manyoyo.default_cmd"}}' "${CONTAINER_NAME}"`).trim();
520
+
521
+ if (!EXEC_COMMAND) {
522
+ EXEC_COMMAND = `${EXEC_COMMAND_PREFIX}${DEFAULT_COMMAND}${EXEC_COMMAND_SUFFIX}`;
523
+ } else {
524
+ EXEC_COMMAND = `${EXEC_COMMAND_PREFIX}${EXEC_COMMAND}${EXEC_COMMAND_SUFFIX}`;
525
+ }
526
+ }
527
+
528
+ get_hello_tip(CONTAINER_NAME, DEFAULT_COMMAND);
529
+ console.log(`${BLUE}----------------------------------------${NC}`);
530
+ console.log(`💻 执行命令: ${YELLOW}${EXEC_COMMAND || '交互式 Shell'}${NC}`);
531
+
532
+ // Execute command in container
533
+ if (EXEC_COMMAND) {
534
+ spawnSync(`${DOCKER_CMD}`, ['exec', '-it', CONTAINER_NAME, '/bin/bash', '-c', EXEC_COMMAND], { stdio: 'inherit' });
535
+ } else {
536
+ spawnSync(`${DOCKER_CMD}`, ['exec', '-it', CONTAINER_NAME, '/bin/bash'], { stdio: 'inherit' });
537
+ }
538
+
539
+ // Post-exit prompt
540
+ console.log("");
541
+ get_hello_tip(CONTAINER_NAME, DEFAULT_COMMAND);
542
+
543
+ const reply = await askQuestion(`❔ 会话已结束。是否保留此后台容器 ${CONTAINER_NAME}? [ y=默认保留, n=删除, 1=首次命令进入, s=执行命令, i=交互式SHELL ]: `);
544
+ console.log("");
545
+
546
+ const firstChar = reply.trim().toLowerCase()[0];
547
+
548
+ if (firstChar === 'n') {
549
+ console.log(`${YELLOW}🗑️ 正在删除容器...${NC}`);
550
+ docker_exec(`${DOCKER_CMD} rm -f "${CONTAINER_NAME}"`, { stdio: 'pipe' });
551
+ console.log(`${GREEN}✅ 已彻底删除。${NC}`);
552
+ } else if (firstChar === '1') {
553
+ console.log(`${GREEN}✅ 离开当前连接,用首次命令进入。${NC}`);
554
+ // Reconstruct the command and execute recursively
555
+ const newArgs = ['-n', CONTAINER_NAME];
556
+ process.argv = [process.argv[0], process.argv[1], ...newArgs];
557
+ await main();
558
+ } else if (firstChar === 's') {
559
+ const command = await askQuestion('❔ 输入要执行的命令: ');
560
+ console.log(`${GREEN}✅ 离开当前连接,执行命令。${NC}`);
561
+ const newArgs = ['-n', CONTAINER_NAME, '-x', command];
562
+ process.argv = [process.argv[0], process.argv[1], ...newArgs];
563
+ await main();
564
+ } else if (firstChar === 'i') {
565
+ console.log(`${GREEN}✅ 离开当前连接,进入容器交互式SHELL。${NC}`);
566
+ const newArgs = ['-n', CONTAINER_NAME, '-x', '/bin/bash'];
567
+ process.argv = [process.argv[0], process.argv[1], ...newArgs];
568
+ await main();
569
+ } else {
570
+ console.log(`${GREEN}✅ 已退出连接。容器 ${CONTAINER_NAME} 仍在后台运行。${NC}`);
571
+ }
572
+
573
+ } catch (e) {
574
+ console.error(`${RED}Error: ${e.message}${NC}`);
575
+ process.exit(1);
576
+ }
577
+ }
578
+
579
+ main().catch(err => {
580
+ console.error(err);
581
+ process.exit(1);
582
+ });
@@ -0,0 +1,215 @@
1
+ FROM ubuntu:24.04
2
+
3
+ ARG TARGETARCH
4
+ ARG NODE_VERSION=24
5
+ ARG EXT=""
6
+
7
+ RUN <<EOX
8
+ # 部署 system
9
+
10
+ # 修复CA证书
11
+ sed -i 's|http://[^/]*\.ubuntu\.com|https://mirrors.aliyun.com|g' /etc/apt/sources.list.d/ubuntu.sources
12
+ apt-get -o Acquire::https::Verify-Peer=false update -y
13
+ apt-get -o Acquire::https::Verify-Peer=false install -y --no-install-recommends ca-certificates openssl
14
+ update-ca-certificates
15
+
16
+ # 安装基本依赖
17
+ apt-get update -y
18
+ apt-get install -y --no-install-recommends --reinstall ca-certificates openssl
19
+ update-ca-certificates
20
+ apt-get install -y --no-install-recommends curl wget net-tools iputils-ping git lsof socat ncat dnsutils \
21
+ nano jq file tree ripgrep less bc xxd \
22
+ tar zip unzip gzip make sqlite3 \
23
+ supervisor
24
+
25
+ # 安装 docker
26
+ case ",$EXT," in *,all,*|*,docker,*)
27
+ apt-get install -y --no-install-recommends docker.io
28
+ ;; esac
29
+
30
+ # 清理
31
+ apt-get clean
32
+ rm -rf /tmp/* /var/tmp/* /var/log/apt /var/log/*.log /var/lib/apt/lists/* ~/.cache ~/.npm ~/go/pkg/mod/cache
33
+ EOX
34
+
35
+ RUN <<EOX
36
+ # 安装 python
37
+ apt-get update -y
38
+ apt-get install -y --no-install-recommends python3.12 python3.12-dev python3.12-venv python3-pip
39
+ ln -sf /usr/bin/python3 /usr/bin/python
40
+ ln -sf /usr/bin/pip3 /usr/bin/pip
41
+ pip config set global.index-url "https://mirrors.tencent.com/pypi/simple"
42
+
43
+ # 清理
44
+ apt-get clean
45
+ rm -rf /tmp/* /var/tmp/* /var/log/apt /var/log/*.log /var/lib/apt/lists/* ~/.cache ~/.npm ~/go/pkg/mod/cache
46
+ EOX
47
+
48
+ RUN <<EOX
49
+ # 安装 node.js
50
+ case "$TARGETARCH" in
51
+ amd64) ARCH_NODE="x64" ;;
52
+ arm64) ARCH_NODE="arm64" ;;
53
+ *) ARCH_NODE="$TARGETARCH" ;;
54
+ esac
55
+ NVM_NODEJS_ORG_MIRROR=https://mirrors.tencent.com/nodejs-release/
56
+ NODE_TAR=$(curl -sL ${NVM_NODEJS_ORG_MIRROR}/latest-v${NODE_VERSION}.x/SHASUMS256.txt | grep linux-${ARCH_NODE}.tar.gz | awk '{print $2}')
57
+ curl -fsSL ${NVM_NODEJS_ORG_MIRROR}/latest-v${NODE_VERSION}.x/${NODE_TAR} | tar -xz -C /usr/local --strip-components=1 --exclude='*.md' --exclude='LICENSE'
58
+ npm config set registry=https://mirrors.tencent.com/npm/
59
+ npm install -g npm
60
+
61
+ # 安装 LSP服务(python、typescript)
62
+ npm install -g pyright typescript-language-server typescript
63
+
64
+ # 安装 Claude CLI
65
+ npm install -g @anthropic-ai/claude-code
66
+ mkdir -p ~/.claude/plugins/marketplaces/
67
+ cat > ~/.claude.json <<EOF
68
+ {
69
+ "bypassPermissionsModeAccepted": true,
70
+ "hasCompletedOnboarding": true,
71
+ "env": {
72
+ "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
73
+ "CLAUDE_CODE_HIDE_ACCOUNT_INFO": "1",
74
+ "DISABLE_AUTOUPDATER": "1"
75
+ }
76
+ }
77
+ EOF
78
+ claude plugin marketplace add anthropics/claude-plugins-official
79
+ claude plugin install ralph-loop@claude-plugins-official
80
+ claude plugin install typescript-lsp@claude-plugins-official
81
+ claude plugin install pyright-lsp@claude-plugins-official
82
+ claude plugin install gopls-lsp@claude-plugins-official
83
+ claude plugin install jdtls-lsp@claude-plugins-official
84
+
85
+ # 安装 Gemini CLI
86
+ case ",$EXT," in *,all,*|*,gemini,*)
87
+ npm install -g @google/gemini-cli
88
+ mkdir -p ~/.gemini/
89
+ cat > ~/.gemini/settings.json <<EOF
90
+ {
91
+ "privacy": {
92
+ "usageStatisticsEnabled": false
93
+ },
94
+ "security": {
95
+ "auth": {
96
+ "selectedType": "oauth-personal"
97
+ }
98
+ },
99
+ "general": {
100
+ "previewFeatures": true,
101
+ "disableAutoUpdate": true,
102
+ "disableUpdateNag": true
103
+ },
104
+ "model": {
105
+ "name": "gemini-3-pro-preview"
106
+ }
107
+ }
108
+ EOF
109
+ ;; esac
110
+
111
+ # 安装 Codex CLI
112
+ case ",$EXT," in *,all,*|*,codex,*)
113
+ npm install -g @openai/codex
114
+ ;; esac
115
+
116
+ # 安装 Copilot CLI
117
+ case ",$EXT," in *,all,*|*,copilot,*)
118
+ npm install -g @github/copilot
119
+ mkdir -p ~/.copilot/
120
+ cat > ~/.copilot/config.json <<EOF
121
+ {
122
+ "banner": "never",
123
+ "model": "gemini-3-pro-preview",
124
+ "render_markdown": true,
125
+ "screen_reader": false,
126
+ "theme": "auto"
127
+ }
128
+ EOF
129
+ ;; esac
130
+
131
+ # 安装 OpenCode CLI
132
+ case ",$EXT," in *,all,*|*,opencode,*)
133
+ npm install -g opencode-ai
134
+ mkdir -p ~/.config/opencode/
135
+ cat > ~/.config/opencode/opencode.json <<EOF
136
+ {
137
+ "$schema": "https://opencode.ai/config.json",
138
+ "autoupdate": false,
139
+ "permission": "allow",
140
+ "model": "myprovider/{env:ANTHROPIC_MODEL}",
141
+ "provider": {
142
+ "myprovider": {
143
+ "npm": "@ai-sdk/openai-compatible",
144
+ "options": {
145
+ "baseURL": "{env:ANTHROPIC_BASE_URL}",
146
+ "apiKey": "{env:ANTHROPIC_AUTH_TOKEN}",
147
+ "headers": {
148
+ "User-Agent": "opencode-cli"
149
+ }
150
+ },
151
+ "models": {
152
+ "{env:ANTHROPIC_MODEL}": {},
153
+ "claude-sonnet-4-5-20250929": {},
154
+ "gpt-5.2": {}
155
+ }
156
+ }
157
+ }
158
+ }
159
+ EOF
160
+ ;; esac
161
+
162
+ # 清理
163
+ npm cache clean --force
164
+ rm -rf /tmp/* /var/tmp/* /var/log/apt /var/log/*.log /var/lib/apt/lists/* ~/.cache ~/.npm ~/go/pkg/mod/cache
165
+ EOX
166
+
167
+ COPY ./docker/lib/jdt-language-server-latest.tar.gz /tmp/
168
+ RUN <<EOX
169
+ # 安装 java
170
+ case ",$EXT," in *,all,*|*,java,*)
171
+ apt-get update -y
172
+ apt-get install -y --no-install-recommends openjdk-21-jdk maven
173
+
174
+ # 安装 LSP服务(java)
175
+ mkdir -p ~/.local/share/jdtls
176
+ # wget -O /tmp/jdt-language-server-latest.tar.gz https://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz
177
+ tar -xzf /tmp/jdt-language-server-latest.tar.gz -C ~/.local/share/jdtls
178
+ rm -f /tmp/jdt-language-server-latest.tar.gz
179
+ ln -sf ~/.local/share/jdtls/bin/jdtls /usr/local/bin/jdtls
180
+
181
+ # 清理
182
+ apt-get clean
183
+ rm -rf /tmp/* /var/tmp/* /var/log/apt /var/log/*.log /var/lib/apt/lists/* ~/.cache ~/.npm ~/go/pkg/mod/cache
184
+ ;; esac
185
+ EOX
186
+
187
+ RUN <<EOX
188
+ # 安装 go
189
+ case ",$EXT," in *,all,*|*,go,*)
190
+ apt-get update -y
191
+ apt-get install -y --no-install-recommends golang golang-src gcc
192
+ go env -w GOPROXY=https://mirrors.tencent.com/go
193
+
194
+ # 安装 LSP服务(go)
195
+ go install golang.org/x/tools/gopls@latest
196
+ ln -sf ~/go/bin/gopls /usr/local/bin/gopls
197
+
198
+ # 清理
199
+ apt-get clean
200
+ go clean -modcache -cache
201
+ rm -rf /tmp/* /var/tmp/* /var/log/apt /var/log/*.log /var/lib/apt/lists/* ~/.cache ~/.npm ~/go/pkg/mod/cache
202
+ ;; esac
203
+ EOX
204
+
205
+ RUN <<EOX
206
+ # 配置 supervisor
207
+ cat > /etc/supervisor/conf.d/s.conf << EOF
208
+ [supervisord]
209
+ user=root
210
+ nodaemon=true
211
+ EOF
212
+ EOX
213
+
214
+ WORKDIR /tmp
215
+ CMD ["supervisord", "-n", "-c", "/etc/supervisor/supervisord.conf"]
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@xcanwin/manyoyo",
3
+ "version": "2.0.0",
4
+ "description": "AI Agent CLI Sandbox",
5
+ "main": "bin/manyoyo.js",
6
+ "bin": {
7
+ "manyoyo": "bin/manyoyo.js"
8
+ },
9
+ "scripts": {
10
+ "install-link": "npm link",
11
+ "test": "node bin/manyoyo.js --help"
12
+ },
13
+ "keywords": [
14
+ "ai",
15
+ "agent",
16
+ "sandbox",
17
+ "docker",
18
+ "cli",
19
+ "container",
20
+ "development"
21
+ ],
22
+ "author": "xcanwin",
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/xcanwin/manyoyo.git"
27
+ },
28
+ "homepage": "https://github.com/xcanwin/manyoyo",
29
+ "engines": {
30
+ "node": ">=14.0.0"
31
+ },
32
+ "files": [
33
+ "manyoyo.js",
34
+ "README.md",
35
+ "LICENSE",
36
+ "docker/manyoyo.Dockerfile"
37
+ ]
38
+ }