This guide covers everything you need to set up, develop, and maintain the Papeterie Engine.
Before you begin, ensure you have the following installed:
- WSL2 (Ubuntu 22.04 or 24.04 recommended).
- Python 3.10+ (The project is pinned to 3.10.x).
- Node.js 20+ (Required for the Web Dashboard).
- uv: The primary package manager for Python.
- npm: Node Package Manager.
The most reliable way to initialize or refresh your environment is to run the automated check script. This script is also automatically called by validate.sh and start_dev.sh.
# Automated environment check and setup
./agent_env/bin/ensure_env.shIf the automated script fails or you need more granular control, you can follow these manual steps:
# 1. Sync Python dependencies and create .venv
uv sync
# 2. Install the project in editable mode (Essential for internal imports)
uv pip install -e .
# 3. Install Web Dashboard dependencies
cd src/web && npm install && cd ../..The absolute cleanest start is to delete the directory and re-clone (shallowly for speed/size).
Caution
Backup your .env file first! e.g., cp .env ../papeterie.env
# 1. Delete the directory
cd ..
rm -rf papeterie-clean # or whatever your folder is named
# 2. Shallow Clone (Depth 1 = No History, fast & small)
git clone --depth 1 https://github.com/charojo/papeterie-engine.git papeterie-clean
cd papeterie-clean
# 3. Restore .env
cp ../papeterie.env .env
# 4. Bootstrap
```bash
./agent_env/bin/ensure_env.shWith the shallow clone strategy (git clone --depth 1), the project footprint is maybe reasonable for vibe coding:
- Repository History (
.git): ~16 MB - Source & Assets: ~52 MB
- Total Source Control: ~68 MB
The bulk of the disk usage (~1.2 GB) comes from build artifacts and dependencies generated during setup:
.venv(Python env): ~961 MBnode_modules(Web env): ~182 MB
The shallow clone strategy is an efficient way to perform a clean start.
You must manually create a .env file in the root directory. This file is ignored by Git.
Create .env with the following content:
GEMINI_API_KEY=your_google_ai_studio_api_key
To run a scene locally using the Pygame renderer:
uv run python src/renderer/theatre.pyThis opens a Pygame window displaying the animation (default is scene_sailboat.json).
To start the FastAPI backend:
uv run fastapi dev src/server/main.pyThe API will be available at http://127.0.0.1:8000 (or localhost). The engine now supports dynamic origin handling.
To start the React development server:
cd src/web
npm run devThe web interface will be available at http://127.0.0.1:5173 (or localhost). The frontend automatically detects the backend host.
The bin/ directory contains essential tools for maintenance and validation.
| Task / Script | Command | Description |
|---|---|---|
| Fast Validation | ./bin/validate.sh --fast |
LOC-only tests for uncommitted changes (~5s). |
| Medium Validation | ./bin/validate.sh --medium |
File-level coverage with auto-fix (~30s). |
| Full Validation | ./bin/validate.sh --full |
All tests + E2E, recommended for pre-commit (~90s). |
| Exhaustive Validation | ./bin/validate.sh --exhaustive |
Maximum coverage + parallel execution (~5m). |
| Check AI Models | uv run python agent_env/bin/ADE_check_models.py |
Verifies Google AI Studio API access. |
| Process Assets | uv run python bin/process_assets.py |
Utilities for green screen removal, etc. |
| Diagrams | uv run python agent_env/bin/ADE_generate_diagrams.py |
Converts .dot files to SVGs. |
| Analyze Coverage | ./agent_env/bin/ADE_analyze.sh |
Generates a coverage report from validation logs. |
| Start Dev Stack | ./bin/start_dev.sh |
Starts both backend and frontend via tmux. |
- Ensure the
.vscode/settings.jsonfile exists. - If the terminal doesn't show
(.venv), useCtrl+Shift+P->Python: Select Interpreterand select the path to./.venv/bin/python. - Recommended Extensions:
- Python (Microsoft): Core Python language support.
- Markdown All in One: Enhanced markdown editing and preview.
- ESLint: JavaScript/React linting.
- Prettier: Code formatting.
- Python Debugger: Direct test execution and debugging.
When starting a new session with an AI Agent:
- Enable Agent Mode in the IDE.
- Instruct the AI: "Read HOWTO_develop.md and AGENTS.md to initialize project context."
We use the Antigravity agent as the canonical assistant for development tasks and for capturing issues encountered during work on feature branches. Follow these steps when you start work on a backlog item (for example, a clean development pull):
- Enable Agent Mode and ensure the Antigravity brain is available at
.gemini/antigravity/brain(the project already reserves this path). - Start an Antigravity session and ask it to scan
docs/HOWTO_Develop.md,docs/AGENTS.md, anddocs/BACKLOG.md(the project backlog is the canonical ledger for issues). - For every blocker, environment quirk, or procedural gap you encounter, run the helper script to record it immediately (see
bin/ADE_capture_issue.sh). This creates a timestamped entry indocs/BACKLOG.mdso the HOWTO can be updated incrementally. - After resolving an issue or completing a task, update
docs/HOWTO_Develop.mdwith the fix or guidance and mark the correspondingdocs/BACKLOG.mdentry as resolved by appending- RESOLVED: <date> by <your-name>under the issue. - Run
python agent_env/bin/ADE_update_workflow_docs.pywhen you add or change agent workflows sodocs/HOWTO_Agent_Workflows.mdstays in sync.
Guidelines for living documentation
- Record issues at the moment they occur; short, factual notes are best.
- Prefer step-by-step remediation notes (commands and expected output) when possible.
- Use the branch and PR to propose HOWTO changes; the PR description should reference
docs/BACKLOG.mdentries you addressed.
Example capture flow:
# Start working on feature branch
git checkout -b feature/clean-development
# When you hit a missing env var or a failing test, capture it:
./agent_env/bin/ADE_capture_issue.sh "Missing GEMINI_API_KEY in .env when running uv run pytest -m live"
# After fixing, append a resolution note to the issue entry and update HOWTO
git add docs/BACKLOG.md docs/HOWTO_Develop.md && git commit -m "docs: record and resolve env var issue in HOWTO"src/compiler/: LLM integration and metadata generation.src/renderer/: Pygame and MoviePy rendering logic.src/server/: FastAPI backend routes.src/web/: React frontend source.assets/sprites/: Source.pngfiles and generated.prompt.jsonmetadata.assets/prompts/: Meta-instruction templates for Gemini.docs/: Project documentation and architecture diagrams.tests/: Comprehensive behavioral test suite.
The main branch is protected. To contribute:
git checkout -b feature/your-feature-name- Commit changes and
git push origin feature/your-feature-name - Open a Pull Request on GitHub. (All tests must pass).
- WSL Mouse/Input Lag: If the mouse becomes unresponsive in Pygame windows, run
wsl --shutdownfrom Windows and restart. - VS Code Sync: If the
(.venv)prompt is missing, restart the terminal after selecting the correct interpreter. - Asyncio Warnings: Ensure
pytest-asynciois installed andpyproject.tomlhas the correct loop scope configuration. - Git Auth: If terminal push fails, use the VS Code Source Control sidebar to "Publish Branch."
- WSL Connection Drops: Avoid running
pkill -f "node"as it kills the VS Code Server. Use specific process killing (e.g.,lsof -ti:PORT | xargs kill) instead. - Validation Hangs/Crashes: If
validate.shhangs or crashes WSL, it's likely memory pressure from E2E tests (Chromium). Runvalidate.sh --full --skip-e2efor lighter validation, or ensure you have ample free RAM (close other VS Code windows). Check for zombie processes withpkill -f chrome || true.
The typical development cycle involves an iterative loop between asset creation, metadata generation, and visual verification.
(Source: development_workflow.dot)
- Asset Creation: Design RGBA
.pngsprites and write initial.promptfiles. - Compilation: Run
uv run python main.pyto generate.prompt.jsonvia Gemini. - Visual Feedback: Use
theatre.pyor the Web Dashboard to see the animation in action. - Refinement: Adjust prompts or art based on visual results and re-compile.
- Validation: Run
./bin/validate.shto ensure no regressions before committing.
We use a "Safe CSS" workflow to prevent visual regressions during refactoring.
- Check Baseline: Run
./agent_env/bin/ADE_safe_css.shto ensure current state passes (or generate baseline snapshots). - Refactor: Make your CSS changes.
- Verify: Run
./agent_env/bin/ADE_safe_css.shagain.- Success:
✅ CSS Safety Checks PASSED. - Failure: The script will point you to the report. Open
src/web/playwright-report/index.htmlto compare Before/After images.
- Success:
If the validation script fails immediately, the dev server might be down. Run ./agent_env/bin/ADE_check_health.sh to diagnose.
As an agentic engine, Papeterie is designed to be co-developed with AI agents like Antigravity.
- Prompt Engineering: Use Antigravity to draft and refine
.promptfiles. The models are excellent at translating visual descriptions into the engine's physics-based parameters. - Automated Fixups: The engine uses Gemini 3 Pro to automatically repair malformed JSON. If you encounter validation errors, check
logs/to see the AI's reasoning. - Brain Artifacts: Antigravity maintains state in the
.gemini/antigravity/braindirectory. This context helps the AI understand your current implementation plan and task status.
For deep dives into specific system architectures, refer to the following design documents:
- High Level Design: Overall system architecture and goals.
- Scene Editing Architecture: Deep dive into the web-based scene editor and state management.
- Persistence & User Design: How assets and user data are stored and managed.
- Verification Strategy: Detailed breakdown of the testing and validation layers.
- Undo/Redo System: Command pattern architecture for reversible actions.
- Issues & Refactoring: Consolidated architecture issues, refactoring plans, and historical regressions.
- Junior Dev Ecosystem: Guidance for junior developers and AI agents working on the project.