TNG VSCode Plugin
A Visual Studio Code extension for TNG: generate tests and run code intelligence (audit, clones, dead code, trace, and call sites) directly from your editor. Supports Ruby on Rails, Python, JavaScript, TypeScript, and React (JSX/TSX) projects with method detection and one-click actions.
Installation Links
Features
- Multi-Language Support - Ruby, Python, JavaScript, TypeScript, React (JSX/TSX)
- Method-Level Testing - Generate tests for specific methods/functions with cursor detection
- Audit Method - AI audit with issues, behaviours, and fixes
- Clones (Duplicates) - Find duplicate code blocks in a file
- Dead Code - Detect unused imports, variables, functions, and unreachable code
- Trace - Symbolic trace of a method’s execution path
- Status Bar Integration - Current method displayed with click-to-run functionality
- Intelligent Context Detection - Command appears only when cursor is inside methods
- Automatic Project Detection - Finds nearest
Gemfile (Ruby), package.json (JS/TS), or pyproject.toml (Python)
- Terminal Integration - Runs appropriate TNG command based on language
- Enhanced Error Handling - Clear, actionable error messages with troubleshooting guidance
- Smart Path Resolution - Handles Rails paths, JS/TS packages, and Python packages correctly
- Multi-Environment Support - Works with venv, uv, conda, pip, and global installations
Prerequisites
For Ruby Projects
- Install TNG gem: Add
gem 'tng' to your Gemfile and run bundle install
- Get API key: Sign up at https://app.tng.sh/
- Configure: Run
rails generate tng:install and set TNG_API_KEY environment variable
For Python Projects
- Install tng:
- pip:
pip install tng-python
- uv:
uv add tng-python
- Poetry:
poetry add tng-python
- Download: Get releases from GitHub
- Get API key: Sign up at https://app.tng.sh/
- Configure: Run
tng init to generate tng_config.py and set your API key
Supported Python Environments:
- Virtual environments:
venv, virtualenv, .venv
- uv:
uv run tng or uv tool install tng-python
- Poetry:
poetry run tng or poetry add tng-python
- Conda/Miniconda:
conda install tng-python
- Global pip:
pip install --user tng-python
Please reach out to support@tng.sh for help regarding installation and configuration, or for any other questions you may have.
Troubleshooting
Command Not Found Errors
If you see "command not found" errors, the extension will automatically show fallback command options. You can:
- Copy suggested commands from the notification popup
- Run them manually in your terminal
- Configure your environment to make TNG available globally
Supported Python Environments
The extension automatically detects and supports:
- venv/virtualenv:
./venv/bin/tng
- uv:
uv run tng or uv tool install tng-python
- Poetry:
poetry run tng or poetry add tng-python
- conda:
conda install tng-python
- pip:
pip install tng-python (global or user)
- Homebrew:
brew install tng-python (macOS)
Manual Command Execution
If automatic detection fails, try these commands in your terminal:
# Direct execution
tng -f "file.py" -m "method_name"
# Python module
python -m tng_python.main -f "file.py" -m "method_name"
# uv managed
uv run tng -f "file.py" -m "method_name"
# Poetry managed
poetry run tng -f "file.py" -m "method_name"
# Virtual environment
./venv/bin/tng -f "file.py" -m "method_name"
# Ruby bundler
bundle exec tng -f "file.rb" -m "method_name"
Usage
Method-Level Test Generation
The extension works with Ruby, Python, JavaScript, TypeScript, and React files:
- Open a file in your project (
.rb, .py, .js, .jsx, .ts, .tsx)
- Position cursor inside any method/function definition
- Status Bar shows current method name:
$(symbol-method) create
- Generate test using any of these:
- Click the status bar item
- Right-click → "TNG: Generate Test"
- Keyboard:
Cmd+Shift+T (Mac) or Ctrl+Shift+T (Windows/Linux)
- Command Palette:
TNG: Generate Test
Commands generated:
Ruby:
bundle exec tng "app/controllers/users_controller.rb" "create"
Python:
tng -f "app/services/user_service.py" -m "create_user"
JavaScript/TypeScript:
tng -f "src/services/userService.ts" -m "createUser"
How It Works
- Language Detection - Automatically detects Ruby (
.rb), Python (.py), JavaScript (.js/.jsx), and TypeScript (.ts/.tsx)
- Cursor Detection - Detects which method/function your cursor is inside
- Path Resolution - Finds the correct file path relative to project root
- Command Execution - Runs the appropriate TNG tool for your language
- Test Generation - Generates focused tests for the specific method
Command Availability
The "Generate Test" command only appears when:
- File is Ruby (
.rb), Python (.py), JavaScript (.js/.jsx), or TypeScript (.ts/.tsx)
- Cursor is positioned inside a method/function definition
- Project root can be detected (Gemfile, package.json, or Python config files)
Command Palette
Access via Command Palette (Ctrl+Shift+P / Cmd+Shift+P):
TNG: Generate Test - Generate test for method under cursor
Configuration
The extension provides the following settings:
tng.showMethodStatus (default: true) - Show current method in status bar with click-to-run functionality
tng.pythonRunner (default: auto) - Python runner for TNG (auto | uv | poetry | pipenv | python | tng)
tng.rubyRunner (default: auto) - Ruby runner for TNG (auto | bundle | ruby | tng)
tng.rubyBundlePath - Full path to bundle (optional)
tng.rubyPath - Full path to ruby (optional)
tng.rubyGemfile - Full path to Gemfile (optional, helpful for monorepos)
tng.jsRunner (default: auto) - JS runner for TNG (auto | node | npx | npm | pnpm | yarn)
tng.nodeBinaryPath - Full path to node (optional)
tng.npxBinaryPath - Full path to npx (optional)
tng.jsLocalBinaryPath - Full path to a local tng.js or tng (optional)
You can set these in:
- VS Code Settings UI:
Settings → Extensions → TNG Test Generator
- settings.json (workspace or user)
Sample Settings
Monorepo (force Gemfile)
{
"tng.rubyGemfile": "/Users/username/work/project/Gemfile"
}
Custom Ruby + Bundler
{
"tng.rubyRunner": "bundle",
"tng.rubyBundlePath": "/Users/username/.local/share/mise/installs/ruby/3.4.4/bin/bundle",
"tng.rubyPath": "/Users/username/.local/share/mise/installs/ruby/3.4.4/bin/ruby"
}
Python via uv
{
"tng.pythonRunner": "uv"
}
JS with custom node + npx
{
"tng.jsRunner": "npx",
"tng.nodeBinaryPath": "/opt/homebrew/bin/node",
"tng.npxBinaryPath": "/opt/homebrew/bin/npx"
}
Examples
Ruby (Rails)
| File + Method |
Command Generated |
app/controllers/users_controller.rb → def create |
bundle exec tng "app/controllers/users_controller.rb" "create" |
app/models/user.rb → def valid? |
bundle exec tng "app/models/user.rb" "valid?" |
app/services/payment_service.rb → def process |
bundle exec tng "app/services/payment_service.rb" "process" |
Python
| File + Method |
Command Generated |
app/services/user_service.py → def create_user |
tng -f "app/services/user_service.py" -m "create_user" |
src/models/user.py → async def validate |
tng -f "src/models/user.py" -m "validate" |
tests/helpers.py → def setup_database |
tng -f "tests/helpers.py" -m "setup_database" |
How It Works
The extension uses a clean, modular architecture with language-specific detection:
Project Detection
- Ruby: Finds nearest
Gemfile, falls back to workspace root
- Python: Finds
pyproject.toml, setup.py, requirements.txt, or other Python config files
- JavaScript/TypeScript: Finds nearest
package.json
Method Detection
- Language Server Protocol (LSP): Primary method using VS Code's built-in DocumentSymbol provider
- Ruby LSP, Python LSP (Pylance), JS/TS
- Regex Fallback: If LSP unavailable, uses pattern matching
- Ruby: Handles
def, operators, class methods (self.method)
- Python: Handles
def and async def
- JavaScript/TypeScript: Handles
function, class methods, and arrow functions
Command Execution
- Detects language from file extension
- Finds method name at cursor position
- Resolves project root and relative file path
- Builds appropriate command for the language
- Executes in terminal with proper working directory
Requirements
- VS Code 1.80.0+ (desktop only)
- Language-specific tools:
- Ruby: TNG gem with API key configured
- Python:
tng command available (via pip or binary)
- JavaScript/TypeScript:
tng command available (via npm package @tng-sh/js, npx, or local binary)
Troubleshooting
- Command not showing: Ensure cursor is inside a method/function definition
- "Place cursor inside a method": Extension requires cursor to be inside a method body
- Command not found:
- Ruby: Verify in terminal with
bundle exec tng --help
- Python: Verify in terminal with
tng --help
- JavaScript/TypeScript: Verify in terminal with
npx -p @tng-sh/js tng --help
- Project root not found: Open the project folder (containing Gemfile/package.json/pyproject.toml) as workspace
- API key issues: Set API key in respective config files
- Method not detected: Install appropriate LSP extension (Ruby LSP, Pylance, JS/TS)
- Status bar not showing: Enable
tng.showMethodStatus in VS Code settings
Support
Happy coding!