Skip to content

feat(health): parsec health Phase 1 — lock/uncommitted/stale worktree checks#325

Merged
erishforG merged 1 commit into
developfrom
feat/auto-health-phase1
May 29, 2026
Merged

feat(health): parsec health Phase 1 — lock/uncommitted/stale worktree checks#325
erishforG merged 1 commit into
developfrom
feat/auto-health-phase1

Conversation

@erishforG
Copy link
Copy Markdown
Owner

무엇

parsec health 신규 명령 추가 (v0.5 milestone, Issue #299 Phase 1).

모든 active worktree를 순회해 3가지 경량 건강 지표를 표시:

지표 설명
lock .git/index.lock 잔여 여부 — 인터럽트된 git 프로세스 신호
uncommitted staged + unstaged 파일 수
stale 마지막 커밋이 7일 초과 — 방치된 워크트리

예시 출력:

parsec health
  ✓ PROJ-123           0 uncommitted  last commit 2d ago
  ⚠ PROJ-456           3 uncommitted  last commit 1d ago
  ✗ PROJ-789           0 uncommitted  last commit 9d ago (stale)  ⚠ lock file!

2/3 worktrees need attention.

--json 지원:

{
  "worktrees": [{"ticket":"PROJ-123","has_lock":false,"uncommitted":0,"stale_days":2,"stale":false}],
  "all_healthy": false
}

Issue #299 (parsec health epic)의 Phase 1 구현. CI-status overlay는 #309/#310 선행 이슈 완료 후 Phase 2에서 추가 예정.

parsec doctor가 환경(git 버전, 토큰 등)을 점검한다면 parsec health는 worktree 상태 자체를 점검한다.

변경

파일 변경
src/cli/commands/health.rs 신규 (~99줄)
src/cli/commands/mod.rs health 모듈 추가 (+2줄)
src/cli/mod.rs Health 커맨드 variant + dispatch (+11줄)
src/output/mod.rs HealthRecord struct + dispatch_output! (+15줄)
src/output/human.rs 컬러 테이블 렌더러 (+66줄)
src/output/json.rs JSON 렌더러 (+34줄)

리스크

  • read-only 전용 — worktree 상태 변경 없음
  • 새 외부 의존성 없음
  • 기존 명령 동작 변경 없음
  • 실패는 silent (git 명령 실패 시 해당 필드만 None으로 처리)

롤백

git revert <commit>Health variant 제거만으로 완전 롤백 가능.

Test plan

cargo build --quiet       # ✅ 통과
cargo fmt --check         # ✅ 통과
cargo clippy -- -D warnings  # ✅ 통과
cargo test --quiet        # ✅ 111/111 passed

기능 테스트:

parsec health             # 현재 repo에서 테이블 출력 확인
parsec health --json      # JSON 구조 확인

다음 단계

@erishforG 검토 부탁드립니다 🖤

Closes #324
Refs #299

…eleton (#324)

Add `parsec health` command that scans all active worktrees for three
lightweight health indicators:

- has_lock     — .git/index.lock exists (interrupted git process)
- uncommitted  — count of staged + unstaged files
- stale        — last commit older than 7 days

Output (human mode): colored table with ✓/⚠/✗ per worktree and a
summary line. JSON mode emits a structured array with `all_healthy` flag.

Files changed:
- src/cli/commands/health.rs       (new, ~99 lines)
- src/cli/commands/mod.rs          (+2 lines, re-export)
- src/cli/mod.rs                   (+11 lines, Health variant + dispatch)
- src/output/mod.rs                (+15 lines, HealthRecord + dispatch_output!)
- src/output/human.rs              (+66 lines, colored table renderer)
- src/output/json.rs               (+34 lines, JSON renderer)

CI-status overlay deferred to Phase 2 (depends on #309/#310).
All checks are read-only; no worktree state is modified.

Closes #324
Refs #299

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@erishforG erishforG added the auto-improvement Daily auto-generated improvement PR/issue label May 29, 2026
@erishforG erishforG merged commit 65b4fd1 into develop May 29, 2026
12 checks passed
erishforG added a commit that referenced this pull request May 30, 2026
Phase 1 구현(#325)을 커버하는 통합 테스트:

- test_health_empty_repo: 빈 repo → 'No active worktrees.' 확인
- test_health_empty_repo_json: 빈 repo → --json 시 '[]' 출력 확인
- test_health_shows_worktree: 워크트리 1개 → 티켓명 포함 출력 확인
- test_health_json_one_worktree: --json 구조 검증
  (worktrees 배열, all_healthy 불리언, ticket/has_lock/uncommitted/stale_days/stale 필드)
- test_health_exit_zero_with_issues: lock 파일 존재해도 exit 0 (정보성 only)

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
erishforG added a commit that referenced this pull request May 30, 2026
* test(health): parsec health CLI 통합 테스트 5개 추가 (#324)

Phase 1 구현(#325)을 커버하는 통합 테스트:

- test_health_empty_repo: 빈 repo → 'No active worktrees.' 확인
- test_health_empty_repo_json: 빈 repo → --json 시 '[]' 출력 확인
- test_health_shows_worktree: 워크트리 1개 → 티켓명 포함 출력 확인
- test_health_json_one_worktree: --json 구조 검증
  (worktrees 배열, all_healthy 불리언, ticket/has_lock/uncommitted/stale_days/stale 필드)
- test_health_exit_zero_with_issues: lock 파일 존재해도 exit 0 (정보성 only)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* feat(smartlog): Phase 2 — PR/CI status overlay (Refs #245)

Phase 1 (#305) skeleton에서 `SmartlogNode.pr` 가 placeholder로 남아있던 걸
실제 GitHub PR/CI 데이터로 채움. Issue #245 의 예시 (`[PR #42 ✓ CI passed,
✓ approved]`) 가 이제 ASCII 트리에 그대로 렌더링됨.

## 변경
- `SmartlogPrOverlay` struct 신설 (number/state/ci_status/review_status/url)
- `smartlog()` 가 GitHubClient 통해 brach → PR 매칭 + PrStatus 조회 후
  node.pr 채움. 토큰 없거나 비-GitHub remote거나 HTTP 실패 = 그냥 overlay
  생략 (best-effort, 명령 실패 안 함)
- `--no-overlay` 플래그 추가 (강제 offline 모드)
- ASCII 렌더러: ticket 라인 아래 `├─ [PR #N ● open ✓ CI ✓ approved]` 한 줄
- 글리프 규칙: 기존 `parsec pr status` / `parsec ci` 와 동일 (✓/✗/●/○)

## CI 필드는?
`SmartlogNode.ci` 는 일단 None 유지. Phase 2 는 CI 요약을 overlay 안에
포함시켜 한 줄로 표시 (스마트로그 본질은 한눈 — per-check 디테일은
`parsec ci` 가 이미 담당).

## 드라이브-바이
tests/cli_tests.rs:1725 에 `assert_eq!(bool, false)` clippy 경고 (#326
회귀) → `assert!(!...)` 로 수정. develop 의 clippy strict 빌드 회복.

## 테스트
- 신규 unit 5개 (format_pr_badge × 3 + render_text overlay + JSON 직렬화)
- 기존 9개 smartlog unit + 5개 통합 테스트 모두 통과
- cargo build / clippy -D warnings / fmt --check / test 전체 clean

## 다음 Phase 힌트
- Phase 3: per-worktree filtering (`--ticket CL-2283` 등)
- Phase 4: stack 관계 시각화 (PR base = 다른 PR head)
- Phase 5: review state 색상 강조 (terminal color)

Refs #245

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-improvement Daily auto-generated improvement PR/issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant