@@ -73,16 +73,15 @@ echo "print('piped')" | python3
7373
7474## Virtual Filesystem (VFS) Bridging
7575
76- Python ` pathlib.Path ` operations are bridged to Bashkit's virtual filesystem.
77- Files created by bash are readable from Python and vice versa.
76+ Python ` open() ` and ` pathlib.Path ` operations are bridged to Bashkit's virtual
77+ filesystem. Files created by bash are readable from Python and vice versa.
7878
7979### Bash → Python
8080
8181``` bash
8282echo " important data" > /tmp/shared.txt
8383python3 -c "
84- from pathlib import Path
85- content = Path('/tmp/shared.txt').read_text()
84+ content = open('/tmp/shared.txt').read()
8685print(f'Got: {content.strip()}')
8786"
8887```
@@ -91,16 +90,20 @@ print(f'Got: {content.strip()}')
9190
9291``` bash
9392python3 -c "
94- from pathlib import Path
95- _ = Path('/tmp/result.txt').write_text ('computed by python\n')
93+ with open('/tmp/result.txt', 'w') as f:
94+ _ = f.write ('computed by python\n')
9695"
9796cat /tmp/result.txt
9897```
9998
100- ### Supported Path Operations
99+ ### Supported File Operations
101100
102101| Operation | Example |
103102| -----------| ---------|
103+ | Open/read | ` open('f.txt').read() ` |
104+ | Open/write | ` open('f.txt', 'w').write('data') ` |
105+ | Open/append | ` open('f.txt', 'a').write('more') ` |
106+ | Path open | ` Path('f.txt').open('r') ` |
104107| Read text | ` Path('f.txt').read_text() ` |
105108| Read bytes | ` Path('f.txt').read_bytes() ` |
106109| Write text | ` Path('f.txt').write_text('data') ` |
@@ -117,7 +120,7 @@ cat /tmp/result.txt
117120### Architecture
118121
119122``` text
120- Python code → Monty VM → OsCall(ReadText, path) → Bashkit VFS → resume
123+ Python code → Monty VM → OsCall(Open/ ReadText, path) → Bashkit VFS → resume
121124```
122125
123126Monty pauses at filesystem operations, Bashkit bridges them to the VFS, then
@@ -169,19 +172,20 @@ let help = tool.help(); // Includes a Markdown Notes section with Python hints
169172```
170173
171174The builtin's ` llm_hint() ` is automatically included in the tool's documentation,
172- so LLMs know not to generate code using ` open() ` , HTTP requests, or classes .
175+ so LLMs know file I/O is VFS-scoped and HTTP requests/classes are unavailable .
173176
174177## Limitations
175178
176- ** No ` open() ` builtin.** Monty does not implement Python's ` open() ` . Use ` pathlib.Path ` instead:
179+ ** VFS-only file I/O.** ` open() ` and ` pathlib.Path ` read/write Bashkit's virtual
180+ filesystem, not the host filesystem:
177181
178182``` python
179- # Won't work:
180- # f = open('data.txt')
181-
182- # Use instead:
183183from pathlib import Path
184- content = Path(' data.txt' ).read_text()
184+
185+ with open (' /tmp/data.txt' , ' w' ) as f:
186+ f.write(' hello' )
187+
188+ content = Path(' /tmp/data.txt' ).read_text()
185189```
186190
187191** No HTTP/network.** No ` socket ` , ` urllib ` , ` requests ` , or ` http.client ` modules.
0 commit comments