Skip to content

feat(memory): 在菜单中展示记忆管理并隐藏鉴权 DMN 命令 - #5

Merged
JohnRichard4096 merged 2 commits into
mainfrom
fix/menu-metadata
Oct 18, 2026
Merged

JohnRichard4096 merged 2 commits into
mainfrom
fix/menu-metadata

Conversation

@AmriaLin

@AmriaLin AmriaLin commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

问题

/memory 从未出现在菜单里,带不带 --sudo 都一样。

原因

Amrita 的菜单管理器从 nonebot.get_loaded_plugins() 收集数据,generate_menu 的第一道判断是:

if not plugin.metadata or not plugin.matcher_grouping:
    continue

plugin-memory 没有定义 __plugin_meta__,plugin.metadata 恒为 None,整个插件在任何可见性判断之前就被跳过。--sudo 只作用于 show_if 的权限节点,管不到这一层,所以开不开都看不到。

matchers.py 里的 MatcherData 本身没问题,缺的是外层插件元数据。

改动

  • amrita_plugin_memory/__init__.py 补 __plugin_meta__:名称、描述、用法、homepage、type="application"、supported_adapters={"~onebot.v11"}
  • 版本 bump 到 0.7.1(pyproject 与 uv.lock 同步)

验证

本地 pyright 0 errors,ruff check / format 均通过。合并后菜单的模块列表里会出现「Amrita长期记忆」,其下是「记忆管理」一条。

补充:dmn 收为隐藏管理选项

按讨论,/memory dmn(含 run、触发)不做成独立菜单项,也不出现在 usage 提示里:

  • MatcherData 的 description 与 usage 移除 dmn,菜单里只剩 list / search / delete / memo
  • 命令入口先校验身份:超级用户白名单优先,其次 lp.admin 权限节点;不通过直接回「未知选项:dmn」,不暴露这是管理入口
  • _trigger_dmn 去掉自身鉴权,改为调用前必须已校验,避免双份判断口径不一致
  • README 命令参考同步,说明这是隐藏选项与鉴权顺序

Summary by Sourcery

Expose the memory plugin in Amrita’s menu while securing and hiding its manual subconscious scheduling command.

New Features:

  • Add plugin metadata so Amrita can display long-term memory management in its menu.

Bug Fixes:

  • Make the hidden dmn/run/触发 management command enforce administrator access and conceal unauthorized usage as an unknown option.

Enhancements:

  • Keep dmn management commands out of menu entries and usage hints while documenting their administrator authorization behavior.
  • Bump the package version to 0.7.1.

Documentation:

  • Update the command reference to document the hidden dmn option and its authorization order.

Amrita 的菜单管理器会跳过没有 metadata 的插件,plugin-memory 一直没定义
__plugin_meta__,所以 /memory 从不进菜单,与 --sudo 无关。顺便 bump 到 0.7.1。
@sourcery-ai

sourcery-ai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

本 PR 通过在插件入口定义 __plugin_meta__,补齐菜单管理器依赖的外层元数据,让长期记忆插件及其“记忆管理”matcher 能进入菜单;同时将版本从 0.7.0 bump 至 0.7.1 并同步锁文件。

Flow diagram for memory plugin menu visibility

flowchart TD
    A["Load amrita_plugin_memory"] --> B["Read __plugin_meta__"]
    B --> C["generate_menu"]
    C --> D{metadata and matcher_grouping exist}
    D -->|yes| E["Show Amrita长期记忆"]
    E --> F["Show 记忆管理"]
    D -->|no| G["Skip plugin"]
Loading

File-Level Changes

Change Details Files
为插件补充 NoneBot 插件元数据,使其能够被 Amrita 菜单管理器发现并展示。
  • 新增插件名称、描述、用法、主页和 application 类型元数据
  • 声明仅支持 OneBot V11 适配器
  • 保留现有菜单与依赖加载流程,依赖菜单的 matcher 分组生成“记忆管理”项
amrita_plugin_memory/__init__.py
将插件版本提升至 0.7.1,并同步锁文件。
  • 更新项目声明版本
  • 更新 uv.lock 中对应版本信息
pyproject.toml
uv.lock

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Oct 18, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

菜单与 usage 里不再出现 dmn;调用时先校验超级用户或 lp.admin,
不通过直接回「未知选项」,避免暴露管理入口。README 同步说明。
@sourcery-ai
sourcery-ai Bot dismissed their stale review October 18, 2026 04:35

Sourcery withdrew this approval because the latest commits introduced blocking findings.

@JohnRichard4096

Copy link
Copy Markdown
Member

@sourcery-ai title

@sourcery-ai sourcery-ai Bot changed the title fix: 补上 __plugin_meta__,让记忆管理进入菜单 feat(memory): 在菜单中展示记忆管理并隐藏鉴权 DMN 命令 Oct 18, 2026
@JohnRichard4096
JohnRichard4096 merged commit 8c3f5ad into main Oct 18, 2026
3 checks passed
@JohnRichard4096
JohnRichard4096 deleted the fix/menu-metadata branch October 18, 2026 04:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants