Mo Assistant VS Code ExtensionMo 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
Installation
Getting Started
Quick Access to Mo Assistant command paletteUse the keyboard shortcut Usage GuideAI-Powered Commit Message GenerationGenerate commit messages based on your staged changes:
Code RefactoringRefactor your code using AI suggestions:
Automatically do a full refactor on file using AI suggestions. Automatically refactor sections of your code using AI suggestions. Context-Aware Code AssistanceImprove AI responses by managing context:
Unit Testing SupportCreate and manage unit tests effortlessly:
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 InterfaceAccess different functionalities through dedicated panels:
CommandsUse the keyboard shortcut Open Mo Assistant command prompt:
Mo Assistant provides the following commands:
Mo Assistant ConfigurationYou can override the default configuration by creating a Using
|
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.
Troubleshooting
If you encounter any issues while using Mo Assistant, try these common solutions:
Claude API Token Issues
- Ensure your Claude API token is correctly set in the VS Code settings.
- Check that your token hasn't expired or been revoked.
- Verify your internet connection to ensure the extension can communicate with the API.
Extension Not Loading
- Restart VS Code.
- Ensure you have the latest version of the extension installed.
- Check the VS Code output panel for any error messages related to Mo Assistant.
Commands Not Working
- Make sure you're using the correct keyboard shortcut:
Ctrl+Shift+A
(Windows/Linux) orCmd+Shift+A
(Mac). - Verify that the command palette is showing Mo Assistant commands.
- Check if there are any conflicting extensions that might be overriding the commands.
Incorrect or Unexpected AI Responses
- Review the context added to the AI. Use
/context-show
to see what files are currently in context. - Try clearing the context with
/context-clear
and then re-adding relevant files. - Ensure your project's
.moassistant.json
configuration file is correctly formatted.
Unit Test Generation Issues
- Verify that your project's test framework is correctly set up.
- Check that the
testCommand
in your configuration matches your project's test run command. - Ensure the
testDirectories
andtestFileExtensions
in your configuration are correct for your project structure.
"Command Not Found" Error When Running Tests (macOS)
If you encounter a "command not found" error when using the /test-run
command, it may be due to npm not being accessible in a non-interactive shell. To resolve this:
Ensure npm is accessible at the system root:
- Open your terminal
- Run
sudo nano /etc/paths
- Add the path to your Node.js installation, e.g.:
/Users/[username]/.nvm/versions/node/[version]/bin
- Save and exit the editor
Reload the paths:
- Run
source /etc/paths
- Run
Verify npm is available:
- Open a new terminal
- Start a shell with
/bin/sh
- Run
npm --version
If the version number displays correctly, npm should now be accessible to the extension.
Note: The exact path may vary depending on your Node.js installation method (e.g., nvm, direct download). Adjust the path accordingly.
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!