|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +githru-vscode-ext is a VSCode extension that provides Git visualization and analytics. It's a monorepo with three main packages: |
| 8 | + |
| 9 | +- **analysis-engine**: Core Git analysis engine that parses git logs and GitHub data |
| 10 | +- **view**: React-based UI components for visualization (uses D3.js, Material-UI) |
| 11 | +- **vscode**: VSCode extension wrapper that bridges the engine and view |
| 12 | + |
| 13 | +## Development Commands |
| 14 | + |
| 15 | +### Root Level |
| 16 | +```bash |
| 17 | +# Install dependencies for all packages |
| 18 | +npm install |
| 19 | + |
| 20 | +# Build all packages |
| 21 | +npm run build:all |
| 22 | + |
| 23 | +# Test all packages |
| 24 | +npm run test:all |
| 25 | + |
| 26 | +# Lint all packages |
| 27 | +npm run lint |
| 28 | +npm run lint:fix |
| 29 | + |
| 30 | +# Format code |
| 31 | +npm run prettier |
| 32 | +npm run prettier:fix |
| 33 | +``` |
| 34 | + |
| 35 | +### Package-Specific Commands |
| 36 | + |
| 37 | +#### Analysis Engine (packages/analysis-engine) |
| 38 | +```bash |
| 39 | +# Build with type declarations |
| 40 | +npm run build |
| 41 | + |
| 42 | +# Run specific tests |
| 43 | +npm run test:stem |
| 44 | +npm run test |
| 45 | + |
| 46 | +# Lint |
| 47 | +npm run lint |
| 48 | +``` |
| 49 | + |
| 50 | +#### View (packages/view) |
| 51 | +```bash |
| 52 | +# Start development server |
| 53 | +npm run start |
| 54 | + |
| 55 | +# Build for production |
| 56 | +npm run build |
| 57 | + |
| 58 | +# Run tests |
| 59 | +npm run test |
| 60 | + |
| 61 | +# Run E2E tests |
| 62 | +npm run test:e2e |
| 63 | +``` |
| 64 | + |
| 65 | +#### VSCode Extension (packages/vscode) |
| 66 | +```bash |
| 67 | +# Build extension (also builds view package) |
| 68 | +npm run build |
| 69 | + |
| 70 | +# Watch mode for development |
| 71 | +npm run watch |
| 72 | + |
| 73 | +# Package extension |
| 74 | +npm run package |
| 75 | + |
| 76 | +# Debug: F5 in VSCode or Run > Start Debugging |
| 77 | +``` |
| 78 | + |
| 79 | +### Debugging the Extension |
| 80 | +1. Run `npm run build:all` from root |
| 81 | +2. Open the `packages/vscode` folder in VSCode |
| 82 | +3. Press F5 or use Run > Start Debugging |
| 83 | +4. In the Extension Development Host, use Command Palette > "Open Githru View" |
| 84 | + |
| 85 | +## Architecture |
| 86 | + |
| 87 | +### Data Flow |
| 88 | +1. **VSCode Extension** captures git repository context |
| 89 | +2. **Analysis Engine** processes git log and GitHub API data: |
| 90 | + - Parses raw git commits (`parser.ts`) |
| 91 | + - Builds commit dictionary (`commit.util.ts`) |
| 92 | + - Creates stem/branch structure (`stem.ts`) |
| 93 | + - Generates cluster summary map (`csm.ts`) |
| 94 | +3. **View** renders interactive visualizations using the processed data |
| 95 | + |
| 96 | +### Key Components |
| 97 | + |
| 98 | +#### Analysis Engine Core Classes |
| 99 | +- `AnalysisEngine`: Main orchestrator class |
| 100 | +- `PluginOctokit`: GitHub API integration with retry/throttling |
| 101 | +- Dependency injection using `tsyringe` |
| 102 | + |
| 103 | +#### View Architecture |
| 104 | +- **State Management**: Zustand stores in `src/store/` |
| 105 | +- **Components**: Modular React components with D3.js integration |
| 106 | +- **IDE Adapter Pattern**: `VSCodeIDEAdapter` bridges VSCode API |
| 107 | +- Component structure: `ComponentName/index.ts` exports, separate `.const.ts`, `.type.ts`, `.util.ts` files |
| 108 | + |
| 109 | +#### VSCode Extension |
| 110 | +- Extension activation on git repositories |
| 111 | +- Webview integration for React UI |
| 112 | +- Command palette integration |
| 113 | +- GitHub authentication management |
| 114 | + |
| 115 | +## Code Conventions |
| 116 | + |
| 117 | +### Commit Messages |
| 118 | +Follow conventional commits with these scopes: |
| 119 | +- `feat(engine)`: Analysis engine features |
| 120 | +- `feat(view)`: UI/visualization features |
| 121 | +- `feat(vscode)`: VSCode extension features |
| 122 | +- `fix(scope)`: Bug fixes |
| 123 | +- `refactor(scope)`: Code refactoring |
| 124 | + |
| 125 | +### Code Style |
| 126 | +- ESLint configuration with Prettier |
| 127 | +- TypeScript strict mode |
| 128 | +- 2-space indentation, 120 character line width |
| 129 | +- Single quotes disabled, trailing commas on ES5 |
| 130 | + |
| 131 | +### Testing |
| 132 | +- Jest for unit testing |
| 133 | +- Playwright for E2E testing (view package) |
| 134 | +- Test files: `*.spec.ts` or `*.test.ts` |
| 135 | + |
| 136 | +## Development Environment Setup |
| 137 | + |
| 138 | +### Prerequisites |
| 139 | +- Node.js >= 16 |
| 140 | +- npm >= 8 |
| 141 | +- VSCode with ESLint extension |
| 142 | + |
| 143 | +### TypeScript Configuration |
| 144 | +In VSCode, activate workspace TypeScript: |
| 145 | +1. Open a TypeScript file |
| 146 | +2. Ctrl/Cmd + Shift + P |
| 147 | +3. "Select TypeScript Version" |
| 148 | +4. "Use Workspace Version" |
| 149 | + |
| 150 | +### Package Structure |
| 151 | +The project uses npm workspaces. Each package has its own dependencies and build configuration but shares root-level linting and formatting rules. |
0 commit comments