划词助手的核心库(无界面)· The core library of the Selection Assistant macOS app — no UI.
A reusable Swift package for macOS that powers a PopClip-style selection assistant:
- 划词抓取引擎 (Text selection engine) — three-tier fallback: Accessibility API → Safari AppleScript → clipboard simulation
- 大模型服务 (LLM service) — OpenAI-compatible chat for DeepSeek / OpenRouter / local Ollama
- 设置模型 (Settings models) — provider config, custom skill prompts (
{{text}}placeholder), toolbar order - 权限助手 (Permission helpers) — Accessibility / Screen Recording status + requests
完整 App(含 SwiftUI 界面)是一个独立私有项目,不在本仓库。非专业用户请直接下载下方 App。 The full app (with its SwiftUI frontend) lives in a separate private repository. Non-developers should just download the app below.
Selection Assistant(划词助手,完整界面版)— 仅 Apple Silicon / macOS 15.0+:
⬇️ 下载 SelectionAssistant.dmg(最新 Release)
- 双击
.dmg,把 Selection Assistant.app 拖入 Applications。 - 未做 Apple 公证,首次启动请 右键 → 打开(或
xattr -dr com.apple.quarantine "/Applications/Selection Assistant.app")。 - 全部版本:Releases
// Package.swift
dependencies: [
.package(url: "https://github.com/veritasian/selection-assistant-mac.git", from: "1.0.0")
]import SelectionAssistantCore
let result = try await LLMService.chat(provider: provider, prompt: prompt)
SelectionMonitor.shared.onTextSelected = { text, point in /* show your own UI */ }| 类型 | 用途 |
|---|---|
LLMService.chat(provider:prompt:) |
向大模型发请求(DeepSeek/OpenRouter/Ollama) |
SelectionMonitor |
全局划词监听:start() / onTextSelected / injectSelection(_:) |
SettingsStore.shared |
持久化设置(provider、skills、toolbarOrder、detectionMode…) |
PermissionManager.shared |
辅助功能 / 录屏权限状态与申请 |
ScreenCaptureOCR |
区域截图 + Vision OCR |
技能 = 一段 prompt,{{text}} 会被替换为选中文本:
let prompt = "Explain the following text:\n\n{{text}}"
let result = try await LLMService.chat(provider: provider, prompt: prompt)./build.sh # 或 swift build -c release --arch arm64本仓库是核心的权威来源;完整 App(含 SwiftUI 界面)在私有仓库 selection-assistant-mac-views。
# 1. 改核心 → 提交并推送本仓库
git add -A && git commit -m "..." && git push origin main
# 2. 同步到私有 App 仓库并重建
cd ../selection-assistant-mac-views
./sync-core.sh # rsync 本仓库的 Sources/SelectionAssistantCore 覆盖过去
./build.shMIT — 核心库可自由使用、修改、分发(含商业用途)。
Copyright © 2026 veritasian