vsh is a validation-first command engine for agent workspaces.
Project description
vsh
Validation-first command engine for AI agents operating on workspaces.
vsh is not a POSIX shell emulator. It is a safe command planning and execution control layer for AI agents: shell-like intent becomes typed StructuredCommand models, side effects are simulated on a workspace snapshot, plans are approved, drift is revalidated, and only then are mutations applied to the real filesystem. Read commands validate path access and return captured stdout on execution; simulation does not stream file contents.
Install
uv sync
uv sync installs the project plus dev and agent dependency groups (including pydantic-ai).
For pip-only workflows:
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev,agent]"
Quick start
vsh search ls
vsh schema vsh_list
vsh serve
End-to-end lifecycle
from vsh import LsCommand
from vsh.execute import execute_approved
from vsh.plans import approve_plan
from vsh.simulate.engine import simulate_command
from vsh.snapshot.builder import snapshot_workspace
workspace = "/path/to/project"
snapshot = snapshot_workspace(workspace, cwd=workspace)
result = simulate_command(LsCommand(path=".", all=True), snapshot)
token = approve_plan(result.plan_id)
execution = execute_approved(token.token)
print(execution.applied, execution.matches_prediction)
Flow: search → get_schema → snapshot → simulate → approve → execute_approved
Documentation
- Architecture — modules, lifecycle, drift detection, persistence
- API reference — public Python/MCP surface
- CodeMode MCP server — discovery-first FastMCP server and prompts
MCP
vsh serve starts the default FastMCP server.
For CodeMode-style discovery (search → schema on demand → simulate → approve → execute), use the dedicated server:
vsh serve-codemode
# or
vsh-codemode
See docs/CODEMODE.md for the CodeMode inspiration, prompts, and client config examples.
Both servers expose the same compact tool surface:
- tools:
search,get_schema,snapshot_workspace,simulate,approve,execute_approved - resources: workspace snapshot/projection, command spec cards, simulation records
pydantic-ai agent
cp .env.example .env
# fill in MODEL_NAME and OPENROUTER_API_KEY
uv run python examples/pydantic_ai_agent_demo.py --mode live
from pydantic_ai import Agent
from vsh.agent import VshAgentDeps, create_vsh_function_toolset
deps = VshAgentDeps.from_path("/path/to/workspace")
agent = Agent(
os.environ["MODEL_NAME"],
deps_type=VshAgentDeps,
toolsets=[create_vsh_function_toolset()],
)
Configuration
| Variable | Default | Purpose |
|---|---|---|
VSH_DATA_DIR |
~/.vsh |
JSON persistence directory |
VSH_PERSIST |
1 |
Set 0 to disable disk writes |
VSH_PROTECTED_PATTERNS |
built-in defaults | Comma-separated protected path globs |
VSH_PROTECTED_PATTERNS_FILE |
— | Newline-separated protected globs file |
VSH_MAX_TOUCHED_PATHS |
500 |
Simulation limit for touched paths |
MODEL_NAME |
— | Live agent model id (demo) |
Development
ruff check src tests
ruff format src tests
ty check
basedpyright src tests
pytest tests/
Performance benchmarks
Compare every vsh command against native shell (5 runs, median + min/max, plots):
uv run python playground/benchmark_vsh_vs_native.py
Reports land in playground/reports/<timestamp>/. See playground/README.md.
License
Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file vbash-0.2.0.tar.gz.
File metadata
- Download URL: vbash-0.2.0.tar.gz
- Upload date:
- Size: 727.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e44f3996b84262254a1c0f86ea7ae53f5d2c4b156b4f41bdd195919988849dd3
|
|
| MD5 |
d911f88c4c4882207697d6ab57ea041c
|
|
| BLAKE2b-256 |
e66520f799b24fbcff89a80a64e689e554b6b11de499bbc422e42180a029fae7
|
File details
Details for the file vbash-0.2.0-py3-none-any.whl.
File metadata
- Download URL: vbash-0.2.0-py3-none-any.whl
- Upload date:
- Size: 67.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.19 {"installer":{"name":"uv","version":"0.11.19","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9802cfe2ddbcd3bf48c03a3f0ff240ea674389e627d4bd5114a00c191910ecaa
|
|
| MD5 |
ceee109b168936fd42699cd5b1311103
|
|
| BLAKE2b-256 |
9541aff3a5013ae6887aafcc05d76bc083eb7f0fe0630000fbe1d04f3e4058cc
|