Hitman VS Code Extension
A comprehensive VS Code extension for the Hitman HTTP scripting language that provides syntax highlighting, intelligent code completion, linting, and integrated CLI execution.
Features
🎨 Syntax Highlighting
- Full syntax highlighting for
.hit
files with custom file icons
- Support for HTTP methods (
GET
, POST
, PUT
, PATCH
, DELETE
, HEAD
, OPTIONS
)
- Highlighting for clauses (
WITH HEADER
, WITH DATA
, WITH QUERY
)
- Variable definitions (
DEFINE
) and interpolation ({{variable}}
) highlighting
- JSON syntax highlighting within data blocks
- Comment support (
#
and //
)
🚀 Code Execution
- Run Entire File - Execute the complete file including all DEFINE statements and blocks
- Run All Blocks - Execute all HTTP request blocks in the file sequentially
- Run Individual Blocks - CodeLens buttons to run specific request blocks
- Run with Variables - Automatically include required DEFINE statements when running blocks
- Run with Flags - Interactive flag selection for advanced execution options
- Smart Variable Detection - CodeLens shows variable usage count and missing variables
- Integrated terminal output with real-time feedback
- Support for all CLI flags:
--log
, --strict
, --report
, --dry-run
, --timeout
, --color
🔍 Intelligent Features
- Enhanced Variable Support - Define and use variables with
DEFINE
statements and {{variable}}
interpolation
- Smart Variable Detection - Automatically detect undefined variables with context-aware suggestions
- Auto-completion for HTTP methods, clauses, headers, and common URLs
- Enhanced Hover tooltips with documentation for methods, headers, and variables
- Undefined Variable Help - Hover over undefined variables for smart suggestions based on variable name
- Code snippets for common request patterns and variable definitions
- Enhanced Real-time linting with comprehensive validation:
- Duplicate WITH clause detection
- Variable placement validation
- Undefined variable warnings with suggestions
- JSON structure validation
- DEFINE statement syntax validation (catches extra content after values)
- Context-aware error messages
📊 Report Viewer
- Beautiful HTML report viewer for execution results
- Interactive request details with expandable sections
- Success/failure statistics and performance metrics
- Color-coded status codes and response times
⚙️ Configuration
- Customizable default CLI flags
- Configurable timeout settings
- Color mode preferences
- Custom CLI path support
- Enable/disable linting
Requirements
- Hitman CLI must be installed and available in your system PATH
- VS Code version 1.100.0 or higher
To install the Hitman CLI, follow the instructions in the Hitman documentation.
Quick Start
- Install the extension
- Create a new file with
.hit
extension
- Start typing HTTP requests:
# Simple GET request
GET https://api.example.com/users
# POST with JSON data
POST https://api.example.com/users
WITH HEADER {
"Content-Type": "application/json"
}
WITH DATA {
"name": "John Doe",
"email": "john@example.com"
}
- Press
Ctrl+F5
(or Cmd+F5
on Mac) to run the file
- Use CodeLens buttons for individual block execution
- View results in the integrated terminal
Commands
Command |
Shortcut |
Description |
Hitman: Run File |
Ctrl+F5 / Cmd+F5 |
Execute the entire .hit file |
Hitman: Run File with Flags |
- |
Execute with interactive flag selection |
Hitman: Run Block |
CodeLens |
Execute a specific HTTP request block |
Hitman: Run Block with Variables |
CodeLens |
Execute block with auto-included DEFINE statements |
Hitman: Run Block with Flags |
CodeLens |
Execute block with interactive flag selection |
Hitman: Open Report |
- |
Open and view a Hitman report file |
🆕 Enhanced Features
Smart Variable Management
- Auto-Variable Detection: CodeLens automatically detects which variables each block uses
- Run with Variables: Automatically includes required DEFINE statements when running individual blocks
- Missing Variable Warnings: CodeLens titles show missing variables (e.g., "⚠️ Missing: token, userId")
- Context-Aware Suggestions: Hover over undefined variables for smart suggestions based on variable name
Improved Block Execution
- Run Entire File: Execute the complete file including all DEFINE statements
- Run All Blocks: Execute only the HTTP request blocks sequentially
- Run Individual Blocks: Execute specific blocks with or without variable auto-inclusion
- Variable Usage Display: CodeLens shows how many variables each block uses
Enhanced Validation
- DEFINE Statement Validation: Catches extra content after values (e.g.,
DEFINE var="value"extra
)
- Contextual Error Messages: More helpful error messages with specific suggestions
- Variable Placement Validation: Ensures DEFINE statements are at the top of the file
CodeLens Enhancements
Each HTTP request block now shows:
▶️ Run (uses X vars)
- Basic execution with variable count
▶️ Run with Variables
- Auto-includes required DEFINE statements
⚙️ Run with Flags
- Interactive flag selection
Extension Settings
This extension contributes the following settings:
hitman.defaultFlags
: Default CLI flags to use when running Hitman files
hitman.timeout
: Default timeout in seconds for HTTP requests (default: 30)
hitman.colorMode
: Color mode for CLI output (auto
, always
, never
)
hitman.reportPath
: Default path for generated reports
hitman.enableLinting
: Enable/disable syntax validation and linting
hitman.cliPath
: Path to the Hitman CLI executable (default: hitman
)
Syntax Reference
Variables
# Define variables at the top of the file (strict syntax)
DEFINE token="Bearer abc123" # String (must be quoted)
DEFINE baseUrl="https://api.example.com"
DEFINE userId=123 # Number
DEFINE debug=true # Boolean (true/false)
DEFINE headers={ # Multi-line JSON object
"Content-Type": "application/json",
"Authorization": "{{token}}"
}
DEFINE tags=["api", "test"] # Single-line JSON array
DEFINE config={ # Complex nested JSON
"database": {
"host": "localhost",
"port": 5432
},
"features": ["auth", "api"],
"debug": true
}
DEFINE optional="value"; # Optional semicolon
DEFINE x=2; #!MAHJ2l="ksk"; # Inline comments supported
# Use variables with {{variable}} syntax
GET {{baseUrl}}/users/{{userId}}
WITH HEADER {{headers}}
WITH DATA {
"debug": {{debug}},
"token": "{{token}}"
}
WITH QUERY {
"format": "json",
"debug": {{debug}}
}
DEFINE Syntax Rules:
- Format:
DEFINE variableName=value
(strict validation)
- Variable names: Must start with letter/underscore, followed by letters/numbers/underscores
- String values: Must be quoted (
"string value"
)
- Numbers: Unquoted integers or decimals (
123
, 45.67
)
- Booleans:
true
or false
(unquoted)
- Objects/Arrays: Valid JSON, single-line (
{"key": "value"}
) or multi-line
- Optional semicolon:
DEFINE var="value";
- Inline comments:
DEFINE var="value"; # comment
or DEFINE var=123 // comment
- Must be at top of file (before HTTP requests)
Invalid Examples:
DEFINE username="mahmoud"extra # ❌ Extra content after value
DEFINE 123invalid="value" # ❌ Variable name can't start with number
DEFINE invalid-name="value" # ❌ Hyphens not allowed in variable names
DEFINE username hello world # ❌ Unquoted string with spaces
DEFINE user name="value" # ❌ Spaces in variable name
HTTP Methods
GET https://api.example.com/endpoint
POST https://api.example.com/endpoint
PUT https://api.example.com/endpoint
PATCH https://api.example.com/endpoint
DELETE https://api.example.com/endpoint
HEAD https://api.example.com/endpoint
OPTIONS https://api.example.com/endpoint
GET https://api.example.com/endpoint
WITH HEADER {
"Content-Type": "application/json",
"Authorization": "Bearer token",
"Accept": "application/json"
}
Request Data
POST https://api.example.com/endpoint
WITH DATA {
"key": "value",
"number": 42,
"boolean": true
}
Query Parameters
GET https://api.example.com/endpoint
WITH QUERY {
"page": "1",
"limit": "10",
"sort": "name",
"active": true
}
# This is a line comment
// This is also a line comment
/* This is a
block comment */
# Inline comments in DEFINE statements
DEFINE port=8080; # Server port
DEFINE url="https://api.com"; // API endpoint
DEFINE debug=true # Enable debugging
Code Snippets
The extension provides several built-in snippets:
get
- Simple GET request
post
- POST request with JSON data
put
- PUT request with JSON data
patch
- PATCH request with JSON data
delete
- DELETE request with headers
auth
- Request with authentication
form
- Form data request
multi
- Multiple requests template
define
- Variable definition
defineobj
- Object variable definition
getvar
- GET request with variables
query
- Request with query parameters
complete
- Complete request with all sections
Known Issues
- Large JSON responses in the report viewer may impact performance
- CLI path detection may require manual configuration on some systems
Release Notes
1.0.0
Initial release with core features:
- Syntax highlighting for .hit files
- Code completion and hover providers
- Integrated CLI execution
- Real-time linting and diagnostics
- HTML report viewer
- Comprehensive configuration options
Contributing
Found a bug or want to contribute? Please visit our GitHub repository to report issues or submit pull requests.
License
This extension is licensed under the MIT License.