feat: 新增脚手架/开发模式/权限白名单/system-monitor插件
- nebula create mod/key/list-templates 模组脚手架 - nebula dev 开发模式热重载 - manifest permissions.imports 权限白名单机制 - system-monitor 系统监控仪表盘插件 - 默认端口统一为 10086 - 修复 _init_nbpf 误读 Ed25519 私钥为 RSA 的 bug - 更新 README.md 文档
This commit is contained in:
24
oss/templates/mod/README.md
Normal file
24
oss/templates/mod/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# @{{ author }}/{{ mod_name }}
|
||||
|
||||
{{ description }}
|
||||
|
||||
## 安装
|
||||
|
||||
将 `{{ mod_name }}.nbpf` 放入 NebulaShell 的 `mods/` 目录即可。
|
||||
|
||||
## 开发
|
||||
|
||||
```bash
|
||||
# 安装依赖
|
||||
pip install -r requirements.txt
|
||||
|
||||
# 打包
|
||||
nebula nbpf pack ./{{ mod_name }} -o {{ mod_name }}.nbpf \
|
||||
--ed25519-key ./keys/ed25519.pem \
|
||||
--rsa-key ./keys/rsa.pem \
|
||||
--signer "{{ author }}"
|
||||
```
|
||||
|
||||
## 许可证
|
||||
|
||||
MIT
|
||||
50
oss/templates/mod/main.py
Normal file
50
oss/templates/mod/main.py
Normal file
@@ -0,0 +1,50 @@
|
||||
"""
|
||||
@{{ author }}/{{ mod_name }}
|
||||
{{ description }}
|
||||
"""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
# 模组信息(可选,用于动态获取)
|
||||
NAME = "{{ mod_name }}"
|
||||
VERSION = "0.1.0"
|
||||
|
||||
|
||||
def init(deps):
|
||||
"""
|
||||
模组初始化。
|
||||
deps 包含:
|
||||
- deps["services"] — 其他模组注册的服务
|
||||
- deps["config"] — 当前模组的配置
|
||||
- deps["logger"] — 日志工具
|
||||
"""
|
||||
logger = deps.get("logger")
|
||||
if logger:
|
||||
logger.info(f"{NAME} v{VERSION} 初始化完成")
|
||||
|
||||
|
||||
def start():
|
||||
"""模组启动。init 成功后调用。"""
|
||||
pass
|
||||
|
||||
|
||||
def stop():
|
||||
"""模组停止。框架关闭时调用,释放资源。"""
|
||||
pass
|
||||
|
||||
|
||||
def reload(config: dict):
|
||||
"""热重载配置(可选)"""
|
||||
pass
|
||||
|
||||
|
||||
def health() -> dict:
|
||||
"""健康检查(可选)"""
|
||||
return {"status": "ok", "version": VERSION}
|
||||
|
||||
|
||||
def stats() -> dict:
|
||||
"""统计信息(可选)"""
|
||||
return {}
|
||||
22
oss/templates/mod/manifest.json
Normal file
22
oss/templates/mod/manifest.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "@{{ author }}/{{ mod_name }}",
|
||||
"version": "0.1.0",
|
||||
"description": "{{ description }}",
|
||||
"author": "{{ author }}",
|
||||
"license": "MIT",
|
||||
"type": "{{ mod_type }}",
|
||||
"main": "main.py",
|
||||
"enabled": true,
|
||||
"priority": 999,
|
||||
"runtime": {
|
||||
"language": "python",
|
||||
"entry_point": "main.py",
|
||||
"requirements": []
|
||||
},
|
||||
"capabilities": [],
|
||||
"services": {
|
||||
"provides": [],
|
||||
"consumes": []
|
||||
},
|
||||
"config": {}
|
||||
}
|
||||
Reference in New Issue
Block a user