Skip to content

feat(completion): 최초 1회 자동완성 설치 권유 힌트#218

Merged
DaveDev42 merged 1 commit into
mainfrom
agent-a29e9d3fd08014cab
Jun 26, 2026
Merged

feat(completion): 최초 1회 자동완성 설치 권유 힌트#218
DaveDev42 merged 1 commit into
mainfrom
agent-a29e9d3fd08014cab

Conversation

@DaveDev42

Copy link
Copy Markdown
Contributor

목적

자동완성(_aitcc)이 설치돼 있지 않으면 탭 완성이 동작하지 않는다. 그런데 사용자는 설치가 필요하다는 사실 자체를 모르는 경우가 많다 — install.sh가 출력하는 안내는 설치 시점에 한 번 흘러가고, npm/pnpm dlx 경로로 들어온 사용자는 그 안내를 아예 못 본다.

이 PR은 최초 대화형 실행에서, 자동완성이 미설치일 때만 한 번 설치 방법을 stderr로 안내하는 힌트를 추가한다.

동작

  • 트리거: 대화형(stderr.isTTY) 실행 + 자동완성 미설치 + 아직 권유한 적 없음(마커 부재).
  • 한 번만: 힌트를 출력하거나 이미 설치됐음을 확인하면 캐시에 마커(completion-suggested.json)를 남기고 다시는 스캔/표시하지 않는다.
  • 침묵 조건: --json 출력 / upgrade·completion 서브커맨드 / 비-TTY(파이프·에이전트 호출) / 알 수 없는 셸 → 항상 침묵.
  • rc 파일 자동 수정 없음: 사용자가 붙여넣을 수 있는 one-liner만 안내(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 힌트가 시각적으로 겹치지 않게 업데이트 안내가 먼저 나온다. citty cleanup 훅을 못 쓰는 이유는 process.exit가 cleanup 단계를 pre-empt하기 때문(update-notice와 동일). 두 훅 모두 bounded·never-throws.

shouldRunCompletionHintshouldRunUpdateNotice와 같은 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

- 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
@DaveDev42
DaveDev42 merged commit ebcea9b into main Jun 26, 2026
1 check passed
@DaveDev42
DaveDev42 deleted the agent-a29e9d3fd08014cab branch June 26, 2026 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

completion: 최초 1회 설치 권유 힌트 (미설치·미권유일 때만)

1 participant