From 84947957b52a2ef9f913b4d15f72c0fc54366b34 Mon Sep 17 00:00:00 2001 From: huashen <2494946808@qq.com> Date: Tue, 28 Jul 2026 23:28:54 +0800 Subject: [PATCH 1/2] feat: migrate plugin api v2 --- .github/workflows/plugin-api-v2.yml | 26 ++++++++++++++++++++++++++ plugin.py | 3 ++- tests/test_plugin.py | 6 +++--- 3 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/plugin-api-v2.yml diff --git a/.github/workflows/plugin-api-v2.yml b/.github/workflows/plugin-api-v2.yml new file mode 100644 index 0000000..d754535 --- /dev/null +++ b/.github/workflows/plugin-api-v2.yml @@ -0,0 +1,26 @@ +name: plugin-api-v2 + +on: + pull_request: + push: + +permissions: + contents: read + +jobs: + contract: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 + with: + repository: akashic-plugins/plugin-contracts + ref: 24543445c7b99ca63fcd90b5828f754a148b184c + path: .plugin-contracts + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + - name: Check Plugin API v2 + env: + PYTHONPATH: .plugin-contracts + run: python -m akashic_plugin_contracts check plugin.py diff --git a/plugin.py b/plugin.py index 437ea39..5dc655f 100644 --- a/plugin.py +++ b/plugin.py @@ -28,6 +28,7 @@ def emit(self, event: object) -> None: ... class ObservePlugin(Plugin): + api_version = 2 @classmethod def dashboard_module(cls) -> str | None: return "dashboard.py" @@ -47,7 +48,7 @@ def mobile_ui(cls) -> MobileUiContribution: name = "observe" version = "1.2.0" - async def initialize(self) -> None: + def activate(self) -> None: workspace = self.context.workspace if workspace is None: logger.warning("observe 插件缺少 workspace,跳过加载") diff --git a/tests/test_plugin.py b/tests/test_plugin.py index 618cf56..56d0aee 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -93,7 +93,7 @@ async def _run_mobile_turn_observe_seam( event_bus.on(TurnCommitted, committed.append) try: # 1. 用真实 after-reasoning 持久化生成 assistant message ID - await plugin.initialize() + plugin.activate() session = manager.get_or_create("mobile:observe-seam") message = InboundMessage( channel="mobile", @@ -180,7 +180,7 @@ async def _run_mobile_turn_observe_seam( @pytest.mark.asyncio -async def test_observe_plugin_initialize_and_terminate(tmp_path: Path) -> None: +async def test_observe_plugin_activate_and_terminate(tmp_path: Path) -> None: plugin = ObservePlugin() scope = PluginScope("observe") plugin.context = PluginContext( @@ -193,7 +193,7 @@ async def test_observe_plugin_initialize_and_terminate(tmp_path: Path) -> None: workspace=tmp_path, scope=scope, ) - await plugin.initialize() + plugin.activate() await asyncio.sleep(0.05) await plugin.terminate() assert await scope.aclose() == [] From 9556b317c04afc8874bf6f0116f76001e0394cbb Mon Sep 17 00:00:00 2001 From: huashen <2494946808@qq.com> Date: Wed, 29 Jul 2026 01:56:38 +0800 Subject: [PATCH 2/2] ci: avoid duplicate branch contract gate --- .github/workflows/plugin-api-v2.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/plugin-api-v2.yml b/.github/workflows/plugin-api-v2.yml index d754535..7c1876b 100644 --- a/.github/workflows/plugin-api-v2.yml +++ b/.github/workflows/plugin-api-v2.yml @@ -3,6 +3,8 @@ name: plugin-api-v2 on: pull_request: push: + branches: + - main permissions: contents: read