Skip to content

Add VS Code extension API analysis tools and reports#1461

Open
sinelaw wants to merge 1 commit intomasterfrom
claude/analyze-vscode-extensions-f4bBB
Open

Add VS Code extension API analysis tools and reports#1461
sinelaw wants to merge 1 commit intomasterfrom
claude/analyze-vscode-extensions-f4bBB

Conversation

@sinelaw
Copy link
Copy Markdown
Owner

@sinelaw sinelaw commented Apr 3, 2026

Summary

This PR adds comprehensive AST-based analysis tools to examine how the top 12 most-installed open-source VS Code extensions use the VS Code extension API. The analysis helps identify the minimal API surface needed to support these extensions and provides gap analysis between VS Code's API and Fresh's plugin API.

Key Changes

  • Analysis Scripts:

    • analyze-vscode-api-ast.ts: TypeScript compiler API-based analyzer that precisely extracts vscode API usage, Node.js builtins, environment access, network/IO, and shell execution patterns from extension source code
    • analyze-vscode-api.ts: Regex-based analyzer for extracting activation events and contributions from package.json manifests
    • analyze-vscode-extensions.sh: Bash orchestration script to clone extensions and run analyses
    • generate_minimal_api.py: Python script to synthesize analysis results into minimal API surface recommendations
  • Analysis Reports:

    • Per-extension detailed reports (ast_api_usage.txt and api_usage.txt) for all 12 extensions
    • Aggregated JSON data (api_usage.json, ast_api_usage.json) for programmatic access
    • Comprehensive summary reports including minimal_api_surface.txt and ast_analysis_report.txt
  • Documentation:

    • docs/internal/vscode-extension-api-analysis.md: Overview of analyzed extensions with API usage statistics
    • docs/internal/vscode-vs-fresh-api-gap-analysis.md: Detailed gap analysis comparing VS Code extension API with Fresh's current plugin API capabilities
  • Configuration:

    • Updated .gitignore to exclude cloned extension repositories (which are large)
    • Added TypeScript as a dev dependency for running the analysis scripts

Notable Implementation Details

  • The AST-based analyzer uses the TypeScript compiler API to walk the abstract syntax tree, providing precise extraction of API usage patterns rather than relying on regex matching
  • Analysis covers 12 extensions including Python (~211M installs), C/C++ (~97M), Live Server (~76M), and others
  • Reports include usage frequency visualization and extension-by-extension breakdowns
  • The gap analysis identifies which extensions Fresh can already support with current APIs and which would require new subsystems

https://claude.ai/code/session_01A5155teGEnWd4jT8e3BxVo

AST-based analysis of the top 12 open-source VS Code extensions (Python,
C/C++, Live Server, Prettier, ESLint, GitLens, Code Runner, Material Icon
Theme, Path Intellisense, Auto Rename Tag, REST Client, Docker) to
determine the minimal vscode API surface and platform capabilities
needed to support them.

Scripts (scripts/vscode-extension-analysis/):
- analyze-vscode-api-ast.ts: TypeScript compiler API (AST) analyzer that
  tracks vscode API, Node.js builtins, process/env access, shell execution,
  network/HTTP, and global side effects
- analyze-vscode-api.ts: Faster regex-based analyzer (less precise)
- analyze-vscode-extensions.sh + generate_minimal_api.py: Bash/Python tools

Key findings:
- 6 core namespaces (workspace, window, commands, extensions, env, languages)
  cover all analyzed extensions
- 14 essential methods used by 6+ of 12 extensions
- path.join is the only API used by literally every extension
- 55% of extensions need child_process (spawn/exec) for external tools
- process.env/platform/cwd each used by 6/11 extensions

Full report: docs/internal/vscode-extension-api-analysis.md

https://claude.ai/code/session_01A5155teGEnWd4jT8e3BxVo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants