feat(cli): insights check — count-based behavior + --analyze flag#252
feat(cli): insights check — count-based behavior + --analyze flag#252
Conversation
…lyze flag Implements Issue #242: backfill check + recovery for unanalyzed sessions. - insightsCheckCommand is now async - 0 unanalyzed: silent exit - 1-2 unanalyzed: auto-analyze silently using ClaudeNativeRunner - 3-10 unanalyzed: print count + suggest `insights check --analyze` - 11+: print count + time estimate (~22s/session) + suggest command - --analyze flag: process all sessions with [N/total] progress output - --quiet: outputs just the count (no progress, no colors) - --days: lookback window (default 7) - Per-session error handling in batch: log error, continue to next - _runner param on runInsightsCommand for batch reuse (avoids repeated validate()) - Registered --analyze in index.ts check subcommand Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
TA Review (Phase 1 - Insider): insights check — count-based behavior + --analyze flag — Round 1Data Contract Impact
Architecture AlignmentSQL Query (LEFT JOIN anti-pattern): The fix from Count-based dispatch logic: Verified the dispatch tiers:
The ordering is correct:
Error resilience: Each session in the Async migration: Test Coverage (TDD Domain Verification)
Pattern Consistency
Issues Found🔴 FIX NOW:
(No FIX NOW items found.) 🟡 SUGGESTION:
🔵 NOTE:
Phase 1 Verdict
Clean implementation. No schema changes, no type contract breaks, no cross-layer impact. The SQL fix is correct, the dispatch logic is sound, error resilience is properly implemented, and test coverage is thorough. The |
Triple-Layer Code Review — Round 1Reviewers
Pre-Review Gates
Issues Found & Resolution🔴 FIX NOWNone. 🟡 SUGGESTIONS (non-blocking)
Round 1 verdict: PASS — Ready for merge |
What
Enhances
code-insights insights checkwith count-based behavior and a new--analyzeflag. Closes #242.Why
Users needed a way to discover and recover unanalyzed sessions without manually hunting for session IDs. The hook installs analysis on new sessions but doesn't backfill existing ones.
How
insightsCheckCommandis now async (required for--analyzebatch processing)ClaudeNativeRunner(zero-config)insights check --analyze--analyze: process all found sessions sequentially with[N/total] session-title ... done (Xs)progress; errors per-session are logged and processing continues--quiet: outputs just the count as a number (for scripting)--days: overrides lookback window (default 7)_runnerparam torunInsightsCommandfor batch callers to reuse a single runner instance (avoids repeatedvalidate()calls)--analyzeoption inindex.tscheck subcommandSchema Impact
InsightsCommandOptions— added optional_runnerfield (internal, not user-facing)Testing
Build & Tests
pnpm buildfrom repo root)New test coverage (TDD)
Added 13 new tests in
cli/src/commands/__tests__/insights.test.ts:insightsCheckCommand — count-based behavior(6 tests): silent on 0, quiet count, 3-10 suggestion, 11+ time estimate, --days windowinsightsCheckCommand — auto-analyze (1-2 sessions)(2 tests): validate() called, runner usedinsightsCheckCommand — --analyze flag(3 tests): progress output, error resilience, silent on 0Test plan
--analyze--analyze--analyzeprocesses all sessions with[N/total]progress--quietoutputs just the count--daysoverrides lookback window