CodeScope
CodeScope is a Visual Studio Code extension with a native C++ workspace indexer. The indexer records files, languages, and content hashes in a SQLite database under the workspace's .codescope directory.
Release status: CodeScope is under development and is not yet published. Publisher BrilliantAmbuj is configured. A Windows x64 VSIX was installed and smoke-tested in an isolated local VS Code profile; installation on a clean second computer has not yet been verified.
Installation for users
These installation options apply after a compatible release is available:
Install from the VS Code Marketplace
- Open VS Code 1.146.0 or later.
- Open Extensions with
Ctrl+Shift+X.
- Once it is published, search for CodeScope, verify the publisher is BrilliantAmbuj, and select Install. A Marketplace listing is not yet available.
- Open your project folder and follow First-time usage.
Install a VSIX on another laptop
- Obtain a trusted CodeScope Windows x64
.vsix from the publisher. A clean-computer installation test is still required before public release.
- Copy the file to the other laptop.
- In VS Code, open Extensions (
Ctrl+Shift+X), select the ... menu, and choose Install from VSIX....
- Select the VSIX, reload VS Code if prompted, and follow First-time usage.
The Windows x64 package includes the native engine, SQLite, and OpenSSL DLLs. End users do not need Node.js, npm, CMake, or a compiler. The engine requires a compatible Microsoft Visual C++ Redistributable for x64; this candidate was built with a preview MSVC compiler, and runtime compatibility on a clean computer has not yet been verified. Other operating systems and architectures are not supported by this package.
First-time usage: analyze before exporting
Important: run analysis first. Export, file/symbol browsing, and impact queries read the existing index; exporting does not create one.
- In VS Code, choose File > Open Folder... and open the project you want to analyze. For a multi-root workspace, CodeScope currently uses the first folder.
- Open the Command Palette with
Ctrl+Shift+P and run CodeScope: Analyze Workspace.
- Wait until analysis finishes successfully. CodeScope creates or updates
<project>\.codescope\index.db; the project folder must be writable. Check View > Output > CodeScope if analysis fails.
- Select the CodeScope icon in the Activity Bar to see the project overview and browse Files and Symbols.
- To create a diagram, run CodeScope: Export Interactive Relationship Report from the Command Palette. Save the suggested
<project_name>.html file and confirm replacement if asked.
- In the opened report, select a file to see its symbols and directly connected external symbols. Select Back to project overview to return. You can also open the saved HTML file in a browser without an internet connection.
Repeat analysis for each new project folder before using its index. File changes are normally reanalyzed automatically, but watcher scans currently use full scans. A failed or cancelled automatic scan retains pending changes only for the current session; save another file or run analysis manually to retry.
Troubleshooting
- Cannot open CodeScope database: Open the intended project folder and complete CodeScope: Analyze Workspace before exporting. Confirm that
<project>\.codescope\index.db exists and that the folder and database are accessible. In a multi-root workspace, check the first folder. If it still fails, inspect View > Output > CodeScope; do not delete the index as a first step.
- CodeScope engine not found / engine cannot start: Check that you installed the Windows x64 VSIX and have a compatible Visual C++ x64 runtime. Check View > Output > CodeScope, and contact the package provider if it still fails.
- Missing relationships or symbols: Reanalyze the project and check for indexing warnings. CodeScope shows only relationships that its indexer can resolve; it does not infer missing links or runtime behavior.
- Large or slow diagram: Large graphs can consume significant browser resources. The exported HTML contains the complete indexed graph, including paths and symbol names, so review it before sharing.
Features
- Run CodeScope: Analyze Workspace from VS Code.
- View the latest scan's file totals and language distribution in the CodeScope activity-bar overview.
- Browse indexed files and symbols in the Files and Symbols activity-bar view.
- Search indexed symbols and navigate to their source locations.
- Analyze direct and indirect impact for selected files or symbols.
- View relationship evidence, evidence coverage, CMake target paths, and process impact paths.
- Export an offline interactive HTML/Mermaid visualization of indexed project and file relationships.
- Watch workspace changes and debounce reanalysis while excluding generated, dependency, build, and index directories. Changes arriving during a scan are queued.
- Watcher-triggered analyses use full scans pending separate incremental integration and end-to-end verification. Failed or cancelled automatic scans retain changes in memory for retry on another file event or a manual analysis.
- Native
--incremental checks for a clean, hash-verified baseline and falls back to a hash-verified full scan when needed, including after an ordinary full scan that reuses metadata. The caller must supply every changed workspace-relative file path since that baseline.
- Index workspace file metadata and language counts.
- Reuse stored file hashes to skip unchanged content, with an optional hash-verification mode.
- Parse
.c files with a dedicated Tree-sitter C grammar and persist C symbols, includes, and call sites alongside C++ results.
- Parse
.ts, .tsx, .mts, and .cts files; persist common TypeScript symbols, import dependencies, and call sites.
- Parse
.js, .jsx, .mjs, and .cjs files; persist common JavaScript symbols, module dependencies, and call sites.
- Parse
.py and .pyi files; persist common Python symbols, relative imports, and call sites.
- Parse
.java files; persist common Java types, members, package imports, and call sites.
- Parse
.go files; persist common Go types, members, package imports, and call sites.
- Parse
.cs files; persist common C# types, members, namespace using directives, and call sites.
- Parse
.rs files; persist common Rust types, members, module/use dependencies, and call sites.
- Parse
.php files; persist common PHP declarations, namespace imports, and call sites.
- Parse
.pl and .pm files; persist Perl packages, classes, roles, subroutines, methods, variables, dependencies, and call sites.
- Parse
.rb files; persist Ruby classes, modules, methods, constants, fields, static require dependencies, and call sites.
- Parse
.sh files; persist Shell functions, variables, static source dependencies, and command call sites.
- Parse
.ps1, .psm1, and .psd1 files; persist PowerShell functions, classes, methods, fields, variables, static module dependencies, and command call sites.
- Discover
CMakeLists.txt and .cmake files and persist statically declared executable/library targets and their literal workspace-local source paths.
- Inventory direct static
cmake --build, make/gmake, and ninja commands from Shell, PowerShell, and Makefile-family files without executing them.
- Record explicit relative output paths from supported direct compiler commands without inferring the command's working directory or claiming that the output exists.
- Parse changed C++ files and persist symbols and resolved inheritance relationships in the workspace SQLite index.
- Use deterministic symbol and relationship IDs; inheritance edges resolve to symbol IDs with namespace-aware lookup.
- Preserve qualified names for nested namespaces/classes and symbols in anonymous namespaces.
- Match declarations to unambiguous definitions across workspace files with stable
DEFINES relationships.
- Report malformed C++ syntax and preserve the last successfully indexed symbols until the source parses cleanly again.
- Version the SQLite schema and migrate supported legacy databases transactionally.
- Extract C++ include directives and resolve quoted includes to files indexed inside the workspace.
- Record direct and member C++ call sites with their containing function symbol.
- Resolve explicitly qualified calls to unique indexed definitions as stable
CALLS relationships; ambiguous same-arity candidates are not guessed.
- Record explicitly qualified symbol references in function bodies and resolve unique targets across the workspace.
- Resolve inheritance edges across workspace files with namespace-aware lookup; ambiguous bases are not guessed.
- Query reverse symbol dependencies with configurable depth and node bounds, and detect cyclic symbol relationship components from the native CLI.
- Query the unified file, symbol, build, and process graph through bounded traversal, shortest-path, and cycle CLI commands.
- Find direct and transitive dependents of a file, symbol, target, or other graph node with a bounded impact report.
- Use named impact profiles for file dependencies, symbol dependents, callers, and subclasses.
- Trace a changed source file to its statically declared CMake targets with evidence paths.
- Inspect impact evidence status to see when indexing or relationship-resolution gaps may affect the report.
- Extract named enums and scoped/unscoped enumerators,
using and typedef aliases, and distinct primary/specialized template symbols.
The parser library is shared by the workspace engine and standalone parser test harnesses. The activity-bar overview shows file and language counts after a successful scan in the current extension session. C support currently covers .c files; .h files continue through the C++ parser path. TypeScript support includes TSX; JavaScript and JSX use a separate JavaScript grammar.
Export a relationship report
- Open a local project folder and run CodeScope: Analyze Workspace. Wait for it to finish successfully.
- Run CodeScope: Export Interactive Relationship Report from the Command Palette.
- Choose an HTML file in the save dialog; the suggested name is
<project_name>.html. Confirm before replacing an existing file.
- The report opens in a VS Code webview using the extension's local Mermaid bundle. You can also open the saved, self-contained file in a browser without a network connection.
The project overview shows indexed files, executable/library targets and projected relationships. Select a file node (or focus it and press Enter/Space) to see all its indexed symbols, symbol-to-symbol relationships within the file, and only directly connected external symbols and their edges. Use Back to project overview to return. External symbols are not recursively expanded. Cross-file symbol relationships are also projected to file-level arrows in the overview. Arrows from targets to files mean the target declares the source. Recorded script launches and associated build invocations point from the script to the target. Targets are declarations, not proof that binaries exist.
The existing index may be stale or incomplete; unresolved relationships and runtime behavior are not inferred. Python call sites, general cross-language calls and library linking are not currently resolved. The report does not generate conceptual architecture or sequence diagrams. Large graphs may be slow or exceed browser memory or rendering limits; rendering errors are displayed. The standalone HTML embeds the complete indexed graph, paths, symbol names and third-party licenses; review it before sharing.
Developer requirements and setup
- Visual Studio Code
^1.146.0 and Node.js >=22.12.0/npm for building the extension and Mermaid bundle.
- CMake 3.20+, a C++20-capable compiler, and the dependencies declared in
vcpkg.json for the native engine.
- Configure the C++ dependencies with vcpkg, then configure and build the engine with CMake. The commands below assume an already configured Windows
engine\build directory; build directories copied from another machine are not a portable setup.
Build the extension:
npm install
npm run compile
Build and run the C++ parser harness from the repository root:
cmake --build engine\build --config Debug
engine\build\Debug\codescope-parser-test.exe engine\tests\bank_sample.cpp
ctest --test-dir engine\build -C Debug --output-on-failure
For a reproducible synthetic workspace benchmark, run:
node engine\tests\benchmark_workspace.cjs engine\build\Debug\codescope-engine.exe 1000
It creates and normally removes a temporary workspace of 2-5,000 small C++ files, verifies scan, explorer, and dependency-chain results, and reports end-to-end timings. Forced termination may leave the temporary directory behind. It does not benchmark the open project.
The extension invokes codescope-engine with the open workspace path. The engine writes its index to .codescope\index.db; --verify-hashes <workspace-path> forces content rehashing.
The native engine can query an already indexed workspace without scanning or modifying it:
engine\build\Debug\codescope-engine.exe --dependents <workspace-path> <symbol-id> <max-depth> <max-nodes>
engine\build\Debug\codescope-engine.exe --cycles <workspace-path> <max-nodes>
engine\build\Debug\codescope-engine.exe --explore <workspace-path>
engine\build\Debug\codescope-engine.exe --graph-snapshot <workspace-path>
engine\build\Debug\codescope-engine.exe --graph-traverse <workspace-path> <root-id> <outgoing|incoming> <max-depth> <max-nodes> <max-edges> <node-types|-> <edge-kinds|->
engine\build\Debug\codescope-engine.exe --graph-path <workspace-path> <source-id> <target-id> <outgoing|incoming> <max-depth> <max-nodes> <max-edges> <node-types|-> <edge-kinds|->
engine\build\Debug\codescope-engine.exe --graph-cycles <workspace-path> <max-nodes> <max-edges> <node-types|-> <edge-kinds|->
engine\build\Debug\codescope-engine.exe --graph-impact <workspace-path> <root-id> <max-depth> <max-nodes> <max-edges> <node-types|-> <edge-kinds|->
engine\build\Debug\codescope-engine.exe --graph-impact <workspace-path> <root-id> <file-dependents|symbol-dependents|callers|subclasses|build-targets|process-impact> <max-depth> <max-nodes> <max-edges>
Each query writes one JSON object to stdout; diagnostics go to stderr. --graph-snapshot exports the complete indexed graph without traversal bounds. Unified graph filters are comma-delimited, case-sensitive node types/edge kinds; use - for no filter. Empty entries are rejected. Depth may be zero; node and edge limits must be positive. Traversal returns typed node/edge arrays and a truncated flag; path results include endpoint-found flags and pathFound; cycle results group node IDs by cyclic strongly connected component. Impact results classify incoming dependents as direct (depth 1) or indirect (depth greater than 1), include their shortest discovered depths and traversed edges, and indicate truncated when limits exclude work. Named impact profiles are file-dependents (FILE/INCLUDES), symbol-dependents (SYMBOL/CALLS, INHERITS, REFERENCES), callers (SYMBOL/CALLS), subclasses (SYMBOL/INHERITS), build-targets (FILE through RESOLVES_TO_FILE and DECLARES_SOURCE), and process-impact (changed FILE through CMake source declarations and executable launches to process-file accesses); each validates that the root has the expected entity type. The build-targets response includes a targetPaths array, while process-impact includes a processPaths array with ordered nodes and original edge evidence. Process paths label access-to-file links as resolved, unresolved, or truncated; unresolved access links are counted in evidence and produce incomplete. The original filter-based syntax remains available and is reported as the custom profile. Impact JSON also reports evidence status: no_known_gaps, incomplete, unavailable, or not_applicable for a missing root. Known scan errors, parse-hash mismatches, unresolved file dependencies, unresolved CMake source declarations, and unresolved process file accesses produce incomplete; legacy scan states and relationship-site records without per-site resolution state produce unavailable. Counts are project-wide. no_known_gaps is not a guarantee of complete static analysis or absence of runtime impact. Persisted call, inheritance, and symbol-reference site counts are labeled resolution-unavailable because the current schema does not record each site's resolution outcome; those counts are not assertions that every such site is unresolved. These are impacts inferred from indexed static graph evidence, not compiler or runtime guarantees. Queries open the existing index read-only and do not trigger a scan. The existing --dependents and --cycles commands retain their symbol-only behavior.
Example:
engine\build\Debug\codescope-engine.exe --graph-traverse C:\work\demo file:src/main.cpp outgoing 4 500 1000 FILE,BUILD_TARGET -
engine\build\Debug\codescope-engine.exe --graph-impact C:\work\demo file:src/main.cpp 6 500 1000 FILE,SYMBOL -
engine\build\Debug\codescope-engine.exe --graph-impact C:\work\demo symbol:replace-with-indexed-id callers 6 500 1000
engine\build\Debug\codescope-engine.exe --graph-impact C:\work\demo symbol:replace-with-indexed-class-id subclasses 6 500 1000
engine\build\Debug\codescope-engine.exe --graph-impact C:\work\demo file:src/main.cpp build-targets 4 500 1000
engine\build\Debug\codescope-engine.exe --graph-impact C:\work\demo file:src/main.cpp process-impact 6 500 1000
In the Debug CLI integration fixture, an outgoing query over a 1,000-node dependency chain completed in 190–224 ms end-to-end over three runs on the development Windows environment. This includes process startup, database loading, graph indexing, traversal, and JSON serialization; it is a baseline observation, not a performance guarantee. Each query currently builds a temporary adjacency index in O(V+E) before bounded graph processing.
To use the extension, open a workspace in VS Code, select the CodeScope activity-bar icon, and run CodeScope: Analyze Workspace from the Command Palette or the overview title action. The overview updates after a successful scan.
Packaging and publishing
The configured Marketplace publisher is BrilliantAmbuj, and the CodeScope source is licensed under MIT. This repository has no public repository URL configured; the package command below therefore keeps relative documentation links unchanged.
On a Windows x64 development machine with Node.js, the vsce CLI, vcpkg dependencies, and an already configured engine\build directory:
vsce ls --no-dependencies
vsce package --target win32-x64 --out codescope-win32-x64.vsix --no-dependencies --allow-missing-repository --no-rewrite-relative-links
vsce package invokes vscode:prepublish, which builds the JavaScript bundles and the Release engine, then copies the SQLite and OpenSSL DLLs next to the executable. npm run package alone builds only the JavaScript bundles; it does not create a VSIX. The .vscodeignore allowlist includes the required extension assets, Release engine, DLLs and third-party license notices, but not the local index or Debug build. Always review the actual file list before sharing.
Before publishing, install the resulting VSIX on a clean Windows x64 computer without the development toolchain. Verify engine startup, initial workspace analysis, watcher behavior, HTML export and offline report interaction. Confirm the Visual C++ runtime is available and no private files are included. A separate native build and validation is required for other operating systems and architectures.
After verification, upload the tested VSIX through the Marketplace publisher management page or configure Trusted Publishing. A Marketplace upload has not yet been performed. Never commit or share publishing credentials.
Configuration and security
There are no extension environment variables or contributed settings currently. The engine reads local workspace files and stores metadata and hashes locally. It does not need authentication credentials. Symbol IDs use a non-cryptographic FNV-1a hash for stable identification, not for security or integrity verification.
Status and limitations
Phases 2 through 6.12, including Phases 5.1 through 5.6, Phase 7.1, Phases 7.2a through 7.2c, Phases 7.3a and 7.3b, Phases 8.1 through 8.4, Phases 9.1 through 9.2b, Phases 9.3a and 9.3b, and Phases 10.1 through 10.4 are implemented and verified using SQLite schema version 11; unversioned databases are upgraded sequentially and newer schema versions are rejected. Phase 7.2c adds conservative CMake executable artifact associations, Phase 7.3a inventories direct static Shell/PowerShell launches of uniquely matched CMake executable targets, and Phase 7.3b records supported static redirections and explicitly labeled file operands. The read-only unified graph snapshot includes files, symbols, resolved file dependencies, symbol relationships, CMake targets and source declarations, build invocations, process launches, and process-file accesses. The native CLI supports bounded filtered traversal, shortest paths, cycle queries, and bounded direct/transitive impact reports with named file, symbol, caller, subclass, build-target, and process-impact profiles plus evidence-coverage status. The VS Code UI provides a session-scoped project overview, a file/symbol explorer backed by native --explore, and Relationships and Impact backed by native --graph-impact.
Phase 10.2 - Analysis Interaction and Diagnostics is complete: analysis now has a cancellable progress notification, duplicate-run protection, strict engine JSON validation, warning-preserving overview behavior, and actionable engine/error diagnostics.
Phase 10.4 provides impact exploration, but broader graph navigation remains unfinished. Phase 11.2b verifies native incremental baseline and recovery cases; watcher-triggered scans still use full scans. Caller-supplied paths must include all changes since the baseline, and independently concurrent engine processes have not been verified. Phase 11.3a establishes a synthetic performance baseline; Phase 11.3b tests recovery after terminating an active Windows native process. Phase 11.3c's isolated extension-host tests verify cancellation and watcher retry with an injected token; actual Cancel-button interaction remains unverified.
Process I/O extraction is intentionally narrow: Shell supports literal <, >, >>, 1>, 1>>, 2>, and 2>>; PowerShell supports the output/error forms but not stdin redirection. Explicit --input, --input-file, -i, --output, --output-file, and -o operands are recognized. Only absolute paths canonically contained in the workspace are retained. Inputs must resolve to indexed files; output paths can be retained before the file exists. Relative paths, pipes, dynamic expansions, unsupported syntax, and inferred file usage remain unresolved. CodeScope does not run scripts or executables.
The VS Code command and native workspace indexer persist C, C++, TypeScript, JavaScript, Python, Java, Go, C#, Rust, PHP, Perl, Ruby, Shell, and PowerShell symbols, workspace-wide C/C++ declaration/definition matching, supported C++ inheritance relationships, file-level dependencies, and call sites for all supported languages. CMake configuration is separately scanned for simple add_executable and add_library declarations. Literal in-workspace source paths are stored and linked only to indexed files; variables, generator-dependent expressions, conditional evaluation, imported/alias targets, and CMake execution are unsupported. For executable targets, an artifact path is derived only from unconditional RUNTIME_OUTPUT_DIRECTORY in the exact constant $<1:literal-path> form, plus literal OUTPUT_NAME, PREFIX, and SUFFIX values. This constant expression prevents multi-config generators from appending a configuration directory; bare output directories and other expressions remain unresolved. The output directory must be absolute and inside the workspace. Direct supported output-property overrides, dynamic/conditional values, and duplicate target artifact paths do not associate. Malformed CMake configuration preserves the last good target inventory. Static build invocation records recognize direct literal cmake --build, make/gmake, and ninja commands in Shell, PowerShell, and Makefile-family files. Explicit output paths are recorded for direct gcc, g++, clang, clang++, cc, c++, cl, and clang-cl commands using -o or /Fe; only workspace-relative paths are retained, and the engine does not infer a process working directory or assert that outputs exist. A compiler invocation is linked to a CMake target only when its output path exactly matches one unique declared artifact path. Wrappers, expansions, shell operators, and other ambiguous forms are ignored; commands are never executed. The association does not establish that an artifact exists or that the compiler command was run by that CMake target. TypeScript and JavaScript imports/re-exports are stored; Python, Java, Go, C#, Rust, PHP, and Perl dependencies are indexed as module records. Relative and local module paths can resolve to indexed workspace files with supported extensions; non-local package imports remain unresolved. Go, C#, Rust, PHP, Perl, Ruby, Shell, and PowerShell dependency resolution is syntactic and workspace-local. Rust module/use dependencies are conservatively resolved to .rs files or mod.rs directories; PHP namespace imports resolve only to exact matching .php paths under the workspace root, without Composer or PSR-4 mapping; Perl use and static quoted require paths resolve only to supported indexed workspace .pm files; Ruby static require and require_relative literals resolve to .rb files in supported workspace candidates. Shell source/. and PowerShell Import-Module resolve only explicit static relative paths to indexed supported script files; dynamic paths and module search behavior remain unresolved. TypeScript, JavaScript, Python, Java, Go, C#, Rust, PHP, Perl, Ruby, Shell, and PowerShell call sites are not resolved to CALLS edges. C support applies to .c; .h continues through C++. JavaScript covers .js, .jsx, .mjs, .cjs; Python covers .py, .pyi; Go covers .go; C# covers .cs; Rust covers .rs; PHP covers .php; Perl covers .pl and .pm; Ruby covers .rb; Shell covers .sh; PowerShell covers .ps1, .psm1, and .psd1. These parsers are syntactic and do not provide compiler-level type checking or semantic call resolution. C++ call resolution requires a fully qualified callee and a unique indexed definition with the same argument count. Symbol-reference extraction is limited to explicitly qualified C++ identifiers inside function bodies. Templates are parsed syntactically. Quoted local includes are resolved within the workspace; system and macro includes remain unresolved. Malformed files produce syntax diagnostics; recovered records are not committed. Graph queries are available in the native CLI.
Run the extension tests with npm test in an environment where the VS Code test runner can launch VS Code. On Windows, npm run test:relationship tests HTML export and npm run test:cancellation tests watcher cancellation; both require the Debug engine and create and remove a synthetic temporary workspace. Native parser verification uses the CMake target and executable shown above.
Development
See CHANGELOG.md for release notes. The project is currently unreleased.
No contribution guidelines are defined. CodeScope is licensed under MIT; bundled third-party components have their own license notices.