From 1deb0c8a27e5ee6e867d93c0cd0680a2728cd430 Mon Sep 17 00:00:00 2001 From: Prad Nukala Date: Mon, 12 Jan 2026 00:21:22 -0500 Subject: [PATCH] docs(AGENTS): update Nebula project guidelines and knowledge base --- AGENTS.md | 292 ++++++++++++++++++------------------------------------ 1 file changed, 99 insertions(+), 193 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index aaf4503..a8a681e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,227 +1,133 @@ -# AGENTS.md - Nebula Project Guidelines +# NEBULA PROJECT KNOWLEDGE BASE -## Project Overview +**Generated:** 2026-01-11 | **Commit:** fcbe848 | **Branch:** feat/pkg -Nebula is a Go/Templ wallet application with HTMX 4 for server-driven UI and WebAwesome (wa-*) web components. +## OVERVIEW -**Stack**: Go 1.25+ | templ v0.3.977 | htmx 4.0.0-alpha5 | WebAwesome | SQLite WASM +Go/Templ wallet UI framework using HTMX 4 for server-driven interactions and WebAwesome (`wa-*`) web components. Hybrid: root is a library (`package nebula`), `cmd/server/` is the reference app. -## Build & Run Commands - -```bash -# Generate Go code from .templ files (REQUIRED after any .templ changes) -templ generate - -# Build the project -go build ./... - -# Run development server (serves on :8080) -go run main.go - -# Watch mode for templ files -templ generate --watch - -# Full build + run + open browser -make all -``` - -## Directory Structure +## STRUCTURE ``` nebula/ -├── models/ # Data types (MVC models) -├── views/ # Page templates (.templ) -├── layouts/ # Base layouts (DashboardLayout, CenteredLayout) -├── components/ # Reusable UI components -├── handlers/ # HTTP route handlers -├── _migrate/ # HTML prototypes to convert -├── HTMX.md # htmx 4 patterns documentation -└── SQLC.md # Database schema documentation +├── cmd/server/ # App entry: main.go + routes.go (handlers HERE, not handlers/) +├── views/ # Page templates (.templ) - XxxPage, XxxContent, XxxWithStepper +├── components/ # Reusable UI (sidebar, stepper, navbar, charts) +├── layouts/ # Base (HTML shell), App (dashboard), Centered (auth) +├── models/ # Data structs + DefaultXxxData() factories +├── htmx/ # HTMX 4 context/request/response helpers +├── pkg/config/ # Config models for middleware injection +├── _migrate/ # HTML prototypes pending conversion (technical debt) +├── middleware.go # Injects HTMX + Config into request context +├── mount.go # Mount() helper for handler registration +├── options.go # WithXxx() functional options +└── config.go # DefaultConfig() + Config struct ``` -## Code Style +## WHERE TO LOOK -### Go Files +| Task | Location | Notes | +|------|----------|-------| +| Add route | `cmd/server/routes.go` | Go 1.22+ patterns: `GET /path/{param}` | +| Add page | `views/` + `models/` | Create XxxPage + model, register in routes.go | +| HTMX patterns | `HTMX.md` | ``, morphing, SSE, OOB updates | +| Modify layout | `layouts/base.templ` | CDN scripts, htmx-config meta tag | +| WebAwesome ref | [webawesome.com](https://webawesome.com) | All `wa-*` components | +| Migrate HTML | `_migrate/` -> `views/` | See MIGRATION.md | -- Standard `gofmt` formatting -- Package-level types in `models/` directory -- Handlers in `handlers/routes.go` with pattern: `handleX(w http.ResponseWriter, r *http.Request)` -- Use `r.Header.Get("HX-Request") == "true"` to detect HTMX requests -- Return partials for HTMX, full pages for direct navigation +## CONVENTIONS -### Templ Files (.templ) +### Naming -- One main page template per file: `PageName(data ModelType) templ.Component` -- Helper functions lowercase: `helperName()` -- CSS-in-templ using `templ css` blocks or `