Skip to content

feat(create-plugin): add grafana-app-sdk CUE kind code generation - #2853

Draft
stevesg wants to merge 8 commits into
grafana:mainfrom
stevesg:app-sdk-npm-generate
Draft

feat(create-plugin): add grafana-app-sdk CUE kind code generation#2853
stevesg wants to merge 8 commits into
grafana:mainfrom
stevesg:app-sdk-npm-generate

Conversation

@stevesg

@stevesg stevesg commented Aug 24, 2026

Copy link
Copy Markdown

What this PR does / why we need it:

Adds opt-in support for grafana-app-sdk:

$ create-plugin add experimental-app-sdk

Code generation runs through npm run generate:kinds, a convenience script to download the grafana-app-sdk binary and run it.

This change covers frontend-only app plugins: kinds/config.cue sets codegen: goEnabled: false, so no Go code, go.mod dependency, or backend is involved. Validation/mutation/conversion and custom routes are not supported.

Summary of changes:

  • templates/app-sdk/: CUE kinds, the generate script, and a README
  • kinds/config.cue writes the manifest straight into src/app-sdk-manifest.json, so the frontend build's existing **/*.json copy pattern picks it up with no dedicated copy step
  • docker-compose.yaml: enable the plugins.appSDKManifest feature toggle
  • AGENTS/: app-sdk.md and edit to instructions.md to point at it

Which issue(s) this PR fixes:

Part of #2842

Special notes for your reviewer:

@cla-assistant

cla-assistant Bot commented Aug 24, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@cla-assistant

cla-assistant Bot commented Aug 24, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@grafana-catalog-project-bot grafana-catalog-project-bot Bot moved this from 📬 Triage to 🧑‍💻 In development in Grafana Catalog Team Aug 24, 2026
@stevesg stevesg added the preview Opts the PR into pkg.pr.new preview publishing label Aug 24, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 24, 2026

Copy link
Copy Markdown

Open in StackBlitz

@grafana/create-plugin

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/create-plugin@124b3b6 -D

@grafana/eslint-config

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/eslint-config@124b3b6 -D

@grafana/eslint-plugin-plugins

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/eslint-plugin-plugins@124b3b6 -D

@grafana/plugin-docs-cli

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/plugin-docs-cli@124b3b6 -D

@grafana/plugin-docs-parser

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/plugin-docs-parser@124b3b6 -D

@grafana/plugin-e2e

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/plugin-e2e@124b3b6 -D

@grafana/plugin-meta-extractor

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/plugin-meta-extractor@124b3b6 -D

@grafana/plugin-types-bundler

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/plugin-types-bundler@124b3b6 -D

@grafana/react-detect

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/react-detect@124b3b6 -D

@grafana/sign-plugin

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/sign-plugin@124b3b6 -D

@grafana/tsconfig

npm i https://pkg.pr.new/grafana/plugin-tools/@grafana/tsconfig@124b3b6 -D

commit: 124b3b6

@sunker sunker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really promising. I really like the simplicity of this. Feels like it aligns really well with the goal defined in the product DNA. Also like the fact that app sdk support is optionally additional and that it can live alongside existing APIs. Added some minor inline comments. Aside from that, I have the following high-level feedback:

Since the add command mechnism was introduced we're moving away from feature toggles in the root command and try to enable "optional capabilities" via the add cmd instead. So I'd drop --feature-flags=experimentalAppSdk and only push on add experimental-app-sdk for now. Once these APIs for app sdk have proven stable for internal users and we have a clear path for community plugins, we can flip to enabling app sdk by default for new scaffolded plugins too. Since the short term goal is to get internal devs started quickly, the add script is what we should focus on IMO.

Just note that internal plugins that have been around for a while may have a different file structure etc, so worth testing your add script against a few real ones before announcing internally. I tried it on a 7.6.0 app plugin and hit a couple of smaller issues things (see inlinbe comments). Also, while this is being actively worked on you may not even want to merge the add cmd yet, simply pointing people at the pre-release is probably easier:

npx https://pkg.pr.new/grafana/plugin-tools/@grafana/create-plugin@2d6533a add experimental-app-sdk

IIUC there's nothing protecting us from drift between the CUE and the generated code right now. Easy to edit a kind, forget to regenerate and commit and typecheck won't catch it since the stale types are still valid ts. Not necessarily something that needs to be addressed in this PR, but would be good to scaffold a workflow that protects against this at some point.

Comment thread packages/create-plugin/src/constants.ts Outdated
Comment thread packages/create-plugin/templates/app-sdk/kinds/config.cue
Comment thread packages/create-plugin/src/codemods/additions/scripts/app-sdk.ts Outdated
Comment thread packages/create-plugin/src/codemods/additions/scripts/app-sdk.ts
Comment thread packages/create-plugin/src/codemods/additions/scripts/app-sdk.ts
Comment thread packages/create-plugin/templates/common/_package.json Outdated
*/
export default function appSdk(context: Context): Context {
if (!isAppPlugin(context)) {
return context;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this working in all versions of Grafana? If only supported in certain versions, you need to check grafanaDependency in plugin.json and take necessary actions if the plugin supports version of Grafana that dot not support app platform APIs.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a nice idea, didn't think of that. Though the work is still under development in so we don't know the exact version number yet.

@stevesg

stevesg commented Aug 24, 2026

Copy link
Copy Markdown
Author

Thanks for the valuable feedback, appreciate it.

I've removed the feature-flag version which cleaned up a lot of code, will address the other points too shortly.

Adds opt-in support for `grafana-app-sdk` via feature flag or `add`:

```
$ create-plugin --feature-flags=experimentalAppSdk
$ create-plugin add experimental-app-sdk
```

Code generation runs through `npm run generate:kinds`, a convenience script to
download the grafana-app-sdk binary and run it.

This change covers frontend-only app plugins: `kinds/config.cue` sets
`codegen: goEnabled: false`, so no Go code, go.mod dependency, or backend is
involved. Validation/mutation/conversion and custom routes are not supported.

Summary of changes:

- templates/app-sdk/: CUE kinds, the generate script, and a README
- kinds/config.cue writes the manifest straight into src/app-sdk-manifest.json,
  so the frontend build's existing **/*.json copy pattern picks it up with no
  dedicated copy step
- docker-compose.yaml: enable the plugins.appSDKManifest feature toggle
- AGENTS/: app-sdk.md and edit to instructions.md to point at it
@stevesg
stevesg force-pushed the app-sdk-npm-generate branch from fb2aa12 to 124b3b6 Compare August 25, 2026 08:00
@stevesg

stevesg commented Aug 25, 2026

Copy link
Copy Markdown
Author

Addressed most of the feedback - will do a round of manual testing on some existing plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Opts the PR into pkg.pr.new preview publishing

Projects

Status: 🧑‍💻 In development

Development

Successfully merging this pull request may close these issues.

2 participants