This document provides detailed instructions for installing the TypeScript VSCode Interface extension, a WebSocket-based extension for running tasks, managing files, and executing tests in VSCode. The extension is designed to work with projects like Python.VsCode.Interface, enabling automation via scripts such as setup_project_pytest_persistent.sh.
- Prerequisites
- Setup Project Directory
- Compile the Extension
- Package the Extension
- Install the Extension
- Configure the Extension
- Verify Installation
- Test with a Project
- Troubleshooting
- License
Before installing the extension, ensure the following are installed and configured:
-
Node.js and npm:
- Required for compiling and packaging the extension.
- Install Node.js (version 16.x or higher) and npm (version 8.x or higher):
sudo apt update sudo apt install nodejs npm node --version # Should output v16.x or higher npm --version # Should output 8.x or higher
- If needed, install a specific version using
nvm:curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash nvm install 16 nvm use 16
-
VSCode CLI:
- Ensure Visual Studio Code is installed and accessible via the
codecommand:code --version
- If not installed, download and install from code.visualstudio.com or via:
sudo snap install code --classic
- Ensure Visual Studio Code is installed and accessible via the
-
vsce:
- The VSCode Extension CLI for packaging the extension.
- Install globally:
npm install -g vsce vsce --version
-
Project Directory:
- The extension source code should be in
~/WebstormProjects/typescript-vscode-interface, containing:src/extension.tssrc/task-runner.tssrc/file-reader.tssrc/file-writer.tssrc/utils.tspackage.jsonLICENSE.md
- If any files are missing, contact the project maintainer or refer to the repository at
https://github.com/venantvr/Python.VsCode.Interface.
- The extension source code should be in
-
Clone or Verify the Repository:
- If you haven't already, clone the extension repository or ensure it exists:
Replace
cd ~/WebstormProjects git clone <repository-url> typescript-vscode-interface
<repository-url>with the actual repository URL if available. - Alternatively, verify the directory exists:
Expected:
ls ~/WebstormProjects/typescript-vscode-interfacepackage.json src LICENSE.md
- If you haven't already, clone the extension repository or ensure it exists:
-
Install Dependencies:
- Navigate to the project directory:
cd ~/WebstormProjects/typescript-vscode-interface
- Install dependencies specified in
package.json:npm install
- This installs
ws,json-patch,@types/vscode,@types/node,@types/ws,@types/json-patch,@types/mocha, andtypescript.
- Navigate to the project directory:
-
Verify
package.json:- Ensure the
namefield is valid:Expected:grep '"name"' ~/WebstormProjects/typescript-vscode-interface/package.json
"name": "typescript-vscode-interface" - Confirm required fields:
{ "name": "typescript-vscode-interface", "displayName": "TypeScript VSCode Interface", "version": "0.0.1", "publisher": "xAI", "main": "./out/extension.js" }
- Ensure the
Compile the TypeScript source files to JavaScript for packaging:
cd ~/WebstormProjects/typescript-vscode-interface
npm run compile- This runs
tsc -p ./, generating files in theout/directory (e.g.,out/extension.js,out/task-runner.js). - Verify compilation:
Expected:
ls ~/WebstormProjects/typescript-vscode-interface/outextension.js task-runner.js file-reader.js file-writer.js utils.js
Create a VSIX file for the extension:
cd ~/WebstormProjects/typescript-vscode-interface
vsce package- This generates
typescript-vscode-interface-0.0.1.vsixin the project directory. - Verify the VSIX file:
Expected:
ls ~/WebstormProjects/typescript-vscode-interface/*.vsix
typescript-vscode-interface-0.0.1.vsix
Install the extension permanently in VSCode:
code --install-extension ~/WebstormProjects/typescript-vscode-interface/typescript-vscode-interface-0.0.1.vsix- This installs the extension globally, making it available in all VSCode workspaces until uninstalled.
- Verify installation:
Expected:
code --list-extensions | grep typescript-vscode-interfacexAI.typescript-vscode-interface
The extension uses workspace settings for the WebSocket port, task name, and test directory. Configure these settings:
-
Using the Configuration UI:
- Open VSCode:
code
- Open the Command Palette (
Ctrl+Shift+PorCmd+Shift+Pon macOS). - Run
TypeScript VSCode Interface: Configure Settings. - Set:
- Port WebSocket:
3000 - Nom de la tâche:
run-tests - Dossier des tests:
tests
- Port WebSocket:
- Save the configuration.
- Open VSCode:
-
Manually Edit Settings:
- Open or create
~/PycharmProjects/Python.VsCode.Interface/.vscode/settings.json:mkdir -p ~/PycharmProjects/Python.VsCode.Interface/.vscode nano ~/PycharmProjects/Python.VsCode.Interface/.vscode/settings.json
- Add:
{ "typescriptVscodeInterface.port": 3000, "typescriptVscodeInterface.taskName": "run-tests", "typescriptVscodeInterface.testDir": "tests" }
- Open or create
-
Check Extension in VSCode:
- Open VSCode and go to the Extensions view (
Ctrl+Shift+XorCmd+Shift+X). - Search for "TypeScript VSCode Interface" and confirm it’s installed.
- Open VSCode and go to the Extensions view (
-
Test WebSocket Server:
- Open a workspace in VSCode (e.g.,
~/PycharmProjects/Python.VsCode.Interface):code ~/PycharmProjects/Python.VsCode.Interface - Check if the WebSocket server is running:
Expected:
netstat -tuln | grep 3000tcp 0 0 127.0.0.1:3000 0.0.0.0:* LISTEN
- Open a workspace in VSCode (e.g.,
-
Check Logs:
- In VSCode, go to View > Output > TypeScript VSCode Interface Logs.
- Look for:
[2025-07-10T09:21:00.000Z] Extension TypeScript VSCode Interface activée. [2025-07-10T09:21:00.000Z] Serveur WebSocket démarré avec succès.
To verify the extension’s functionality, use the setup_project_pytest_persistent.sh script to set up a Python project and run tests:
-
Run the Script:
cd ~/PycharmProjects/Python.VsCode.Interface chmod +x setup_project_pytest_persistent.sh ./setup_project_pytest_persistent.sh
-
Verify Test Results:
- After the script completes (instruction 27), check the test output:
Expected: JSON with 21 tests passed, e.g.:
cat ~/PycharmProjects/Python.VsCode.Interface/test_results.json{ "tests": [ { "nodeid": "tests/test_math.py::TestMath::test_add", "outcome": "passed", "duration": 0.001 }, ... ], "summary": { "total": 21, "passed": 21, "failed": 0 } }
- After the script completes (instruction 27), check the test output:
-
Verify Git Push:
- After instruction 29, confirm changes are pushed to the repository:
Expected: Commits including "Initial commit" and "Add 20 classes and tests".
git -C ~/PycharmProjects/Python.VsCode.Interface log --oneline
- After instruction 29, confirm changes are pushed to the repository:
-
If
vsce packageFails:- Verify
package.json:Expected:grep '"name"' ~/WebstormProjects/typescript-vscode-interface/package.json
"name": "typescript-vscode-interface" - Reinstall
vsce:npm install -g vsce
- Verify
-
If Extension Doesn’t Load:
- Check installed extensions:
Expected:
code --list-extensions | grep typescript-vscode-interfacexAI.typescript-vscode-interface - Verify logs in VSCode (View > Output > TypeScript VSCode Interface Logs).
- Check installed extensions:
-
If WebSocket Server Doesn’t Start:
- Ensure port 3000 is free:
If in use, kill the process:
netstat -tuln | grep 3000fuser -k 3000/tcp
- Restart VSCode:
code ~/PycharmProjects/Python.VsCode.Interface
- Ensure port 3000 is free:
-
If
ModuleNotFoundError: No module named 'src':- Verify
PYTHONPATH(instruction 4):Expected: Includeswscat -c ws://localhost:3000 -x '{"requestId":"7033","command":"execute-command","shellCommand":"echo $PYTHONPATH"}'/home/rvv/PycharmProjects/Python.VsCode.Interface. - Test manually:
cd ~/PycharmProjects/Python.VsCode.Interface . venv/bin/activate PYTHONPATH=$PYTHONPATH:${PWD} pytest tests
- Verify
-
If
git pushFails (Instruction 29):- Ensure credentials are set:
wscat -c ws://localhost:3000 -x '{"requestId":"7029","command":"execute-command","shellCommand":"git push https://venantvr:<your-token>@github.com/venantvr/Python.VsCode.Interface.git main"}' - Replace
<your-token>with a valid GitHub personal access token.
- Ensure credentials are set:
-
If Extension Breaks After VSCode Update:
- Reinstall the VSIX:
code --install-extension ~/WebstormProjects/typescript-vscode-interface/typescript-vscode-interface-0.0.1.vsix - Check
engines.vscodeinpackage.jsonfor compatibility.
- Reinstall the VSIX:
This extension is licensed under the MIT License. See LICENSE.md for details.