Skip to content

[245] feat(smartlog): skeleton — DAG data model + ASCII tree + JSON output#305

Merged
erishforG merged 1 commit into
developfrom
245-feat/smartlog-skeleton
May 13, 2026
Merged

[245] feat(smartlog): skeleton — DAG data model + ASCII tree + JSON output#305
erishforG merged 1 commit into
developfrom
245-feat/smartlog-skeleton

Conversation

@erishforG
Copy link
Copy Markdown
Owner

배경

v0.5 milestone 의 smartlog (#245) 첫 PR — Phase 1 skeleton.

변경

`parsec smartlog` (alias `sl`) 명령 추가:

  • 활성 worktree 전부 → ticket/branch/base/commits 수집
  • `base..branch` git log 로 commit 리스트
  • ASCII 트리 렌더 (base 별 그룹) + `--json` 출력
  • `--depth N` 옵션 (default 10)

출력 예시 (parsec 자체 worktrees)

```
○ develop (base)

├─● 207 #207 [feature/207]
│ └─ (no commits since develop)

└─● 279 #279 [feature/279]
└─ (no commits since develop)
```

JSON 도 동일 구조로 출력 (PR/CI 필드는 `skip_serializing_if` 로 미노출).

설계

  • `SmartlogNode` 에 `pr` / `ci` placeholder 필드 추가 — 후속 PR 에서 GitHub PR/CI 상태 채움
  • `collect_commits` 는 `git2` 의존 없이 `git::run_output` 사용 — `git/` 모듈 일관성 유지
  • worktree 단위 soft-fail: 하나 corrupt 여도 전체 명령 안 죽음
  • `render_text` 는 String 반환 → 테스트 용이

후속 PR (별도)

  • PR 상태 overlay (open/draft/merged) — `GitHubClient` 활용
  • CI 상태 overlay (passed/failed/running)
  • Review 상태 (approved/changes requested)
  • Stack 관계 시각화
  • Color / 더 똑똑한 wrapping

테스트

  • 9 신규 단위 테스트 (parse_commit_line × 4, render_text × 4, JSON serialize × 1)
  • 전체 `cargo test`: bin 42 / integration 40 / 5 — 0 fail
  • `cargo fmt --check` 통과
  • 실제 parsec 자체 worktree 에서 smoke 실행 검증

관련

🤖 Generated with Claude Code

…utput

Phase 1 of #245. Establishes the command surface and rendering path
without any forge-side enrichment.

Adds `parsec smartlog` (alias `sl`):
- `SmartlogNode` per active worktree: ticket, branch, base, commits,
  plus `pr` / `ci` placeholder fields gated on `skip_serializing_if`
  so the JSON output stays clean until follow-up PRs populate them.
- `collect_commits` shells out to `git log <base>..<branch>` (no
  `git2` dependency — matches the rest of `git/`). Soft-fails per
  worktree so a corrupt worktree can't take the whole command down.
- `render_text` groups nodes by base branch and draws ASCII tree
  glyphs (○ │ ├─● └─). Returns the rendered string for testability.
- `--json` emits the same structure for tooling.
- `--depth N` caps commits per worktree (default 10).

Out of scope for this PR (follow-ups on the same epic):
- PR overlay (open/draft/merged)
- CI overlay (passed/failed/running)
- Review state (approved / changes requested)
- Stack relationship visualization
- Color / smarter wrapping

Tests (9 new in `cli::commands::smartlog::tests`):
- `parse_commit_line` happy path + tab-in-subject + garbage + empty SHA
- `render_text` empty / single / no-commits / multi-base grouping
- JSON serialization omits placeholder overlay fields

Smoke run on parsec's own worktrees produces:
  ○ develop (base)
  ├─● 207 #207 [feature/207]
  │  └─ (no commits since develop)
  └─● 279 #279 [feature/279]
     └─ (no commits since develop)
@erishforG erishforG merged commit 02cb26d into develop May 13, 2026
11 checks passed
@erishforG erishforG deleted the 245-feat/smartlog-skeleton branch May 13, 2026 00:13
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>
erishforG added a commit that referenced this pull request May 26, 2026
parsec smartlog (#305)과 sl 별칭이 develop에 머지됐지만
CLI 통합 테스트가 전혀 없었음. 5개 시나리오 추가:

- test_smartlog_empty_repo: 빈 repo → 'No active worktrees' 확인
- test_sl_alias_works_like_smartlog: sl == smartlog 동일 출력 확인
- test_smartlog_json_empty_is_array: --json 빈 repo → [] JSON 배열
- test_smartlog_shows_worktree: worktree 1개 → 티켓·(base) 마커 표시
- test_smartlog_json_one_worktree: --json 1 worktree → 필드 검증
  (ticket, branch, base_branch, commits, pr/ci 미노출)

Closes #318

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant