CodeGraph Sync on Save
CodeGraph Sync on Save runs a configured workspace command after a file is saved in selected folders. It is designed to keep a CodeGraph index synchronized without running a command for every unrelated edit.
Requirements
- Visual Studio Code 1.85.0 or later.
- A trusted workspace. The extension stays disabled in Restricted Mode because it executes a workspace-defined shell command.
- The configured command, such as the CodeGraph CLI, must be available in the extension host's
PATH.
Configuration
Create codegraph.watch.json in the root of each workspace folder that should be watched:
{
"watchFolders": ["src", "scripts"],
"command": "codegraph sync .",
"debounceMs": 500,
"ignored": ["src/generated"]
}
All four fields are required:
| Field |
Type |
Description |
watchFolders |
string[] |
Non-empty list of non-empty folder paths whose saved files trigger the command. Use "." for the whole workspace folder. |
command |
string |
Non-empty shell command to run. |
debounceMs |
number |
Non-negative delay after the latest matching save. |
ignored |
string[] |
Non-empty folder paths excluded from the watched folders; use [] for none. |
Folder paths are resolved from the workspace root. The extension matches files strictly inside those folders; it does not interpret glob patterns.
Behavior
- The configuration is read again whenever a file is saved, so changes take effect without reloading VS Code.
- Commands run in the corresponding workspace-folder root through the operating system shell.
- Runs are serialized. If matching files are saved while a command is running, one follow-up run is queued with the latest configuration.
- Multi-root workspaces get an independent runner for each folder containing
codegraph.watch.json; folders without the file are ignored.
- Output and failures are written to the CodeGraph Sync on Save output channel.
- Run CodeGraph Sync on Save: Show Output from the Command Palette to open that channel.
Security
This extension executes the command stored in codegraph.watch.json. Review that file before trusting an unfamiliar workspace. VS Code prevents the extension from running in untrusted workspaces.
Installation
Install CodeGraph Sync on Save from the Visual Studio Code Marketplace after it is published.
To install a locally packaged build:
npm install
npm run package
code --install-extension .\codegraph-sync-on-save-0.1.1.vsix
Reload VS Code after installation. Opening a workspace that already contains codegraph.watch.json activates the extension automatically.
Support
Use the issue tracker linked on the Marketplace page to report bugs or request features.
License
MIT. See LICENSE.