A Spatial Computing IDE for Visual Programming
PolyForm is a VS Code extension that transforms your editor into an infinite canvas where you can write, execute, and visualize code in a spatial environment. Think Excalidraw meets Jupyter Notebooks.
- Features
- Quick Start
- Screenshots
- Architecture β Full Documentation
- Environment Detection β Full Documentation
- Development
- Customization
- Security
- Troubleshooting
- Roadmap
- Contributing
- License
- Acknowledgments
- Contact
- Infinite Canvas: Pan, zoom, and organize your code spatially using the Tldraw engine
- Executable Code Nodes: Write and run JavaScript and Python code directly on the canvas
- Real-time Execution: See output instantly in a terminal-style display below each code node
- Excalidraw Aesthetic: Hand-drawn, sketch-like styling with the Virgil font
- Polyglot Support: Switch between languages with a dropdown selector
- Resizable Nodes: Adjust code blocks to fit your workflow
- Syntax Highlighting: Powered by Prism.js for clear, readable code
- VS Code 1.60.0 or higher
- Node.js (for JavaScript execution)
- Python 3 (for Python execution)
-
Clone the repository:
git clone https://github.com/yourusername/polyform.git cd polyform -
Install dependencies:
npm install
-
Compile the extension:
npm run compile
-
Open in VS Code and press F5 to launch the Extension Development Host
- Create a new file with the
.canvasextension (e.g.,myproject.canvas) - Click the + Code Node button in the bottom-right corner
- Write your code in the editor
- Select the language (JavaScript or Python) from the dropdown
- Click Run to execute
- See the output appear below the code block
console.log("Hello World");
// Output: Hello Worlda = 5
b = 6
print(f"{a} + {b} = {a + b}")
# Output: 11PolyForm uses a dual-environment architecture:
- Webview (React): Renders the infinite canvas and code nodes
- Extension Host (Node.js): Executes code using system interpreters
Communication happens via VS Code's postMessage API. See ARCHITECTURE.md for detailed technical documentation.
PolyForm automatically detects and uses your project's development environment:
- β VS Code Python extension's selected interpreter
- β
Workspace virtual environments (
venv,.venv,env) - β
VIRTUAL_ENVenvironment variable - β
Falls back to system
python3
- β
Local
node_modules/.bin/node - β
Falls back to system
node
Working Directory: Code runs with your workspace folder as the working directory, allowing you to import local modules and packages.
See ENVIRONMENT_DETECTION.md for complete documentation and examples.
PolyForm/
βββ src/
β βββ extension.ts # Extension entry point
β βββ PolyFormEditorProvider.ts # Webview & execution handler
β βββ webview/
β βββ index.tsx # Webview entry point
β βββ App.tsx # Canvas component
β βββ shapes/
β βββ CodeShape.tsx # Code node implementation
βββ dist/ # Compiled output
βββ package.json # Extension manifest
βββ webpack.config.js # Build configuration
# Compile TypeScript
npm run compile
# Watch mode (auto-recompile on changes)
npm run watch
# Run extension in debug mode
# Press F5 in VS CodeSee ARCHITECTURE.md for a step-by-step guide on adding support for Ruby, Go, Rust, or any other language with a CLI interpreter.
The Excalidraw aesthetic is achieved through:
- Virgil font for hand-drawn text
- Rough borders with
box-shadow: 4px 4px 0px #000 - Tldraw CSS overrides in
src/webview/tldraw-styles.css
The code editor uses react-simple-code-editor with Prism.js. To customize:
- Change theme: Import a different Prism theme in
CodeShape.tsx - Adjust font: Modify the
fontFamilyin editor options - Add languages: Import Prism language components
Risks:
- File system access
- Network requests
- System commands
Recommendations:
- Only run code you trust
- Consider using Docker for isolation
- Review code before execution
See ARCHITECTURE.md for detailed security information.
-
Verify the interpreter is installed:
node --version python3 --version
-
Check the Debug Console (View β Debug Console) for errors
-
Open Webview Developer Tools:
- Command Palette β "Developer: Open Webview Developer Tools"
- Reload the window:
Ctrl+R/Cmd+R - Check for compilation errors:
npm run compile - Verify all dependencies are installed:
npm install
Ensure Prism language components are imported in CodeShape.tsx:
import 'prismjs/components/prism-javascript';
import 'prismjs/components/prism-python';- Multi-file projects (import/export between nodes)
- Package manager integration (npm, pip)
- Debugger support (breakpoints, step-through)
- Collaborative editing (live sharing)
- Cloud execution (serverless functions)
- More languages (Ruby, Go, Rust, etc.)
- LSP integration (IntelliSense, autocomplete)
- Export to Jupyter Notebook
- Canvas templates (algorithms, data structures)
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Tldraw - Infinite canvas engine
- Excalidraw - Design inspiration
- Prism.js - Syntax highlighting
- react-simple-code-editor - Code input component
- Author: Hridesh Sharma
- Email: hridesh.khandal@gmail.com
- GitHub: @hridesh-net
Built with β€οΈ for visual thinkers and creative coders