Mo Assistant VS Code Extension
Mo Assistant is a powerful Visual Studio Code extension designed to enhance your development workflow by integrating AI-assisted features. It provides an intuitive webview interface that allows you to manage commits, documentation, unit testing, and code refactoring directly from editor.
Table of Contents
Key Features
- 🤖 AI-Powered Commit Messages: Generate meaningful commit messages automatically based on your code changes.
- 🔧 Intelligent Code Refactoring: Improve your code quality with AI-suggested refactoring.
- 🧪 Comprehensive Unit Testing Support: Create, update, run, and validate unit tests with ease.
- 📚 Context-Aware Assistance: Add files to the AI's context for more accurate and relevant responses.
- 🎨 Interactive Webview Interface: Access all features through a user-friendly sidebar interface.
Installation
- Open Visual Studio Code
- Go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X)
- Search for "Mo Assistant"
- Click "Install"
Getting Started
- After installation, click on the Mo Assistant icon in the Activity Bar.
- Set up your Claude AI token (Set up the Claude Anthropic token. Check Anthropic docs here):
- You're all set! Start using Mo Assistant's powerful features.
Quick Access to Mo Assistant command palette
Use the keyboard shortcut Ctrl+Shift+A
(Windows/Linux) or Cmd+Shift+A
(Mac) to quickly ask Mo Assistant for help.
Usage Guide
AI-Powered Commit Message Generation
Generate commit messages based on your staged changes:
- Stage your files in Git
- Open Mo Assistant and navigate to the Commit Message Generation panel
- Click "Generate Commit Message"
- Review and execute the generated message with a single click
Code Refactoring
Refactor your code using AI suggestions:
- Open the file you want to refactor
- Use the command palette (
Ctrl+Shift+A
or Cmd+Shift+A
) and search for /refactor
- Review and apply the suggested changes
Automatically do a full refactor on file using AI suggestions.
Automatically refactor sections of your code using AI suggestions.
Context-Aware Code Assistance
Improve AI responses by managing context:
- Use the command palette (
Ctrl+Shift+A
or Cmd+Shift+A
) and searchfor
/context-add
to add files to context
/context-remove
to remove files from context
/context-show
to show the files in context
/context-clear
to remove all files from context
Unit Testing Support
Create and manage unit tests effortlessly:
- To create a test: Use
/test-create
- To run tests: Use
/test-run
- To update existing tests: Use
/test-update
- To increase coverage and validate: Use
/test-auto-increase-coverage-validate
Create unit tests for your code.
Run a unit test and validate them.
Update existing unit tests.
Increase coverage and validate in one step.
Interactive Webview Interface
Access different functionalities through dedicated panels:
- Documentation
- Configuration
- Commit Message Generation
- Unit Testing
- Code Refactoring
Commands
Use the keyboard shortcut Ctrl+Shift+A
(Windows/Linux) or Cmd+Shift+A
(Mac).
Open Mo Assistant command prompt:
Ctrl+Shift+A
(Windows/Linux) or Cmd+Shift+A
(Mac), Mo Assistant: Ask Mo
: Initiates a conversation with the AI assistant, allowing you to ask questions or request help with your code.
Mo Assistant provides the following commands:
/refactor
: Automatically analyzes and suggests improvements for your code using AI-powered refactoring techniques.
/context-add
: Adds the current file to the AI's context, improving the relevance of its responses.
/context-remove
: Removes a previously added file from the AI's context.
/context-show
: Displays the current files and code snippets that are part of the AI's context.
/context-clear
: Removes all files from the AI's context, resetting it to its initial state.
/test-runt
: Executes the unit tests for the current file or project.
/test-create
: Generates a new unit test for the selected code or current file using AI assistance.
/test-update
: Modifies an existing unit test to reflect changes in the code it's testing, with AI guidance.
/test-auto-validate
: ⚡ Checks the validity and effectiveness of the current unit test.
/test-auto-create-validate
: ⚡ Combines the creation and validation of a unit test in one step for faster development.
/test-auto-increase-coverage-validate
: ⚡ Analyzes the current test coverage, suggests improvements, and validates the enhanced tests.
/git-changes-create-test
: Automatically generates unit tests for recent changes in your codebase.
/git-changes-increase-test-coverage
: Identifies areas of low test coverage in recent changes and suggests additional tests to improve coverage.
/open-readme
: Displays the README file for the Mo Assistant extension, offering detailed information about its usage and configuration.
/show-view
: Opens the main page of the Mo Assistant extension, providing an overview of its features and functionality.
Mo Assistant Configuration
You can override the default configuration by creating a .moassistant.json
file in your project's root directory or package. The structure of this file should match the default configuration object. This allows you to customize Mo Assistant's behavior to better fit your project's specific needs and structure.
Using .moassistant.json
The .moassistant.json
file is a powerful way to tailor Mo Assistant to your project's requirements. Here's how to use it:
- Create a file named
.moassistant.json
in your project's root directory.
- Add your custom configuration options to this file, following the structure of the default configuration.
- Mo Assistant will automatically detect and use these custom settings.
Example .moassistant.json
:
{
"testCommand": "npm run test:unit -- ",
"testDirectories": ["test", "__tests__"],
"testFileExtensions": [".test.ts", ".test.js", ".spec.js", ".spec.ts"],
"testSampleCode": "",
"testSpecialConsiderations": "",
"defaultTestExtension": ".spec.ts",
"gitCommandsConfig": {
"allowedExtensions": [".ts", ".tsx", ".js", ".jsx", ".vue"],
}
}
*You cam create multiple configuration files in your project. The Assistant is going to look for the nearest top configuration file from the editor where the command was executed.
Automatically add Mo Assistant configuration files to your project
Mo Assistant uses a configuration file to set up the working rules for the project when running unit test commands. If you have not created the configuration file you will be prompted to created when working with unit tests.
Default Configuration
Mo Assistant comes with a set of default configurations that you can customize. Here are the default settings:
Configuration Option |
Default Value |
Description |
testCommand |
"npm run test:unit -- " |
The command used to run unit tests for your project. Note: The "--" parameter is crucial as it ensures that the code can inject the path of the file to be tested after the command. |
testDirectories |
["test", "__tests__"] |
An array of directory names where Mo Assistant will look for test files. The first element in the array will take precedence. You can also you ./ for a relative path to the main code. |
testFileExtensions |
[".test.ts", ".test.js", ".spec.js", ".spec.ts"] |
An array of file extensions that Mo Assistant recognizes as test files. |
testSampleCode |
(example code snippet) |
A sample code snippet used as a reference for generating an updating unit tests. IMPORTANT: The sample code has to be stringify otherwise it can cause errors. You can use this online tool. |
testSpecialConsiderations |
(special considerations text) |
Special instructions or considerations for generating and updating unit tests. |
defaultTestExtension |
".spec.ts" |
The default file extension used when creating new test files. |
gitCommandsConfig.allowedExtensions |
[".ts", ".tsx", ".js", ".jsx", ".vue"] |
An array of file extensions that Mo Assistant will consider when working with Git-related features. |
Note: When you run a Mo Assistant command for the first time, and it needs configuration, you will be automatically prompted to create the .moassistant.json
configuration file if it doesn't already exist. This makes it easy to set up your custom configuration without manually creating the file.
By using a .moassistant.json
file, you can ensure that Mo Assistant works seamlessly with your project's specific testing framework, file structure, and development practices.
Feedback and Support
For more information and updates, visit the Mo Assistant GitHub repository.
Enjoy using Mo Assistant to boost your productivity and streamline your development workflow!