Documentation
¶
Overview ¶
Package inspect reads a Līdza project's source and produces the context an agent needs: the API routes with their handler signatures, the Rust exports, and the configuration. `lidza context` writes it to .lidza/context.json; `lidza mcp` and the /llms.txt endpoints serve it.
Index ¶
- Constants
- func LLMS(c *Context, cfg *config.Config, guide string) (short, full string)
- func LLMSFor(dir string, cfg *config.Config) (short, full string, err error)
- func ModulePath(root string) string
- func OpenAPI(c *Context) map[string]any
- type App
- type Context
- type Export
- type Handler
- type Operation
- type Route
- type Rust
Constants ¶
const ( LLMSFile = ".lidza/llms.txt" LLMSFullFile = ".lidza/llms-full.txt" OpenAPIFile = ".lidza/openapi.json" )
Files under .lidza that Refresh writes and the dev server serves.
const FileName = ".lidza/context.json"
FileName is the context dump, relative to the project root.
const GuideFile = "docs/lidza-guide.md"
GuideFile is the app's guide, written by `lidza new`, relative to the project root. It opens /llms-full.txt.
Variables ¶
This section is empty.
Functions ¶
func LLMS ¶
LLMS renders /llms.txt (short: what the app is, its routes, its commands) and /llms-full.txt (the guide, every handler signature, the Rust exports and the configuration). guide is the app's docs/lidza-guide.md, may be empty.
func ModulePath ¶
ModulePath reads the module path from root/go.mod, or "".
Types ¶
type App ¶
type App struct {
Name string `json:"name"`
Module string `json:"module"`
Template string `json:"template"`
// Dir is the absolute project root.
Dir string `json:"dir"`
}
App identifies the project.
type Context ¶
type Context struct {
Generated time.Time `json:"generated"`
// Lidza is the framework version that produced the dump.
Lidza string `json:"lidza"`
App App `json:"app"`
// Routes lists every registration found in the source, typed or not.
Routes []Route `json:"routes"`
// Operations are the typed routes with their schemas; Schemas holds the
// JSON Schema components they reference.
Operations []Operation `json:"operations"`
Schemas map[string]any `json:"schemas"`
Rust *Rust `json:"rust,omitempty"`
// Warnings are type-check errors: the operations may be incomplete
// until they are fixed.
Warnings []string `json:"warnings,omitempty"`
}
Context is the machine-readable description of a project.
type Export ¶
type Export struct {
Name string `json:"name"`
File string `json:"file"`
Line int `json:"line"`
Signature string `json:"signature"`
}
Export is a `#[no_mangle] pub extern "C" fn`: what the Go side can call.
type Handler ¶
type Handler struct {
// Name is the function name, "pkg.Func" for one from another package,
// or "func literal" for an inline handler.
Name string `json:"name"`
// File and Line point at the registration for literals and at the
// declaration for named functions. File is relative to the project root.
File string `json:"file,omitempty"`
Line int `json:"line,omitempty"`
Signature string `json:"signature,omitempty"`
}
Handler describes the function behind a route.
type Operation ¶
type Operation struct {
// ID is the operationId and the client method name: the handler's name
// in lowerCamel, or method plus path for a func literal.
ID string `json:"id"`
Method string `json:"method"`
Path string `json:"path"`
// Params are the path parameters, in order.
Params []string `json:"params"`
// Input and Output name the component schema (empty for router.None).
// For a stream, Output is the schema of one event.
Input string `json:"input,omitempty"`
Output string `json:"output,omitempty"`
// Stream marks a router.Stream operation: the reply is server-sent
// events, each one Output as JSON.
Stream bool `json:"stream,omitempty"`
// Upload marks a router.Route whose In is router.File: the request
// body is a file sent raw, not JSON, and Input is empty.
Upload bool `json:"upload,omitempty"`
Handler Handler `json:"handler"`
// Builtin marks operations the framework registers in every app.
Builtin bool `json:"builtin,omitempty"`
// Pack names the framework pack whose Mount registered the operation
// (auth for the sign-in routes); empty for the app's own.
Pack string `json:"pack,omitempty"`
}
Operation is a typed route (router.Route[In, Out] or router.Stream[In, Event]) with the JSON Schemas of its input and output, the basis of the OpenAPI document and the generated client.
type Route ¶
type Route struct {
// Method is empty when the pattern matches every method.
Method string `json:"method,omitempty"`
Path string `json:"path"`
// Pattern is the net/http ServeMux pattern as written.
Pattern string `json:"pattern"`
Handler Handler `json:"handler"`
// Builtin marks routes the framework registers in every app.
Builtin bool `json:"builtin,omitempty"`
// Typed marks routes registered with router.Route or router.Stream;
// their schemas are in Context.Operations.
Typed bool `json:"typed,omitempty"`
// Pack names the framework pack whose Mount registered the route.
Pack string `json:"pack,omitempty"`
}
Route is one registered API route.
func Routes ¶ added in v0.1.127
Routes lists the app's routes from its source alone: the built-in ones and every pattern registered in Go, with handler names and positions, in milliseconds. The typed operations' schemas, the handler signatures and the routes a mounted pack brings need the type-check Project does.