JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix: fix gatekeeper problem and packing skills on mac
huanggawabd4f95db2d13
diff --git a/.gitignore b/.gitignoreindex 8d61821577..8ed036bffa 100644--- a/.gitignore+++ b/.gitignore@@ -41,6 +41,14 @@ pnpm-debug.log*.env_personal!.env.example+# Apple code signing & notarization secrets — NEVER commit (contains private keys!)+*.p12+*.cer+*.mobileprovision+AuthKey_*.p8+DeveloperID_backup.p12+developerID_application.cer+# IDE / Editor.vscode/.idea/diff --git a/scripts/build-macos.sh b/scripts/build-macos.shindex 96698b98ff..a648d5364f 100644--- a/scripts/build-macos.sh+++ b/scripts/build-macos.sh@@ -1,5 +1,22 @@#!/usr/bin/env bash# JiuwenSwarm macOS .app + .dmg build script+#+# 签名/公证是可选的,按机器是否配置了 Developer ID 身份自动决定:+# - 配置了 Developer ID 身份(含私钥)→ 自动用真签名;加 NOTARIZE=1 再做 Apple 公证+staple+# - 没配置签名身份(如全新机器)→ 跳过签名,等同原先未签名构建,产物仅本地可用+#+# 前置条件(仅分发时需要):+# 1. 本机 login 钥匙串已装入 "Developer ID Application: ..." 身份(含私钥)。+# `security find-identity -v -p codesigning` 应看到 1 valid identity。+# 2.(公证)已用 notarytool 存入 keychain profile,例如:+# xcrun notarytool store-credentials "jiuwenswarm-notary" \+# --key AuthKey_XXXXXXXXXX.p8 --key-id KEY_ID --issuer ISSUER_ID+#+# 用法:+# bash scripts/build-macos.sh # 有身份就签名、没身份就跳过(不公证)+# NOTARIZE=1 bash scripts/build-macos.sh # 签名 + 公证 + staple(分发用,需真身份)+# SIGN_IDENTITY="-" bash scripts/build-macos.sh # 强制 ad-hoc 本地测试签名+# NOSIGN=1 bash scripts/build-macos.sh # 强制跳过签名,构建未签名 DMG(= 原先流程)set -euo pipefail@@ -10,6 +27,32 @@ DMG_ROOT="$PROJECT_ROOT/dist/dmg-root"VERSION="0.2.3"DMG_PATH="$PROJECT_ROOT/dist/JiuwenSwarm-$VERSION.dmg"+# === 签名 + 公证配置 ===+# 签名身份(codesign -s 的值)与是否签名。解析顺序:+# 1. 环境变量 SIGN_IDENTITY(可设具体身份,或 "-" 做 ad-hoc 本地测试)+# 2. 自动探测 keychain 里唯一的 "Developer ID Application" 身份+# 3. 都没有 → DO_SIGN=0,跳过签名(等同原先未签名构建,产物仅本地可用,不过 Gatekeeper)+ENTITLEMENTS="$PROJECT_ROOT/scripts/entitlements.mac.plist"+NOTARY_PROFILE="${NOTARY_PROFILE:-jiuwenswarm-notary}"+# 设 NOTARIZE=1 才执行公证(提交 Apple + staple)+DO_NOTARIZE="${NOTARIZE:-0}"+DO_SIGN=1++if [ "${NOSIGN:-0}" = "1" ]; then+ # 显式跳过签名(即使本机有 Developer ID 身份),构建未签名 DMG = 原先流程+ DO_SIGN=0+ SIGN_IDENTITY=""+elif [ -z "${SIGN_IDENTITY:-}" ]; then+ # 未显式指定:自动找 keychain 里的 Developer ID Application 身份(取第一个)+ SIGN_IDENTITY="$(security find-identity -v -p codesigning 2>/dev/null \+ | grep -oE 'Developer ID Application: [^(]+\([0-9A-Z]+\)' \+ | head -1 || true)"+ if [ -z "$SIGN_IDENTITY" ]; then+ # 新机器/未配置签名身份:跳过签名,保留 PyInstaller 默认 ad-hoc,等同原先流程+ DO_SIGN=0+ fi+fi+# ── 内置 Node 运行时(单架构,M 系列优先 arm64)─────────────────# 任选 ≥ v18 的 LTS;v20/v22 为推荐版本。可用环境变量覆盖。NODE_VERSION="${NODE_VERSION:-v22.11.0}"@@ -96,12 +139,41 @@ copy_node_into_app() {}printf '=== JiuwenSwarm macOS package build ===\n'-printf 'Project root: %s\n\n' "$PROJECT_ROOT"+printf 'Project root: %s\n' "$PROJECT_ROOT"+if [ "$DO_SIGN" = "1" ]; then+ printf 'Sign identity: %s\n' "$SIGN_IDENTITY"+else+ printf 'Sign identity: (skipped,本机未配置签名身份,产物仅本地可用)\n'+fi+if [ "$DO_NOTARIZE" = "1" ]; then+ printf 'Notarization: ENABLED (profile=%s)\n' "$NOTARY_PROFILE"+else+ printf 'Notarization: DISABLED(未设 NOTARIZE=1,不公证)\n'+fi+printf '\n'++# 校验签名身份 / 公证前提+if [ "$DO_SIGN" = "0" ]; then+ if [ "$DO_NOTARIZE" = "1" ]; then+ printf '错误:NOTARIZE=1 需要真实 Developer ID 身份。请先导入 .p12,或用 SIGN_IDENTITY 显式指定。\n' >&2+ exit 1+ fi+elif [ "$SIGN_IDENTITY" = "-" ]; then+ printf '注意:ad-hoc 签名(SIGN_IDENTITY="-"),仅供本地测试,无法通过 Gatekeeper/公证。\n'+ if [ "$DO_NOTARIZE" = "1" ]; then+ printf '错误:公证(NOTARIZE=1)需要真实的 Developer ID 身份,不能用 ad-hoc "-"。\n' >&2+ exit 1+ fi+elif ! security find-identity -v -p codesigning | grep -q "$SIGN_IDENTITY"; then+ printf '错误:钥匙串中找不到签名身份 "%s"\n' "$SIGN_IDENTITY" >&2+ printf ' 用 security find-identity -v -p codesigning 查看可用身份。\n' >&2+ exit 1+fi-printf '[1/5] Install Python dependencies (uv sync --extra dev)...\n'+printf '[1/9] Install Python dependencies (uv sync --extra dev)...\n'uv sync --extra dev-printf '\n[2/5] Build frontend (jiuwenswarm/channels/web/frontend)...\n'+printf '\n[2/9] Build frontend (jiuwenswarm/channels/web/frontend)...\n'rm -rf "$PROJECT_ROOT/jiuwenswarm/web/dist"pushd "$PROJECT_ROOT/jiuwenswarm/channels/web/frontend" >/dev/nullnpm install@@ -109,7 +181,7 @@ npm run buildpopd >/dev/nullTUI_BINARY=""-printf '\n[3/5] Build TUI native binary (Bun)...\n'+printf '\n[3/9] Build TUI native binary (Bun)...\n'if command -v bun &>/dev/null; thenpushd "$PROJECT_ROOT/jiuwenswarm/channels/tui/frontend" >/dev/nullbun install@@ -130,7 +202,7 @@ elseprintf 'Install bun: curl -fsSL https://bun.sh/install | bash\n'fi-printf '\n[4/5] Build macOS app bundle with PyInstaller...\n'+printf '\n[4/9] Build macOS app bundle with PyInstaller...\n'uv run pyinstaller scripts/jiuwenswarm.spec --noconfirmif [[ ! -d "$APP_PATH" ]]; then@@ -147,12 +219,36 @@ fi# 内置 Node 运行时:在打 DMG 之前暂存进 .app,随后 cp -R app 到 dmg-root# 会把它一并卷进 DMG。if [[ "$BUNDLE_NODE" == "1" ]]; then- printf '\n[4.5/5] Bundle Node.js runtime (single arch, M-series first)...\n'+ printf '\n[5/9] Bundle Node.js runtime (single arch, M-series first)...\n'NODE_SRC="$(resolve_node_dir)" || exit 1copy_node_into_app "$NODE_SRC"fi-printf '\n[5/5] Create DMG...\n'+# 注意:--deep 会打印 deprecation 警告,但对 PyInstaller 应用(含大量嵌套 .so/.dylib、+# TUI 二进制、内置 node-runtime)仍是最省事的方式,会把所有可执行码一次性签掉。+if [ "$DO_SIGN" = "1" ]; then+ printf '\n[6/9] Code sign the .app (hardened runtime + entitlements, --deep)...\n'+ codesign --force --deep --options runtime \+ --entitlements "$ENTITLEMENTS" \+ --sign "$SIGN_IDENTITY" \+ "$APP_PATH"+ codesign --verify --deep --strict --verbose=2 "$APP_PATH"+else+ printf '\n[6/9] Skipping .app signing (本机未配置签名身份).\n'+fi++if [ "$DO_NOTARIZE" = "1" ]; then+ printf '\n[7/9] Notarize the .app (submit to Apple + staple)...\n'+ ditto -c -k --keepParent "$APP_PATH" "$APP_PATH.zip"+ xcrun notarytool submit "$APP_PATH.zip" --keychain-profile "$NOTARY_PROFILE" --wait+ xcrun stapler staple "$APP_PATH"+ rm -f "$APP_PATH.zip"+ xcrun stapler validate "$APP_PATH"+else+ printf '\n[7/9] Skipping .app notarization (NOTARIZE 未启用).\n'+fi++printf '\n[8/9] Create DMG...\n'rm -rf "$DMG_ROOT"mkdir -p "$DMG_ROOT"cp -R "$APP_PATH" "$DMG_ROOT/"@@ -160,6 +256,27 @@ ln -s /Applications "$DMG_ROOT/Applications"rm -f "$DMG_PATH"hdiutil create -volname "JiuwenSwarm" -srcfolder "$DMG_ROOT" -ov -format UDZO "$DMG_PATH"+printf '\n[9/9] Code sign + notarize + staple the DMG, then verify...\n'+if [ "$DO_SIGN" = "1" ]; then+ codesign --sign "$SIGN_IDENTITY" "$DMG_PATH"+fi+if [ "$DO_NOTARIZE" = "1" ]; then+ xcrun notarytool submit "$DMG_PATH" --keychain-profile "$NOTARY_PROFILE" --wait+ xcrun stapler staple "$DMG_PATH"+ xcrun stapler validate "$DMG_PATH"+fi+# Gatekeeper 评估(公证后应 accepted, source=Notarized Developer ID)+if [ "$DO_SIGN" = "1" ]; then+ spctl -a -t open --context context:primary-signature -v "$DMG_PATH" 2>&1 || true+fi+printf '\n=== Build complete ===\n'printf 'App bundle: %s\n' "$APP_PATH"printf 'DMG file: %s\n' "$DMG_PATH"+if [ "$DO_NOTARIZE" = "1" ]; then+ printf '该 DMG 已签名+公证+staple,可分发给用户通过 Gatekeeper。\n'+elif [ "$DO_SIGN" = "1" ]; then+ printf '提示:当前只签名未公证。分发前请用 NOTARIZE=1 重新构建。\n'+else+ printf '提示:未签名(本地构建)。分发前需在配置好签名身份的机器上用 NOTARIZE=1 重新构建。\n'+fidiff --git a/scripts/entitlements.mac.plist b/scripts/entitlements.mac.plistnew file mode 100644index 0000000000..cd1ed1f04c--- /dev/null+++ b/scripts/entitlements.mac.plist@@ -0,0 +1,14 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.security.cs.allow-unsigned-executable-memory</key>+ <true/>+ <key>com.apple.security.cs.allow-jit</key>+ <true/>+ <key>com.apple.security.cs.disable-library-validation</key>+ <true/>+ <key>com.apple.security.cs.allow-dyld-environment-variables</key>+ <true/>+</dict>+</plist>diff --git a/scripts/jiuwenswarm.spec b/scripts/jiuwenswarm.specindex 6594d2fac8..251ac8ab2b 100644--- a/scripts/jiuwenswarm.spec+++ b/scripts/jiuwenswarm.spec@@ -67,7 +67,11 @@ def collect_resources_data_files(source_dir, target_dir):if any(root_abs == excluded or root_abs.startswith(excluded + os.sep) for excluded in excluded_dirs):continue- rel_dir = os.path.dirname(os.path.relpath(root, source_dir))+ # 这里 root 本身就是目录,dirname 会砍掉最后一级,导致+ # skills/<name>/SKILL.md 被错误放到 skills/SKILL.md,无子目录的技能整个消失。+ rel_dir = os.path.relpath(root, source_dir)+ if rel_dir == ".":+ rel_dir = ""dest_dir = os.path.normpath(os.path.join(target_dir, rel_dir))for filename in files:data_files.append((os.path.join(root, filename), dest_dir))