From 78c34dd79ca18e79a484a30522508ac93887e265 Mon Sep 17 00:00:00 2001 From: huashen <2494946808@qq.com> Date: Mon, 24 Aug 2026 22:55:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=B9=E9=BD=90=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=A5=91=E7=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- akashic.plugin.toml | 2 +- plugin.py | 10 ++++++---- tests/test_plugin.py | 22 ++++++++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/akashic.plugin.toml b/akashic.plugin.toml index af23561..82265e4 100644 --- a/akashic.plugin.toml +++ b/akashic.plugin.toml @@ -1,5 +1,5 @@ schema_version = 1 name = "emotion" -version = "3.0.0" +version = "3.0.1" api_version = 3 entrypoint = "plugin.py" diff --git a/plugin.py b/plugin.py index 18cf7d3..4dacc0f 100644 --- a/plugin.py +++ b/plugin.py @@ -1,5 +1,6 @@ from __future__ import annotations +import json from pathlib import Path from collections.abc import Mapping from typing import Any @@ -31,7 +32,7 @@ api_version = 3 name = "emotion" -version = "3.0.0" +version = "3.0.1" desc = "Timer-refreshed Emotion context and ordinary Drift preference projection." DRIFT_PROPOSALS = ServiceKey[DriftProposalServices]("drift.proposals.v1") DRIFT_WAKE = ServiceKey[DriftWakeServices]("drift.wake.v1") @@ -242,15 +243,16 @@ def _mobile_ui_query( async def emotion_commit_preference_context( - tool_context: object, + context: object, arguments: Mapping[str, object], -) -> Mapping[str, object]: +) -> str: """Delegate legacy export lookup to the exact Root runtime.""" runtime = _v3_emotion_runtime if runtime is None: raise RuntimeError("emotion v3 generation 尚未完成 apply") - return await runtime.commit_preference_context(tool_context, arguments) + result = await runtime.commit_preference_context(context, arguments) + return json.dumps(result, ensure_ascii=False, sort_keys=True) def _commit_tool_schema() -> dict[str, object]: diff --git a/tests/test_plugin.py b/tests/test_plugin.py index e52f4d2..156fa8d 100644 --- a/tests/test_plugin.py +++ b/tests/test_plugin.py @@ -60,6 +60,28 @@ def _load_plugin_module(): ].refresh_current_context +def test_tool_export_matches_core_contract(monkeypatch: pytest.MonkeyPatch) -> None: + async def commit( + context: object, + arguments: dict[str, object], + ) -> dict[str, object]: + assert context is tool_context + assert arguments == {"proposal_id": "proposal-1"} + return {"committed": True} + + tool_context = object() + monkeypatch.setattr( + module, + "_v3_emotion_runtime", + SimpleNamespace(commit_preference_context=commit), + ) + handler = module.emotion_commit_preference_context + assert tuple(inspect.signature(handler).parameters) == ("context", "arguments") + assert json.loads( + asyncio.run(handler(tool_context, {"proposal_id": "proposal-1"})) + ) == {"committed": True} + + class DriftServices: """Expose both ordinary Drift ports over the real Core store."""