Skip to main content

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.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for amctl-template-ambot-plugin 0.1.2
File Size Uploaded Provenance Actions
amctl_template_ambot_plugin-0.1.2.tar.gz 13.5 kB Without provenance Details for amctl_template_ambot_plugin-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for amctl-template-ambot-plugin 0.1.2
File Interpreter ABI Platform Actions
amctl_template_ambot_plugin-0.1.2-py3-none-any.whl Python 3 none any Details for amctl_template_ambot_plugin-0.1.2-py3-none-any.whl

Total release size: 30.5 kB

Release files / amctl_template_ambot_plugin-0.1.2.tar.gz

Download URL amctl_template_ambot_plugin-0.1.2.tar.gz
Size 13.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a48547a00d979b3c64371f314c4ff1b35ef21d2077c313d572f7b465508cabe7
BLAKE2b-256 checksum
How to use checksums
3697a7bf10b1f0498214005d3bcfd622749a6b9d8f9334c390136a1a687817a7
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.2-py3-none-any.whl

Download URL amctl_template_ambot_plugin-0.1.2-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcea76768cbe78e72e0ab6873d78045d98aee9e4885a0b1598d53816199e5e6f
BLAKE2b-256 checksum
How to use checksums
fdb2cdec19ef436ce5a4d512a66e8bec2464262c9982e1a0cb51328253199d94
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.2

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page