Files
hyungi_document_server/applescript/omnifocus_sync.scpt
Hyungi Ahn 084d3a8c63 feat: 전체 PKM 스크립트 일괄 작성 — 분류/법령/메일/다이제스트/임베딩
- scripts/pkm_utils.py: 공통 유틸 (로거, dotenv, osascript 래퍼)
- scripts/prompts/classify_document.txt: Ollama 분류 프롬프트
- applescript/auto_classify.scpt: Inbox → AI 분류 → DB 이동
- applescript/omnifocus_sync.scpt: Projects → OmniFocus 작업 생성
- scripts/law_monitor.py: 법령 변경 모니터링 + DEVONthink 임포트
- scripts/mailplus_archive.py: MailPlus IMAP → Archive DB
- scripts/pkm_daily_digest.py: 일일 다이제스트 + OmniFocus 액션
- scripts/embed_to_chroma.py: GPU 서버 벡터 임베딩 → ChromaDB
- launchd/*.plist: 3개 스케줄 (07:00, 07:00+18:00, 20:00)
- docs/deploy.md: Mac mini 배포 가이드
- docs/devonagent-setup.md: 검색 세트 9종 설정 가이드
- tests/test_classify.py: 5종 문서 분류 테스트

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 12:32:36 +09:00

72 lines
2.4 KiB
AppleScript

-- DEVONthink 4 Smart Rule: OmniFocus 연동
-- Projects DB 새 문서에서 TODO 패턴 감지 → OmniFocus 작업 생성
-- Smart Rule 설정: Event = On Import, DB = Projects
on performSmartRule(theRecords)
tell application id "DNtp"
repeat with theRecord in theRecords
try
set docText to plain text of theRecord
set docTitle to name of theRecord
set docUUID to uuid of theRecord
set docLink to reference URL of theRecord -- x-devonthink-item://UUID
-- TODO 패턴 감지: "TODO", "할일", "□", "[ ]", "FIXME"
set hasAction to false
if docText contains "TODO" or docText contains "할일" or docText contains "□" or docText contains "[ ]" or docText contains "FIXME" then
set hasAction to true
end if
if not hasAction then continue repeat
-- 액션 아이템 추출 (Python으로 파싱)
set extractCmd to "echo " & quoted form of docText & " | python3 -c \"
import sys, re
text = sys.stdin.read()
patterns = [
r'(?:TODO|FIXME|할일)[:\\s]*(.+?)(?:\\n|$)',
r'(?:□|\\[ \\])\\s*(.+?)(?:\\n|$)',
]
items = []
for p in patterns:
items.extend(re.findall(p, text, re.MULTILINE))
# 최대 5개, 중복 제거
seen = set()
for item in items[:10]:
item = item.strip()
if item and item not in seen:
seen.add(item)
print(item)
if len(seen) >= 5:
break
\""
set actionItems to paragraphs of (do shell script extractCmd)
if (count of actionItems) = 0 then continue repeat
-- OmniFocus에 작업 생성
tell application "OmniFocus"
tell default document
set taskIDs to {}
repeat with actionItem in actionItems
set taskName to docTitle & " — " & (contents of actionItem)
set newTask to make new inbox task with properties {name:taskName, note:"DEVONthink 문서: " & docLink}
set end of taskIDs to id of newTask
end repeat
end tell
end tell
-- DEVONthink 메타데이터에 OmniFocus Task ID 저장
set AppleScript's text item delimiters to ","
set taskIDString to taskIDs as text
set AppleScript's text item delimiters to ""
add custom meta data taskIDString for "omnifocusTaskID" to theRecord
on error errMsg
do shell script "echo '[" & (current date) & "] [omnifocus_sync] [ERROR] " & errMsg & "' >> ~/Documents/code/DEVONThink_my\\ server/logs/omnifocus_sync.log"
end try
end repeat
end tell
end performSmartRule