fix: address remaining code review issues from PR #39

Merged
AN
8mo ago
+86-29

Summary

Addresses all remaining issues from the comprehensive code review on PR #39. PR #40 fixed some issues; this PR covers the rest.

Critical (1)

  • Issue #2: MCP listPrompts()/listResources() now wrapped in withTimeout() — prevents CLI hang when MCP server stalls

Major (3)

  • Issue #5: MCP tool type detection — added MCP.isMcpTool() with a maintained Set, replacing broken startsWith("mcp__") prefix check that caused all MCP tools to be tracked as "standard"
  • Issue #6: MCP prompt template getter — replaced new Promise(async ...) anti-pattern with .then() chain; now throws on undefined template instead of silently returning blank
  • Issue #7: Truncate.cleanup() — wrapped Identifier.timestamp() per-entry in try/catch so a single malformed filename no longer aborts entire cleanup

Minor (8)

  • Issue #8: Empty session_id in early events — fallback to "startup" instead of empty string
  • Issue #9: session_end on early termination — added process.once("beforeExit") handler
  • Issue #10: compactionAttempts unbounded growth — delete session entry on completion/error
  • Issue #11: ai.cloud.role tag — changed from "altimate-code" to "altimate"
  • Issue #12: Error truncation — standardized on .message (not .toString()) to avoid leaking stack traces
  • Issue #13: skill_count — populated from Skill.all() instead of hardcoded 0
  • Issue #14: Context utilization — removed cache_write from token count (not part of context window consumption)
  • Issue #15: Buffer overflow — added dropped events counter, logged on next flush

Docs

  • Fixed incorrect config path in telemetry docs (~/.config/altimate/config.json → ~/.config/altimate-code/altimate-code.json)
  • Added missing telemetry field to config schema table in config docs

Already fixed in PR #40 (verified)

  • Issue #1 (PII): email already SHA-256 hashed
  • Issue #3 (env var opt-out): ALTIMATE_TELEMETRY_DISABLED already implemented
  • Issue #4 (MCP disconnect transport): already reads from stored state

Test plan

  • All 103 existing tests pass (bun test on telemetry, command-resilience, truncation, compaction)
  • No new TypeScript errors introduced (2 pre-existing errors remain)
  • Manual: verify MCP tool calls are tracked as "mcp" type (not "standard")
  • Manual: verify listPrompts()/listResources() timeout after 30s on unresponsive server
  • Manual: verify session_end fires on Ctrl+C

🤖 Generated with Claude Code