feat(completion): __complete subcommand foundation (#291)#312
Merged
Conversation
Adds `parsec __complete <worktrees|branches>` — a hidden subcommand that shell completion scripts can call to enumerate candidates dynamically. Failure paths (no repo / no config) silently emit nothing so completion never errors at the prompt. Also adds `git::list_local_branches`, a helper for enumerating local branch names via `git for-each-ref refs/heads/`. This is the **foundation only**. The follow-up work — post-processing clap-generated completion scripts (zsh/bash/fish) so that ticket-shaped arguments call `parsec __complete worktrees` and branch-shaped arguments call `parsec __complete branches` — lands in a separate PR. Refs: #291
Owner
Author
두 질문에 대한 결정 (현재 코드 유지)Q1:
Q2: 헤더 emit 안 함 (현재 그대로)
→ 코드 변경 없이 ready 전환 + 머지. |
This was referenced May 25, 2026
erishforG
added a commit
that referenced
this pull request
May 25, 2026
…317) develop에 머지됐지만 CHANGELOG.md [Unreleased]에 누락된 항목 4개를 추가한다: - parsec smartlog (alias sl): commit DAG 시각화 (#245, #305) - parsec __complete: 동적 shell completion 헬퍼 (#291, #312) - 에러 메시지 3줄 표준화 (error/caused by/help) (#303, #306) - Windows VS2026 pre-validation CI job (#307, #311) Closes #316 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
5 tasks
erishforG
added a commit
that referenced
this pull request
May 30, 2026
…291) (#328) Phase 1 (#312) 가 `parsec __complete <kind>` 내부 명령을 만들어 shell completion 스크립트가 동적으로 worktree/branch 후보를 가져올 수 있게 했음. 이번에는 그 위에 실제 zsh/bash/fish 스크립트 3개를 추가해서 사용자가 sourcing 만 하면 `parsec switch <Tab>` 처럼 live ticket 자동완성을 받을 수 있게 함. ## 변경 - `completions/_parsec` (zsh, #compdef) — `_parsec_worktrees` / `_parsec_branches` helper + 모든 주요 subcommand 의 positional/option 자동완성 - `completions/parsec.bash` — `complete -F _parsec parsec`. bash-completion 의존 (`_init_completion`). prev word 기반 dispatch + `compgen -W` - `completions/parsec.fish` — `__fish_seen_subcommand_from` 기반. per-subcommand 옵션 (`--base`, `--on`, `--branch`) 도 동적 branch/worktree 후보 연결 - README "Install > Shell completion" 섹션 추가 (3개 shell install 명령) ## 커버 범위 (Tier 1 + 2) - ticket 받는 subcommand: start, switch, ship, open, clean, status, ticket, pr-status, ci, merge, diff, sync, log, compress, adopt, rename - branch 받는 옵션: `start --base|--on|--branch`, `ship --base`, `adopt --branch` - smartlog: `--depth`, `--no-overlay` (PR #327 와 호환) ## __complete kind 추가 없음. Phase 1 의 `worktrees` / `branches` 두 개로 충분 — future Phase 3 에서 필요하면 추가 (예: `tickets` 트래커, `reviewers` GitHub 사용자). ## 드라이브-바이 PR #327 에서 같이 잡았던 `tests/cli_tests.rs:1725` clippy 회귀 (#326) develop 머지 전이라 또 한 번 적용. PR #327 머지되면 충돌 안 남. ## 테스트 - 신규 4개 통합 테스트: - `completion_zsh_present_and_dynamic` — `#compdef parsec` + `__complete` 호출 + 핵심 sub 7개 - `completion_bash_present_and_dynamic` — `complete -F _parsec parsec` + 동일 - `completion_fish_present_and_dynamic` — `__parsec_worktrees` 함수 + 동일 - `completion_scripts_reference_phase1_subcommand_signature` — 스크립트가 Phase 1 가 지원하지 않는 kind 부르지 않는지 (silent fail 방지) - 전체 62 통합 테스트 + smartlog 14 단위 + health 5 통과 - cargo build / clippy -D warnings / fmt --check 전부 clean ## 다음 Phase 힌트 - Phase 3: `__complete tickets` (트래커 미해결 티켓), `__complete reviewers` (GitHub mention) - Phase 4: shell auto-install hook (parsec init 에서 자동 설치 옵션) Refs #291 Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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
Scope of this PR (foundation only)
This is step 1 of 2 for #291. It lands the data-emission half:
```
$ parsec __complete worktrees
PROJ-101
PROJ-102
$ parsec __complete branches
develop
feature/x
main
```
What's NOT in this PR (follow-up)
Step 2 — making the existing `parsec config completions ` output call `__complete` from inside the generated zsh/bash/fish functions. The post-processing approach (replace `_files` with shell-specific `compadd "$(parsec __complete worktrees)"` blocks at known argument positions) belongs in its own PR so this one stays reviewable.
Filing as draft so we can agree on the foundation shape (hidden command name, candidate format, silent-failure policy) before wiring the shell scripts.
Test plan
Open questions for review
Refs: #291