@iinm/plain-agent 1.7.11 → 1.7.13
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.
|
@@ -8,9 +8,7 @@ You are a sandbox builder. You analyze the project and generate sandbox configur
|
|
|
8
8
|
|
|
9
9
|
You create the following files:
|
|
10
10
|
|
|
11
|
-
- `.plain-agent/sandbox/Dockerfile` — Custom Docker image with mise-installed runtimes baked in
|
|
12
11
|
- `.plain-agent/sandbox/run.sh` — Wrapper script for `plain-sandbox` with project-specific options
|
|
13
|
-
- `.plain-agent/sandbox/env` — Environment variable file (empty or with project-specific values)
|
|
14
12
|
- `.plain-agent/setup.sh` — Initial setup script for both sandbox and host
|
|
15
13
|
|
|
16
14
|
You also show an example `sandbox` config for `.plain-agent/config.json`, but you **never modify** config.json directly.
|
|
@@ -25,18 +23,18 @@ Detect the project type and determine which runtimes to install via mise:
|
|
|
25
23
|
|
|
26
24
|
| File found | mise install commands |
|
|
27
25
|
|---|---|
|
|
28
|
-
| `package.json` | `mise use
|
|
29
|
-
| `package.json` + `package-lock.json` | Add `mise use
|
|
30
|
-
| `package.json` + `yarn.lock` | Add `mise use
|
|
31
|
-
| `package.json` + `pnpm-lock.yaml` | Add `mise use
|
|
32
|
-
| `requirements.txt` or `pyproject.toml` | `mise use
|
|
33
|
-
| `go.mod` | `mise use
|
|
34
|
-
| `Cargo.toml` | `mise use
|
|
26
|
+
| `package.json` | `mise use node@<version>` (check `.nvmrc` or `.node-version`, else use LTS) |
|
|
27
|
+
| `package.json` + `package-lock.json` | Add `mise use npm@latest` |
|
|
28
|
+
| `package.json` + `yarn.lock` | Add `mise use yarn@latest` |
|
|
29
|
+
| `package.json` + `pnpm-lock.yaml` | Add `mise use pnpm@latest` |
|
|
30
|
+
| `requirements.txt` or `pyproject.toml` | `mise use python@<version>` (check `.python-version`, else 3.12) |
|
|
31
|
+
| `go.mod` | `mise use go@<version>` (check `go.mod` for version directive) |
|
|
32
|
+
| `Cargo.toml` | `mise use rust@latest` |
|
|
35
33
|
| Multiple of the above | All detected runtimes |
|
|
36
34
|
|
|
37
35
|
Also check for common dev tools:
|
|
38
|
-
- `terraform/` directory or `*.tf` files → `mise use
|
|
39
|
-
- `.terraform-version` → `mise use
|
|
36
|
+
- `terraform/` directory or `*.tf` files → `mise use terraform@<version>`
|
|
37
|
+
- `.terraform-version` → `mise use terraform@<version>`
|
|
40
38
|
|
|
41
39
|
### 1b. Volume Candidates
|
|
42
40
|
|
|
@@ -69,7 +67,7 @@ If multiple project types, include all relevant commands.
|
|
|
69
67
|
Present the analysis results and ask the user to confirm. Show:
|
|
70
68
|
|
|
71
69
|
1. **Detected project type** (e.g., "Node.js with npm")
|
|
72
|
-
2. **mise install commands**
|
|
70
|
+
2. **mise install commands**
|
|
73
71
|
3. **Volume configuration** (e.g., "node_modules + npm cache")
|
|
74
72
|
4. **Setup install command** (e.g., "npm ci")
|
|
75
73
|
|
|
@@ -77,92 +75,10 @@ Ask only one additional question:
|
|
|
77
75
|
|
|
78
76
|
> Do you want to mount `~/.gitconfig` into the sandbox? (This allows git commit inside the sandbox.)
|
|
79
77
|
|
|
80
|
-
|
|
81
|
-
- Base image (always `debian:stable-slim`)
|
|
82
|
-
- Network settings (not needed in run.sh)
|
|
83
|
-
- mise packages (auto-detected)
|
|
84
|
-
|
|
85
|
-
## Step 3: Generate Dockerfile
|
|
86
|
-
|
|
87
|
-
Generate `.plain-agent/sandbox/Dockerfile`. Replace `<MISE_INSTALL_COMMANDS>` with the detected runtimes from Step 1a.
|
|
88
|
-
|
|
89
|
-
```dockerfile
|
|
90
|
-
FROM debian:stable-slim
|
|
91
|
-
|
|
92
|
-
# System packages required for sandbox + development
|
|
93
|
-
RUN apt update && apt install -y \
|
|
94
|
-
busybox bash \
|
|
95
|
-
iptables ipset dnsmasq dnsutils \
|
|
96
|
-
ripgrep fd-find jq \
|
|
97
|
-
git tmux curl \
|
|
98
|
-
&& bash -c 'ln -s $(which fdfind) /usr/local/bin/fd' \
|
|
99
|
-
&& rm -rf /var/lib/apt/lists/*
|
|
100
|
-
|
|
101
|
-
RUN groupadd sandbox && useradd -g sandbox -m sandbox
|
|
102
|
-
USER sandbox
|
|
103
|
-
|
|
104
|
-
# Install mise and project runtimes
|
|
105
|
-
ENV PATH="/home/sandbox/.local/share/mise/shims:/home/sandbox/.local/bin:$PATH"
|
|
106
|
-
RUN curl https://mise.jdx.sh/install.sh | sh
|
|
107
|
-
|
|
108
|
-
<MISE_INSTALL_COMMANDS>
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
**Example `<MISE_INSTALL_COMMANDS>` for Node.js project:**
|
|
112
|
-
|
|
113
|
-
```dockerfile
|
|
114
|
-
RUN mise use -g node@22 && mise use -g npm@latest
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
**Example for Python project:**
|
|
118
|
-
|
|
119
|
-
```dockerfile
|
|
120
|
-
RUN mise use -g python@3.12
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
**Example for multi-runtime (Node.js + Terraform):**
|
|
124
|
-
|
|
125
|
-
```dockerfile
|
|
126
|
-
RUN mise use -g node@22 && mise use -g npm@latest && mise use -g terraform@latest
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
**Important rules:**
|
|
130
|
-
- Always start from `debian:stable-slim`
|
|
131
|
-
- Always install mise via install script — simpler and more reliable than apt
|
|
132
|
-
- All runtimes go through `mise use -g` — never install directly via apt/curl
|
|
133
|
-
- `mise use -g` installs and sets the tool globally, making it available via shims
|
|
134
|
-
- Always create `sandbox` user — home dir is always `/home/sandbox`
|
|
135
|
-
- If the project needs additional system packages (e.g., `shellcheck`, `make`, `locales`), add them to the first `RUN apt install` block
|
|
136
|
-
|
|
137
|
-
## Step 4: Generate run.sh
|
|
78
|
+
## Step 3: Generate run.sh
|
|
138
79
|
|
|
139
80
|
Generate `.plain-agent/sandbox/run.sh`. The structure varies by project type.
|
|
140
81
|
|
|
141
|
-
### Common structure (always included):
|
|
142
|
-
|
|
143
|
-
```bash
|
|
144
|
-
#!/usr/bin/env bash
|
|
145
|
-
|
|
146
|
-
set -eu -o pipefail
|
|
147
|
-
|
|
148
|
-
options=(
|
|
149
|
-
--dockerfile .plain-agent/sandbox/Dockerfile
|
|
150
|
-
--env-file .plain-agent/sandbox/env
|
|
151
|
-
--allow-write
|
|
152
|
-
# <PROJECT_SPECIFIC_VOLUMES>
|
|
153
|
-
)
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### Project-specific cache volumes:
|
|
157
|
-
|
|
158
|
-
| Project type | Volume additions |
|
|
159
|
-
|---|---|
|
|
160
|
-
| Node.js | `--volume plain-sandbox--global--home-npm:/home/sandbox/.npm` + `--volume node_modules` |
|
|
161
|
-
| Python | `--volume plain-sandbox--global--home-pip:/home/sandbox/.cache/pip` |
|
|
162
|
-
| Go | `--volume plain-sandbox--global--home-go-pkg:/home/sandbox/go/pkg/mod` |
|
|
163
|
-
| Rust | `--volume plain-sandbox--global--home-cargo:/home/sandbox/.cargo/registry` |
|
|
164
|
-
| Multi | All relevant volumes combined |
|
|
165
|
-
|
|
166
82
|
### Monorepo handling:
|
|
167
83
|
|
|
168
84
|
If multiple `package.json` files exist, dynamically create volumes for each `node_modules`:
|
|
@@ -207,8 +123,6 @@ fi
|
|
|
207
123
|
set -eu -o pipefail
|
|
208
124
|
|
|
209
125
|
options=(
|
|
210
|
-
--dockerfile .plain-agent/sandbox/Dockerfile
|
|
211
|
-
--env-file .plain-agent/sandbox/env
|
|
212
126
|
--allow-write
|
|
213
127
|
--volume plain-sandbox--global--home-npm:/home/sandbox/.npm
|
|
214
128
|
--volume node_modules
|
|
@@ -229,22 +143,7 @@ fi
|
|
|
229
143
|
plain-sandbox "${options[@]}" "$@"
|
|
230
144
|
```
|
|
231
145
|
|
|
232
|
-
## Step
|
|
233
|
-
|
|
234
|
-
Create `.plain-agent/sandbox/env`. Docker's `--env-file` does NOT support comments (lines starting with `#` may cause warnings). Keep the file either:
|
|
235
|
-
|
|
236
|
-
- **Empty** (just an empty file), or
|
|
237
|
-
- **With actual values only** (no `#` comment lines)
|
|
238
|
-
|
|
239
|
-
For example, a Node.js project that needs more memory:
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
NODE_OPTIONS=--max-old-space-size=4096
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
Do NOT include any comment lines in this file.
|
|
246
|
-
|
|
247
|
-
## Step 6: Generate setup.sh
|
|
146
|
+
## Step 4: Generate setup.sh
|
|
248
147
|
|
|
249
148
|
Generate `.plain-agent/setup.sh`:
|
|
250
149
|
|
|
@@ -256,17 +155,16 @@ set -eu -o pipefail
|
|
|
256
155
|
this_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
257
156
|
|
|
258
157
|
# Setup sandbox (install dependencies inside container with full network access)
|
|
259
|
-
"$this_dir/sandbox/run.sh" --verbose --allow-net 0.0.0.0/0
|
|
158
|
+
"$this_dir/sandbox/run.sh" --verbose --allow-net 0.0.0.0/0 mise use node@lts
|
|
159
|
+
"$this_dir/sandbox/run.sh" --verbose --allow-net 0.0.0.0/0 npm ci
|
|
260
160
|
|
|
261
161
|
# Setup host (install dependencies on host)
|
|
262
|
-
|
|
162
|
+
npm ci
|
|
263
163
|
```
|
|
264
164
|
|
|
265
|
-
Replace `<INSTALL_COMMAND>` with the appropriate command from Step 1c analysis. For multiple project types, include both commands.
|
|
266
|
-
|
|
267
165
|
The `--allow-net 0.0.0.0/0` is needed only during setup for downloading packages. It should NOT be in run.sh for normal usage.
|
|
268
166
|
|
|
269
|
-
## Step
|
|
167
|
+
## Step 5: Show config.json Example
|
|
270
168
|
|
|
271
169
|
After generating all files, display the following example and instruct the user to add it to their `.plain-agent/config.json`:
|
|
272
170
|
|
|
@@ -292,14 +190,3 @@ If the project already has a `.plain-agent/config.json`, show only the `sandbox`
|
|
|
292
190
|
- `--skip-build` assumes the image is already built (run `setup.sh` first to build)
|
|
293
191
|
- `--keep-alive 30` reuses the container for 30 seconds between commands for performance
|
|
294
192
|
- `rules` for `gh` and `docker` should typically run unsandboxed (host access needed)
|
|
295
|
-
|
|
296
|
-
## Important Rules
|
|
297
|
-
|
|
298
|
-
1. **Always create a custom Dockerfile** — never use the plain-sandbox preset
|
|
299
|
-
2. **All runtimes go through `mise use -g`** — never install directly via apt/curl
|
|
300
|
-
3. **Always use debian:stable-slim** as the base image
|
|
301
|
-
4. **Always create the `sandbox` user** — home dir is `/home/sandbox`
|
|
302
|
-
5. **Never modify .plain-agent/config.json** — only show the example
|
|
303
|
-
6. **All volume paths use `/home/sandbox/`** — never `/home/node/` or other user paths
|
|
304
|
-
7. **Create the env file** — it's referenced in run.sh; keep it empty or with actual values only (no `#` comments)
|
|
305
|
-
8. **Make shell scripts executable** — after writing run.sh and setup.sh, run `chmod +x` on them
|
package/package.json
CHANGED
|
@@ -78,8 +78,8 @@ Examples:
|
|
|
78
78
|
$SCRIPT_NAME --tty --verbose --dry-run zsh
|
|
79
79
|
|
|
80
80
|
Install tools with mise:
|
|
81
|
-
$SCRIPT_NAME --allow-net mise-versions.jdx.dev,nodejs.org
|
|
82
|
-
|
|
81
|
+
$SCRIPT_NAME --allow-write --allow-net mise-versions.jdx.dev,nodejs.org \\
|
|
82
|
+
--verbose mise use node@lts
|
|
83
83
|
|
|
84
84
|
Use volume:
|
|
85
85
|
$SCRIPT_NAME --volume $SCRIPT_NAME--global--home-npm:/home/node/.npm \\
|
|
@@ -96,7 +96,7 @@ Examples:
|
|
|
96
96
|
|
|
97
97
|
Preset Configuration:
|
|
98
98
|
|
|
99
|
-
When --dockerfile is not specified, a preset
|
|
99
|
+
When --dockerfile is not specified, a preset Debian stable image is used with:
|
|
100
100
|
- System packages: busybox, bash, zsh (with grml config), ripgrep, fd, dig, curl, git
|
|
101
101
|
- mise package manager for additional runtime installations
|
|
102
102
|
- Persistent storage for shell history, git config
|
|
@@ -839,20 +839,18 @@ setup_container_user() {
|
|
|
839
839
|
|
|
840
840
|
print_preset_dockerfile() {
|
|
841
841
|
cat << 'EOF'
|
|
842
|
-
FROM
|
|
842
|
+
FROM public.ecr.aws/docker/library/debian:stable-slim
|
|
843
843
|
|
|
844
844
|
RUN apt update \
|
|
845
845
|
&& apt install -y \
|
|
846
|
-
busybox \
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
curl git gpg locales tmux \
|
|
846
|
+
busybox bash zsh locales gpg \
|
|
847
|
+
fd-find ripgrep jq \
|
|
848
|
+
iptables ipset dnsmasq dnsutils curl \
|
|
849
|
+
build-essential git tmux \
|
|
851
850
|
&& bash -c 'ln -s $(which fdfind) /usr/local/bin/fd' \
|
|
852
851
|
&& echo 'en_US.UTF-8 UTF-8' >> /etc/locale.gen \
|
|
853
852
|
&& echo 'ja_JP.UTF-8 UTF-8' >> /etc/locale.gen \
|
|
854
|
-
&& locale-gen
|
|
855
|
-
&& npm install -g npm@latest
|
|
853
|
+
&& locale-gen
|
|
856
854
|
|
|
857
855
|
# mise: https://mise.jdx.dev/
|
|
858
856
|
RUN install -dm 755 /etc/apt/keyrings \
|
|
@@ -887,8 +885,6 @@ USER_ENTRYPOINT
|
|
|
887
885
|
RUN chmod +x /sandbox/bin/user-entrypoint.sh
|
|
888
886
|
|
|
889
887
|
USER sandbox
|
|
890
|
-
ENV NPM_CONFIG_PREFIX=/sandbox/npm-global
|
|
891
|
-
ENV PATH=/home/sandbox/.local/bin:/sandbox/npm-global/bin:$PATH
|
|
892
888
|
|
|
893
889
|
# Configure shell
|
|
894
890
|
# - grml zsh config: https://grml.org/zsh/
|
package/src/agentLoop.mjs
CHANGED