Thank you for your interest in contributing to Code Analyzer! This guide will help you get set up and understand our development workflow.
- Node.js >= 20.0.0
- pnpm >= 9.0.0
- Git
# Clone the repository
git clone https://github.com/AgentiX-E/code-analyzer.git
cd code-analyzer
# Install dependencies
pnpm install
# Build all packages
pnpm build
# Run tests
pnpm testcode-analyzer/
├── .github/ # GitHub Actions workflows
├── .vscode/ # VS Code workspace settings
├── docs/ # Documentation
├── packages/ # Monorepo packages
│ ├── cli/ # CLI entry point and commands
│ ├── core/ # Domain models and abstractions
│ ├── shared/ # Shared types and utilities
│ ├── infra/ # Storage, Git, file system adapters
│ ├── analyzer/ # Language analysis engine
│ ├── intelligence/ # Search, embeddings, code review
│ ├── mcp/ # MCP server (Model Context Protocol)
│ ├── server/ # HTTP REST API
│ ├── vscode/ # VS Code extension
│ └── web/ # Web dashboard
├── scripts/ # Build and utility scripts
├── tests/ # Test suites
│ ├── unit/ # Unit tests
│ ├── integration/ # Integration tests
│ ├── e2e/ # End-to-end tests
│ └── property/ # Property-based tests
├── eslint.config.mjs # ESLint configuration (flat config)
├── tsconfig.base.json # Shared TypeScript configuration
├── turbo.json # Turborepo pipeline
└── vitest.config.ts # Unit test configuration
The codebase follows a seven-layer architecture where each layer can only depend on layers below it:
- Foundation (
@code-analyzer/core,@code-analyzer/shared) — types, config, logging - Infrastructure (
@code-analyzer/infra) — storage, Git, file system - Analysis Engine (
@code-analyzer/analyzer) — parsing, resolution, graphs - Intelligence (
@code-analyzer/intelligence) — search, embeddings, review - Service (
@code-analyzer/server,@code-analyzer/mcp) — APIs and MCP - Integration — CI/CD adapters
- Presentation (
@code-analyzer/cli,@code-analyzer/vscode,@code-analyzer/web)
# Build all packages
pnpm build
# Build with dependency graph awareness (recommended)
pnpm turbo build
# Run type checking
pnpm typecheck
# Run linting
pnpm lint
# Format code
pnpm format
# Check formatting
pnpm format:check# Run all tests
pnpm test
# Run only unit tests
pnpm test:unit
# Run integration tests
pnpm test:integration
# Run property-based tests
pnpm test:property
# Run end-to-end tests
pnpm test:e2e
# Run tests with coverage
pnpm vitest run --coverage- Unit tests — Reside in
packages/*/src/**/*.test.ts. Test individual functions/modules in isolation. Fast, no I/O. - Integration tests — Reside in
tests/integration/. Test interactions between packages. May use the in-memory graph store or file system. - Property-based tests — Reside in
tests/property/. Usefast-checkto verify invariants with random inputs. - E2E tests — Reside in
tests/e2e/. Full CLI or server tests exercising the complete pipeline.
Unit tests must meet strict coverage thresholds:
| Metric | Threshold |
|---|---|
| Lines | 95% |
| Branches | 90% |
| Functions | 95% |
| Statements | 95% |
Barrel files (src/index.ts) are excluded from coverage as they are covered by consumer tests.
- All code is written in TypeScript with strict mode enabled
- No
anytypes outside of test files - Prefer explicit types over inference when it improves readability
- Use
tsxfor files containing JSX/TSX - Exported APIs must have JSDoc comments
| Convention | Usage |
|---|---|
PascalCase |
Classes, interfaces, types, enums |
camelCase |
Variables, functions, methods, properties |
UPPER_SNAKE_CASE |
Constants and enum members |
kebab-case |
File names, package names |
Imports are enforced by ESLint in this order with blank lines between groups:
- Built-in modules (
fs,path) - External packages (
vitest,fast-check) - Internal workspace packages (
@code-analyzer/core) - Relative imports (
./utils,../types) - Type imports
We use ESLint 9 with flat config and @typescript-eslint strict-type-checked rules.
Key rules:
- No unused variables — prefix with
_to explicitly mark as unused - No
console.log— useconsole.warnandconsole.errorfor diagnostics - No
any— useunknownor proper types instead - Strict null checks — enabled at TypeScript level
We use Prettier for consistent formatting:
- Semicolons: always
- Quotes: single
- Trailing commas: all
- Print width: 100
- Tab width: 2
pnpm format # Auto-format all files
pnpm format:check # Check formatting in CIThis project follows Conventional Commits:
<type>(<scope>): <description>
[optional body]
[optional footer]
| Type | Description |
|---|---|
feat |
A new feature |
fix |
A bug fix |
docs |
Documentation changes |
style |
Formatting, missing semicolons, etc. |
refactor |
Code change that neither fixes a bug nor adds a feature |
perf |
Performance improvement |
test |
Adding or updating tests |
chore |
Maintenance tasks, dependency updates |
ci |
CI/CD changes |
build |
Build system or external dependency changes |
Use the package name as the scope (e.g., analyzer, cli, intelligence, mcp).
For cross-cutting changes, use deps, config, or omit the scope.
feat(analyzer): add TypeScript decorator support
fix(mcp): handle large response limits correctly
docs: update contributing guidelines
chore(deps): bump typescript to 5.7
test(intelligence): add vector search benchmarks
-
Fork the repository and create a feature branch from
main -
Write code following our Coding Standards
-
Add tests for new functionality. Ensure existing tests pass.
-
Run the full CI pipeline locally before pushing:
pnpm turbo build lint test typecheck pnpm format:check -
Write a descriptive PR following the template:
- What does this PR do?
- Which packages are affected?
- Breaking changes?
- How to test?
-
Request review from a maintainer
-
Address feedback and wait for CI to pass
-
Squash and merge once approved
- TypeScript compiles without errors
- ESLint passes with zero warnings
- All tests pass (unit, integration, property-based)
- Prettier formatting passes
- New code has appropriate test coverage
- Breaking changes are documented in changeset
- Commit messages follow conventional commits
We use Changesets for versioning and changelogs.
# Create a changeset for your changes
pnpm changesetFollow the prompts to select affected packages and describe the change.
Before cutting a release, ensure the following:
- All CI checks pass on
main(build, lint, typecheck, test, benchmarks) - Coverage thresholds are met (95% lines, 90% branches, 95% functions, 95% statements)
- No benchmark regressions >20%
-
CHANGELOG.mdis up to date with all changes since last release - Version numbers are consistent across root
package.jsonand all sub-packages - Breaking changes are documented in the changelog
-
pnpm buildcompletes successfully -
pnpm testpasses with all test suites
We use Changesets for version management.
-
Create a changeset for each PR that changes package behavior:
pnpm changeset
Select the affected packages and choose the appropriate bump type:
major— breaking changesminor— new features (backwards compatible)patch— bug fixes and small improvements
-
Bump versions when preparing a release:
pnpm version
This updates
package.jsonfiles andCHANGELOG.mdentries based on all pending changesets. -
Commit the version bump:
git add . git commit -m "chore: bump versions for release" git push
Releases to npm are automated via GitHub Actions. To publish:
- Ensure all changes are merged to
mainand CI passes - Bump versions using the process above
- Create a GitHub Release:
- Tag:
v{version}(e.g.,v0.2.0) - Title:
v{version} - Description: Copy the relevant section from
CHANGELOG.md - Click "Publish release"
- Tag:
The .github/workflows/publish-npm.yml workflow triggers on release publish and will:
- Build all packages
- Run the full test suite with coverage
- Publish all packages to npm with
--access public
Prerequisites:
- An
npmenvironment in GitHub repository settings NPM_TOKENsecret configured in that environment
Multi-arch Docker images are built and pushed automatically:
- Create a GitHub Release as described above
- The
.github/workflows/publish-docker.ymlworkflow triggers on release publish - Images are built for
linux/amd64andlinux/arm64platforms - Tags:
latest,vX.Y.Z,vX.Y,vX
Prerequisites:
- A
dockerenvironment in GitHub repository settings DOCKER_USERNAMEandDOCKER_TOKENsecrets configured
Manual multi-arch build (for local testing):
# Create a builder
docker buildx create --use
# Build and push
VERSION=0.2.0 docker buildx bake --pushThe VS Code extension is published to both VS Code Marketplace and Open VSX Registry:
- Create a GitHub Release as described above
- The
.github/workflows/publish-vscode.ymlworkflow triggers on release publish
Prerequisites:
- A
vscode-marketplaceenvironment in GitHub repository settings VSCODE_MARKETPLACE_TOKENandOPEN_VSX_TOKENsecrets configured
All notable changes must be documented in CHANGELOG.md. Follow these guidelines:
- Use Keep a Changelog format
- Group changes by categories: Added, Changed, Deprecated, Removed, Fixed, Security
- Reference relevant issues and PR numbers
- Include migration instructions for breaking changes
- Summarize high-level impact at the top of each release section
- Archive older releases under a collapsible "Version History" section
Example entry:
## [0.2.0] — YYYY-MM-DD
### Added
- Feature description (#123)
### Changed
- Breaking change description with migration guide (#456)
### Fixed
- Bug fix description (#789)- Open a GitHub Discussion
- Join our community chat (link coming soon)
Thank you for contributing to Code Analyzer!