Skip to content

Commit 7a2cf35

Browse files
authored
rename to just-bash (#9)
1 parent 79ee0f5 commit 7a2cf35

File tree

155 files changed

+2232
-2232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+2232
-2232
lines changed

README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# bash-env
1+
# just-bash
22

33
A simulated bash environment with an in-memory virtual filesystem, written in TypeScript.
44

@@ -30,25 +30,25 @@ Supports optional network access via `curl` with secure-by-default URL filtering
3030
## Security model
3131

3232
- The shell only has access to the provided file system.
33-
- Execution is protected against infinite loops or recursion through. However, BashEnv is not fully robust against DOS from input. If you need to be robust against this, use process isolation at the OS level.
33+
- Execution is protected against infinite loops or recursion through. However, Bash is not fully robust against DOS from input. If you need to be robust against this, use process isolation at the OS level.
3434
- Binaries or even WASM are inherently unsupported (Use [Vercel Sandbox](https://vercel.com/docs/vercel-sandbox) or a similar product if a full VM is needed).
3535
- There is no network access by default.
3636
- Network access can be enabled, but requests are checked against URL prefix allow-lists and HTTP-method allow-lists. See [network access](#network-access) for details
3737

3838
## Installation
3939

4040
```bash
41-
npm install bash-env
41+
npm install just-bash
4242
```
4343

4444
## Usage
4545

4646
### Basic API
4747

4848
```typescript
49-
import { BashEnv } from "bash-env";
49+
import { Bash } from "just-bash";
5050

51-
const env = new BashEnv();
51+
const env = new Bash();
5252
await env.exec('echo "Hello" > greeting.txt');
5353
const result = await env.exec("cat greeting.txt");
5454
console.log(result.stdout); // "Hello\n"
@@ -61,7 +61,7 @@ Each `exec()` is isolated—env vars, functions, and cwd don't persist across ca
6161
### Configuration
6262

6363
```typescript
64-
const env = new BashEnv({
64+
const env = new Bash({
6565
files: { "/data/file.txt": "content" }, // Initial files
6666
env: { MY_VAR: "value" }, // Initial environment
6767
cwd: "/app", // Starting directory (default: /home/user)
@@ -77,11 +77,11 @@ await env.exec("echo $TEMP", { env: { TEMP: "value" }, cwd: "/tmp" });
7777
Seed the bash environment with files from a real directory. The agent can read but not write to the real filesystem - all changes stay in memory.
7878

7979
```typescript
80-
import { BashEnv, OverlayFs } from "bash-env";
80+
import { Bash, OverlayFs } from "just-bash";
8181

8282
// Files are mounted at /home/user/project by default
8383
const overlay = new OverlayFs({ root: "/path/to/project" });
84-
const env = new BashEnv({ fs: overlay, cwd: overlay.getMountPoint() });
84+
const env = new Bash({ fs: overlay, cwd: overlay.getMountPoint() });
8585

8686
// Reads come from the real filesystem
8787
await env.exec("cat package.json"); // reads /path/to/project/package.json
@@ -98,7 +98,7 @@ const overlay2 = new OverlayFs({ root: "/path/to/project", mountPoint: "/" });
9898
Creates a bash tool for use with the [AI SDK](https://ai-sdk.dev/):
9999

100100
```typescript
101-
import { createBashTool } from "bash-env/ai";
101+
import { createBashTool } from "just-bash/ai";
102102
import { generateText } from "ai";
103103

104104
const bashTool = createBashTool({
@@ -116,10 +116,10 @@ See [`examples/bash-agent`](./examples/bash-agent) for a full implementation.
116116

117117
### Vercel Sandbox Compatible API
118118

119-
BashEnv provides a `Sandbox` class that's API-compatible with [`@vercel/sandbox`](https://vercel.com/docs/vercel-sandbox), making it easy to swap implementations. You can start with BashEnv and switch to a real sandbox when you need the power of a full VM (e.g. to run node, python, or custom binaries).
119+
Bash provides a `Sandbox` class that's API-compatible with [`@vercel/sandbox`](https://vercel.com/docs/vercel-sandbox), making it easy to swap implementations. You can start with Bash and switch to a real sandbox when you need the power of a full VM (e.g. to run node, python, or custom binaries).
120120

121121
```typescript
122-
import { Sandbox } from "bash-env";
122+
import { Sandbox } from "just-bash";
123123

124124
// Create a sandbox instance
125125
const sandbox = await Sandbox.create({ cwd: "/app" });
@@ -141,29 +141,29 @@ const content = await sandbox.readFile("/app/data.json");
141141
// Create directories
142142
await sandbox.mkDir("/app/logs", { recursive: true });
143143

144-
// Clean up (no-op for BashEnv, but API-compatible)
144+
// Clean up (no-op for Bash, but API-compatible)
145145
await sandbox.stop();
146146
```
147147

148148
### CLI Binary
149149

150-
After installing globally (`npm install -g bash-env`), use the `bash-env` command as a secure alternative to `bash` for AI agents:
150+
After installing globally (`npm install -g just-bash`), use the `just-bash` command as a secure alternative to `bash` for AI agents:
151151

152152
```bash
153153
# Execute inline script
154-
bash-env -c 'ls -la && cat package.json | head -5'
154+
just-bash -c 'ls -la && cat package.json | head -5'
155155

156156
# Execute with specific project root
157-
bash-env -c 'grep -r "TODO" src/' --root /path/to/project
157+
just-bash -c 'grep -r "TODO" src/' --root /path/to/project
158158

159159
# Pipe script from stdin
160-
echo 'find . -name "*.ts" | wc -l' | bash-env
160+
echo 'find . -name "*.ts" | wc -l' | just-bash
161161

162162
# Execute a script file
163-
bash-env ./scripts/deploy.sh
163+
just-bash ./scripts/deploy.sh
164164

165165
# Get JSON output for programmatic use
166-
bash-env -c 'echo hello' --json
166+
just-bash -c 'echo hello' --json
167167
# Output: {"stdout":"hello\n","stderr":"","exitCode":0}
168168
```
169169

@@ -230,7 +230,7 @@ All commands support `--help` for usage information.
230230

231231
## Default Layout
232232

233-
When created without options, BashEnv provides a Unix-like directory structure:
233+
When created without options, Bash provides a Unix-like directory structure:
234234

235235
- `/home/user` - Default working directory (and `$HOME`)
236236
- `/bin` - Contains stubs for all built-in commands
@@ -245,7 +245,7 @@ Network access (and the `curl` command) is disabled by default for security. To
245245

246246
```typescript
247247
// Allow specific URLs with GET/HEAD only (safest)
248-
const env = new BashEnv({
248+
const env = new Bash({
249249
network: {
250250
allowedUrlPrefixes: [
251251
"https://api.github.com/repos/myorg/",
@@ -255,15 +255,15 @@ const env = new BashEnv({
255255
});
256256

257257
// Allow specific URLs with additional methods
258-
const env = new BashEnv({
258+
const env = new Bash({
259259
network: {
260260
allowedUrlPrefixes: ["https://api.example.com"],
261261
allowedMethods: ["GET", "HEAD", "POST"], // Default: ["GET", "HEAD"]
262262
},
263263
});
264264

265265
// Allow all URLs and methods (use with caution)
266-
const env = new BashEnv({
266+
const env = new Bash({
267267
network: { dangerouslyAllowFullInternetAccess: true },
268268
});
269269
```
@@ -295,10 +295,10 @@ curl -X POST -H "Content-Type: application/json" \
295295

296296
## Execution Protection
297297

298-
BashEnv protects against infinite loops and deep recursion with configurable limits:
298+
Bash protects against infinite loops and deep recursion with configurable limits:
299299

300300
```typescript
301-
const env = new BashEnv({
301+
const env = new Bash({
302302
executionLimits: {
303303
maxCallDepth: 100, // Max function recursion depth
304304
maxCommandCount: 10000, // Max total commands executed

knip.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://unpkg.com/knip@5/schema.json",
3-
"entry": ["src/cli/bash-env.ts"],
3+
"entry": ["src/cli/just-bash.ts"],
44
"project": ["src/**/*.ts"],
55
"ignore": ["src/**/*.test.ts", "src/spec-tests/**"],
66
"ignoreBinaries": ["tsx"],

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"name": "bash-env",
2+
"name": "just-bash",
33
"version": "1.0.0",
44
"description": "A simulated bash environment with virtual filesystem",
55
"repository": {
66
"type": "git",
7-
"url": "git+https://github.com/vercel-labs/bash-env.git"
7+
"url": "git+https://github.com/vercel-labs/just-bash.git"
88
},
9-
"homepage": "https://github.com/vercel-labs/bash-env#readme",
9+
"homepage": "https://github.com/vercel-labs/just-bash#readme",
1010
"bugs": {
11-
"url": "https://github.com/vercel-labs/bash-env/issues"
11+
"url": "https://github.com/vercel-labs/just-bash/issues"
1212
},
1313
"type": "module",
1414
"main": "dist/bundle/index.js",
@@ -52,8 +52,8 @@
5252
"README.md"
5353
],
5454
"bin": {
55-
"bash-env": "./dist/bin/bash-env.js",
56-
"bash-env-shell": "./dist/bin/shell/shell.js"
55+
"just-bash": "./dist/bin/just-bash.js",
56+
"just-bash-shell": "./dist/bin/shell/shell.js"
5757
},
5858
"publishConfig": {
5959
"access": "public"
@@ -63,7 +63,7 @@
6363
"build:clean": "find dist -name '*.test.js' -delete && find dist -name '*.test.d.ts' -delete",
6464
"build:lib": "esbuild dist/index.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bundle --chunk-names=chunks/[name]-[hash] --external:diff --external:minimatch --external:sprintf-js --external:turndown",
6565
"build:ai": "esbuild dist/ai/index.js --bundle --platform=node --format=esm --minify --outfile=dist/bundle/ai/index.js --external:ai --external:zod --external:diff --external:minimatch --external:sprintf-js --external:turndown",
66-
"build:cli": "esbuild dist/cli/bash-env.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node'",
66+
"build:cli": "esbuild dist/cli/just-bash.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node'",
6767
"build:shell": "esbuild dist/cli/shell.js --bundle --splitting --platform=node --format=esm --minify --outdir=dist/bin/shell --entry-names=[name] --chunk-names=chunks/[name]-[hash] --banner:js='#!/usr/bin/env node'",
6868
"prepublishOnly": "pnpm validate",
6969
"validate": "pnpm build && pnpm typecheck && pnpm lint && pnpm knip && pnpm test:run && pnpm test:dist",
@@ -73,7 +73,7 @@
7373
"knip": "knip",
7474
"test": "vitest",
7575
"test:run": "vitest run",
76-
"test:dist": "vitest run src/cli/bash-env.bundle.test.ts",
76+
"test:dist": "vitest run src/cli/just-bash.bundle.test.ts",
7777
"test:unit": "vitest run --config vitest.unit.config.ts",
7878
"test:comparison": "vitest run --config vitest.comparison.config.ts",
7979
"shell": "npx tsx src/cli/shell.ts",
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { describe, expect, it } from "vitest";
2-
import { BashEnv } from "./BashEnv.js";
2+
import { Bash } from "./Bash.js";
33
import { getCommandNames } from "./commands/registry.js";
44

5-
describe("BashEnv commands filtering", () => {
5+
describe("Bash commands filtering", () => {
66
it("registers all commands by default", async () => {
7-
const env = new BashEnv();
7+
const env = new Bash();
88

99
// Check that common commands are available
1010
const echoResult = await env.exec("echo hello");
@@ -18,7 +18,7 @@ describe("BashEnv commands filtering", () => {
1818
});
1919

2020
it("only registers specified commands", async () => {
21-
const env = new BashEnv({
21+
const env = new Bash({
2222
commands: ["echo", "cat"],
2323
});
2424

@@ -37,7 +37,7 @@ describe("BashEnv commands filtering", () => {
3737
});
3838

3939
it("grep is not available when not in commands list", async () => {
40-
const env = new BashEnv({
40+
const env = new Bash({
4141
commands: ["echo", "cat"],
4242
});
4343

@@ -58,7 +58,7 @@ describe("BashEnv commands filtering", () => {
5858
});
5959

6060
it("empty commands array means no commands", async () => {
61-
const env = new BashEnv({
61+
const env = new Bash({
6262
commands: [],
6363
});
6464

@@ -68,7 +68,7 @@ describe("BashEnv commands filtering", () => {
6868
});
6969

7070
it("can use a subset of file commands", async () => {
71-
const env = new BashEnv({
71+
const env = new Bash({
7272
commands: ["ls", "cat", "mkdir"],
7373
files: { "/test.txt": "hello" },
7474
});

0 commit comments

Comments
 (0)