Publish JSON Schemas for user and project config
Motivation
Worktrunk's config files are the main way users tune behavior, but there is no published JSON Schema for editor completion or validation. wt list --format=json already has one at https://worktrunk.dev/schema/list-v2.json, generated from the Rust output types. The config types already derive schemars::JsonSchema to drive unknown-key diagnostics, so the same source of truth could produce user and project schemas.
Without a schema, users either hand-maintain one or get no feedback on typos until wt warns at runtime.
Proposal
Publish two schemas:
https://worktrunk.dev/schema/config.jsonfor~/.config/worktrunk/config.tomlhttps://worktrunk.dev/schema/wt.jsonfor.config/wt.toml
and expose them through a command such as:
$ wt config schema
$ wt config schema --project
The generated documents should:
- use the serde deserialize contract so omitted optional/defaulted fields are valid;
- set
additionalProperties: falseon objects with named properties, so typos are flagged; - include deprecated serde aliases such as
pre-create/post-create, markeddeprecated; - cover global config, project config, and
[projects."…"]overrides; - use stable
$ids matching their published URLs.
The docs-sync test that regenerates list-v2.json could also regenerate these files, so the published documents cannot drift from the Rust types. The existing schema_top_level_keys path in src/config/mod.rs and schema_document in src/commands/list/json_v2.rs are the relevant precedents.
Current workaround
I generated both documents from the existing JsonSchema derives and published them to a public gist:
- https://gist.githubusercontent.com/FlavioAmurrioCS/665fa9175d7bdd7cc0fe8ff8afb89e26/raw/worktrunk-config.schema.json
- https://gist.githubusercontent.com/FlavioAmurrioCS/665fa9175d7bdd7cc0fe8ff8afb89e26/raw/worktrunk-wt.schema.json
This works in editors, but an official URL would be discoverable and kept in sync. I'd be happy to open a PR if this direction sounds reasonable.
Follow-up
Once the URLs are stable, submitting to SchemaStore would give automatic editor association. That can be a separate change.
The published-schema part fits the existing list-v2.json pattern: test_docs_are_in_sync already regenerates that file from a Rust schema generator. A config-schema contribution could use the deserialize contract, commit both documents under docs/public/schema/, and test that representative user and project TOML values validate while misspelled keys fail. The sample schemas also account for the hook aliases that schemars does not derive from #[serde(alias)].
I would scope a first PR to the two stable URLs and their sync/validation tests. wt config schema is a separate public CLI addition; the published files may cover the editor use case without it, so that part needs a maintainer's product decision. SchemaStore association can follow once the URLs are established. I haven't opened a PR for this feature request pending that scope decision.
I can help with the published-schema-only scope discussed above: the two generated config schema documents plus sync/validation tests, preserving accepted defaults, aliases and project overrides. No new CLI command or SchemaStore submission.
@FlavioAmurrioCS, are you already implementing this? Since you offered a PR, I will hold off unless you would welcome a handover or a specific part of the work. Maintainers, please also confirm whether that files-and-tests scope is wanted before implementation starts.
No implementation or PR has been started. Source inspection and this comment were prepared with OpenAI Codex assistance on behalf of @Mohammad-Maraqa.
Yes to the files-and-tests scope: the two generated schemas under docs/public/schema/, regenerated by test_docs_are_in_sync, with validation tests. No wt config schema command or SchemaStore submission for now. @FlavioAmurrioCS you offered a PR first, so it's yours if you'd like it; if not, @Mohammad-Maraqa can take it.
This was written by Claude Code on behalf of max-sixty
Sorry, was busy all week, let me put a pr out. :)
PR is up: #4726
It follows the scope agreed above: two generated schemas plus tests, with no wt config schema command and no SchemaStore submission. A few details differ from the original proposal:
- Schema URLs. I used
https://worktrunk.dev/schema/user-config.jsonandhttps://worktrunk.dev/schema/project-config.jsoninstead ofconfig.json/wt.json. The new names match the "user config" / "project config" terms the docs already use, andwt.jsonwould sit confusingly next tolist-v2.json, which also describeswtoutput. Happy to switch back if you prefer the original names. - No CLI command.
test_docs_are_in_syncregenerates both files next tolist-v2.json. The config types live in the library crate, so the sync test calls the generator directly instead of shelling out the waywt list --print-schemadoes. - Hook aliases.
pre-create/post-createnow come from oneHOOK_ALIASEStable insrc/config/mod.rs. Both the schema generator andschema_top_level_keysuse it, so a new alias can't be added in one place and missed in the other. - Tests use TOML. The fixtures are TOML, and each one must also deserialize into the real
UserConfig/ProjectConfig, so the tests can only pass with configs the loader actually accepts. Misspelled keys are checked at the root, in nested tables, and inside[projects."…"]. - One docs addition. The "Configuration files" section of
wt config --helpnow has one sentence on the#:schemadirective. That's how users opt in until there's a SchemaStore entry. I checked it with both Taplo and Tombi.
Once this is merged and the URLs are live, I'll retire the gist. SchemaStore can be a follow-up whenever you want it.