feat: publish a JSON schema for the Agentkitfile for editor autocomplete
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- docker, go, json, yaml
- Ambito
- developer-experience, tooling
Direzione di ricerca
Start by reading the Go config types in pkg/agentkit/config/specs.go, tool.go, and source.go, then compare the generator example at dalec's cmd/gen-jsonschema/main.go. Generate docs/agentkitfile.schema.json from the YAML tags, add the documented special cases, and cover the listed fixtures and invalid examples. The issue's done criteria include a CI freshness check, editor behavior, and the --call feature only after #58 lands.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
The Agentkitfile is strict: an unknown or misspelled field fails the build. But editors give no help while you write one. There's no autocomplete, no hover help and no red underline on a typo, so:
- every typo costs a full build attempt;
- you learn field names by reading
docs/agentkitfile.md.
Most YAML editors can do all of this if they're given a JSON schema, a file that describes which fields are allowed. AgentKit doesn't publish one. dalec generates one from its Go types (cmd/gen-jsonschema/main.go, docs/spec.schema.json) and also serves it through docker buildx build --call dalec.schema.
What
- Generate a JSON schema for the Agentkitfile from the Go config types and check it in as
docs/agentkitfile.schema.json. - Keep it current: CI fails if someone changes the config types without regenerating it.
- Let editors use it with one comment in the file:
#syntax=ghcr.io/orka-agents/agentkit/agentkit:latest # yaml-language-server: $schema=https://raw.githubusercontent.com/orka-agents/agentkit/main/docs/agentkitfile.schema.json apiVersion: v1alpha1 kind: Agent- Order matters. The schema comment must come after the
#syntaxline. BuildKit stops looking for#syntaxat the first comment that isn't a directive (seeDirectiveParser.ParseLinein BuildKit'sfrontend/dockerfile/parser/directives.go). - Matching versions. For a pinned frontend version, use the same tag in the schema URL, for example
.../v0.5.0/docs/agentkitfile.schema.json, so the editor matches the frontend.
- Order matters. The schema comment must come after the
- Serve it from the frontend:
docker buildx build --call agentkit.schema -f agentkitfile.yaml .prints the schema for the exact frontend version in#syntax, the same way dalec's--call dalec.schemadoes. This builds on the--callsupport in #58. If #58 isn't merged yet, leave this part for a follow-up.
The schema is there to help with editing. The Go checks in validate.go remain the source of truth, so don't try to express every rule in the schema.
Out of scope
- A VS Code extension.
- Registering the schema with SchemaStore so editors pick it up without the comment. That's a good follow-up once the file is stable.
Why
- Typos show up while typing, not after a build.
- Autocomplete and hover help make the format easy to learn.
- It's cheap: the schema is generated from code that already exists.
How
Where things are
| File | What it does |
|---|---|
pkg/agentkit/config/specs.go, tool.go, source.go |
The Agentkitfile types. They use yaml tags (no json tags) and have doc comments. |
pkg/agentkit/config/load.go |
Strict loader: unknown fields fail. The schema should match this with additionalProperties: false. |
pkg/agentkit/config/source.go |
Source (used by instructions) accepts a plain string or an {inline} / {file} mapping. It needs a hand-written schema. |
pkg/agentkit/runtimes |
Runtime names and aliases, for the runtime enum. |
dalec cmd/gen-jsonschema/main.go |
Example generator using github.com/invopop/jsonschema. |
Steps
- Add a generator, for example
cmd/gen-schema/main.go, usinggithub.com/invopop/jsonschema.- Field names must come from the
yamltags. invopop readsjsontags by default, so set its option for another tag name. Check the exact option in the version you pick. - Use Go doc comments as field descriptions (
AddGoComments, as dalec does) so editors show hover help. - Set
additionalProperties: falseso unknown fields are flagged, matching the strict loader.
- Field names must come from the
- Hand-write the special cases with a
JSONSchema()method on the type. invopop picks it up automatically.instructions(Source): a string, or an object withinlineorfile.- Fields with fixed values, using
enum:apiVersion: v1alpha1kind: Agentmodel.provider: openai-compatibleruntime: names and aliases frompkg/agentkit/runtimesauth.typecontext.providers[].typetools[].transport
- Fields that hold env var names (
apiKeyEnv,urlEnv,tokenEnv,env[].nameand so on):pattern: "^[A-Z0-9_]+$", the same rule asisEnvVarNameinvalidate.go.
- Add a make target, for example
make schema, that writesdocs/agentkitfile.schema.json. - Add a CI check: regenerate the file and fail on
git diff --exit-code docs/agentkitfile.schema.json. - Add
--call agentkit.schemaonce #58 has landed.- Embed the file in the frontend (
//go:embed) and return it asresult.json/result.txtmetadata, as dalec'shandleJSONSchemadoes infrontend/client.go. - BuildKit's
dockerui.HandleSubrequestrejects unknown calls unlessAllowOther: true, so either handle this call before it or set that option.
- Embed the file in the frontend (
Tests
- Every example file passes the schema: each
test/agentkitfile-*.yamlfixture, and each YAML example inREADME.mdanddocs/, if they're easy to extract. Use a Go JSON Schema validator such asgithub.com/santhosh-tekuri/jsonschema. This catches the schema and the loader drifting apart. - Mistakes fail it: a misspelled field, a wrong
kind, and a lowercase env name. - Manual check: in VS Code with the Red Hat YAML extension, a file with the comment shows autocomplete, hover help and an error on a typo.
Run:
go test ./...
make lint
Docs
docs/agentkitfile.md: add an "Editor support" section with:- the comment line;
- the note that it goes after
#syntax; - the versioned URL;
- how to set it up in VS Code;
- the
--call agentkit.schemacommand, once available.
README.md: add the comment line to the quick-start example.
Done when
docs/agentkitfile.schema.jsonis generated from the Go types, and CI fails when it's out of date.- All fixtures and examples pass the schema, and the sample mistakes fail it.
- With the comment line, VS Code shows autocomplete and flags typos, and
#syntaxstill works. --call agentkit.schemaprints the schema, once #58 has landed.
- Lingua principale
- Python
- Stelle
- 7
- Fork
- 5
- Merge medio
- 3h 39m
- PR unite (30g)
- 1
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di orka-agents/agentkit
-
fix(pydantic-ai): CI fails with newest pydantic-ai (unexpected 'history' argument)Forse già presa @gambtho l’ha presa 30 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
orka-agents/agentkit#77 ·
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
orka-agents/agentkit#76 · 3 commenti ·
-
area/build area/orka area/runtime blocked enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
orka-agents/agentkit#69 ·
-
area/build area/orka area/runtime enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
orka-agents/agentkit#68 ·
-
area/build enhancement testing
Difficoltà 5/5 Più di una settimana Idoneità per principianti 42/100
orka-agents/agentkit#65 ·
Tutte le issue di orka-agents/agentkit
Issue simili
-
【文档错误】创建镜像空间步骤中的截图标注与文字描述不一致Apertaenhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
DaoCloud/DaoCloud-docs#7839 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 78/100
sav-oss-org/ptusa_main#1610 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
bug status/accepted type/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
microsoft/apm#4925 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
sagemathinc/sagebrush#1701 ·
I maintainer di solito rispondono entro 1 giorno