From ec89bb705564bcd1d0f04a0354c6a5af6b4963a6 Mon Sep 17 00:00:00 2001 From: LEN5010 <1649211052@qq.com> Date: Tue, 6 Oct 2026 23:40:40 -0700 Subject: [PATCH 1/4] refactor: import the public plugin API from len_bot.plugin len_bot.next is internal to the host. Plugins and tests now import len_bot.plugin, len_bot.plugin_testing, len_bot.image_assets and len_bot.text_cards only. Requires the LenBot development commit that moved these modules; the CI host pin still needs updating once it is pushed. --- __init__.py | 2 +- tests/test_counter.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/__init__.py b/__init__.py index a80a8c8..b4a255b 100644 --- a/__init__.py +++ b/__init__.py @@ -1,6 +1,6 @@ """A copyable plugin using only the public interface.""" -from len_bot.next.plugin import Invocation, Plugin, command, fullmatch, tool +from len_bot.plugin import Invocation, Plugin, command, fullmatch, tool class Counter(Plugin): diff --git a/tests/test_counter.py b/tests/test_counter.py index f6dd07c..5c59f19 100644 --- a/tests/test_counter.py +++ b/tests/test_counter.py @@ -5,7 +5,7 @@ import pytest -from len_bot.next.plugin_testing import PluginTest +from len_bot.plugin_testing import PluginTest @pytest.mark.asyncio From 569e7538cfe96064a57f79006e06956aec2bdaf9 Mon Sep 17 00:00:00 2001 From: LEN5010 <1649211052@qq.com> Date: Wed, 7 Oct 2026 00:29:34 -0700 Subject: [PATCH 2/4] =?UTF-8?q?=E6=94=B9=E7=94=A8=20LenBot=20=E7=9A=84?= =?UTF-8?q?=E5=8F=AF=E5=A4=8D=E7=94=A8=E6=8F=92=E4=BB=B6=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CI 和发行改为调用 lendevs/LenBot 的 plugin-ci.yml 与 plugin-release.yml, 跟随宿主 master 测试,不再写死宿主提交;删除本仓库的 scripts/package.py, 打包统一使用宿主的 scripts/package_plugin.py。发行时核对标签与 plugin.toml 版本一致,发行说明只取 CHANGELOG 中当前版本一节。 --- .github/workflows/ci.yml | 26 +------------------------- .github/workflows/release.yml | 16 ++-------------- README.md | 2 +- scripts/package.py | 24 ------------------------ 4 files changed, 4 insertions(+), 64 deletions(-) delete mode 100644 scripts/package.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a1bc35f..50e1942 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,28 +2,4 @@ name: Plugin tests on: [push, pull_request, workflow_dispatch] jobs: test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - path: plugin - - uses: astral-sh/setup-uv@v5 - with: - version: "0.12.13" - - uses: actions/checkout@v4 - with: - repository: lendevs/LenBot - ref: 078d91e0a69948755f6b81dec89aab15842a9fae - path: host-source - - run: uv python install 3.13 - - run: uv venv --python 3.13 - - run: uv pip install ./host-source pytest pytest-asyncio - - name: Install declared plugin dependencies - run: | - uv run --no-project --python .venv/bin/python python -c 'import pathlib,tomllib; data=tomllib.loads(pathlib.Path("plugin/plugin.toml").read_text()); pathlib.Path("plugin-requirements.txt").write_text("\n".join(data.get("dependencies", [])))' - uv pip install --requirements plugin-requirements.txt - - run: uv run --no-project --python ../.venv/bin/python python -m pytest -q --confcutdir=tests - working-directory: plugin - - name: Check runtime ZIP resources - run: uv run --no-project --python ../.venv/bin/python python scripts/package.py "$RUNNER_TEMP/plugin.zip" - working-directory: plugin + uses: lendevs/LenBot/.github/workflows/plugin-ci.yml@master diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4fdff09..158f41c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,17 +5,5 @@ on: permissions: contents: write jobs: - package: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: astral-sh/setup-uv@v5 - with: - version: "0.12.13" - - run: uv python install 3.13 - - name: Package plugin - run: uv run --no-project --python 3.13 python scripts/package.py "plugin-${GITHUB_REF_NAME}.zip" - - name: Publish ZIP - env: - GH_TOKEN: ${{ github.token }} - run: gh release create "$GITHUB_REF_NAME" "plugin-${GITHUB_REF_NAME}.zip" --verify-tag --notes-file CHANGELOG.md + release: + uses: lendevs/LenBot/.github/workflows/plugin-release.yml@master diff --git a/README.md b/README.md index 755a8f0..1cd2e9a 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ uv run --no-sync pytest -q tests CI 固定到包含当前插件接口的宿主开发提交;本次未创建版本标签或 Release。catalog-entry.json 只记录开发安装来源,未公开插件不加入主目录。 -本机生成 ZIP:`uv run --no-project --python 3.13 python scripts/package.py /tmp/plugin.zip`。打包取 Git 已跟踪的运行源码和资源,新增文件需先加入 Git;不会收录本机环境、测试或配置。 +本机生成 ZIP(LenBot 仓库与本仓库放在同一目录下):`uv run --no-project --python 3.13 python ../LenBot/scripts/package_plugin.py . /tmp/plugin.zip`。打包取 Git 已跟踪的运行源码和资源,新增文件需先加入 Git;不会收录本机环境、测试或配置。 ## 工具数量与能力边界 diff --git a/scripts/package.py b/scripts/package.py deleted file mode 100644 index bfc1b41..0000000 --- a/scripts/package.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Build a plugin ZIP from tracked runtime files without publishing it.""" -from pathlib import Path -import subprocess -import sys -import tomllib -from zipfile import ZIP_DEFLATED, ZipFile - -root = Path(__file__).resolve().parents[1] -manifest = tomllib.loads((root / 'plugin.toml').read_text()) -output = Path(sys.argv[1]).resolve() -output.parent.mkdir(parents=True, exist_ok=True) -files = subprocess.check_output(['git', 'ls-files', '-z'], cwd=root).decode().split('\0') -with ZipFile(output, 'w', ZIP_DEFLATED) as archive: - for name in sorted(filter(None, files)): - path = Path(name) - if path.parts[0] in {'prompts', 'skills', 'assets', 'fonts'} or len(path.parts) == 1 and ( - path.suffix in {'.py', '.toml', '.md'} or path.name in {'LICENSE', 'NOTICE'}): - if path.name not in {'pyproject.toml', 'AGENTS.md'}: - archive.write(root / path, name) -with ZipFile(output) as archive: - instructions = manifest.get('model', {}).get('instructions') - if instructions is not None and instructions not in archive.namelist(): - raise ValueError(f'model.instructions resource is not tracked: {instructions}') -print(output) From f34149ba99f68640596f0b9de23f3bcd9e95aaed Mon Sep 17 00:00:00 2001 From: LEN5010 <1649211052@qq.com> Date: Wed, 7 Oct 2026 00:31:30 -0700 Subject: [PATCH 3/4] =?UTF-8?q?README=20=E6=94=B9=E5=86=99=20CI=20?= =?UTF-8?q?=E8=AF=B4=E6=98=8E=EF=BC=9A=E8=B7=9F=E9=9A=8F=E5=AE=BF=E4=B8=BB?= =?UTF-8?q?=20master=EF=BC=8C=E4=B8=8D=E5=86=8D=E5=9B=BA=E5=AE=9A=E5=AE=BF?= =?UTF-8?q?=E4=B8=BB=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.en.md | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.en.md b/README.en.md index 77adaa2..1474d10 100644 --- a/README.en.md +++ b/README.en.md @@ -25,7 +25,7 @@ Counts are stored per group and survive source updates. uv run --no-sync pytest -q tests ``` -Tests use the host's `PluginTest` harness to simulate messages and configuration, so LenBot does not need to run. CI installs the host version pinned in `.github/workflows/ci.yml`; update it when you move to a newer host. +Tests use the host's `PluginTest` harness to simulate messages and configuration, so LenBot does not need to run. CI calls LenBot's reusable workflow, which tests and packages the plugin against host `master` by default; pass `host_ref` in `.github/workflows/ci.yml` to pin a host version. ## Releasing diff --git a/README.md b/README.md index 1cd2e9a..239de3e 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ uv run --no-sync pytest -q tests ``` -测试用宿主提供的 `PluginTest` 模拟消息和配置,不用启动 LenBot。CI 会安装 `.github/workflows/ci.yml` 里固定的宿主版本再跑测试,升级宿主时改这个版本。 +测试用宿主提供的 `PluginTest` 模拟消息和配置,不用启动 LenBot。CI 调用 LenBot 提供的可复用工作流,默认用宿主 `master` 跑测试和打包检查;需要固定宿主版本时在 `.github/workflows/ci.yml` 里传 `host_ref`。 ## 发布 @@ -45,7 +45,7 @@ uv run --no-sync pytest -q tests 工具采用接口 1 的显式简介、Field 参数说明与 `prompts/tools.md` 共享指南,返回原生 JSON 或文本。用 `PluginTest.preview_tools()` 查看模型说明、参数与可用性;模型服务默认关闭,真实发送仍单独核对。兼容和更新事项见 [CHANGELOG](CHANGELOG.md)。 -CI 固定到包含当前插件接口的宿主开发提交;本次未创建版本标签或 Release。catalog-entry.json 只记录开发安装来源,未公开插件不加入主目录。 +CI 调用 LenBot 的可复用工作流,跟随宿主 master 测试;本次未创建版本标签或 Release。catalog-entry.json 只记录开发安装来源,未公开插件不加入主目录。 本机生成 ZIP(LenBot 仓库与本仓库放在同一目录下):`uv run --no-project --python 3.13 python ../LenBot/scripts/package_plugin.py . /tmp/plugin.zip`。打包取 Git 已跟踪的运行源码和资源,新增文件需先加入 Git;不会收录本机环境、测试或配置。 From 139472e2551df60e44c3d2c5a55526f7756e951f Mon Sep 17 00:00:00 2001 From: LEN5010 <1649211052@qq.com> Date: Wed, 7 Oct 2026 00:48:33 -0700 Subject: [PATCH 4/4] =?UTF-8?q?CHANGELOG=20=E5=8E=BB=E6=8E=89=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=A5=97=E8=AF=9D=EF=BC=8C=E5=8F=AA=E5=86=99=E6=9C=AC?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 发行说明直接取自本版本一节,删去未发行开发版本之类只适用于开发期的说明。 --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d5dd6f2..cd06892 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # 1.1.0 -适配 LenBot 首版 0.2.0 的插件接口 1:显式工具简介、参数说明、按需共享指南与 JSON 结果。使用新增接口的版本需要包含插件生态改造的最终 0.2.0 基线;早期同版本开发提交不支持。 +需要 LenBot 0.2.0 起的插件接口 1(从 `len_bot.plugin` 导入)。插件名、配置和业务数据不变,无需数据迁移。 -保留原插件名、配置和业务数据,无需数据迁移。与旧宿主共同回退时须使用原插件版本。当前为未发行开发版本;只提交源码,不创建版本标签或 Release。 - -模板保留查询和后台发送两个工具,增加按业务能力合并与严格 action 分支的作者说明;本次仍是开发改动,未创建标签或 Release。 +- 模板保留查询(`counter_read`)和后台发送(`counter_card`)两个工具,并说明怎样按业务能力合并工具、用严格的 `action` 分支组织相关操作。 +- CI 和发行改用 LenBot 提供的可复用工作流。 +- 工具带显式简介和参数说明,相关用法写在按需加载的共享指南里,结果返回 JSON。