# Codebase Context ## Purpose Rhedyn is a small static site generator/asset pipeline. It reads a config file, runs tasks (optionally in parallel per step), and writes outputs to `opts.outDir` with caching based on file hashes and state access. ## Entry Point and Flow - `src/index.js` is the CLI entrypoint. It loads config (user or defaults), then iterates through steps in `tasks`, running each task group in parallel. - `src/lib.js` owns config loading, task expansion (file/state), caching, and the task runner that calls action functions. ## Configuration (current shape) - `src/defaults.js` exports `tasks` and `opts` used by `src/index.js`. - Tasks are objects (or arrays of objects for parallelism) with: - `jobConfig` for file/state selection, expansion, output paths, and caching - `actionConfig` for action-specific options - `action` function and a `name` - Global config under `opts` controls output/cache dirs, logging, and site meta. ## Task Expansion - File-based tasks expand input files via glob patterns (`readFilesByGlob`), driven by `jobConfig.inputFiles`. - State-based tasks expand via selectors into `meta.resources`, with optional pagination and auto-built output paths from `jobConfig` settings. - Tasks can opt out of expansion (`expand: false`) to run once with aggregated inputs. ## Caching - `src/cache.js` stores cache files per job. Cache keys are based on job IDs, file hashes, and accessed state paths. - `createTrackedObject` wraps state/config so accessed properties are tracked and used as cache dependencies. ## Actions - `src/actions/` contains built-ins: - `compileSass`, `renderMarkdownToHtml`, `renderTemplate`, `renderMarkdownWithTemplate`, `optimiseSvg`, `copy`, `imageToWebP`, `generateFavicons`, `generateTaxonomy`. - Actions receive `{ config, jobConfig, meta }` and return `{ detail, paths, deps, ref }`. The `config` value maps to `actionConfig`. - Returned `ref` results are exposed via `meta.resources` for later tasks. ## Utilities - `src/util/*` provides filesystem helpers, path manipulation, and simple object/state utilities. - `src/logging.js` formats log output and implements log levels.