A Python tool to export code snippets from Pieces for Developers to massCode format.
- Python 3
- Pieces OS installed and running locally
- Virtual environment recommended
-
Activate the virtual environment depending on your method (conda, pip, uv...)
-
Install prerequisites:
pip install -r requirements.txt
- Ensure Pieces OS is running locally
Simply run the main script:
python src/main.py
The program will:
- Connect to your local Pieces OS instance
- Fetch all your saved snippets
- Convert them to massCode format
- Save them in a JSON file named
masscode_export_[timestamp].json
- Language extraction and folder organization based on Pieces metadata
- Tag preservation
- Partial snippet metadata preservation (Masscode handles less metadata actually than Pieces)
- Timeout handling (3 minutes max for fetching assets)
- Cross-platform support
- Detailed progress logging
The program creates a JSON file that can be imported directly into massCode. Snippets are organized by:
- Language-specific folders
- Original tags
- Original metadata (name, description, etc.)
It appears some snippets could have been wrongly classified by Pieces, resulting in some snippets mapped to a wrong folder. So, double-check your snippets folders after the migration.
The program will display helpful error messages if:
- Pieces OS is not running
- No snippets are found
- The virtual environment is not activated
- Any other issues occur during conversion
src/main.py
- Main entry pointsrc/converter.py
- Core conversion logicsrc/models/masscode.py
- massCode data modelssamples/
- Sample files and SDK reference