@celp/celp-cli
v1.0.95
Published
`celp-cli` is a contextually aware, A.I.-driven command line tool that generates unit tests for your TypeScript Node.js projects. It simplifies the testing process by analyzing your code and automatically generating meaningful, comprehensive tests.
Downloads
273
Readme
celp-cli
celp-cli
is a contextually aware, A.I.-driven command line tool that generates unit tests for your TypeScript Node.js projects. It simplifies the testing process by analyzing your code and automatically generating meaningful, comprehensive tests.
Table of Contents
Requirements
- TypeScript Node Projects Only:
celp-cli
supports backend projects written in TypeScript and running on Node.js. Frontend support is coming soon. - Node 20+
Installation
To install celp-cli
, run:
npm install -g @celp/celp-cli
Usage
Generate Unit Tests
Navigate to your project directory and run:
celp-cli generate:tests
This command analyzes your staged changes (diff) and generates unit tests based on the identified changes and existing code structure.
Special Features
- Reflection (
--reflection
): Automatically run and fix generated tests. - Feedback (
celp-cli feedback:add <text>
): Provide feedback to improve future test generations.
Example
celp-cli generate:tests --reflection --reflection-attempts 3
Optional Parameters
Customize test generation with these parameters:
--reflection
: Automatically run and fix generated tests on failure.--reflection-attempts <number>
: Set the maximum number of reflection attempts (default: 3).--output <path>
: Specify the file to write tests to (new or existing).--lines <range>
: Define the line range to generate tests for (format: start-end).--layers <number>
: Set the number of layers deep to collect context (default: 3).--file <path>
: Specify the file to generate tests for.--context <path>
: Provide a test file for context (automatic context detection is recommended).--diff-branch
: Select a branch to compare your diff to.--entire-file
: If you want to generate tests for an entire file, provide the--file
and add--entire-file
--directory <path>
: Generate unit tests for each file in a directory in your project
Configurable Testing Preferences
Configure celp-cli
to match your testing preferences:
celp-cli feedback:add "Avoid testing implementation details"
celp-cli feedback:add "Always use equality assertions"
celp-cli feedback:add "Avoid global setups like beforeEach and afterEach"
Example
celp-cli generate:tests --file src/example.ts --context tests/context.test.ts --output tests/output.test.ts
Choosing an AI Provider
celp-cli
allows you to choose your preferred AI provider for generating unit tests. You can select from the following options:
- OpenAI: Use OpenAI's models like GPT-4 for high-quality AI capabilities.
- Anthropic: Choose Anthropic for advanced and ethical AI models like Claude-3.5-Sonnet.
- Bedrock + Anthropic: Combine AWS Bedrock infrastructure with Anthropic's AI models for robust performance.
To set your preferred AI provider, run:
celp-cli configure:ai
You will then be prompted for the corresponding credentials (api key or access key/secret).
Cost
celp-cli
defaults to OpenAI's GPT-4o-mini for generating unit tests. This is FREE to use. If you use another AI model, then the cost varies depending on the size of the git diff and the number of tokens processed.
Commands
celp-cli generate:tests <options>
: Generates new unit tests for your project.celp-cli configure:path <path>
: Configure a custom directory path for storingcelp-cli
files (default: .celp-ai).celp-cli configure:reset
: Reset the configuredcelp-cli
path to the default path.celp-cli feedback:add <text>
: Provide feedback to improve future test generations.celp-cli feedback:reset
: Reset the feedback data.celp-cli feedback:edit
: Edit your feedback.celp-cli help
: Display help information.celp-cli --version
: Display the current version ofcelp-cli
.
Troubleshooting
Common Issues
- Permission Denied: Ensure you have the necessary permissions to install to
/usr/local/bin
. You may need to run the install script withsudo
. - Unsupported OS/Architecture: Currently,
celp-cli
supports Linux x86_64 and macOS. Ensure your system meets these requirements.
Reporting Issues
If you encounter any issues or have suggestions for improvements, please post them to our Discord channel.
License
This project is licensed under the Commercial License. See the LICENSE file for details.