feat: Auto-generated settings schema for GUI/TUI parity#803
Conversation
Add #ai_description to all 163 theme settings form elements and auto-generate data/settings-schema.json via the Grunt build. - #ai_description is a custom Form API property (invisible to GUI) containing design-oriented guidance for AI agents - scripts/generate-settings-schema.js parses all 8 *-theme-settings.inc files and extracts type, title, description, ai_description, options, ranges, and defaults into JSON - Gruntfile.js gets a 'generate-schema' task that watches features/**/*-theme-settings.inc for changes - dxpr_theme_helper reads the schema from this theme at runtime, eliminating cross-repo sync Developer workflow: edit the inc file, the watch process regenerates the schema, commit both in the same PR. No parallel PR needed in dxpr_theme_helper. Closes #802
The PHP form API uses generic 'textfield' and 'select' types for color pickers and font selectors. The parser now detects these by key naming conventions (_custom suffix for color, _font_face suffix for font, known color select keys for theme_color) matching the hand-crafted schema types that the validator relies on.
…chema-auto-generation
Field testing note: dxt commands + theme schemaThe dxt:* commands (from dxpr_theme_helper PR #47) were tested against this theme's settings schema while recreating the bricksbuilder.io homepage. A few schema-related observations: ai_description qualityThe Suggestions for schema improvements
|
| } | ||
|
|
||
| // Skip loop-generated keys (color_palette_ prefix, etc.) | ||
| if (key.startsWith('color_palette_') || key.startsWith('local_')) { |
There was a problem hiding this comment.
[P2] Skipping loop-generated color_palette_* keys here means the runtime schema no longer describes the most important color controls. dxpr_theme_helper PR 47 prefers the installed theme schema, so on a real site dxt:config:list --detail, dxt:config:export, and dxt:config:reset cannot surface or round-trip palette settings even though dxt:config:set color_palette_* / dxt:palette:set can still mutate them. That leaves AI agents with a writable API that is larger than the introspectable API. I think the generated schema needs to emit either color_palette or synthetic color_palette_* entries rather than skipping them.
jjroelofs
left a comment
There was a problem hiding this comment.
Left 1 inline comment. Main concern: the generated runtime schema currently drops palette controls, which creates a real discoverability/export/reset gap for AI-agent CLI workflows in dxpr_theme_helper#47 because the helper prefers the installed theme schema at runtime.
Code Review: #803Overall AssessmentStrong PR. The auto-generation approach from PHP form definitions is the right architecture — it eliminates cross-repo sync and makes the theme the single owner of its settings contract. The Critical Issues1. Boolean defaults have inconsistent types (int vs boolean)File: Some booleans get
An AI agent reading the schema may interpret Fix: Normalize in 2. Range defaults stored as strings instead of numbersFile: Five range-type settings have string defaults due to PHP source using quoted literals:
When Fix: Post-processing step: if 3.
|
|
Review notes on the generated schema as the new runtime contract for
|
jjroelofs
left a comment
There was a problem hiding this comment.
Skill Development Review — Settings Schema Auto-generation
Reviewed in the context of the cross-project AI skill infrastructure (dxpr/dxpr_cms#58, dxpr/dxpr_builder#4468, dxpr/rl#32) and skill development best practices (progressive disclosure, content organization, reference material handling).
✅ What's done well
#ai_descriptionas Form API property: This is an elegant approach — the AI guidance lives alongside the form element definitions, invisible to the GUI, and is auto-extracted into the schema. This means developers maintain one source of truth.- Auto-generation via Grunt: The
generate-schematask + watch onfeatures/**/*-theme-settings.incmeans the schema stays in sync during development without manual steps. - Schema richness: 163 settings with type, title, description, ai_description, options, ranges, and defaults. This gives AI agents everything they need to understand and set theme settings correctly.
- Type detection by naming convention: The parser detects
color,theme_color, andfonttypes by key naming conventions (_customsuffix,_font_facesuffix, known color select keys). This is practical and matches how the form API actually works in this theme. - Developer workflow: Edit inc file → watch regenerates schema → commit both. Clean and simple.
⚠️ Progressive disclosure considerations
The generated data/settings-schema.json is 1,554 lines. This is a reference file in the progressive disclosure model — it should be loaded by AI agents only when they need to understand or modify specific theme settings, not loaded into context by default.
The dxpr_theme_helper module (which reads this schema at runtime via dxt:* commands) handles this correctly — it reads the JSON file from the installed theme directory on demand. This is the right pattern: the schema lives as data in the theme, and the Drush commands surface it when needed.
If the Claude skill for theme settings (in dxpr_theme_helper) references this file, ensure it's documented as a reference to be loaded on demand, not embedded in SKILL.md.
📋 Schema generation observations
-
_metasection: Good to includegeneratedtimestamp and field descriptions. Thesectionsarray is useful for agents to understand the settings categories. -
Parser robustness: The parser handles nested form arrays, conditional form elements, and various form API types. A few edge cases to verify:
- Settings that are only visible conditionally (e.g.,
#statesdependent fields) — are these included in the schema? - Settings with
#access= FALSE — these should probably be excluded - The parser extracts
#default_value— does it handle cases where the default is computed (e.g., from a variable)?
- Settings that are only visible conditionally (e.g.,
-
Grunt vs. npm scripts: The project uses Grunt (existing infrastructure), so adding the task there is the right choice. No need to introduce a second build system.
-
Schema validation: Consider adding a simple assertion in the Grunt task that verifies the output has the expected number of settings (or at least > 100), to catch parser regressions early.
📋 Cross-project integration
This PR is the data foundation for the dxt:* Drush commands in dxpr_theme_helper (dxpr/dxpr_theme_helper#40). The architecture is:
dxpr_theme (this PR) → generates data/settings-schema.json
dxpr_theme_helper (separate PR) → reads schema at runtime via dxt:settings:* commands
.claude/skills/dxt/SKILL.md → references schema via dxt:settings:list/get/set commands
This separation of concerns is well-designed — the theme owns its own schema, and the helper module provides the CLI interface.
Summary
Clean data-layer PR that provides the foundation for AI-accessible theme settings. The #ai_description pattern and auto-generation workflow are well thought out. Main consideration is ensuring the schema is treated as a reference file in the progressive disclosure model (loaded on demand, not always in context).
Linked issues
Solution
Adds
#ai_descriptionto all 163 theme settings form elements and auto-generatesdata/settings-schema.jsonvia the Grunt build process. This enablesdxpr_theme_helper'sdxt:*Drush commands to read the settings schema from the installed theme at runtime — no manual cross-repo sync.How it works
features/*-theme-settings.inc— adds form element with#ai_descriptionDEV_WATCH=true docker compose up devauto-regeneratesdata/settings-schema.jsondxpr_theme_helperreads the schema from the theme directory at runtime — zero changes neededFiles
#ai_descriptionadded to all form elements (custom Form API property, invisible to GUI)generate-schematask + watch onfeatures/**/*-theme-settings.incChecklist