Skip to content

Commit 817cd59

Browse files
committed
Update example
1 parent c7979b6 commit 817cd59

File tree

4 files changed

+75
-16
lines changed

4 files changed

+75
-16
lines changed

CLAUDE.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

7-
bash-env is a TypeScript implementation of a bash interpreter with an in-memory virtual filesystem. Designed for AI agents needing a secure, sandboxed bash environment. No WASM dependencies allowed.
7+
just-bash is a TypeScript implementation of a bash interpreter with an in-memory virtual filesystem. Designed for AI agents needing a secure, sandboxed bash environment. No WASM dependencies allowed.
88

99
## Commands
1010

@@ -13,6 +13,7 @@ bash-env is a TypeScript implementation of a bash interpreter with an in-memory
1313
pnpm build # Build TypeScript (required before using dist/)
1414
pnpm typecheck # Type check
1515
pnpm lint:fix # Fix lint errors (biome)
16+
pnpm knip # Check for unused exports/dependencies
1617

1718
# Testing
1819
pnpm test:run # Run ALL tests (including spec tests)
@@ -34,30 +35,30 @@ pnpm shell # Full network access
3435
pnpm shell --no-network # No network
3536

3637
# Sandboxed CLI (read-only by default)
37-
node ./dist/cli/bash-env.js -c 'ls -la' --root .
38-
node ./dist/cli/bash-env.js -c 'cat package.json' --root .
39-
node ./dist/cli/bash-env.js -c 'grep -r "TODO" src/' --root .
38+
node ./dist/cli/just-bash.js -c 'ls -la' --root .
39+
node ./dist/cli/just-bash.js -c 'cat package.json' --root .
40+
node ./dist/cli/just-bash.js -c 'grep -r "TODO" src/' --root .
4041
```
4142

42-
### Sandboxed Shell Execution with `bash-env`
43+
### Sandboxed Shell Execution with `just-bash`
4344

44-
The `bash-env` CLI provides a secure, sandboxed bash environment using OverlayFS:
45+
The `just-bash` CLI provides a secure, sandboxed bash environment using OverlayFS:
4546

4647
```bash
4748
# Execute inline script (read-only by default)
48-
node ./dist/cli/bash-env.js -c 'ls -la && cat README.md | head -5' --root .
49+
node ./dist/cli/just-bash.js -c 'ls -la && cat README.md | head -5' --root .
4950

5051
# Execute with JSON output
51-
node ./dist/cli/bash-env.js -c 'echo hello' --root . --json
52+
node ./dist/cli/just-bash.js -c 'echo hello' --root . --json
5253

5354
# Allow writes (writes stay in memory, don't affect real filesystem)
54-
node ./dist/cli/bash-env.js -c 'echo test > /tmp/file.txt && cat /tmp/file.txt' --root . --allow-write
55+
node ./dist/cli/just-bash.js -c 'echo test > /tmp/file.txt && cat /tmp/file.txt' --root . --allow-write
5556

5657
# Execute script file
57-
node ./dist/cli/bash-env.js script.sh --root .
58+
node ./dist/cli/just-bash.js script.sh --root .
5859

5960
# Exit on first error
60-
node ./dist/cli/bash-env.js -e -c 'false; echo "not reached"' --root .
61+
node ./dist/cli/just-bash.js -e -c 'false; echo "not reached"' --root .
6162
```
6263

6364
Options:
@@ -121,6 +122,21 @@ Input Script → Parser (src/parser/) → AST (src/ast/) → Interpreter (src/in
121122

122123
**Filesystem** (`src/fs.ts`, `src/overlay-fs/`): In-memory VFS with optional overlay on real filesystem
123124

125+
**AWK** (`src/commands/awk/`): AWK text processing implementation
126+
127+
- `parser.ts` - Parses AWK programs (BEGIN/END blocks, rules, user-defined functions)
128+
- `executor.ts` - Executes parsed AWK programs line by line
129+
- `expressions.ts` - Expression evaluation (arithmetic, string functions, comparisons)
130+
- Supports: field splitting, pattern matching, printf, gsub/sub/split, user-defined functions
131+
- Limitations: User-defined functions support single return expressions only (no multi-statement bodies or if/else)
132+
133+
**SED** (`src/commands/sed/`): Stream editor implementation
134+
135+
- `parser.ts` - Parses sed commands and addresses
136+
- `executor.ts` - Executes sed commands with pattern/hold space
137+
- Supports: s, d, p, q, n, a, i, c, y, =, addresses, ranges, extended regex (-E/-r)
138+
- Has execution limits to prevent runaway compute
139+
124140
### Adding Commands
125141

126142
Commands go in `src/commands/<name>/` with:
@@ -133,7 +149,7 @@ Commands go in `src/commands/<name>/` with:
133149
### Testing Strategy
134150

135151
- **Unit tests**: Fast, isolated tests for specific functionality
136-
- **Comparison tests**: Run same script in bash-env and real bash, compare output
152+
- **Comparison tests**: Run same script in just-bash and real bash, compare output
137153
- **Spec tests** (`src/spec-tests/`): Bash specification conformance (may have known failures)
138154

139155
Prefer comparison tests when uncertain about bash behavior. Keep test files under 300 lines.
@@ -142,7 +158,7 @@ Prefer comparison tests when uncertain about bash behavior. Keep test files unde
142158

143159
- Read AGENTS.md
144160
- Use `pnpm dev:exec` instead of ad-hoc test scripts (avoids approval prompts)
145-
- Always verify with `pnpm typecheck && pnpm test:run` before finishing
161+
- Always verify with `pnpm typecheck && pnpm lint:fix && pnpm knip && pnpm test:run` before finishing
146162
- Assert full stdout/stderr in tests, not partial matches
147163
- Implementation must match real bash behavior, not convenience
148164
- Dependencies using WASM are not allowed

examples/bash-agent/agent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
import * as path from "node:path";
1010
import { streamText, stepCountIs } from "ai";
11-
import { createBashTool } from "../../src/ai/index.js";
12-
import { OverlayFs } from "../../src/overlay-fs/index.js";
11+
import { createBashTool } from "just-bash/ai";
12+
import { OverlayFs } from "just-bash";
1313

1414
export interface AgentRunner {
1515
chat(

examples/bash-agent/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"dependencies": {
1111
"ai": "^6.0.0",
12-
"glob": "^11.0.0"
12+
"glob": "^11.0.0",
13+
"just-bash": "^1.0.1"
1314
}
1415
}

examples/bash-agent/pnpm-lock.yaml

Lines changed: 42 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)