Repository navigation
feat(config): ship an editor schema for config.toml and models.json - #370
Merged
Merged
Conversation
liuedcson
requested review from
MelodyVAR,
Uking-xxx and
ZouR-Ma
as code owners
November 26, 2026 11:17
Writing a setting in `config.toml` or `models.json` had no way to be checked before starting a session: an unknown key was carried along and ignored, and an out-of-range value fell back to its default with one line of output. The only way to learn the accepted keys was to read the source, which is what the reported workflow was doing against the compiled binary. The key definitions are now the single source: `settings-schema.ts` declares each settings table once as TypeBox, the TypeScript types are derived from it with `Static<>`, and the JSON Schema is rendered from the same objects. The `models.json` shape and the theme shape follow the same pattern, so an editor validates against the definitions the loaders actually use. The schemas are generated into `schema/`, rendered again at runtime, and written beside the global `config.toml`, which points at its copy with `#:schema ./config.schema.json`. Nothing is fetched over the network and no URL is published: an editor validates against the same build that wrote the file, so a schema change is an ordinary code change. A project file gets no copy -- the repository owns that directory, and a relative path from there cannot reach the global one. The directive is added when a global config is written for another reason, never as a write of its own, so a launch does not touch the user's file. `models.json` keeps its loader schema open to unknown fields, because a newer Step may add one and an older binary must still load the file. The editor gets a closed copy rendered from the same tree; a test proves the two differ by nothing but that flag, and that a declared record stays open. `step config schema [config|models] [--out <file>]` prints either schema. The documentation carried several claims that contradicted the code: the settings page opened by naming a `settings.json` the product has not read for several releases, `compaction.triggerRatio` was 0.85 against a constant of 0.9, `models.json` and `auth.json` were documented one directory too deep, and the theme schema links pointed at repository paths that return 404. Each is corrected against the code, and the examples are now validated by a test. `pnpm run check:config-schema` renders both schemas again and fails when the committed copy is stale. The tests add what that comparison cannot see: every documented default against the constant the loader reads, every alias the settings manager honors, every field the MCP loader reads, a file the product writes against its own schema, and a static import-graph budget for the CLI entry so the config subsystem cannot be pulled back onto the startup path.
liuedcson
force-pushed
the
feat/config-schema
branch
from
November 26, 2026 12:45
51af32a to
47ed3be
Compare
`config check` ships in a follow-up branch, but its name had leaked into this one: the `--help` summary, two schema descriptions, and two comments. A branch that describes a command it does not provide is the same class of problem this work exists to fix, so the references are removed rather than left for the other branch to overwrite.
`migrateSettings` rewrites `[skills] customDirectories` into the array of the same name plus `enableSkillCommands`, so a file that still uses the table loads correctly. The schema only allowed the array, which made the editor reject a file the loader reads — the same disagreement the other three legacy keys were already listed to avoid. `skills` now accepts either shape, with a test that both validate and a row in the migration table.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
config.tomlandmodels.jsonnow have an editor schema generated from the sameTypeBox definitions their loaders use, plus one command to print it:
step config schema [config|models] [--out <file>]The key definitions are the single source:
settings-schema.tsdeclares eachsettings table once, the TypeScript types derive from it with
Static<>, and theJSON Schema is rendered from the same objects.
Why
Nothing could tell a user whether a configuration file was right before starting
a session. The runtime is deliberately forgiving: an unknown key is carried along
and never read, an out-of-range value falls back to its default with one line of
startup output, and an unrecognized enum falls back silently. All three look the
same from the outside — the file says one thing and the session does another —
and the only way to find the accepted keys was to read the source, which is what
the reported workflow was doing against the compiled binary.
Behavior
Schema generation.
packages/coding-agent/schema/holds the committedconfig.schema.jsonandmodels.schema.json; both are rendered again at runtimeand written beside the global
config.toml, whose first line is#:schema ./config.schema.json. Nothing is fetched over the network and no URLis published, so an editor validates against the build that wrote the file.
A project
.stepcode/config.tomlgets no copy: the repository owns thatdirectory, files there would show up in
git status, and a relative path from itcannot reach the global one. The directive is added when a global config is
written for another reason, never as a write of its own — a launch refreshes the
schema copies and leaves the user's file untouched.
models.json keeps two shapes. Its schema is also the loader's validator, so
it stays open to unknown fields: a newer Step may add one and an older binary
must still load the file. The editor gets a closed copy rendered from the same
tree, so a misspelled
baseUrlis visible where it is written. A test proves thetwo copies differ by nothing but that flag, and that a declared record such as
samplingParamsstays open.pnpm run check:config-schemarenders both again and fails when the committedcopy is stale.
Documentation corrected against the code
The shipped settings page opened by naming a
~/.stepcode/agent/settings.jsonthe product has not read for several releases, so anyone following it wrote a
file nothing opens. It also documented
compaction.triggerRatioas 0.85 (theconstant is 0.9),
compaction.contextProjectionasclm-v1(the default isoff),models.jsonandauth.jsonone directory too deep, a broken provideras skipped when the whole file is rejected, and the npm install directory and
resource base directory one level too high.
The theme schema links in
themes.mdand in five built-in themes pointed atrepository paths that return 404. They now point at the copy shipped beside the
themes.
Drift guards
The generated file is compared as text by
check:config-schema, which catches achanged key but not a changed number. The tests add:
product still reads;
previously undetected — the assertion was written so that it could never fail);
cli/args.ts, so the config subsystem cannotbe pulled back onto the startup path. That happened once on this branch: it
took startup from 25 to 148 modules and ~500ms before anything ran.
Size
45 files, +7436 / −840. Of that, 4339 lines are generated JSON (both schemas plus
the theme schema, 790 of which replace a hand-written file); about 3100 lines are
hand-written, of which roughly 900 are tests.
Validation
pnpm run checkpasses, including the newcheck:config-schema../test.shpasses: 5632 passed / 59 skipped inpackages/coding-agent, 762 inapps/cli, no failures in any package.Follow-up
A separate PR adds
step config check, which answers the other half of thereported problem — "I configured it, why did nothing change" — by validating the
files against this schema before a session starts. It builds on this branch and
will be rebased onto
mainonce this merges.