front/xhs-agent-desktop/engine/xhs_bridge/extension_pack.py
zzh 5a26ae0048 feat: 小红书模块迁移、登录重构与 xhs-agent-desktop 桌面 Agent
- 新增小红书前端模块(启动服务、内容分析、爆款创作、发布记录、技能卡片、拟人设置、AI 助手)

- 新增 xhs-agent-desktop 独立桌面 Agent,对接 OMS 任务调度

- 登录页重构,整合微信登录与 OMS JWT 认证

- 订单、渠道、用户中心等页面与 API 增强

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-30 16:13:13 +08:00

37 lines
1.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from __future__ import annotations
import zipfile
from pathlib import Path
from xhs_bridge.config import load_config
ZIP_NAME = "XHS-Bridge-extension.zip"
def extension_source_dir() -> Path:
return load_config().skills.extension_dir()
def create_extension_zip(dest_path: Path) -> Path:
"""将 extension 目录打包为 zip,供用户在 Chrome 中「加载已解压的扩展」。"""
ext_dir = extension_source_dir()
if not ext_dir.is_dir():
raise FileNotFoundError(f"扩展目录不存在:{ext_dir}")
dest = dest_path.resolve()
if dest.suffix.lower() != ".zip":
dest = dest.with_suffix(".zip")
dest.parent.mkdir(parents=True, exist_ok=True)
with zipfile.ZipFile(dest, "w", zipfile.ZIP_DEFLATED) as zf:
for file_path in sorted(ext_dir.rglob("*")):
if not file_path.is_file():
continue
arcname = file_path.relative_to(ext_dir).as_posix()
zf.write(file_path, arcname)
if not dest.is_file() or dest.stat().st_size == 0:
raise OSError("打包失败:生成的 zip 为空")
return dest