-
Notifications
You must be signed in to change notification settings - Fork 37
Vibe: Scaffolding agents.md for datasource plugins #2322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hello! 👋 This repository uses Auto for releasing packages using PR labels. ✨ This PR can be merged but will not trigger a new release. To trigger a new release add the |
| - `src/datasource.ts` - Datasource implementation | ||
| - `src/components/QueryEditor.tsx` — Query builder UI | ||
| - `src/components/ConfigEditor.tsx` — Data source settings UI | ||
| - `src/types.ts` — Shared frontend models |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
models or types?
| - Keep layouts responsive (use `width`/`height`) | ||
| - Avoid new dependencies unless necessary + Grafana-compatible | ||
| - Maintain consistent file structure and predictable types | ||
| - Use **`@grafana/plugin-e2e`** for E2E tests and **always use versioned selectors** to interact with the Grafana UI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - Use **`@grafana/plugin-e2e`** for E2E tests and **always use versioned selectors** to interact with the Grafana UI. | |
| - Use npm package called **`@grafana/plugin-e2e`** for E2E tests and **always use versioned selectors** to interact with the Grafana UI. |
| **plugin.json** | ||
|
|
||
| - Declares plugin ID, type (`datasource`), name, version | ||
| - Loaded by Grafana at startup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this get more details beyond "Loaded by Grafana at startup" - e.g. why it is loaded and what the purpose is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we could specify that the backend will be loaded if backend: true is set, not sure if we want to talk about other properties (alerts, annotations, etc).
|
|
||
| ## Boundaries | ||
|
|
||
| You must **NOT**: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add "Do not log sensitive data"
|
We should probably add CLAUDE.md file pointing to Agents.md like this: https://github.com/grafana/plugin-tools/blob/3aed54e7d9d26d14dfbaa229806c3377391ccfcc/CLAUDE.md?plain=1 |
andresmgot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bunch of comments here 👍
| **plugin.json** | ||
|
|
||
| - Declares plugin ID, type (`datasource`), name, version | ||
| - Loaded by Grafana at startup |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, we could specify that the backend will be loaded if backend: true is set, not sure if we want to talk about other properties (alerts, annotations, etc).
| - CheckHealth (validates API key from settings) | ||
| - Dispose (cleanup hook). | ||
| - NewDatasource factory called when Grafana starts instance of plugin | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like the default plugin also comes with a pkg/models/settings.go ?
| - Use idiomatic React + TypeScript | ||
| - Use secureJsonData instead of jsonData for credentials and sensitive data | ||
| - Error happening should be logged with level `error` | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bunch of "shoulds" (not sure if worth of having all, extracted from best practices):
- Implement a health check
- Add template variables support
- Skip execution for hidden or empty queries
- Specify a default query
- Add support for alerting (if backend enabled)
- Keep cached connections (if backend enabled)
| - Break public APIs (query model) | ||
| - Use the local file system | ||
| - Use environment variables | ||
| - Execute arbitrary code in the backend |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
more "shouldn'ts":
- Use upstream Golang HTTP client, SHOULD use Grafana plugin SDK HTTP client instead.
- Use "info" log level, use "debug" or "error" instead.
|
|
||
| export const plugin = new DataSourcePlugin<DataSource, MyQuery, MyDataSourceOptions>(DataSource) | ||
| .setQueryEditor(QueryEditor) | ||
| .setVariableQueryEditor(VariableQueryEditor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach is deprecated, better to use a more modern example
What this PR does / why we need it:
It will add an agents.md file that cover the fundamentals of datasource plugins (with and without backend). We are following the convention where we put generic information below
.configfolder (which should not be modified by the developer). Then we reference that file from the projectAGENTS.mdwhere the developers of the plugin can add more plugin specific details.Which issue(s) this PR fixes:
Fixes https://github.com/grafana/grafana-community-team/issues/674
Special notes for your reviewer: