fix: Phase 2 버그 픽스 — JP 번역, API 서버, AppleScript 경로

- 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>
This commit is contained in:
hyungi
2026-03-30 14:00:46 +09:00
parent f21f950c04
commit dc3f03b421
5 changed files with 59 additions and 38 deletions

View File

@@ -35,24 +35,14 @@ def run_applescript(script: str, timeout: int = 120) -> str:
@app.route('/devonthink/stats')
def devonthink_stats():
try:
# DB별 문서 수만 빠르게 조회 (children 순회 대신 count 사용)
script = (
'tell application id "DNtp"\n'
' set today to current date\n'
' set time of today to 0\n'
' set stats to {}\n'
' repeat with db in databases\n'
' set dbName to name of db\n'
' set addedCount to 0\n'
' set modifiedCount to 0\n'
' repeat with rec in children of root of db\n'
' try\n'
' if creation date of rec >= today then set addedCount to addedCount + 1\n'
' if modification date of rec >= today then set modifiedCount to modifiedCount + 1\n'
' end try\n'
' end repeat\n'
' if addedCount > 0 or modifiedCount > 0 then\n'
' set end of stats to dbName & ":" & addedCount & ":" & modifiedCount\n'
' end if\n'
' set docCount to count of contents of db\n'
' set end of stats to dbName & ":" & docCount\n'
' end repeat\n'
' set AppleScript\'s text item delimiters to "|"\n'
' return stats as text\n'
@@ -60,17 +50,18 @@ def devonthink_stats():
)
result = run_applescript(script)
stats = {}
total = 0
if result:
for item in result.split('|'):
parts = item.split(':')
if len(parts) == 3:
stats[parts[0]] = {'added': int(parts[1]), 'modified': int(parts[2])}
total_added = sum(s['added'] for s in stats.values())
total_modified = sum(s['modified'] for s in stats.values())
if len(parts) == 2:
count = int(parts[1])
stats[parts[0]] = {'count': count}
total += count
return jsonify(success=True, data={
'databases': stats,
'total_added': total_added,
'total_modified': total_modified
'total_documents': total,
'database_count': len(stats),
})
except Exception as e:
return jsonify(success=False, error=str(e)), 500
@@ -83,9 +74,11 @@ def devonthink_search():
if not q:
return jsonify(success=False, error='q parameter required'), 400
try:
# 한글 쿼리 이스케이프 (따옴표, 백슬래시)
safe_q = q.replace('\\', '\\\\').replace('"', '\\"')
script = (
'tell application id "DNtp"\n'
f' set results to search "{q}"\n'
f' set results to search "{safe_q}"\n'
' set output to {}\n'
f' set maxCount to {limit}\n'
' set i to 0\n'