feat: 폴더 자동 감시(watch) — launchd로 새 NFD 파일 자동 NFC 정리 - #6
Merged
Conversation
launchd WatchPaths로 등록 폴더를 감시해 NFD 파일 유입 시 자동 NFC 정리. - watch add/remove/list/on/off + 내부 __run - 목록(~/Library/Application Support/nfd2nfc/folders.list), plist(LaunchAgent), 로그(~/Library/Logs/nfd2nfc-watch.log) - __run은 코어를 리스트폼으로 각 폴더에 재호출(셸 미경유), 변경>0이면 알림 - 무한루프: idempotent + ThrottleInterval 10초. 의존성 0, 옵트인. - 상단 디스패치(exit watch_main)가 먼저 실행되므로 라벨은 my가 아닌 sub로 정의.
usage·목록 add/list/remove·plist plutil 유효성·on/off·__run 정리+로그(무한루프 가드)·미존재 폴더 견고성. HOME=$TMP/home 격리, launchctl은 NFD2NFC_WATCH_NO_LAUNCHCTL로 건너뜀. 통과 25/25.
README에 'watch' 섹션(사용법·로그·켜고 끄기), CHANGELOG Unreleased에 자동 감시 기록.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nfd2nfc watch add/remove/list/on/off서브커맨드 추가 — 등록한 폴더를 launchdWatchPaths로 감시해, NFD 파일이 유입되면 자동으로 NFC 정리.ThrottleInterval10초로 차단.__run은 코어를 리스트폼(셸 미경유)으로 각 폴더에 재호출.~/Library/Application Support/nfd2nfc/, plist는 LaunchAgent, 로그~/Library/Logs/nfd2nfc-watch.log.설계 과정
brainstorming → spec(
docs/superpowers/specs/2026-06-02-auto-watch-design.md) → writing-plans(7 task TDD) → 인라인 실행. (spec/plan은 gitignore 정책상 로컬 보관)구현 노트
exit watch_main)가 런타임에 먼저 실행되므로, 라벨 상수는my가 아니라sub watch_label로 정의(미초기화 버그 회피 — 구현 중 발견·수정).watch가 첫 인자일 때만 분기).Test Plan
perl -c nfd2nfc문법 OKshellcheck(4파일) exit 0./test.sh25/25(watch 6종: usage·목록·plist plutil·on/off·__run 무한루프 가드·미존재 폴더 견고성)plutil -lint(watch 코드 임베드돼도 회귀 없음)watch add ~/Downloads후 NFD 파일 넣어 자동 정리 확인 — launchctl은 사용자 세션 필요라 CI 미포함