Dongx for VSCode
A VS Code extension that helps you manage environment variables for terminal integration, specifically designed to set Anthropic API configurations.
Features
- 🚀 Easy Setup: Set custom environment variables with a single command
- 🔧 Safe Configuration: Asks for user confirmation before modifying settings
- 🗑️ Clean Removal: Remove environment variables when no longer needed
- 👀 View Current Settings: Check what environment variables are currently set
- ⚡ Auto-Setup: Optional automatic setup when extension activates
- 🌍 Cross-Platform: Works on Windows, macOS, and Linux
Commands
This extension provides the following commands:
Dongx: Set Environment Variables
- Set ANTHROPIC environment variables
Dongx: Remove Environment Variables
- Remove ANTHROPIC environment variables
Dongx: Show Current Environment Settings
- Display current configuration
Usage
Setting Environment Variables
- Open the Command Palette (
Cmd+Shift+P
on macOS, Ctrl+Shift+P
on Windows/Linux)
- Run the command
Dongx: Set Environment Variables
- Confirm the action when prompted
- The extension will add these environment variables to your VS Code terminal settings:
ANTHROPIC_BASE_URL=http://japi-ai-proxy-pre.jd.com/aiProxy
ANTHROPIC_API_KEY=sk-ant-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Customizing Values
You can customize the default values in VS Code settings:
- Open Settings (
Cmd+,
on macOS, Ctrl+,
on Windows/Linux)
- Search for "dongx"
- Modify the following settings:
dongx.anthropicBaseUrl
: Custom Anthropic API Base URL
dongx.anthropicApiKey
: Your Anthropic API Key
dongx.autoSetOnActivation
: Auto-set variables when extension activates
Removing Variables
- Open the Command Palette
- Run
Dongx: Remove Environment Variables
- Confirm the removal when prompted
Configuration
The extension adds the following settings to VS Code:
{
"dongx.anthropicBaseUrl": "http://japi-ai-proxy-pre.jd.com/aiProxy",
"dongx.anthropicApiKey": "sk-ant-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"dongx.autoSetOnActivation": false
}
How It Works
This extension modifies your VS Code user settings to add environment variables that will be available in all new integrated terminal sessions. The modified setting looks like:
{
"terminal.integrated.env.osx": {
"ANTHROPIC_BASE_URL": "http://japi-ai-proxy-pre.jd.com/aiProxy",
"ANTHROPIC_API_KEY": "sk-ant-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
The platform-specific key (osx
, windows
, or linux
) is automatically detected.
Installation
From Source
Copy the dongx-vscode-extension
folder to your VS Code extensions directory:
- Windows:
%USERPROFILE%\\.vscode\\extensions\\
- macOS:
~/.vscode/extensions/
- Linux:
~/.vscode/extensions/
Restart VS Code
The extension should now be active
Development
- Clone or download this extension
- Open the extension folder in VS Code
- Press
F5
to launch a new Extension Development Host
- Test the extension in the new VS Code window
Safety Features
- User Confirmation: Always asks for permission before modifying settings
- Non-Destructive: Merges with existing environment variables instead of overwriting
- Reversible: Provides easy removal of added variables
- Visible Changes: All changes are made to your VS Code settings.json file
Troubleshooting
Variables Not Working in Terminal
- Make sure you've created a new terminal after setting the variables
- Check that
terminal.integrated.inheritEnv
is enabled in VS Code settings
- Verify the variables are set by running
Dongx: Show Current Environment Settings
Extension Not Loading
- Check the VS Code Developer Console (
Help
→ Toggle Developer Tools
) for errors
- Make sure the extension folder is in the correct location
- Restart VS Code completely
Requirements
- VS Code version 1.74.0 or higher
- No additional dependencies required
Release Notes
1.0.0
- Initial release
- Support for setting ANTHROPIC environment variables
- Cross-platform compatibility
- User confirmation dialogs
- Settings management
Contributing
This is a simple extension built for specific use cases. If you encounter issues or have suggestions, please create an issue or submit a pull request.
License
MIT License - Feel free to modify and distribute as needed.