Loading...
Loading...
Compare original and translation side by side
opencliopencliAUTH_REQUIREDBROWSER_CONNECTopencli doctorRepairContext.adapter.sourcePathclis/<site>/~/.opencli/clis/<site>/src/extension/tests/package.jsontsconfig.jsonAUTH_REQUIREDBROWSER_CONNECTopencli doctorRepairContext.adapter.sourcePathclis/<site>/~/.opencli/clis/<site>/src/extension/tests/package.jsontsconfig.jsonopencli doctor # Verify extension + daemon connectivityopencli doctor # 验证扩展与守护进程的连通性opencli <site> <command>opencli <site> <command>EMPTY_RESULTSELECTORopencli xiaohongshu search "X"opencli xiaohongshu search "X 攻略"opencli doctorresults: []EMPTY_RESULTSELECTORopencli xiaohongshu search "X"opencli xiaohongshu search "X 攻略"opencli doctorresults: []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"
}undefinedOPENCLI_DIAGNOSTIC=1 opencli <site> <command> [args...] 2>diagnostic.json___OPENCLI_DIAGNOSTIC___RepairContext{
"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"
}undefinedundefinedundefined| 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 | STOP — tell user to log in, do not modify code |
| TIMEOUT | Page loads differently, spinner/lazy-load | Add/update wait conditions |
| PAGE_CHANGED | Major redesign | May need full adapter rewrite |
sourcesnapshotnetworkRequests| 错误码 | 可能原因 | 修复策略 |
|---|---|---|
| SELECTOR | DOM结构重构,class/id重命名 | 探查当前DOM → 找到新的选择器 |
| EMPTY_RESULT | API响应结构变更,或数据位置迁移 | 检查网络请求 → 找到新的响应路径 |
| API_ERROR | 接口URL变更,需要新参数 | 通过网络抓包发现新的API |
| AUTH_REQUIRED | 登录流程变更,cookie过期 | 立即停止——告知用户登录,不要修改代码 |
| TIMEOUT | 页面加载逻辑变更, spinner/懒加载逻辑变更 | 添加/更新等待条件 |
| PAGE_CHANGED | 网站大幅改版 | 可能需要完整重写适配器 |
sourcesnapshotnetworkRequestsopencli browseropencli browserundefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedRepairContext.adapter.sourcePathclis/~/.opencli/clis/undefinedRepairContext.adapter.sourcePathclis/~/.opencli/clis/undefinedundefinedundefined// 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"]')// 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现在将数据嵌套在"data"字段下// Before: await page.waitForSelector('.loading-spinner', { hidden: true })
// After: await page.waitForSelector('[data-loaded="true"]')columns@jackwener/opencli/*columns@jackwener/opencli/*undefinedundefined
If it still fails, go back to Step 1 and collect fresh diagnostics. You have a budget of **3 repair rounds** (diagnose → fix → retry). If the same error persists after a fix, try a different approach. After 3 rounds, stop and report what was tried.
如果仍然失败,回到步骤1重新收集最新的诊断数据。你最多有**3轮修复额度**(诊断→修复→重试)。如果修复后仍然出现相同错误,尝试其他修复方案。3轮后仍未解决,停止操作并告知用户已尝试的方案。opencli-exploreropencli-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 browser open https://www.zhihu.com/hot && opencli browser state
→ Confirms new class name ".HotItem" with child ".HotItem-content"
5. AI patches: Edit adapter at RepairContext.adapter.sourcePath — replace ".HotList-item" with ".HotItem"
6. AI verifies: opencli zhihu hot
→ Success: returns hot topics1. 用户运行: opencli zhihu hot
→ 失败: SELECTOR "Could not find element: .HotList-item"
2. AI运行: OPENCLI_DIAGNOSTIC=1 opencli zhihu hot 2>diag.json
→ 获取RepairContext,其中DOM快照显示页面已正常加载
3. AI读取诊断数据: 快照显示页面已加载,但使用的类名是".HotItem"而非".HotList-item"
4. AI探查: opencli browser open https://www.zhihu.com/hot && opencli browser state
→ 确认新的类名为".HotItem",子元素为".HotItem-content"
5. AI打补丁: 编辑`RepairContext.adapter.sourcePath`路径下的适配器,将".HotList-item"替换为".HotItem"
6. AI验证: opencli zhihu hot
→ 成功: 返回热榜话题