Repository navigation
Add agent-friendly diagnostics reports - #207
Conversation
There was a problem hiding this comment.
⚠️ Not ready to approve
The current trimming order in LogsTrimmer.trim(data:) can remove newer structured log events before older legacy entries in mixed-format log files, which breaks expected “trim oldest first” behavior.
Pull request overview
This PR updates Diagnostics’ HTML report pipeline to be agent-friendly by embedding a structured JSON DiagnosticsReportDocument payload in the report and rendering the browser UI from that JSON, while also migrating session logs toward structured, JSON-line records with backward-compatible parsing of legacy stored HTML-fragment logs.
Changes:
- Embed a JSON report document (
script#diagnostics-report-data) in the HTML output and render chapters client-side with updatedfunctions.js. - Introduce structured session-log models/records (
DiagnosticsLogReport,DiagnosticsLogRecord) and a parser that supports mixed legacy + structured log storage. - Add metadata/plugin descriptors and a repo-local “diagnostics-report-analyzer-skill” with eval fixtures.
File summaries
| File | Description |
|---|---|
| Sources/Reporters/LogsReporter.swift | Switch logs chapter to return a structured DiagnosticsLogReport parsed from stored logs. |
| Sources/Logging/LogsTrimmer.swift | Update trimming to account for structured JSON-line log records (plus legacy trimming). |
| Sources/Logging/Loggable.swift | Emit structured JSON-line records for log writing; keep legacy HTML formatting logic as a separate path. |
| Sources/Logging/DiagnosticsLogReport.swift | Add structured log report/session/event models, record encoding/decoding, and mixed-format parser. |
| Sources/functions.js | Render the report UI from embedded JSON instead of pre-rendered HTML. |
| Sources/DiagnosticsReporter.swift | Generate HTML that embeds JSON and mounts a JS-rendered report root; add script-escaping helper. |
| Sources/DiagnosticsReportDocument.swift | Add JSON document schema for the embedded report payload and diagnostics-to-document value conversion. |
| DiagnosticsTests/* | Update/add tests for structured logs, mixed legacy+structured parsing, and embedded-report JSON extraction. |
| diagnostics-report-analyzer-skill/* | Add a support/debugging analysis skill plus eval prompts and fixtures. |
| plugins.json / package.json / openai.yml / agents/openai.yaml / .cursor-plugin/* / .claude-plugin/* | Add agent/plugin metadata for distributing the skill. |
Copilot's findings
- Files reviewed: 23/23 changed files
- Comments generated: 2
Note
Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Preserve browser rendering fidelity while keeping structured JSON for agents, and surface crash diagnostics as first-class log events.
Ensure uncaught exception records are written before the process aborts so reports expose them as crash-level events.
Timestamp uncaught exception records and teach the analyzer skill to distinguish legacy crash-like system logs from structured crash events.
Add concise README guidance and detailed client-specific install instructions for the Diagnostics analyzer skill.
Summary
Test plan