Simple VSCode Context
A VS Code extension that captures your editor context information (open files, selections, workspace folders) and saves it to JSON files for external use.
Features
- Automatically captures your VS Code context as you work
- Stores context data in simple JSON files for each project
- Configurable capture settings - on events or at timed intervals
- No server required - access context data directly from the files
- Fast, lightweight, and unobtrusive
How It Works
Simple VSCode Context works by capturing your editor state - which files are open, what text is selected, what workspaces are active - and saves this information to a JSON file. Each workspace/project gets its own context file, stored in a configurable directory.
Unlike server-based approaches, there's no need to run a separate service - the context is saved directly to disk where other applications can access it. This makes it ideal for integration with external tools like AI assistants that need to understand your current workspace context.
Installation
- Install the extension from the VS Code marketplace
- The extension will automatically start capturing context based on your settings
- Context files are stored in
~/.simple-context
by default (configurable)
Development and Packaging
Prerequisites
- Node.js (latest LTS version recommended)
- Visual Studio Code
Building the Extension
- Clone the repository
- Install dependencies:
npm install
- Build the extension:
npm run compile
Packaging the Extension
- Install the packaging tool:
npm install -g @vscode/vsce
- Package the extension:
vsce package
This will generate a simple-context-x.x.x.vsix
file
Note: The .vscodeignore
file controls which files are included in the package. It excludes development files, external references, and other unnecessary files to keep the package size small.
Installing from VSIX
- In VS Code, open the Command Palette (Ctrl+Shift+P)
- Type "Extensions: Install from VSIX" and select it
- Choose the .vsix file you generated
Publishing to the VS Code Marketplace
- Create a publisher account at https://marketplace.visualstudio.com/
- Get a Personal Access Token from Azure DevOps
- Login to vsce:
vsce login <publisher-name>
- Publish the extension:
vsce publish
Usage
The extension runs in the background, automatically capturing your editor context:
- As you edit files, switch between files, or change selections
- At configurable time intervals
- Manually by running the "Capture Context Now" command
Each project's context is stored in its own JSON file, including:
- Open files
- Current selections
- Active editor
- Workspace folders
Configuration
The following settings are available:
simple-context.contextDir
: Directory to store context files (default: ~/.simple-context
)
simple-context.autoCapture
: Automatically capture context on file changes (default: true
)
simple-context.captureInterval
: Minimum interval in seconds between context captures (default: 30
, set to 0
to disable). This ensures context is saved even during periods of inactivity.
For Developers
Context files are stored as JSON and include:
{
"timestamp": 1621334567890,
"activeEditor": {
"fileName": "src/index.js",
"selections": [
{
"start": {"line": 10, "character": 5},
"end": {"line": 10, "character": 12}
}
]
},
"openFiles": [
{
"fileName": "src/index.js",
"filePath": "/path/to/project/src/index.js",
"languageId": "javascript"
},
{
"fileName": "src/styles.css",
"filePath": "/path/to/project/src/styles.css",
"languageId": "css"
}
],
"workspaceFolders": [
{
"name": "my-project",
"path": "/path/to/project"
}
]
}
License
MIT