feat: structured diagnostic output for AI adapter repair#802
Merged
Conversation
When OPENCLI_DIAGNOSTIC=1 is set, failed commands emit a RepairContext JSON to stderr containing the error, adapter source, and browser state (DOM snapshot, network requests, console errors). AI Agents consume this to diagnose and fix adapters when websites change. Also adds the opencli-repair skill guide for AI Agents.
The e2e helpers pointed to dist/main.js but the actual build output is at dist/src/main.js (matching package.json "main" field). This caused all e2e-headed tests to fail with "Cannot find module".
When browser connection fails before the session callback runs (e.g., BrowserConnectError), the inner diagnostic catch never fires. Use a flag to ensure the outer catch emits diagnostic as a fallback.
The Bloomberg Businessweek RSS feed is intermittently unavailable, causing CI failures unrelated to code changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the auto-fix mechanism (Phase 1 + Phase 2) discussed in the team thread:
Phase 1: Structured diagnostic output — When
OPENCLI_DIAGNOSTIC=1, failed commands emit aRepairContextJSON to stderr containing error details, adapter source code, and browser state (DOM snapshot, network requests, console errors). This gives AI Agents the context they need to diagnose and fix broken adapters.Phase 2: Repair skill —
skills/opencli-repair/SKILL.mdguides AI Agents through the 5-step repair workflow: collect diagnostic → analyze failure → explore current website → patch adapter → verify fix.Key design decisions
repairableflags, no auto-retry logic in runtime___OPENCLI_DIAGNOSTIC___) — AI can parse it directly from command outputFiles changed
src/diagnostic.tsRepairContexttype,collectDiagnostic(),emitDiagnostic()src/diagnostic.test.tssrc/execution.tsskills/opencli-repair/SKILL.mdTest plan
npx tsc --noEmitpassesnpm test— 523 passed, 1 skipped (44 test files)diagnostic.test.ts— 8 tests coveringisDiagnosticEnabled,buildRepairContext,emitDiagnosticOPENCLI_DIAGNOSTIC=1 opencli <site> <cmd>on a failing adapter and confirm JSON output