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/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。 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 755a8f0..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,9 +45,9 @@ 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:`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/__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/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) 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