Scan which apps are installed on the user's computer, and recommend the most suitable tools based on task requirements.
Use Cases
- The user says, "Is there any software on my computer that can edit PDFs?"
- The user says, "Help me open the video editing software."
- A task requires a certain app but it is uncertain whether the user has it installed.
Scanning Methods
List installed apps
# 方式 1:扫描 /Applications 目录(最常用)
ls /Applications/ | grep -i ".app"
Method 2: system_profiler (complete information, including version)
system_profiler SPApplicationsDataType -json 2>/dev/null | python3 -c " import json, sys data = json.load(sys.stdin) apps = data.get('SPApplicationsDataType', []) for app in sorted(apps, key=lambda x: x.get('_name', ''))[:50]: name = app.get('_name', '') version = app.get('version', '?') path = app.get('path', '') print(f'{name} (v{version}) — {path}') "
Method 3: mdfind (includes apps in non-standard locations)mdfind "kMDItemContentType == 'com.apple.application-bundle'" | head -50
### 检查特定应用是否安装
```bash
# 检查应用是否存在
test -d "/Applications/Visual Studio Code.app" && echo "已安装" || echo "未安装"
# 通过 mdfind 查找
mdfind "kMDItemCFBundleIdentifier == 'com.microsoft.VSCode'"
# 通过 CLI 检查
which code && echo "VS Code CLI 可用" || echo "VS Code CLI 不可用"
Get detailed app information
# 获取应用 Bundle ID
mdls -name kMDItemCFBundleIdentifier "/Applications/Safari.app"
# 获取应用版本
mdls -name kMDItemVersion "/Applications/Safari.app"
# 获取应用支持的文件类型
mdls -name kMDItemContentTypeTree "/Applications/Preview.app"
Recommend apps by file type
# 查找能打开 PDF 的应用
python3 -c "
import subprocess, json
result = subprocess.run(
['python3', '-c', '''
import CoreServices
from LaunchServices import LSCopyAllRoleHandlersForContentType
handlers = LSCopyAllRoleHandlersForContentType(\"com.adobe.pdf\", 0xFFFFFFFF)
if handlers:
for h in handlers:
print(h)
'''],
capture_output=True, text=True
)
print(result.stdout)
"
# 简单方式:用 open 命令查看默认应用
open -Ra "Preview" 2>/dev/null && echo "Preview 可用"
Common Capability Mapping
| User Need | Search Keywords | Common Apps |
|---|---|---|
| Edit PDF | PDF, Preview, Acrobat | Preview, Adobe Acrobat |
| Write documents | Word, Pages, Writer | Pages, Word, LibreOffice |
| Make spreadsheets | Excel, Numbers, Sheets | Numbers, Excel |
| Make PPTs | Keynote, PowerPoint | Keynote, PowerPoint |
| Edit images | Photos, Photoshop, GIMP | Preview, Photos, Pixelmator |
| Edit videos | iMovie, Final Cut, DaVinci | iMovie, Final Cut Pro |
| Write code | VS Code, Xcode, Sublime | VS Code, Xcode |
| Browser | Safari, Chrome, Firefox | Safari, Chrome |
Output Specifications
- First answer the user's question (whether a certain app exists)
- If there are multiple options, briefly explain the differences and recommend one
- When recommending, consider: built-in system apps first, apps the user has already installed first
- If not installed, provide installation methods (App Store / brew / official website)