How utensil/forest works
Main Components
• Source Content and Data Store:
– The “trees” directory holds hundreds of .tree files that represent the note trees (Zettelkasten notes).
– Other directories also include “tex” for LaTeX source, “assets” for HTML/CSS/JS, “theme” for styling, and “templates” for layout definitions.
• Build Pipeline and Task Automation:
– Build scripts such as “build.sh” and “dev.sh” coordinate the conversion of source content (trees, tex, assets) into a static website.
– “just”, along with shell and Python scripts, acts as a task runner to manage environment setup and file transformation.
• Compilation & Rendering Components:
– Forester (via opam) processes the trees and renders them to an intermediate XML/HTML representation.
– Bun is used to compile and bundle JavaScript/TypeScript code (found in the “bun” directory) for interactive components.
– Additional build tools include dvisvgm for converting LaTeX to SVG.
• Development and Deployment Environment:
– The development server (invoked by “dev.sh”) watches file changes (e.g., with watchexec) and serves the site locally (http://localhost:1314).
– GitHub Actions (evident from “.github/workflows” files) manage CI/CD, running “build.sh” during deployment.
• Experimental / Extension Layers:
– Experimental WASM builds (conditional in build.sh) integrate Rust-based components.
– Configuration and environment files (e.g., .env.in, bundler configurations) support the cross-tool integration.
Out the Relationships and Interactions
– The content creation happens in “trees”, “tex”, “assets”, “templates”, “theme”, and config files.
• Build Process:
– “dev.sh” (or “build.sh” when triggered by CI) initiates the build pipeline.
– Forester reads the note trees and uses configuration from “forest.toml” and “forest” setups (like “config.lua” and “uts-plugins.lua”) to generate intermediate content.
– Bun takes the JavaScript/TypeScript source (files in “bun”) and compiles these, possibly integrating WASM components if they build.
– Other scripts (e.g., “scripts/build-dvisvgm.sh”) ensure that LaTeX content is converted properly.
• Output and Serving:
– The processed files are assembled into the final static website, which is then served by the development server.
– GitHub Actions use “build.sh” to rebuild the site and deploy it (as seen in the workflow file for gh-pages).
Architectural Patterns and Design Principles
• Pipeline Architecture:
– There is a clear sequence from source content → build processing (via Forester and bundlers) → final static site generation.
• Modularity:
– Separation of concerns is evident: each directory (assets, trees, bun, scripts) serves a distinct purpose.
– Use of task runners (“just”, shell/Python scripts) enables isolated handling of tasks like asset compilation, linting (Biome), and file watching.
• Extensibility:
– Experimental features, like WASM integration and the use of “just”, are designed so that they do not block the main build process.
• Integration of Heterogeneous Technologies:
– The system combines OCaml-based tools (Forester via opam), JavaScript/TypeScript (via Bun), and traditional UNIX scripting.
Additional Inclusions
• External dependencies like opam, rustup, and brew-managed packages that are prerequisites.
• Fallback paths in the build process (e.g., WASM build may fail silently but does not hinder the main website build).