From 1cb13a6a551808b7ce5b18727e7b378c7a1be221 Mon Sep 17 00:00:00 2001 From: Spencer Brower <6729162+sbrow@users.noreply.github.com> Date: Mon, 20 Jul 2026 13:46:31 -0400 Subject: [PATCH] chore: Updated `AGENTS.md`. --- AGENTS.md | 271 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 194 insertions(+), 77 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e604af9..3ce0488 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -5,63 +5,119 @@ Thor is a static site generator written in [Odin](https://odin-lang.org), replac ## Architecture ``` -thor.json ← site config (title, base_url, author, params) +thor.json ← site config (title, base_url, author, params, modules) content/ ← markdown and HTML content files -layouts/ ← Mustache templates + partials (including icons) -assets/ ← CSS (Tufte-based), JS, fonts, images — copied/processed to public/ +layouts/ ← Mustache templates + partials (user overrides) +assets/ ← CSS (Tufte-based), JS, fonts, images +thor/defaults/ ← bundled default templates (embedded via #directory) public/ ← build output (generated) ``` -### Source files +### Package structure + +``` +thor/ +├── treesitter/ # FFI types + grammar management (standalone package) +├── markdown/ # Content transformation pipeline (imports ../treesitter) +├── mustache/ # Template engine with lambdas + pipe filters +├── content.odin # Page struct, scan_content, load_page +├── render.odin # Template rendering, data structs, RSS, sitemap +├── site.odin # Config (Flags, Config_File, Site), init_site +├── minify.odin # HTML/CSS minification (imports treesitter) +├── feed.odin # RSS + sitemap generation +├── vfs.odin # Union file system (defaults → modules → site) +├── assets.odin # VFS-based asset copying +├── opengraph.odin # Open_Graph struct + og_init/og_for_page +├── frontmatter.odin # JSON frontmatter parser +├── defaults.odin # DEFAULTS_PATH constant (#directory) +├── main.odin # Entry point +└── defaults/layouts/ # Bundled default templates +``` + +### Source files (main package) | File | Responsibility | |---|---| -| `main.odin` | Entry point. Sets `context.logger`, calls `init_site`, `walk_content`, `render_site`. Optional Spall profiling via `SPALL` config flag. | -| `site.odin` | `Flags` (CLI args), `Config_File` (from `thor.json`), `Site` (runtime state + arena), `Feature` + `Markdown_Extension` bit_set enums, `DEFAULT_MARKDOWN_EXTENSIONS`, 5-step `init_site` (defaults → flags → config → apply config → apply flags), `load_config_file`, `apply_config`, `apply_cli_flags`, `parse_extension_list`, `find_config` | -| `frontmatter.odin` | JSON frontmatter parser (`{ }` delimited) | -| `content.odin` | `Page` struct, content walker, page loader, cmark integration, full markdown pipeline, `copy_assets_dir` (recursive copy with CSS minification) | -| `footnotes.odin` | Note definition stripping (pre-cmark) + sidenote/marginnote injection (post-cmark) | -| `alerts.odin` | GitHub alert post-processor (`> [!CAUTION]` → styled blockquote) | -| `emoji.odin` | Emoji shortcode expander (`:shrug:` → `¯\_(ツ)_/¯`), post-cmark | -| `highlight.odin` | Post-cmark Tree-sitter syntax highlighter; statically links HTML/CSS grammars, dlopen for others; caches loaded grammars, reports syntax errors | -| `tree_sitter.odin` | C FFI bindings for Tree-sitter (TSParser, TSQuery, TSQueryCursor, node traversal, dlopen/dlsym). Statically links `tree-sitter-html` and `tree-sitter-css` via Nix. | -| `sectionate.odin` | `wrap_sections` proc — splits HTML at `` wrappers | -| `render.odin` | Template rendering pipeline: pre-parses templates/partials once, struct-based data model (`Base_Data`/`Page_Data`/`Home_Data`/`Posts_Data`), `mustache.render()`, minification gate, RSS, sitemap, robots.txt | -| `minify.odin` | Tree-sitter-based HTML and CSS minification (`minify_html`, `minify_css`). Strips comments, collapses whitespace, removes inter-tag spaces. Preserves `
`/``/`