Skip to content

Commit 337822e

Browse files
committed
Add uv run --with for zero-config dependency management
- Both skills now use 'uv run --with <pkg>' in docs/examples - Scripts show clear error + install instructions if package missing - Discovery/instructions modes still work without any packages
1 parent 6d37d97 commit 337822e

4 files changed

Lines changed: 58 additions & 14 deletions

File tree

skills/hyperlight-codeact/SKILL.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ Sandboxed code can only reach the outside world through `call_tool()` bridges.
4949
## Quick start
5050

5151
```bash
52-
# 1. Discover tools (matches Copilot CLI tool names)
52+
# 1. Discover tools (works without any packages installed)
5353
python3 scripts/codeact.py --discover
5454

55-
# 2. Run code with auto-discovered tools
56-
python3 scripts/codeact.py --auto --workspace . --code '
55+
# 2. Run code (uv auto-installs hyperlight-sandbox into an ephemeral env)
56+
uv run --with 'hyperlight-sandbox[wasm,python_guest]' python3 scripts/codeact.py --auto --workspace . --code '
5757
content = call_tool("view", path="README.md")
5858
print(f"README has {len(content.splitlines())} lines")
5959
'
@@ -100,15 +100,20 @@ content = call_tool('view', path=call_tool('glob', pattern='config.json')[0])
100100

101101
### Step 3 -- Execute
102102

103+
Use `uv run --with` to auto-install the dependency:
104+
103105
```bash
104106
# Auto-discover + workspace scoping (recommended)
105-
python3 scripts/codeact.py --auto --workspace . --code '...'
107+
uv run --with 'hyperlight-sandbox[wasm,python_guest]' python3 scripts/codeact.py --auto --workspace . --code '...'
106108

107109
# With saved manifest
108-
python3 scripts/codeact.py --manifest tools.json --code-file script.py
110+
uv run --with 'hyperlight-sandbox[wasm,python_guest]' python3 scripts/codeact.py --manifest tools.json --code-file script.py
111+
```
109112

110-
# Via stdin
111-
echo '{"tools": [...], "code": "..."}' | python3 scripts/codeact.py --stdin
113+
If `hyperlight-sandbox` is already installed, plain `python3` works too:
114+
115+
```bash
116+
python3 scripts/codeact.py --auto --workspace . --code '...'
112117
```
113118

114119
Output is always JSON: `{"stdout": "...", "stderr": "...", "exit_code": 0, "success": true}`
@@ -130,4 +135,5 @@ Main executor. Key flags:
130135
## Prerequisites
131136

132137
- Python 3.10+
133-
- `hyperlight-sandbox[wasm,python_guest]` or build via `just python-build`
138+
- `uv` (recommended — auto-installs `hyperlight-sandbox` with no side effects)
139+
- Or: `pip install 'hyperlight-sandbox[wasm,python_guest]'`

skills/hyperlight-codeact/scripts/codeact.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,20 @@ def main() -> None:
499499
return
500500

501501
# ---- execution ----
502-
from hyperlight_sandbox import Sandbox
502+
try:
503+
from hyperlight_sandbox import Sandbox
504+
except ImportError:
505+
print(json.dumps({
506+
"stdout": "",
507+
"stderr": (
508+
"hyperlight-sandbox is not installed.\n"
509+
"Run this script with: uv run --with 'hyperlight-sandbox[wasm,python_guest]' python3 scripts/codeact.py ...\n"
510+
"Or install manually: pip install 'hyperlight-sandbox[wasm,python_guest]'"
511+
),
512+
"exit_code": 1,
513+
"success": False,
514+
}, indent=2))
515+
sys.exit(1)
503516

504517
global _WORKSPACE_ROOT
505518
if args.workspace:

skills/monty-codeact/SKILL.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ or need full Python (classes, third-party libs).
6565
## Quick start
6666

6767
```bash
68-
python3 scripts/codeact.py --auto --workspace . --code '
68+
# Discovery works without any packages installed
69+
python3 scripts/codeact.py --discover
70+
71+
# Execute code (uv auto-installs pydantic-monty into an ephemeral env)
72+
uv run --with pydantic-monty python3 scripts/codeact.py --auto --workspace . --code '
6973
files = glob(pattern="**/*.py", paths="src")
7074
print("Found " + str(len(files)) + " Python files")
7175
for f in files[:3]:
@@ -113,10 +117,17 @@ but it must be imported explicitly).
113117

114118
### Step 3 -- Execute
115119

120+
Use `uv run --with pydantic-monty` to auto-install the dependency:
121+
122+
```bash
123+
uv run --with pydantic-monty python3 scripts/codeact.py --auto --workspace . --code '...'
124+
uv run --with pydantic-monty python3 scripts/codeact.py --manifest tools.json --code-file script.py
125+
```
126+
127+
If `pydantic-monty` is already installed, plain `python3` works too:
128+
116129
```bash
117130
python3 scripts/codeact.py --auto --workspace . --code '...'
118-
python3 scripts/codeact.py --manifest tools.json --code-file script.py
119-
echo '{"tools": [...], "code": "..."}' | python3 scripts/codeact.py --stdin
120131
```
121132

122133
Output is JSON:
@@ -140,4 +151,5 @@ Key flags:
140151
## Prerequisites
141152

142153
- Python 3.10+
143-
- `pip install pydantic-monty` (~4.5MB, no other dependencies)
154+
- `uv` (recommended — auto-installs `pydantic-monty` with no side effects)
155+
- Or: `pip install pydantic-monty` (~4.5MB, no other dependencies)

skills/monty-codeact/scripts/codeact.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,20 @@ def main() -> None:
453453
return
454454

455455
# ---- execution ----
456-
import pydantic_monty
456+
try:
457+
import pydantic_monty
458+
except ImportError:
459+
print(json.dumps({
460+
"stdout": "",
461+
"stderr": (
462+
"pydantic-monty is not installed.\n"
463+
"Run this script with: uv run --with pydantic-monty python3 scripts/codeact.py ...\n"
464+
"Or install manually: pip install pydantic-monty"
465+
),
466+
"return_value": None,
467+
"success": False,
468+
}, indent=2))
469+
sys.exit(1)
457470

458471
global _WORKSPACE_ROOT
459472
if args.workspace:

0 commit comments

Comments
 (0)