From 67f16ad372f7df55313bbc205b399c0d5192ed76 Mon Sep 17 00:00:00 2001 From: Estrella Pan Date: Thu, 8 Oct 2026 17:21:00 +0200 Subject: [PATCH] =?UTF-8?q?refactor(4.0):=20ab-plugin=20=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E8=A1=8C=E5=A4=8D=E7=94=A8=20ab=5Fsdk.manifest=20=E7=9A=84?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=20id=20=E6=AD=A3=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cli.py 自带一份与 manifest.ID_RE 完全相同的私有正则,改为直接导入。 --- backend/src/ab_sdk/cli.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/backend/src/ab_sdk/cli.py b/backend/src/ab_sdk/cli.py index 9a19e663..9a5c41e9 100644 --- a/backend/src/ab_sdk/cli.py +++ b/backend/src/ab_sdk/cli.py @@ -6,14 +6,13 @@ import argparse import json import os -import re import sys import zipfile from pathlib import Path from string import Template from . import SDK_VERSION, points -from .manifest import MANIFEST_NAME, TOOLING_DIRS, PluginManifest, check +from .manifest import ID_RE, MANIFEST_NAME, TOOLING_DIRS, PluginManifest, check # 打包时排除的目录名与文件后缀:开发产物、测试与作者侧的工程文件 _PACK_EXCLUDE_DIRS = TOOLING_DIRS | {"tests"} @@ -164,8 +163,6 @@ uv run ab-plugin pack . # 打包为 dist/$id-<版本>.zip ``` """) -_ID_RE = re.compile(r"^[a-z0-9]+(?:-[a-z0-9]+)*$") - def scaffold(target: Path, plugin_id: str, kind: str) -> list[Path]: """在 ``target`` 下创建插件骨架,返回创建的文件。""" @@ -265,7 +262,7 @@ def link_dev(plugin_dir: Path, config_dir: Path, manifest: PluginManifest) -> Pa def _cmd_new(args: argparse.Namespace) -> int: - if not _ID_RE.match(args.id): + if not ID_RE.match(args.id): print("错误:id 只能由小写字母、数字和连字符组成", file=sys.stderr) return 1 target = Path(args.dir) / args.id