amctl-template-ambot-plugin
amctl 模板:生成一个带 WebUI 页面、前端构建链和发布流程的 AmritaBot 插件工程。
安装与使用
uv tool install amctl --with amctl-template-ambot-plugin
amctl create -t ambot_plugin -n my-plugin
cd my-plugin
uv sync
cd frontend && bun install && bun run build && cd ..
uv run amrita run
生成后:WebUI 侧边栏出现「my-plugin」页面,页面数据走 /api/my-plugin/items,
前端产物在插件包内,随 wheel 分发——部署机不需要 Node。
生成什么
my-plugin/
├── pyproject.toml # 依赖 amrita>=1.18.0,package-data 带上产物
├── amrita_plugin_my_plugin/
│ ├── __init__.py # PluginMetadata,import 即注册
│ ├── config.py # page_title / page_category
│ ├── api.py # /api/my-plugin/items 的 GET 与 POST
│ ├── webui.py # mount_plugin_assets + register_page(module_dir=...)
│ └── assets/ # 构建产物,构建前不存在
├── frontend/
│ ├── amrita-plugin.json # 入口、产物目录、静态资源
│ ├── package.json # 依赖 @amrita-constant/webui-plugin-kit
│ └── src/index.tsx # 示例页面(Card / Input / Button / Badge)
└── .github/workflows/ # CI 检查
项目名会被规整成三种形态:发行名 amrita-plugin-my-plugin、导入名
amrita_plugin_my_plugin、挂载名 my_plugin(同时是 /plugin-assets/<name>/
与页面路径 /my_plugin)。
依赖的两个约定
- 宿主契约版本 3:插件产物末尾带
export const amritaHostContract = 3, 宿主加载时比对;React 等运行时依赖通过window.__AMRITA_HOST__注入, 插件不打包第二份。 - 产物挂载:
mount_plugin_assets("my_plugin", assets/)必须在插件 import 期调用, 晚于driver.on_startup的 catch-all 路由就收不到请求;产物缺失时只告警, 页面显示「产物不可用」而不阻断插件加载。
构建器来自 @amrita-constant/webui-plugin-kit,
UI 组件与类型来自 @amrita-constant/ambot-ui。
开发这个模板
模板本体是 amctl.templ 命名空间包,文件后缀决定处理方式:
| 后缀 | 行为 |
|---|---|
.tmpl |
Jinja2 渲染,输出时去掉后缀 |
.pre |
原样复制,输出时去掉后缀(用于含 ${{ }} 的 GitHub Actions 文件) |
| 其他 | 原样复制 |
目录名 {{ module }} 也会被渲染。改完本地验证:
uv build
uv pip install --force-reinstall dist/*.whl # 装进有 amctl 的环境
amctl create -t ambot_plugin -n demo-panel --frozen -o /tmp/gen
cd /tmp/gen/demo-panel/frontend && bun install && bun run typecheck && bun run build
Metadata
Release files for amctl-template-ambot-plugin 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| amctl_template_ambot_plugin-0.1.3.tar.gz | 13.5 kB | Without provenance | Details for amctl_template_ambot_plugin-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| amctl_template_ambot_plugin-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for amctl_template_ambot_plugin-0.1.3-py3-none-any.whl |
Total release size: 30.4 kB
Release files / amctl_template_ambot_plugin-0.1.3.tar.gz
| Download URL | amctl_template_ambot_plugin-0.1.3.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cff2b36fb127b8e202bd291e4bcdecadc263f45ba45cf4ca0d59cede0b6d8aab
|
|
BLAKE2b-256 checksum How to use checksums |
898ba86e4cda65abe7821a9d76d9b183a615e3b3f522946fc81d541df1a85d38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / amctl_template_ambot_plugin-0.1.3-py3-none-any.whl
| Download URL | amctl_template_ambot_plugin-0.1.3-py3-none-any.whl |
|---|---|
| Size | 16.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9e54cc0bd3b3fedac45cb2abd34ed6dce469f92c9de3a3371673c4d508715cd7
|
|
BLAKE2b-256 checksum How to use checksums |
0a044a53d6b077a9a3e8b00491545a77cc6279080305ee30c4d96084bf6ac9a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for amctl-template-ambot-plugin 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.