discourse/plugins/discourse-ai/spec/support
Alan Guo Xiang Tan 467d42c2df
DEV: Add DiscourseAi.register_feature public API (#39127)
This commit introduces `DiscourseAi.register_feature` as the public
API for other plugins to register AI-powered features. Previously,
plugins had to manually register with `DiscoursePluginRegistry`, define
their own agent site setting in `settings.yml`, create their own
`EnumSiteSetting` subclass for the agent enum, register the site setting
area, and assign settings to that area. This was a lot of boilerplate
that every plugin would need to duplicate.

This commit consolidates all of that into a single
`DiscourseAi.register_feature` call that handles:

1. Auto-defining the `<module>_<feature>_agent` site setting with the
correct enum, `depends_on`, and `depends_behavior` configuration
2. Registering the `ai-features/<module_name>` site setting area so the
admin edit page can load the settings
3. Assigning both the generated agent setting and the
`enabled_by_setting` to that area
4. Registering the feature in the `DiscoursePluginRegistry` external AI
features registry

The data-explorer plugin is updated to use the new API, which lets it
drop its custom `AiAgentEnumerator` class, the manual
`data_explorer_query_generation_agent` setting definition in
`settings.yml`, and the manual area registration and assignment code.
2026-05-12 10:16:07 +08:00
..
embeddings_generation_stubs.rb
fake_external_agent.rb DEV: Add DiscourseAi.register_feature public API (#39127) 2026-05-12 10:16:07 +08:00
sentiment_inference_stubs.rb