Writes the main files of a webtyp appkit app (web/server, web/browser, migrate, config/services). It is a development tool: it ships inside the webtyp program and no app lists it in its go.mod.
A webtyp app declares itself once, in config/ (appkit); its main files are generated from that declaration. You meet appkitc the first time webtyp dev starts an app, and again every time appkit or layout change their API.
| Without this | With this |
|---|---|
The templates were text inside webtyp.com/server, which does not depend on the libraries they call: nothing compiled them, and a template that no longer matched appkit or layout reached the developer as undefined: layoutapp.Browser. |
The templates live next to a compiled fixture app: appkitc does not publish until the files it writes compile against the appkit, layout, devtools, migrate and ddl it requires. |
How it works: docs/diagrams/GENERATED_MAINS.md. Where this repo sits in the framework: docs/diagrams/PLACEMENT.md.
- Go, at the version in go.mod.
- The
webtypprogram, which importsappkitcand connects it to the server (app/main_generator.go). An app does not install or list anything. - An app that declares
var App = appkit.App{…}inconfig/, withconfig/servicesandconfig/screens(ARCHITECTURE).
Goal: generate the files from config/app.go.
package main
import (
"os"
"webtyp.com/appkitc"
"webtyp.com/fmt"
"webtyp.com/server"
)
func main() {
root, err := os.Getwd()
if err != nil {
fmt.Println(err)
return
}
path, err := appkitc.GenerateMain(root, server.ReadModulePath(root), server.MainConfig{Port: "8080", PublicDir: "web/public"})
if err != nil {
fmt.Println(err)
return
}
fmt.Println(path)
}Expected result: it prints the path of web/server/main.go; web/browser/main.go, migrate/main.go and config/services/{migrations,removed}.go are written next to it. A file without the Code generated by webtyp.com/appkitc header is yours and is never touched (generate.go).
When config/app.go declares OpenToAgents, web/browser/main.go also builds webmcp.New(screens.Browser.Caller, config.App) and adds it to
layoutapp.Tools.ScreenWatchers: each screen offers an AI agent the tools of the entities it shows. Without it, the browser never ships webmcp (agents.go).
Goal: bring the app's go.mod up to the libraries the templates need.
Expected result: GenerateMain does it on its own whenever it writes new content (UpgradeGeneratedLibraries); webtyp dev's «Update libraries» calls it too.
| Order | Document | What question it answers & when to read it |
|---|---|---|
| 1 | docs/ARCHITECTURE.md | What each file does and what must never depend on appkitc. |
| 2 | docs/diagrams/GENERATED_MAINS.md | How the files are written and why a template that does not compile is not published. |
| 3 | docs/diagrams/PLACEMENT.md | Who imports appkitc and who it imports. |
| 4 | docs/TESTS.md | Which test proves which rule. |