- pkm_utils.py: strip_thinking() 추가 + llm_generate() no_think 옵션
- <think> 태그 제거 + thinking 패턴("Wait,", "Let me" 등) 필터링
- enable_thinking: false 파라미터 지원
- law_monitor.py: JP 번역 호출에 no_think=True 적용
- pkm_api_server.py: /devonthink/stats 최적화 (children 순회 → count 사용)
+ /devonthink/search 한글 쿼리 이스케이프 수정
- auto_classify.scpt: baseDir property로 경로 변수화
- omnifocus_sync.scpt: 로그 경로 변수화
인프라: MailPlus IMAP HOST → LAN IP(192.168.1.227)로 변경
참고: 한국 법령 API IP(122.153.226.74) open.law.go.kr 등록 필요
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
76 lines
2.5 KiB
AppleScript
76 lines
2.5 KiB
AppleScript
-- DEVONthink 4 Smart Rule: OmniFocus 연동
|
|
-- Projects DB 새 문서에서 TODO 패턴 감지 → OmniFocus 작업 생성
|
|
-- Smart Rule 설정: Event = On Import, DB = Projects
|
|
|
|
property baseDir : "Documents/code/DEVONThink_my server"
|
|
|
|
on performSmartRule(theRecords)
|
|
set homeDir to POSIX path of (path to home folder)
|
|
set logFile to homeDir & baseDir & "/logs/omnifocus_sync.log"
|
|
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 & "' >> " & quoted form of logFile
|
|
end try
|
|
end repeat
|
|
end tell
|
|
end performSmartRule
|