AGENTS.md

52 lines
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
# AGENTS.md

Single-binary Go framework CLI. Scaffolds projects with vendored source, deploys them, wraps Claude Code.

## Build & Test

```bash
go build -o congo ./cmd     # Build CLI
go build -o web/web ./web   # Build website
go mod tidy                 # Resolve deps
make build                  # Build CLI binary
```

No test suite — verify by building.

## Structure

```
congo.go       Root package (package congo) — exports ScaffoldFS, SourceFS, ClaudeContext
cmd/main.go    CLI entry point — dispatches to cmd/commands/
cmd/commands/  Subcommands: init, new, dev, build, launch, connect, claude, source
cmd/internal/  Scaffold rendering + framework extraction helpers
pkg/           Framework source (application, database, frontend, assistant, platform)
res/scaffold/  Project templates (*.tmpl files, view/controller stubs)
web/           Promotional website (dogfoods the framework)
```

## Key Architecture

- `congo.go` embeds `res/scaffold/`, `res/claude-context.md`, and `pkg/` as Go embed.FS
- `cmd/commands/` imports root package as `congo.gg` to access embedded filesystems
- `congo init` extracts `pkg/` via `congo.SourceFS` into `internal/`, rewrites `congo.gg/pkg/` to `<target>/internal/`
- `congo new` adds an app to an existing project (controllers, models, views, main.go)
- `congo source` extracts a flat buildable copy, rewriting `congo.X` to local vars to avoid import cycles
- Scaffold templates use `<<`/`>>` delimiters to avoid conflicts with Go `{{`/`}}`

## Code Conventions

- IDs are always strings (UUIDs)
- SQL columns use PascalCase: `WHERE UserID = ?`
- Value receiver on `Handle()` for request isolation
- Templates by filename only: `{{template "nav.html" .}}`
- `cmp.Or()` for env var defaults
- No custom ServeMux — use `http.DefaultServeMux`
- Package-level vars as runtime state (no config structs)

## Editing Guidelines

- After any change, verify with `go build -o /dev/null ./cmd && go build -o /dev/null ./web`
- Changes to `cmd/commands/source.go` must preserve the import-rewriting logic for the flat layout
- Changes to `pkg/` affect the vendored framework source users receive
- Scaffold templates in `res/scaffold/` use `<<.Field>>` syntax, not `{{.Field}}`