How microsoft/ai-engineering-coach works
1. Repository purpose
- This is a VS Code extension named AI Engineer Coach.
- Its main job is to read local AI coding-assistant session logs, analyze them on-device, and present coaching/analytics views in a VS Code webview.
- The architectural boundary is strong: analysis is local and read-only; no session data is meant to leave the machine.
2. Top-level runtime shape
- The extension runs inside the VS Code extension host.
- The UI is rendered mostly in VS Code webviews rather than a separate browser app.
- A separate MCP/tools surface exists for exposing selected functionality to model/tool clients, but the primary user experience is the extension dashboard.
3. Main entry and orchestration
- src/extension.ts is the extension entrypoint and wires together commands, panels, data access, and analysis services.
- The extension appears to orchestrate an internal pipeline: load logs → parse sessions → compute metrics/rules → cache results → render pages/panels.
4. Session ingestion and parser boundary
- src/core/parser*.ts contains multiple adapters for different AI harnesses/tools:
- Claude, Codex, VS Code, OpenCode, Xcode, and related variants.
- This is a key boundary in the system: raw log formats are normalized into shared session/data types before any analytics run.
- src/core/parser-harnesses.ts and src/core/parser-shared.ts suggest shared normalization across tool-specific formats.
5. Core analytics engine
- src/core/analyzer*.ts is the main analytics layer.
- It produces different domain views such as:
- dashboard summaries,
- timeline views,
- workflow/flow analysis,
- insights,
- production/output analysis,
- context and consumption analysis,
- image/session artifact analysis.
- The architecture is modular: each analyzer focuses on one output surface, all fed by the same normalized session data.
6. Rules, detectors, and anti-pattern scoring
- The anti-pattern subsystem is centered around src/core/rule-*, src/core/detectors*, src/core/metric-engine.ts, and src/core/rules/*.md.
- Rule definitions are largely markdown-driven, compiled and evaluated by a rule engine, and surfaced as coaching feedback.
- This layer turns raw behavior into scored signals such as session hygiene, prompt quality, tool usage, context quality, and workflow issues.
7. DSL and rule authoring
- src/core/dsl/* provides a custom domain-specific language used for rule logic, filtering, or interactive evaluation.
- The DSL has its own lexer, parser, interpreter, schema, and safe-regex support, indicating that rule evaluation is a first-class internal language rather than ad hoc string matching.
- This is important for architecture diagrams because it is a distinct subsystem between “rules authored by humans” and “rules executed against session data.”
8. Caching and worker-based processing
- src/core/cache.ts, cache-write-worker.ts, parse-worker.ts, and warm-up-worker.ts show that expensive work is offloaded from the main extension thread.
- The system likely uses background workers for parsing, warming caches, and persistence to keep the UI responsive.
- Cache is a core boundary: parsed/derived results are stored for reuse rather than recomputed for every page navigation.
9. Webview application and page model
- src/webview/* is the presentation layer.
- src/webview/app.ts, panel.ts, panel-rpc.ts, panel-request-service.ts, and render.ts suggest a panel-based architecture with RPC between extension host and webview.
- Each major product area maps to a page module, such as:
- dashboard,
- timeline,
- output,
- patterns,
- anti-patterns,
- rule editor/playground,
- data explorer,
- skills,
- context management/health,
- learning,
- achievements,
- SDLC,
- share.
- The UI is therefore a shell with many feature pages driven by the same underlying analytics services.
10. Data exploration and feedback loops
- Several pages are not just display-only; they support authoring and refinement:
- page-rule-editor.ts,
- page-rule-playground.ts,
- page-data-explorer.ts,
- page-context-mgmt.ts.
- This means the product has a closed loop:
- observe usage,
- inspect data,
- author/tune rules,
- re-run evaluation,
- review improved coaching signals.
11. Optional LLM-assisted features
- src/chat/* and parts of the rule/context tooling indicate optional use of the VS Code built-in Copilot language model API.
- The README makes clear these are explicitly invoked features, not always-on telemetry.
- This layer is secondary to the local analytics pipeline and should be drawn as an optional external capability used for tasks like rule compilation, skill discovery, or instruction-file review.
12. MCP / external tool exposure
- src/mcp/tools.ts and src/mcp/formatters.ts expose selected functionality in a structured tool interface.
- This is a separate integration boundary from the UI: it packages coach capabilities for tool consumers rather than human-facing dashboards.
13. Input/output artifacts
- The extension consumes local session logs and workspace context.
- It produces:
- dashboard metrics,
- charts/timelines,
- rule findings,
- learning content,
- exportable summaries/Markdown/JSON,
- optionally a shareable stat card.
- The shared-data/export boundary is visible in src/core/summary-export.ts and src/summary-export-vscode.ts.
14. Tooling, packaging, and validation
- The repo is built as a TypeScript VS Code extension with esbuild, linting, Playwright, and Vitest.
- E2E tests under tests/e2e validate the webview pages and navigation; many src/core/*.test.ts files validate analysis logic.
- CI and release workflows indicate this is packaged as a distributable VSIX, with docs generated from the docs/ Hugo site.
15. How to draw the architecture
- A good diagram would show:
- local log sources on the left,
- parsers/normalizers in the middle,
- analytics/rules/DSL/cache/workers as the core engine,
- webview pages and panels as the main UI surface,
- optional Copilot/LLM and MCP integrations as side boundaries,
- and exports/share summaries as the output boundary.
Main entry points: panel.ts Webview shell · extension.ts Extension · rule-engine.ts Rules · analyzer.ts Analytics
Components 19
Runtime
VS Code extension host, workers, and integration surfaces
Ingest & Analysis
Local log parsing, normalization, analytics, and rule evaluation
- Parsers · Normalizes Claude, Codex, VS Code, OpenCode, Xcode, and related session logs.
src/core/parser.ts - Shared model · Shared parser helpers and harness normalization before analytics runs.
src/core/parser-shared.ts - Analytics · Builds dashboard, timeline, workflow, insights, production, context, and image views.
src/core/analyzer.ts - Rules · Loads markdown rule definitions and turns behavior into coaching signals.
src/core/rule-engine.ts - DSL · Custom lexer, parser, interpreter, schema, and safe-regex support for rule logic.
src/core/dsl/index.ts - Detectors · Scoring and detectors that feed the rule/metric engine.
src/core/detectors.ts - Metric engine · Computes behavior metrics used by rules and anti-pattern analysis.
src/core/metric-engine.ts - Cache · Stores parsed and derived results for reuse across pages and navigations.
src/core/cache.ts
Webview UI
Panel shell and feature pages rendered in VS Code webviews
- Webview shell · Panel runtime, RPC bridge, request service, and render pipeline.
src/webview/panel.ts - Dashboard · High-level coaching overview and summary surface.
src/webview/page-dashboard.ts - Timeline · Session chronology and interaction flow visualization.
src/webview/page-timeline.ts - Patterns · Pattern and anti-pattern exploration pages.
src/webview/page-patterns.ts - Rule tools · Rule editor, playground, data explorer, and context management surfaces.
src/webview/page-rule-editor.ts - Learning · Learning, achievements, skills, SDLC, and share pages.
src/webview/page-learning.ts
Support
Exports, chat assistance, and external tool exposure
- Exports · Produces Markdown, JSON, summary cards, and shareable outputs.
src/core/summary-export.ts - Copilot chat · Explicitly invoked Copilot language-model features for selected coaching tasks.
src/chat/participant.ts - MCP tools · Structured tool interface exposing selected coach capabilities to external clients.
src/mcp/tools.ts
Connections 28
- Extension → Parsers: loads logs · Reads local session logs through parser adapters.
- Extension → Analytics: runs analysis · Coordinates analytics services for the active workspace.
- Extension → Rules: evaluates rules · Triggers coaching and anti-pattern scoring.
- Extension → Cache: reads/writes · Uses cached derived results to keep navigation responsive.
- Extension → Webview shell: hosts UI · Creates and manages the VS Code panel/webview shell.
- Extension → Exports: exports · Provides summary and export commands.
- Extension → MCP tools: exposes tools · Publishes selected functionality for external tool clients.
- Parsers → Shared model: normalizes · Converts tool-specific logs into shared session types.
- Shared model → Analytics: feeds · Supplies standardized sessions to analysis modules.
- Analytics → Metric engine: derives signals · Computes domain metrics used by downstream scoring.
- Metric engine → Detectors: powers · Provides numeric signals and thresholds for detectors.
- Detectors → Rules: informs · Supports rule evaluation and anti-pattern classification.
- Rules → DSL: executes via · Uses the internal DSL for rule logic and filtering.
- Rules → Cache: persists findings · Stores evaluated rule results for reuse.
- Workers → Parsers: background parse · Moves expensive parsing off the extension host thread.
- Workers → Cache: warm/persist · Handles cache warm-up and write operations.
- Webview shell → Dashboard: renders · Displays the main coaching overview.
- Webview shell → Timeline: renders · Displays session timelines and flow views.
- Webview shell → Patterns: renders · Displays pattern and anti-pattern exploration.
- Webview shell → Rule tools: renders · Hosts rule authoring, playground, explorer, and context tools.
- Webview shell → Learning: renders · Hosts learning, achievements, skills, and share pages.
- Webview shell → Analytics: requests data · Pulls analyzed views through panel RPC.
- Webview shell → Cache: reads state · Uses cached derived data for page hydration.
- Exports → Webview shell: shows summaries · Feeds export previews and shareable artifacts back to the UI.
- Copilot chat → DSL: assists authoring · Optional LLM help for rule and context tooling.
- Copilot chat → Rules: supports tuning · Can help refine coaching rules when explicitly invoked.
- MCP tools → Analytics: queries · Surfaces analysis results to tool clients.
- MCP tools → Exports: formats · Packages summaries and structured results for external consumption.