chore: auto release commit (2026-06-19 09:53:29)
All checks were successful
技能自动化发布 / release (push) Successful in 7s
All checks were successful
技能自动化发布 / release (push) Successful in 7s
This commit is contained in:
@@ -63,9 +63,11 @@ from db.connection import get_conn, init_db
|
||||
from util.constants import SKILL_SLUG
|
||||
from util.logging_config import get_skill_logger
|
||||
from util.platforms import (
|
||||
PLATFORMS,
|
||||
DEFAULT_CAPABILITIES_JSON,
|
||||
_platform_list_cn_for_help,
|
||||
resolve_platform_key,
|
||||
get_platform_spec,
|
||||
is_valid_platform_key_format,
|
||||
resolve_platform_key_dynamic,
|
||||
seed_platforms,
|
||||
)
|
||||
from util.runtime_paths import (
|
||||
@@ -190,48 +192,26 @@ def _remove_profile_dir(path: str) -> None:
|
||||
|
||||
|
||||
def _resolve_or_fail(input_name: str, hint: str = "") -> Optional[str]:
|
||||
"""Resolve platform key or print ERROR:INVALID_PLATFORM and return None."""
|
||||
raw = (input_name or "").strip()
|
||||
if not raw:
|
||||
_say("ERROR:INVALID_PLATFORM 平台名不能为空。")
|
||||
return None
|
||||
|
||||
# 先尝试 platforms.py 硬编码(兼容历史)
|
||||
key = resolve_platform_key(raw)
|
||||
if key:
|
||||
return key
|
||||
|
||||
# 再查 DB(支持动态注册的平台)
|
||||
"""Resolve platform key or emit structured JSON error and return None."""
|
||||
init_db()
|
||||
conn = get_conn()
|
||||
try:
|
||||
init_db()
|
||||
conn = get_conn()
|
||||
try:
|
||||
row = conn.execute(
|
||||
"SELECT platform_key FROM platforms WHERE platform_key = ? AND enabled = 1",
|
||||
(raw,),
|
||||
).fetchone()
|
||||
if row:
|
||||
return row[0]
|
||||
rows = conn.execute(
|
||||
"SELECT platform_key, aliases_json FROM platforms WHERE enabled = 1"
|
||||
).fetchall()
|
||||
raw_lower = raw.lower()
|
||||
for r in rows:
|
||||
try:
|
||||
aliases = json.loads(r[1] or "[]")
|
||||
if raw_lower in [str(a).lower() for a in aliases]:
|
||||
return r[0]
|
||||
except Exception:
|
||||
continue
|
||||
finally:
|
||||
conn.close()
|
||||
except Exception:
|
||||
pass
|
||||
result = resolve_platform_key_dynamic(input_name, conn=conn)
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
_say(f"ERROR:INVALID_PLATFORM 无法识别的平台「{input_name}」。")
|
||||
if hint:
|
||||
if result.ok:
|
||||
return result.platform_key
|
||||
|
||||
code = result.error_code or "INVALID_PLATFORM"
|
||||
if not code.startswith("ERROR:"):
|
||||
code = f"ERROR:{code}"
|
||||
_say(_err_json(code, result.message or "无法识别平台。"))
|
||||
if hint and result.error_code == "PLATFORM_NOT_REGISTERED":
|
||||
_say(hint)
|
||||
else:
|
||||
elif hint:
|
||||
_say(hint)
|
||||
elif result.error_code not in ("PLATFORM_NOT_REGISTERED", "INVALID_PLATFORM_KEY", "PLATFORM_DISABLED"):
|
||||
_say("支持:" + _platform_list_cn_for_help())
|
||||
return None
|
||||
|
||||
@@ -270,7 +250,10 @@ def cmd_platform_get(input_key: str) -> None:
|
||||
if plat:
|
||||
_say(_ok_json(plat))
|
||||
else:
|
||||
_say(_err_json("ERROR:INVALID_PLATFORM", f"Platform '{key}' not found in DB."))
|
||||
_say(_err_json(
|
||||
"ERROR:PLATFORM_NOT_REGISTERED",
|
||||
f"Platform '{key}' not found in DB.",
|
||||
))
|
||||
|
||||
|
||||
def cmd_platform_ensure(
|
||||
@@ -292,9 +275,15 @@ def cmd_platform_ensure(
|
||||
if not key:
|
||||
_say('ERROR:INVALID_ARGS platform ensure 需要 --key 参数')
|
||||
return 1
|
||||
if not is_valid_platform_key_format(key):
|
||||
_say(_err_json(
|
||||
"ERROR:INVALID_PLATFORM_KEY",
|
||||
f"平台 key 格式非法:「{key}」。建议使用小写字母、数字、下划线或连字符。",
|
||||
))
|
||||
return 1
|
||||
|
||||
aliases_json = aliases if aliases else json.dumps([key, display_name], ensure_ascii=False)
|
||||
capabilities_json = capabilities if capabilities else '{"web": true, "api_key": false, "rpa": true}'
|
||||
capabilities_json = capabilities if capabilities else DEFAULT_CAPABILITIES_JSON
|
||||
|
||||
init_db()
|
||||
conn = get_conn()
|
||||
@@ -353,8 +342,14 @@ def cmd_account_add_web(
|
||||
return
|
||||
|
||||
init_db()
|
||||
platform_spec = PLATFORMS.get(key, {})
|
||||
now = int(time.time())
|
||||
conn = get_conn()
|
||||
try:
|
||||
seed_platforms(conn)
|
||||
platform_spec = get_platform_spec(key, conn=conn)
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
safe_label = (label or "").strip() or f"{platform_spec.get('display_name', key)} {environment} {role}"
|
||||
extra = {}
|
||||
if extra_json_str:
|
||||
@@ -500,7 +495,12 @@ def cmd_account_add_secret(
|
||||
return
|
||||
|
||||
init_db()
|
||||
platform_spec = PLATFORMS.get(key, {})
|
||||
conn = get_conn()
|
||||
try:
|
||||
seed_platforms(conn)
|
||||
platform_spec = get_platform_spec(key, conn=conn)
|
||||
finally:
|
||||
conn.close()
|
||||
now = int(time.time())
|
||||
safe_label = (label or "").strip() or f"{platform_spec.get('display_name', key)} {credential_type}"
|
||||
|
||||
@@ -1373,7 +1373,8 @@ def cmd_delete_by_platform(platform_input: str) -> None:
|
||||
)
|
||||
conn.commit()
|
||||
log.info("delete_by_platform_done platform=%s count=%s", key, len(rows))
|
||||
_say(f"✅ 已删除 {PLATFORMS.get(key, {}).get('display_name', key)} 下共 {len(rows)} 条账号。")
|
||||
display = get_platform_spec(key, conn=conn).get("display_name", key)
|
||||
_say(f"✅ 已删除 {display} 下共 {len(rows)} 条账号。")
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user