How infracost/vscode-infracost works
Project type and purpose
• This is a VS Code extension written in TypeScript, packaged via Webpack.
• Its purpose is to integrate Infracost cost estimates into the editor: showing inline code lenses, a tree view, a status bar indicator, and a webview for breakdowns.
• It orchestrates calls to the Infracost CLI or Cloud API to retrieve Terraform cost data.
File structure
• Top-level scripts & configs: package.json, tsconfig.json, webpack.config.js (build), .github/workflows (CI), lint/format configs.
• src/extension.ts: extension activation entrypoint.
• src/cli.ts: runs the Infracost CLI or Cloud API.
• src/command.ts: registers VS Code commands (e.g. “connect to Infracost”).
• UI components under src/:
• lens.ts for code lenses
• tree.ts for the cost tree view
• webview.ts for the cost-breakdown panel
• statusBar.ts for the status indicator
• Business logic & models: config.ts, context.ts, project.ts, workspace.ts, block.ts, file.ts
• Presentation templates in src/templates/*.hbs and compiled by template.ts.
README for additional insights
• Describes features: inline cost lenses on save, module/resource support, tree overview, and webview breakdown.
• Mentions “connect to Infracost Cloud” and use of local CLI for pricing data.
• Requires Terraform extension in VS Code and a workspace config file.
Final advice
• Be very detailed: list every UI provider, each major .ts module, and the external boundary.
• Asynchronous flows (e.g. CLI subprocess calls).