A Visual Studio Code extension to enhance Salesforce Apex development by generating inline documentation and test classes using an Ollama language model. This extension integrates with a locally running Ollama API to process Apex code and produce well-documented code or test classes, streamlining your development workflow.
Features
Generate Inline Documentation: Add detailed inline comments to your Apex code and create a new .cls file with the documented version.
Generate Test Classes: Automatically create comprehensive Apex test classes for your code, saved as a new .cls file.
Dynamic Model Selection: Choose from available Ollama models (fetched from http://localhost:11434/api/tags) via a Quick Pick menu.
Markdown Descriptions: View detailed Markdown explanations of the generated documentation or test class in an output channel.
Seamless Integration: Works directly with .cls files in your VS Code workspace, creating output files in the same folder.
Requirements
Visual Studio Code: Version 1.85.0 or higher.
Ollama API: A locally running Ollama server (default: http://localhost:11434). Ensure the /api/tags and /api/generate endpoints are accessible.
Apex Files: The extension works with Salesforce Apex files (.cls extension).
Usage
Open an Apex File:
Open a .cls file in VS Code (e.g., MyClass.cls).
Run a Command:
Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P).
Select one of the following commands:
Apex: Generate Inline Documentation: Creates a new file (e.g., MyClass_Docs.cls) with inline comments.
Apex: Generate Test Class: Creates a new file (e.g., MyClassTest.cls) with a test class.
A Quick Pick menu will display available Ollama models (e.g., gemma3:latest). Select a model to proceed.
View Results:
The generated Apex code is saved in a new file and opened in the editor.
A Markdown description of the output is displayed in the Apex Code Assistant output channel (View > Output).
Configuration
Customize the extension via VS Code settings:
Open Settings (Ctrl+, or Cmd+,).
Search for apexCodeAssistant.
Configure the following options:
Setting
Description
Default
apexCodeAssistant.ollamaApiUrl
The URL of the Ollama API endpoint.
http://localhost:11434/api/generate
Notes:
The /api/tags endpoint is derived from ollamaApiUrl by replacing /generate with /tags.
Model selection is dynamic, fetching available models from the Ollama API each time a command is run.