Add a `kolibri plugin create` scaffolder command
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
Recreate cookiecutter-kolibri-plugin as a built-in kolibri plugin create command that scaffolds a new Kolibri plugin. The cookiecutter is unmaintained (last touched 2022) and its template reflects an obsolete plugin structure, so it is rebuilt from current conventions rather than ported. Interactive by default, fully scriptable via flags.
Complexity: Medium Target branch: develop
Context
- The
kolibriCLI is click-based and already has akolibri plugingroup (enable/disable/apply/listinkolibri/utils/cli.py); the new subcommand joins it. Scaffolding needs no Django stack (cls=KolibriCommand). - Every plugin is discovered via a
kolibri.pluginsentry point. A package declares it in its ownpyproject.toml; a module declares it in the nearest enclosingpyproject.toml. - A survey of the 26 in-repo plugins reduces to four reusable surfaces: backend-only, content viewer (
ContentRendererHook), single-page app (NavigationHook+WebpackBundleHook+ namespaced API), and global injector (FrontEndBaseSyncHook, injects into the base template). - No
jinja2/cookiecutterdependency exists; Django's built-in template engine is used standalone viadjango.template.Engine(constructed directly — no app registry orinitialize()needed) for placeholder substitution.
The Change
Add kolibri plugin create — an interactive scaffolder, fully overridable by flags (a flag supplied skips its prompt; all flags supplied = non-interactive).
Positional args (both required): the readable plugin name (e.g. "My Thing") and the target parent directory.
Flags / prompts:
--package/--module— package: a new self-contained package (<path>/kolibri-my-thing-plugin/, ownpyproject.tomldeclaring the entry point). module: a bare module (<path>/my_thing/) registered in the nearest enclosingpyproject.toml. Default package. Mode is never auto-detected — walking up dirs would trip overpython_packages/*/pyproject.toml.--surface—backend-only|content-viewer|single-page-app|global-injector--description,--author,--email(default Learning Equality)- single-page-app only:
--url-slug
The name derives the directory, module, and MyThingPlugin class name; package mode uses kolibri-my-thing-plugin/kolibri_my_thing_plugin, module mode a short my_thing.
Each surface generates a working, discoverable plugin:
| Surface | kolibri_plugin.py |
Frontend | Backend |
|---|---|---|---|
| backend-only | bare KolibriPluginBase |
– | – |
| content-viewer | ContentRendererHook(bundle_id="main", presets=()) (empty placeholder) |
build config, frontend/module.js, starter view |
– |
| single-page-app | WebpackBundleHook + NavigationHook |
frontend/{module.js, routes/, views/} |
api_urls.py + viewsets.py, urls.py |
| global-injector | WebpackBundleHook + FrontEndBaseSyncHook |
build config, frontend/module.js |
– |
Registration: package mode writes the kolibri.plugins entry point into the generated pyproject.toml; module mode auto-inserts it (sorted) into the nearest enclosing pyproject.toml's [project.entry-points."kolibri.plugins"] table, warning and printing the line if none is found.
Out of Scope
- One-off hook kinds are not templated — theme, auth login/logout, OIDC provider, facility sync, network discovery. Authors copy the existing exemplar plugin.
- No backend stubs beyond the single-page-app's default API:
root_view_urls,django_settings,kolibri_optionsare not generated. - No
RoleBasedRedirectHookwiring. - Archiving
cookiecutter-kolibri-plugin— a separate follow-up, not this task.
Acceptance Criteria
General
- [ ]
kolibri plugin createis a subcommand of thekolibri plugingroup and runs without booting Django. - [ ] Prompts interactively for name, target path, mode, surface, and metadata; each prompt is skipped when its flag is given; with all flags supplied it runs fully non-interactively.
- [ ] The plugin name and target path are required positionals; a clear error is shown if either is missing.
- [ ] Package mode creates
<path>/kolibri-<name>-plugin/with its ownpyproject.tomldeclaring thekolibri.pluginsentry point. - [ ] Module mode creates
<path>/<name>/and inserts the entry point (sorted) into the nearest enclosingpyproject.toml; if none is found, it warns and prints the line to add. - [ ] backend-only generates a bare
KolibriPluginBaseand no frontend or backend files. - [ ] content-viewer generates a
ContentRendererHookwith an emptypresets=()plus the frontend build and starter view. - [ ] single-page-app generates
WebpackBundleHook+NavigationHook, the frontend SPA files, andapi_urls.py+viewsets.py+urls.py. - [ ] global-injector generates
WebpackBundleHook+FrontEndBaseSyncHookplus the frontend build. - [ ] Templating uses Django's built-in template engine; no new runtime dependency is added.
Testing
- [ ] For each surface, one test asserts the command generates the expected files (with correctly derived names) and a
kolibri_plugin.pythat imports. - [ ] Entry-point registration is covered once per mode: package writes its own
pyproject.toml; module inserts into the enclosing one. - [ ] One integration test generates a single-page-app plugin and asserts it is discoverable and enable-able.
References
- Archived-to-be source: https://github.com/learningequality/cookiecutter-kolibri-plugin
- Exemplar plugins to imitate:
kolibri/plugins/media_player(content-viewer),kolibri/plugins/user_profile(single-page-app),python_packages/kolibri-sentry-plugin(global-injector)
AI usage
Drafted with Claude Code, which surveyed the in-repo plugins and read the existing kolibri plugin CLI group; I drove every scope decision. I verified the surface archetypes and entry-point mechanism against the cited exemplar plugins and reviewed each section before creating the issue.
Plan: Add kolibri plugin create — an interactive, fully-flag-overridable CLI scaffolder that generates a working, discoverable Kolibri plugin for one of four surfaces (backend-only, content-viewer, single-page-app, global-injector) in either package or module mode.
- [ ] Name derivation (
names.py) - [ ] Template rendering core (
render.py) - [ ] Entry-point registration (
entrypoint.py) - [ ] Surface manifest + orchestrator + backend-only surface
- [ ] content-viewer surface
- [ ] single-page-app surface
- [ ] global-injector surface
- [ ]
kolibri plugin createCLI subcommand - [ ] Integration test — single-page-app discoverable and enable-able
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
- Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
- Ran the project's full test suite and linter before committing
- For UI changes: captured live screenshots to verify rendering
- For backend changes: verified with example API/CLI output
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.