Loading...
Loading...
Diagnose and fix broken OpenCLI adapters when websites change. Use when an opencli command fails with SELECTOR, EMPTY_RESULT, API_ERROR, or PAGE_CHANGED errors. Reads structured diagnostic output and uses browser automation to discover what changed and patch the adapter.
npx skill4agent add jackwener/opencli opencli-repairopencli doctor # Verify extension + daemon connectivityopencli <site> <command>OPENCLI_DIAGNOSTIC=1 opencli <site> <command> [args...] 2>diagnostic.jsonRepairContext___OPENCLI_DIAGNOSTIC___{
"error": {
"code": "SELECTOR",
"message": "Could not find element: .old-selector",
"hint": "The page UI may have changed."
},
"adapter": {
"site": "example",
"command": "example/search",
"sourcePath": "/path/to/clis/example/search.ts",
"source": "// full adapter source code"
},
"page": {
"url": "https://example.com/search",
"snapshot": "// DOM snapshot with [N] indices",
"networkRequests": [],
"consoleErrors": []
},
"timestamp": "2025-01-01T00:00:00.000Z"
}# Extract JSON between markers from stderr output
cat diagnostic.json | sed -n '/___OPENCLI_DIAGNOSTIC___/{n;p;}'| Error Code | Likely Cause | Repair Strategy |
|---|---|---|
| SELECTOR | DOM restructured, class/id renamed | Explore current DOM → find new selector |
| EMPTY_RESULT | API response schema changed, or data moved | Check network → find new response path |
| API_ERROR | Endpoint URL changed, new params required | Discover new API via network intercept |
| AUTH_REQUIRED | Login flow changed, cookies expired | Walk login flow with operate |
| TIMEOUT | Page loads differently, spinner/lazy-load | Add/update wait conditions |
| PAGE_CHANGED | Major redesign | May need full adapter rewrite |
sourcesnapshotnetworkRequestsopencli operate# Open the page and inspect current DOM
opencli operate open https://example.com/target-page && opencli operate state
# Look for elements that match the adapter's intent
# Compare the snapshot with what the adapter expects# Open page with network interceptor, then trigger the action manually
opencli operate open https://example.com/target-page && opencli operate state
# Interact to trigger API calls
opencli operate click <N> && opencli operate network
# Inspect specific API response
opencli operate network --detail <index># Check current auth state
opencli operate open https://example.com && opencli operate state
# If login page: inspect the login form
opencli operate state # Look for login form fields# Read the adapter
cat <sourcePath from diagnostic>// Before: page.evaluate('document.querySelector(".old-class")...')
// After: page.evaluate('document.querySelector(".new-class")...')// Before: const resp = await page.evaluate(`fetch('/api/v1/old-endpoint')...`)
// After: const resp = await page.evaluate(`fetch('/api/v2/new-endpoint')...`)// Before: const items = data.results
// After: const items = data.data.items // API now nests under "data"// Before: await page.waitForSelector('.loading-spinner', { hidden: true })
// After: await page.waitForSelector('[data-loaded="true"]')columns@jackwener/opencli/*# Run the command normally (without diagnostic mode)
opencli <site> <command> [args...]opencli-explorer1. User runs: opencli zhihu hot
→ Fails: SELECTOR "Could not find element: .HotList-item"
2. AI runs: OPENCLI_DIAGNOSTIC=1 opencli zhihu hot 2>diag.json
→ Gets RepairContext with DOM snapshot showing page loaded
3. AI reads diagnostic: snapshot shows the page loaded but uses ".HotItem" instead of ".HotList-item"
4. AI explores: opencli operate open https://www.zhihu.com/hot && opencli operate state
→ Confirms new class name ".HotItem" with child ".HotItem-content"
5. AI patches: Edit clis/zhihu/hot.ts — replace ".HotList-item" with ".HotItem"
6. AI verifies: opencli zhihu hot
→ Success: returns hot topics