276d2bb6-619d-4888-ba11-8a6.../build.sh
徐翔宇 4e22618364 v0.1.0: initial 划词侠 — AI Text Actions plugin for MioIsland
Quick AI actions on clipboard or selected text. Four actions:
- 翻译 (中/英/日)
- 总结 (3-bullet Chinese)
- 改语气 (正式/口语/友好/严谨)
- 邮件回复

Powered by DeepSeek with Server-Sent Events streaming for
typewriter feedback (~600ms first byte). Two source modes:
clipboard (no permission) and selected-text via NSAccessibility
(graceful fallback to clipboard + permission banner if denied).

Five-state UI machine: idle → input → loading (cancellable) →
result → missing-config. Last 20 actions persisted to UserDefaults.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-27 20:21:17 +08:00

66 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
# Build the 划词侠 plugin as a .bundle for Mio Island.
#
# Usage:
# ./build.sh # produce build/clipper.bundle + build/clipper.zip
# ./build.sh install # also copy bundle to ~/.config/codeisland/plugins/
set -e
set -o pipefail
PLUGIN_NAME="clipper"
MODULE_NAME="ClipperPlugin"
BUNDLE_NAME="${PLUGIN_NAME}.bundle"
BUILD_DIR="build"
SOURCES=$(find Sources -name "*.swift" -type f)
SOURCE_COUNT=$(echo "$SOURCES" | wc -l | tr -d ' ')
echo "Building ${PLUGIN_NAME} plugin (${SOURCE_COUNT} swift files)..."
rm -rf "${BUILD_DIR}"
mkdir -p "${BUILD_DIR}/${BUNDLE_NAME}/Contents/MacOS"
# arm64-only is fine for v0.1 — Mio Island host requires macOS 15+
# which means Apple Silicon dominant.
swiftc \
-emit-library \
-module-name "${MODULE_NAME}" \
-target arm64-apple-macos15.0 \
-sdk "$(xcrun --show-sdk-path)" \
-O \
-o "${BUILD_DIR}/${BUNDLE_NAME}/Contents/MacOS/${MODULE_NAME}" \
${SOURCES}
cp Info.plist "${BUILD_DIR}/${BUNDLE_NAME}/Contents/"
if [ -d "Resources" ] && [ "$(ls -A Resources 2>/dev/null)" ]; then
mkdir -p "${BUILD_DIR}/${BUNDLE_NAME}/Contents/Resources"
cp -R Resources/* "${BUILD_DIR}/${BUNDLE_NAME}/Contents/Resources/"
fi
# Ad-hoc sign the whole bundle.
codesign --force --deep --sign - "${BUILD_DIR}/${BUNDLE_NAME}"
echo "✓ Built ${BUILD_DIR}/${BUNDLE_NAME}"
# zip for marketplace upload (顶层是 .bundle 目录)
cd "${BUILD_DIR}"
rm -f "${PLUGIN_NAME}.zip"
zip -rq "${PLUGIN_NAME}.zip" "${BUNDLE_NAME}"
cd ..
echo "✓ Created ${BUILD_DIR}/${PLUGIN_NAME}.zip"
if [ "${1:-}" = "install" ]; then
PLUGIN_DIR="${HOME}/.config/codeisland/plugins"
mkdir -p "${PLUGIN_DIR}"
rm -rf "${PLUGIN_DIR}/${BUNDLE_NAME}"
cp -R "${BUILD_DIR}/${BUNDLE_NAME}" "${PLUGIN_DIR}/"
echo "✓ Installed to ${PLUGIN_DIR}/${BUNDLE_NAME}"
echo " Restart Mio Island (Cmd+Q + reopen) to load the new build."
else
echo ""
echo "Install locally:"
echo " ./build.sh install"
fi