Thanks for your interest in contributing. Here's how to get started.
Website: www.contextai.run
git clone https://github.com/madeburo/contextai.git
cd contextai
npm install# Build
npm run build
# Run tests (single pass)
npm test
# Run a specific test file
npx vitest --run src/config-parser.test.tssrc/
cli.ts # CLI entry point
index.ts # Public library API
types.ts # Shared TypeScript interfaces
errors.ts # Custom error classes
config-parser.ts # Loads and validates context.config.ts
scanner.ts # Detects frameworks in a project
diff-engine.ts # Line-level diffing
template-registry.ts # Built-in framework templates
watcher.ts # File watcher (chokidar)
git-hook-installer.ts # Git pre-commit hook installer
commands/ # One file per CLI command
generators/ # One file per output target
templates/ # Built-in framework convention templates (JSON)
- Every source file has a co-located test file:
foo.ts→foo.test.ts - Commands export a single
run*function (e.g.runGenerate) - Generators extend
BaseGeneratorfromgenerators/base.ts - All shared types live in
types.ts - Domain errors use custom classes from
errors.ts— never throw plainError - Imports use
.jsextension even for.tsfiles (required for CJS output)
- Create
src/generators/my-target.tsextendingBaseGenerator - Implement
generate(config)returning the file content as a string - Add the output key to
OutputsConfiginsrc/types.ts - Register it in
buildGenerators()insrc/commands/generate.ts - Add expected headers to
EXPECTED_HEADERSinsrc/commands/validate.ts - Create
src/generators/my-target.test.ts
- Create
src/templates/my-framework.jsonfollowing the existing format - Add the name to
TemplateNameunion insrc/types.ts - Import and register it in
src/template-registry.ts - Add detection patterns to
FRAMEWORK_INDICATORSinsrc/scanner.ts
- Run
npm testbefore submitting a PR — all 92 tests must pass - No
anytypes unless absolutely necessary (and suppressed with eslint comment) - Use
instanceof Errorchecks instead ofas Errorcasts in catch blocks - All generator writes go through
resolveOutputPath()for path traversal protection
- Fork the repo and create a feature branch
- Make your changes with tests
- Run
npm testto verify - Open a pull request with a clear description
By contributing, you agree that your contributions will be licensed under the MIT License.