SuperAPI AI 工具集

lovstudio-finder-action

编程与开发

查看项目

更新于 10-16 00:01

技能介绍

用途:根据用户描述生成 Mac Finder 右键菜单动作,并自动判断实现模式。触发文件/文件夹右键时使用 Mode A(Automator Quick Action);触发空白处、背景、新建文件等场景时使用 Mode B(Finder Sync Extension,Swift + xcodegen)。参数格式为「<动作名称> [触发描述]」。

主要能力:Mode A 会分析动作名称、触发文件类型与核心命令,用 which 检查依赖(缺失提示 brew install),生成接收 "$@" 文件参数的 shell 脚本,创建 ~/Library/Services/<动作名称>.workflow/Contents/document.wflow,并验证注册。Mode B 检查 xcodegen 与 xcodebuild,创建 project.yml、AppDelegate.swift、FinderSync.swift,通过 xcodegen generate 与 xcodebuild 构建,复制到 /Applications 后用 pluginkit 启用,再用 pluginkit -m -i 验证。

必要用法要点:Quick Action 环境没有 $PATH,工具须用绝对路径;workflow 必须在 Automator 中打开并 Cmd+S 保存才会注册。Finder Extension 需开启沙盒,用 temporary-exception.files.absolute-path.read-write 处理文件读写,Bundle ID 不能含下划线,NSMenuItem 必须设置 target。安装后可运行 pluginkit -e use -i BUNDLE_ID.FinderExtension,若未出现则到系统设置中勾选扩展。

限制:Finder Sync Extension 沙盒禁止写 /tmp、启动 Process() 子进程、使用 NSAppleScript、用 NSWorkspace.open(file) 打开文件;仅可打开应用与读写剪贴板。推荐用非沙盒 Helper App 变通:Extension 把命令写入剪贴板并打开 Helper App 执行。Extension 使用 ad-hoc 签名仅限本机使用,菜单项位置由系统决定。其他细节如收费、平台支持与效果暂未提供。