fix: make Android tasks use extensions automatically and populate marketplace

This commit is contained in:
chenmingxuan committed 2026-10-14 22:32:38 +08:00
1 parent 6663233ab8
commit 9c82a40cbf
32 files changed
+341 -131

No files matched your search

+1
View File
@@ -136,6 +136,7 @@ class PluginSelection(PluginModel):
class CatalogEntry(PluginModel):
manifest: PluginManifest
release_stage: Literal["stable", "preview"] = "stable"
archive_url: str
sha256: str = Field(pattern=r"^[a-f0-9]{64}$")
verification: str = Field(min_length=1, max_length=4000)
+3
View File
@@ -84,6 +84,9 @@ class PluginRuntime:
if not self.packages:
return ""
lines = ["\n可用扩展插件(按需调用 plugin_load 加载说明和工具):"]
lines.append(
"围绕用户测试目标自主选择工具。手机步骤使用手机工具;需要电脑、浏览器或其他外部步骤时才加载相应插件,无需用户切换执行目标。没有相关需求时不要加载或调用插件。"
)
for manifest, profile, _ in self.packages.values():
lines.append(f"- {manifest.id} / {profile.label}: {manifest.description}")
lines.append(
+10 -2
View File
@@ -236,7 +236,9 @@ class PluginStore:
def selections(self, target: str = "mixed") -> list[PluginSelection]:
selections = []
for plugin in self.list():
if not plugin["enabled"] or target not in plugin["manifest"].get("targets", ["mixed"]):
if not plugin["enabled"] or not self._supports_task(
plugin["manifest"].get("targets", ["mixed"]), target
):
continue
profiles = plugin["profiles"]
default = next((p for p in profiles if p.get("is_default")), None)
@@ -251,12 +253,18 @@ class PluginStore:
)
return selections
@staticmethod
def _supports_task(targets: list[str], target: str) -> bool:
# Android tasks can call cross-device extensions without a separate mode.
# Computer-only plugins still need to explicitly support mixed use.
return target in targets or (target == "android" and "mixed" in targets)
@serialized
def pin(self, selections: list[PluginSelection] | None, target: str) -> list[PluginSelection]:
pinned = []
for choice in self.selections(target) if selections is None else selections:
manifest, profile, _ = self.resolve(choice)
if target not in manifest.targets:
if not self._supports_task(manifest.targets, target):
raise ValueError(f"插件 {manifest.name} 不支持 {target} 任务")
pinned.append(
PluginSelection(id=manifest.id, profile=profile.name, version=manifest.version)