refactor(telemetry)!: relocate module, add MCP snapshots, HITL handling, and TUI tracking#197
Conversation
… deepwiki tools Add recency-based file sorting strategy to analyzer and research agents so newest documents are prioritized when gathering context. Update worker agents with improved task focus guidelines. Restrict deepwiki MCP server to ask_question tool only. Add research doc on MCP tool discovery bugs. Assistant-model: Claude Code
…hots, HITL handling, and TUI tracking Relocate telemetry from src/utils/telemetry/ to src/telemetry/ and add new TUI session tracking (telemetry-tui.ts) and graph integration (graph-integration.ts) modules. Update all import paths across commands, SDK clients, and UI layers. Add MCP runtime snapshot API with getMcpSnapshot() on Session interface, implemented in both Claude and OpenCode clients, enabling server introspection for tools, resources, and auth status. Introduce mcp-output utility for Codex-style /mcp rendering and enhance mcp-server-list component with snapshot views. Add HITL response handling utilities for structured tool response records with normalization. Refactor init command to use variant reconciliation instead of SCM template copying, removing the --scm CLI flag. Integrate TUI telemetry callbacks for tool start/complete, interrupts, command execution, and message submit events. Includes tests for init reconciliation, OpenCode MCP snapshots, HITL responses, MCP output formatting, and transcript formatter HITL support. Assistant-model: Claude Code
PR Review: refactor(telemetry): relocate module, add MCP snapshots, HITL handling, and TUI trackingThis is a substantial PR with multiple interconnected changes. Overall, the code is well-structured and follows good practices. Here's my detailed review: ✅ Strengths
🔍 Code Quality Issues1. Inconsistent indentation in
|
Summary
Major refactoring of the telemetry system with new capabilities for TUI session tracking, MCP runtime introspection, and HITL response handling. Includes breaking changes to telemetry module location and init command behavior.
Key Changes
Telemetry System Restructuring
src/utils/telemetry/tosrc/telemetry/with updated import paths across the codebasetelemetry-tui.ts): Tracks chat UI lifecycle including session start/end, message submissions, tool lifecycle, slash command execution, and user interruptsgraph-integration.ts): Added fail-safe callback-based workflow telemetry tracker for graph executor with sampling supportMCP Runtime Introspection
getMcpSnapshot()method to Session interface for runtime server introspectionquery.mcpServerStatus()to fetch auth status and available tools/mcpcommand with Codex-style rendering and enhanced MCP server list component showing transport details, auth status, tools, and resources.mcp.jsonto whitelist onlyask_questiontool for deepwiki serverHITL Response Handling
hitl-response.ts): Structured handling for AskUserQuestion tool responses with normalization and display text formattingoption,custom_input,chat_about_this, anddeclinedmodesInit Command Refactoring (Breaking Change)
--scmflag behavior: No longer copies templates; instead removes unselected SCM variants (gh-* or sl-*) from target directoriessapling-phabricator-windowstemplate variantAgent Configuration Updates
specs/directory to research locator search patternsresearch/docs/,research/tickets/, andspecs/are read firstBreaking Changes
src/utils/telemetry/tosrc/telemetry/initcommand no longer copies SCM template files; it reconciles variants by removing unselected onesgetMcpSnapshot()method to Session interface (returnsnullfor unsupported clients)Test Plan
src/commands/init.test.ts)src/sdk/opencode-client.mcp-snapshot.test.ts)src/ui/utils/hitl-response.test.ts)src/ui/utils/mcp-output.test.ts)src/ui/utils/transcript-formatter.hitl.test.ts)pnpm typecheck && pnpm lint && pnpm testto verify no regressions/mcpcommand renders server snapshots correctly in TUI