feat(completion): 최초 1회 자동완성 설치 권유 힌트#218
Merged
Merged
Conversation
- src/completion-hint.ts: 새 hook. shouldRunCompletionHint(argv)로 --json / upgrade / completion / non-TTY를 사전 차단. detectShell()이 $SHELL basename에서 zsh/bash/fish를 판별. isCompletionInstalled()가 잘 알려진 경로를 existsSync로 탐색 (셸 스폰 없음). 미설치이고 marker 없으면 one-liner(zsh/bash/fish 각각)를 stderr에 dim 텍스트로 출력하고 cacheDir/completion-suggested.json에 one-shot marker를 atomic write. 이미 설치됐으면 hint 없이 marker만 쓴다. 완전 defensive — 절대 throw 안 함. - src/paths.ts: completionSuggestedPath() 추가 (upgradeCheckPath 패턴 mirror). - src/flush.ts: exitAfterFlush에서 runUpdateNoticeOnExit 직후에 maybeSuggestCompletionOnExit 호출 추가. - src/completion-hint.test.ts: shouldRunCompletionHint / detectShell / isCompletionInstalled / _maybeSuggestCompletionOnExit / 공개 wrapper 전 28개 테스트. injectable existsFn + writeMarkerFn으로 ESM spy 문제 우회. - src/flush.test.ts: completion-hint mock 추가 및 두 hook 순서 검증. - .changeset/completion-install-hint.md: patch changeset. Closes #216
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.
목적
자동완성(
_aitcc)이 설치돼 있지 않으면 탭 완성이 동작하지 않는다. 그런데 사용자는 설치가 필요하다는 사실 자체를 모르는 경우가 많다 —install.sh가 출력하는 안내는 설치 시점에 한 번 흘러가고, npm/pnpm dlx경로로 들어온 사용자는 그 안내를 아예 못 본다.이 PR은 최초 대화형 실행에서, 자동완성이 미설치일 때만 한 번 설치 방법을 stderr로 안내하는 힌트를 추가한다.
동작
stderr.isTTY) 실행 + 자동완성 미설치 + 아직 권유한 적 없음(마커 부재).completion-suggested.json)를 남기고 다시는 스캔/표시하지 않는다.--json출력 /upgrade·completion서브커맨드 / 비-TTY(파이프·에이전트 호출) / 알 수 없는 셸 → 항상 침묵.completion.ts·install.sh와 동일 철학).$SHELL베이스네임으로 zsh/bash/fish 식별. 미지원 셸은 침묵.existsSync만 사용 — 셸을 spawn하지 않는다. zsh/bash/fish의 well-known 경로 + XDG 변형을 확인.NO_COLOR존중, dim stderr 한 블록.배선
exitAfterFlush(모든 명령이 빠져나가는 단일 chokepoint)에서runUpdateNoticeOnExit()다음에maybeSuggestCompletionOnExit()를 호출한다 — 둘 다 호출되면 두 stderr 힌트가 시각적으로 겹치지 않게 업데이트 안내가 먼저 나온다. cittycleanup훅을 못 쓰는 이유는process.exit가 cleanup 단계를 pre-empt하기 때문(update-notice와 동일). 두 훅 모두 bounded·never-throws.shouldRunCompletionHint는shouldRunUpdateNotice와 같은argvRequestsJson/topLevelCommand/EXCLUDED_COMMANDS를 재사용한다 — 억제 규칙의 single source.테스트
flush.test.ts: 순서 계약을 명시 검증 —['notice', 'completion-hint', 'exit:7'].completion-hint.test.ts: 28개 — 억제 분기, 셸 감지(전부 + null), 설치 감지(셸별 + XDG), exit-hook 4동작(미설치→힌트, 마커 존재→침묵, 설치됨→마커만, 미지원 셸→no-op), NO_COLOR, never-throws.4 게이트 통과: typecheck / lint / 774 tests / build.
Closes #216