bobo-ai-cli 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +216 -0
  3. package/dist/agent.d.ts +9 -0
  4. package/dist/agent.js +144 -0
  5. package/dist/agent.js.map +1 -0
  6. package/dist/config.d.ts +15 -0
  7. package/dist/config.js +76 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +366 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/knowledge-commands.d.ts +2 -0
  13. package/dist/knowledge-commands.js +40 -0
  14. package/dist/knowledge-commands.js.map +1 -0
  15. package/dist/knowledge.d.ts +17 -0
  16. package/dist/knowledge.js +112 -0
  17. package/dist/knowledge.js.map +1 -0
  18. package/dist/memory.d.ts +17 -0
  19. package/dist/memory.js +215 -0
  20. package/dist/memory.js.map +1 -0
  21. package/dist/planner.d.ts +22 -0
  22. package/dist/planner.js +130 -0
  23. package/dist/planner.js.map +1 -0
  24. package/dist/project.d.ts +25 -0
  25. package/dist/project.js +117 -0
  26. package/dist/project.js.map +1 -0
  27. package/dist/rules-commands.d.ts +2 -0
  28. package/dist/rules-commands.js +51 -0
  29. package/dist/rules-commands.js.map +1 -0
  30. package/dist/skills.d.ts +28 -0
  31. package/dist/skills.js +349 -0
  32. package/dist/skills.js.map +1 -0
  33. package/dist/structured/loader.d.ts +19 -0
  34. package/dist/structured/loader.js +147 -0
  35. package/dist/structured/loader.js.map +1 -0
  36. package/dist/structured/paths.d.ts +2 -0
  37. package/dist/structured/paths.js +14 -0
  38. package/dist/structured/paths.js.map +1 -0
  39. package/dist/structured/project-scaffold.d.ts +7 -0
  40. package/dist/structured/project-scaffold.js +60 -0
  41. package/dist/structured/project-scaffold.js.map +1 -0
  42. package/dist/structured/render-markdown.d.ts +37 -0
  43. package/dist/structured/render-markdown.js +47 -0
  44. package/dist/structured/render-markdown.js.map +1 -0
  45. package/dist/structured/render-table.d.ts +1 -0
  46. package/dist/structured/render-table.js +15 -0
  47. package/dist/structured/render-table.js.map +1 -0
  48. package/dist/structured/search.d.ts +10 -0
  49. package/dist/structured/search.js +104 -0
  50. package/dist/structured/search.js.map +1 -0
  51. package/dist/structured/skill-runner.d.ts +15 -0
  52. package/dist/structured/skill-runner.js +60 -0
  53. package/dist/structured/skill-runner.js.map +1 -0
  54. package/dist/structured/types.d.ts +212 -0
  55. package/dist/structured/types.js +97 -0
  56. package/dist/structured/types.js.map +1 -0
  57. package/dist/structured-skills-commands.d.ts +3 -0
  58. package/dist/structured-skills-commands.js +126 -0
  59. package/dist/structured-skills-commands.js.map +1 -0
  60. package/dist/structured-template-commands.d.ts +2 -0
  61. package/dist/structured-template-commands.js +34 -0
  62. package/dist/structured-template-commands.js.map +1 -0
  63. package/dist/tools/index.d.ts +3 -0
  64. package/dist/tools/index.js +450 -0
  65. package/dist/tools/index.js.map +1 -0
  66. package/dist/ui.d.ts +19 -0
  67. package/dist/ui.js +72 -0
  68. package/dist/ui.js.map +1 -0
  69. package/dist/web.d.ts +4 -0
  70. package/dist/web.js +124 -0
  71. package/dist/web.js.map +1 -0
  72. package/knowledge/advanced-patterns.md +70 -0
  73. package/knowledge/agent-directives.md +74 -0
  74. package/knowledge/dream.md +36 -0
  75. package/knowledge/engineering.md +46 -0
  76. package/knowledge/error-catalog.md +33 -0
  77. package/knowledge/index.json +170 -0
  78. package/knowledge/memory/cache-optimization-and-skill-integration.md +102 -0
  79. package/knowledge/memory/engineering-patterns.md +134 -0
  80. package/knowledge/memory/feedback_root_structure.md +16 -0
  81. package/knowledge/memory/project-contexts.md +69 -0
  82. package/knowledge/memory/tools-and-services.md +85 -0
  83. package/knowledge/rules/agents.md +62 -0
  84. package/knowledge/rules/blocking-rules.md +323 -0
  85. package/knowledge/rules/cache-management.md +379 -0
  86. package/knowledge/rules/capability-evolution.md +132 -0
  87. package/knowledge/rules/coding.md +126 -0
  88. package/knowledge/rules/engineering-workflows.md +225 -0
  89. package/knowledge/rules/evomap-content-guidelines.md +354 -0
  90. package/knowledge/rules/evomap-guide.md +224 -0
  91. package/knowledge/rules/git.md +31 -0
  92. package/knowledge/rules/hooks.md +106 -0
  93. package/knowledge/rules/performance.md +101 -0
  94. package/knowledge/rules/remotion-auto-production.md +1120 -0
  95. package/knowledge/rules/security.md +46 -0
  96. package/knowledge/rules/testing.md +32 -0
  97. package/knowledge/rules/work-mode.md +208 -0
  98. package/knowledge/rules.md +62 -0
  99. package/knowledge/skills/Skill_Seekers.md +1722 -0
  100. package/knowledge/skills/ab-test-setup.md +557 -0
  101. package/knowledge/skills/agent-sdk-dev.md +238 -0
  102. package/knowledge/skills/agent-tools.md +136 -0
  103. package/knowledge/skills/analytics-tracking.md +597 -0
  104. package/knowledge/skills/artifacts-builder.md +89 -0
  105. package/knowledge/skills/asana.md +13 -0
  106. package/knowledge/skills/backend-expert.md +97 -0
  107. package/knowledge/skills/brand-voice.md +481 -0
  108. package/knowledge/skills/browser-use.md +419 -0
  109. package/knowledge/skills/cache-optimization-skill.md +179 -0
  110. package/knowledge/skills/canvas-design.md +147 -0
  111. package/knowledge/skills/citation-validator.md +203 -0
  112. package/knowledge/skills/clangd-lsp.md +52 -0
  113. package/knowledge/skills/code-review-expert.md +85 -0
  114. package/knowledge/skills/code-review.md +280 -0
  115. package/knowledge/skills/code-simplifier.md +13 -0
  116. package/knowledge/skills/commit-commands.md +258 -0
  117. package/knowledge/skills/competitor-alternatives.md +795 -0
  118. package/knowledge/skills/content-atomizer.md +910 -0
  119. package/knowledge/skills/content-research-writer.md +605 -0
  120. package/knowledge/skills/context-optimization-suite.md +162 -0
  121. package/knowledge/skills/context7.md +13 -0
  122. package/knowledge/skills/copy-editing.md +494 -0
  123. package/knowledge/skills/copywriting.md +510 -0
  124. package/knowledge/skills/csharp-lsp.md +40 -0
  125. package/knowledge/skills/decision-making-framework.md +154 -0
  126. package/knowledge/skills/developer-growth-analysis.md +335 -0
  127. package/knowledge/skills/direct-response-copy.md +2336 -0
  128. package/knowledge/skills/docker-expert.md +229 -0
  129. package/knowledge/skills/document-skills.md +13 -0
  130. package/knowledge/skills/documentation-expert.md +126 -0
  131. package/knowledge/skills/email-sequence.md +1061 -0
  132. package/knowledge/skills/email-sequences.md +910 -0
  133. package/knowledge/skills/example-plugin.md +72 -0
  134. package/knowledge/skills/explanatory-output-style.md +82 -0
  135. package/knowledge/skills/feature-dev.md +458 -0
  136. package/knowledge/skills/file-organizer.md +466 -0
  137. package/knowledge/skills/firebase.disabled.md +13 -0
  138. package/knowledge/skills/form-cro.md +488 -0
  139. package/knowledge/skills/free-tool-strategy.md +636 -0
  140. package/knowledge/skills/frontend-design-offical.md +55 -0
  141. package/knowledge/skills/frontend-design.md +41 -0
  142. package/knowledge/skills/frontend-expert.md +93 -0
  143. package/knowledge/skills/github.md +13 -0
  144. package/knowledge/skills/gitlab.md +13 -0
  145. package/knowledge/skills/gopls-lsp.md +32 -0
  146. package/knowledge/skills/got-controller.md +218 -0
  147. package/knowledge/skills/greptile.md +72 -0
  148. package/knowledge/skills/hookify.md +376 -0
  149. package/knowledge/skills/image-editor.md +189 -0
  150. package/knowledge/skills/image-enhancer.md +109 -0
  151. package/knowledge/skills/jdtls-lsp.md +49 -0
  152. package/knowledge/skills/json-canvas.md +654 -0
  153. package/knowledge/skills/keyword-research.md +559 -0
  154. package/knowledge/skills/kotlin-lsp.md +28 -0
  155. package/knowledge/skills/laravel-boost.md +13 -0
  156. package/knowledge/skills/launch-strategy.md +394 -0
  157. package/knowledge/skills/lead-magnet.md +393 -0
  158. package/knowledge/skills/learning-output-style.md +106 -0
  159. package/knowledge/skills/linear.md +13 -0
  160. package/knowledge/skills/lua-lsp.md +47 -0
  161. package/knowledge/skills/marketing-ideas.md +720 -0
  162. package/knowledge/skills/marketing-psychology.md +534 -0
  163. package/knowledge/skills/mcp-builder.md +369 -0
  164. package/knowledge/skills/meeting-insights-analyzer.md +347 -0
  165. package/knowledge/skills/memory-evolution-system.md +172 -0
  166. package/knowledge/skills/multi-lens-thinking.md +407 -0
  167. package/knowledge/skills/nano-banana-pro.md +116 -0
  168. package/knowledge/skills/newsletter.md +736 -0
  169. package/knowledge/skills/notebooklm.md +296 -0
  170. package/knowledge/skills/obsidian-bases.md +634 -0
  171. package/knowledge/skills/obsidian-markdown.md +651 -0
  172. package/knowledge/skills/onboarding-cro.md +494 -0
  173. package/knowledge/skills/orchestrator.md +681 -0
  174. package/knowledge/skills/page-cro.md +379 -0
  175. package/knowledge/skills/paid-ads.md +624 -0
  176. package/knowledge/skills/paywall-upgrade-cro.md +651 -0
  177. package/knowledge/skills/php-lsp.md +36 -0
  178. package/knowledge/skills/planning-with-files.md +193 -0
  179. package/knowledge/skills/playwright.md +13 -0
  180. package/knowledge/skills/plugin-dev.md +434 -0
  181. package/knowledge/skills/popup-cro.md +520 -0
  182. package/knowledge/skills/positioning-angles.md +330 -0
  183. package/knowledge/skills/pr-review-toolkit.md +359 -0
  184. package/knowledge/skills/pricing-strategy.md +777 -0
  185. package/knowledge/skills/programmatic-seo.md +714 -0
  186. package/knowledge/skills/pyright-lsp.md +43 -0
  187. package/knowledge/skills/quality-assurance-framework.md +168 -0
  188. package/knowledge/skills/question-refiner.md +160 -0
  189. package/knowledge/skills/ralph-loop.md +205 -0
  190. package/knowledge/skills/refactoring-expert.md +103 -0
  191. package/knowledge/skills/referral-program.md +668 -0
  192. package/knowledge/skills/research-executor.md +164 -0
  193. package/knowledge/skills/review-with-security.md +12 -0
  194. package/knowledge/skills/rust-analyzer-lsp.md +50 -0
  195. package/knowledge/skills/schema-markup.md +647 -0
  196. package/knowledge/skills/security-audit-expert.md +124 -0
  197. package/knowledge/skills/security-expert.md +140 -0
  198. package/knowledge/skills/security-guidance.md +13 -0
  199. package/knowledge/skills/seedance-prompt.md +139 -0
  200. package/knowledge/skills/self-evolution.md +1160 -0
  201. package/knowledge/skills/seo-audit.md +432 -0
  202. package/knowledge/skills/seo-content.md +787 -0
  203. package/knowledge/skills/serena.md +13 -0
  204. package/knowledge/skills/signup-flow-cro.md +409 -0
  205. package/knowledge/skills/skill-creator.md +220 -0
  206. package/knowledge/skills/skill-manager.md +226 -0
  207. package/knowledge/skills/skill-share.md +98 -0
  208. package/knowledge/skills/slack.md +13 -0
  209. package/knowledge/skills/social-content.md +878 -0
  210. package/knowledge/skills/spec-flow-skill.md +124 -0
  211. package/knowledge/skills/stripe.md +13 -0
  212. package/knowledge/skills/supabase.md +13 -0
  213. package/knowledge/skills/swift-lsp.md +40 -0
  214. package/knowledge/skills/synthesizer.md +236 -0
  215. package/knowledge/skills/template-skill.md +16 -0
  216. package/knowledge/skills/testing-expert.md +99 -0
  217. package/knowledge/skills/theme-factory.md +72 -0
  218. package/knowledge/skills/tiktok-research.md +208 -0
  219. package/knowledge/skills/typescript-lsp.md +36 -0
  220. package/knowledge/skills/ui-ux-pro-max.md +247 -0
  221. package/knowledge/skills/verify.md +15 -0
  222. package/knowledge/skills/visual-prompt-engineer.md +102 -0
  223. package/knowledge/skills/webapp-testing.md +111 -0
  224. package/knowledge/skills/wide-research.md +191 -0
  225. package/knowledge/system.md +93 -0
  226. package/knowledge/task-router.md +37 -0
  227. package/knowledge/verification.md +38 -0
  228. package/knowledge/workflows/3d-viz.md +47 -0
  229. package/knowledge/workflows/data-pipeline.md +47 -0
  230. package/knowledge/workflows/db-migration.md +51 -0
  231. package/knowledge/workflows/feature-dev.md +41 -0
  232. package/knowledge/workflows/tdd-flow.md +52 -0
  233. package/knowledge/workflows/ui-verify.md +51 -0
  234. package/package.json +60 -0
@@ -0,0 +1,419 @@
1
+ ---
2
+ id: "browser-use"
3
+ title: "Browser-Use Skill"
4
+ category: "infrastructure"
5
+ tags: ["browser-use skill", "📚 概述", "🚀 快速开始", "创建环境", "安装 browser-use 和 chromium", "browser use(推荐 - 最快速度 + 最低成本)", "或者使用其他 llm", "🏗️ 核心概念", "🛠️ 开发规则", "🎯 开发命令"]
6
+ triggers: []
7
+ dependencies: []
8
+ source: "E:/Bobo's Coding cache/.claude/skills/browser-use"
9
+ ---
10
+
11
+ # Browser-Use Skill
12
+
13
+ > AI 驱动的浏览器自动化库 - 使用 LLM 控制浏览器完成复杂任务
14
+
15
+ ## 📚 概述
16
+
17
+ Browser-Use 是一个 async Python >= 3.11 库,通过 LLM + CDP (Chrome DevTools Protocol) 实现 AI 浏览器驱动能力。核心架构使 AI agents 能够自主导航网页、与元素交互、通过处理 HTML 并做出 LLM 驱动的决策来完成复杂任务。
18
+
19
+ ## 🚀 快速开始
20
+
21
+ ### 1. 安装 Browser-Use
22
+
23
+ ```bash
24
+ # 创建环境
25
+ pip install uv
26
+ uv venv --python 3.12
27
+ source .venv/bin/activate
28
+ # Windows 使用: .venv\Scripts\activate
29
+
30
+ # 安装 browser-use 和 chromium
31
+ uv pip install browser-use
32
+ uvx browser-use install
33
+ ```
34
+
35
+ ### 2. 选择你喜欢的 LLM
36
+
37
+ 创建 `.env` 文件并添加 API key:
38
+
39
+ ```bash
40
+ # Browser Use(推荐 - 最快速度 + 最低成本)
41
+ BROWSER_USE_API_KEY=your_key_here
42
+ # 在 https://cloud.browser-use.com/new-api-key 获取 $10 免费额度
43
+
44
+ # 或者使用其他 LLM
45
+ OPENAI_API_KEY=your_key_here
46
+ ANTHROPIC_API_KEY=your_key_here
47
+ GOOGLE_API_KEY=your_key_here
48
+ ```
49
+
50
+ ### 3. 运行第一个 Agent
51
+
52
+ ```python
53
+ from browser_use import Agent, ChatBrowserUse
54
+ from dotenv import load_dotenv
55
+ import asyncio
56
+
57
+ load_dotenv()
58
+
59
+ async def main():
60
+ llm = ChatBrowserUse()
61
+ task = "查找 Hacker News 上排名第一的帖子"
62
+ agent = Agent(task=task, llm=llm)
63
+ await agent.run()
64
+
65
+ if __name__ == "__main__":
66
+ asyncio.run(main())
67
+ ```
68
+
69
+ ### 4. 生产部署
70
+
71
+ 使用 `@sandbox` 装饰器部署到生产环境,并扩展到百万级 agents:
72
+
73
+ ```python
74
+ from browser_use import Browser, sandbox, ChatBrowserUse
75
+ from browser_use.agent.service import Agent
76
+ import asyncio
77
+
78
+ @sandbox(cloud_profile_id='your-profile-id')
79
+ async def production_task(browser: Browser):
80
+ agent = Agent(
81
+ task="你的认证任务",
82
+ browser=browser,
83
+ llm=ChatBrowserUse()
84
+ )
85
+ await agent.run()
86
+
87
+ asyncio.run(production_task())
88
+ ```
89
+
90
+ 同步本地 cookies 到云端:
91
+
92
+ ```bash
93
+ export BROWSER_USE_API_KEY=your_key && curl -fsSL https://browser-use.com/profile.sh | sh
94
+ ```
95
+
96
+ ## 🏗️ 核心概念
97
+
98
+ ### Agent 基础
99
+
100
+ ```python
101
+ from browser_use import Agent, ChatBrowserUse
102
+
103
+ agent = Agent(
104
+ task="搜索最新 AI 新闻",
105
+ llm=ChatBrowserUse(),
106
+ )
107
+
108
+ async def main():
109
+ history = await agent.run(max_steps=100)
110
+
111
+ # 访问有用信息
112
+ history.urls() # 访问过的 URL 列表
113
+ history.action_names() # 执行的操作名称
114
+ history.final_result() # 最终提取的内容
115
+ history.is_successful() # 检查是否成功完成
116
+ ```
117
+
118
+ ### Browser 配置
119
+
120
+ ```python
121
+ from browser_use import Agent, Browser, ChatBrowserUse
122
+
123
+ browser = Browser(
124
+ headless=False, # 显示浏览器窗口
125
+ window_size={'width': 1000, 'height': 700},
126
+ proxy=ProxySettings(server='http://host:8080'),
127
+ user_data_dir='./profile', # 保持登录状态
128
+ )
129
+
130
+ agent = Agent(
131
+ task='搜索 Browser Use',
132
+ browser=browser,
133
+ llm=ChatBrowserUse(),
134
+ )
135
+ ```
136
+
137
+ ### Tools(工具)
138
+
139
+ 自定义工具扩展 agent 能力:
140
+
141
+ ```python
142
+ from browser_use import Tools, ActionResult, Browser
143
+
144
+ tools = Tools()
145
+
146
+ @tools.action('向人类询问问题')
147
+ def ask_human(question: str, browser: Browser) -> ActionResult:
148
+ answer = input(f'{question} > ')
149
+ return f'人类回答: {answer}'
150
+
151
+ agent = Agent(
152
+ task='向人类寻求帮助',
153
+ llm=llm,
154
+ tools=tools,
155
+ )
156
+ ```
157
+
158
+ ## 🛠️ 开发规则
159
+
160
+ ### 核心原则
161
+
162
+ 1. **始终使用 `uv` 而不是 `pip`**
163
+
164
+ ```bash
165
+ uv venv --python 3.11
166
+ source .venv/bin/activate
167
+ uv sync
168
+ ```
169
+
170
+ 2. **类型安全编码**
171
+ - 使用 Pydantic v2 模型进行所有内部操作
172
+ - 使用现代 Python 类型提示:`str | None` 而非 `Optional[str]`
173
+
174
+ 3. **Pre-commit 格式化**
175
+ - 在提交 PR 前始终运行 pre-commit
176
+
177
+ 4. **使用描述性名称和文档字符串**
178
+
179
+ 5. **返回 `ActionResult` 结构化内容**
180
+ - 帮助 agent 更好地推理
181
+
182
+ 6. **从不创建随机示例**
183
+ - 测试功能时使用终端内联代码
184
+
185
+ 7. **默认推荐 `ChatBrowserUse` 模型**
186
+ - 最高准确度 + 最快速度 + 最低 token 成本
187
+
188
+ ## 🎯 开发命令
189
+
190
+ ```bash
191
+ # 设置
192
+ uv venv --python 3.11
193
+ source .venv/bin/activate
194
+ uv sync
195
+
196
+ # 测试
197
+ uv run pytest -vxs tests/ci # CI 测试
198
+ uv run pytest -vxs tests/ # 所有测试
199
+
200
+ # 质量检查
201
+ uv run pyright # 类型检查
202
+ uv run ruff check --fix # Linting
203
+ uv run ruff format # 格式化
204
+ uv run pre-commit run --all-files # Pre-commit hooks
205
+
206
+ # MCP 服务器模式
207
+ uvx browser-use[cli] --mcp
208
+ ```
209
+
210
+ ## 📖 可用工具(Actions)
211
+
212
+ ### 导航和浏览器控制
213
+
214
+ - `search` - 搜索查询(DuckDuckGo、Google、Bing)
215
+ - `navigate` - 导航到 URL
216
+ - `go_back` - 返回浏览器历史
217
+ - `wait` - 等待指定秒数
218
+
219
+ ### 页面交互
220
+
221
+ - `click` - 通过索引点击元素
222
+ - `input` - 输入文本到表单字段
223
+ - `upload_file` - 上传文件
224
+ - `scroll` - 滚动页面
225
+ - `find_text` - 滚动到页面上的特定文本
226
+ - `send_keys` - 发送特殊按键(Enter、Escape 等)
227
+
228
+ ### JavaScript 执行
229
+
230
+ - `evaluate` - 在页面上执行自定义 JavaScript 代码
231
+
232
+ ### 标签页管理
233
+
234
+ - `switch` - 在浏览器标签页之间切换
235
+ - `close` - 关闭浏览器标签页
236
+
237
+ ### 内容提取
238
+
239
+ - `extract` - 使用 LLM 从网页提取数据
240
+
241
+ ### 视觉分析
242
+
243
+ - `screenshot` - 请求下一个浏览器状态的截图
244
+
245
+ ### 表单控件
246
+
247
+ - `dropdown_options` - 获取下拉选项值
248
+ - `select_dropdown` - 选择下拉选项
249
+
250
+ ### 文件操作
251
+
252
+ - `write_file` - 写入内容到文件
253
+ - `read_file` - 读取文件内容
254
+ - `replace_file` - 替换文件中的文本
255
+
256
+ ### 任务完成
257
+
258
+ - `done` - 完成任务(始终可用)
259
+
260
+ ## 💡 提示技巧
261
+
262
+ ### 1. 具体 vs 开放式
263
+
264
+ **✅ 具体(推荐)**
265
+
266
+ ```python
267
+ task = """
268
+ 1. 访问 https://quotes.toscrape.com/
269
+ 2. 使用 extract 操作查询 "前 3 条引用及其作者"
270
+ 3. 使用 write_file 操作将结果保存到 quotes.csv
271
+ 4. 对第一条引用进行 Google 搜索并找到写作时间
272
+ """
273
+ ```
274
+
275
+ **❌ 开放式**
276
+
277
+ ```python
278
+ task = "访问网络并赚钱"
279
+ ```
280
+
281
+ ### 2. 直接命名操作
282
+
283
+ 当你确切知道 agent 应该做什么时,直接引用操作名称:
284
+
285
+ ```python
286
+ task = """
287
+ 1. 使用 search 操作查找 "Python 教程"
288
+ 2. 使用 click 在新标签页中打开第一个结果
289
+ 3. 使用 scroll 操作向下滚动 2 页
290
+ 4. 使用 extract 提取前 5 项的名称
291
+ 5. 如果页面未加载,等待 2 秒,刷新并等待 10 秒
292
+ 6. 使用 send_keys 操作输入 "Tab Tab ArrowDown Enter"
293
+ """
294
+ ```
295
+
296
+ ### 3. 通过键盘导航处理交互问题
297
+
298
+ 有时按钮无法点击(你发现了库中的 bug - 提交 issue)。好消息 - 通常可以通过键盘导航解决!
299
+
300
+ ```python
301
+ task = """
302
+ 如果提交按钮无法点击:
303
+ 1. 使用 send_keys 操作输入 "Tab Tab Enter" 进行导航和激活
304
+ 2. 或使用 send_keys 输入 "ArrowDown ArrowDown Enter" 提交表单
305
+ """
306
+ ```
307
+
308
+ ### 4. 自定义操作集成
309
+
310
+ ```python
311
+ @controller.action("从认证器应用获取 2FA 代码")
312
+ async def get_2fa_code():
313
+ # 你的实现
314
+ pass
315
+
316
+ task = """
317
+ 使用 2FA 登录:
318
+ 1. 输入用户名/密码
319
+ 2. 提示输入 2FA 时,使用 get_2fa_code 操作
320
+ 3. 永远不要尝试从页面手动提取 2FA 代码
321
+ 4. 始终使用 get_2fa_code 操作获取认证代码
322
+ """
323
+ ```
324
+
325
+ ### 5. 错误恢复
326
+
327
+ ```python
328
+ task = """
329
+ 稳健的数据提取:
330
+ 1. 访问 openai.com 查找他们的 CEO
331
+ 2. 如果由于反机器人保护导航失败:
332
+ - 使用 Google 搜索查找 CEO
333
+ 3. 如果页面超时,使用 go_back 并尝试替代方法
334
+ """
335
+ ```
336
+
337
+ ## 🌟 高级功能
338
+
339
+ ### 结构化输出
340
+
341
+ 使用 Pydantic 模型获取结构化输出:
342
+
343
+ ```python
344
+ from pydantic import BaseModel
345
+
346
+ class Quote(BaseModel):
347
+ text: str
348
+ author: str
349
+
350
+ agent = Agent(
351
+ task="提取前 3 条引用",
352
+ llm=llm,
353
+ output_model_schema=Quote,
354
+ )
355
+
356
+ history = await agent.run()
357
+ structured_data = history.structured_output
358
+ ```
359
+
360
+ ### 远程浏览器(Browser-Use Cloud)
361
+
362
+ ```python
363
+ from browser_use import Browser, ChatBrowserUse
364
+
365
+ # 简单:使用 Browser-Use 云浏览器服务
366
+ browser = Browser(use_cloud=True)
367
+
368
+ # 高级:配置云浏览器参数
369
+ browser = Browser(
370
+ cloud_profile_id='your-profile-id', # 特定浏览器配置
371
+ cloud_proxy_country_code='us', # 代理位置
372
+ cloud_timeout=30, # 会话超时(分钟)
373
+ )
374
+ ```
375
+
376
+ ### MCP 集成
377
+
378
+ Browser-Use 支持两种模式:
379
+
380
+ 1. **作为 MCP 服务器**:向 MCP 客户端(如 Claude Desktop)公开浏览器自动化工具
381
+ 2. **使用 MCP 客户端**:Agent 可以连接到外部 MCP 服务器以扩展能力
382
+
383
+ ```bash
384
+ # 作为 MCP 服务器运行
385
+ uvx browser-use[cli] --mcp
386
+ ```
387
+
388
+ ## 📂 项目结构
389
+
390
+ ```
391
+ browser_use/
392
+ ├── agent/ # Agent 核心逻辑
393
+ │ ├── service.py # 主编排器
394
+ │ ├── views.py # Pydantic 模型
395
+ │ └── system_prompt*.md # Agent 提示词
396
+ ├── browser/ # 浏览器管理
397
+ │ ├── session.py # BrowserSession + CDP 客户端
398
+ │ └── profile.py # 浏览器配置和启动参数
399
+ ├── dom/ # DOM 处理
400
+ │ └── service.py # DomService 提取和处理
401
+ ├── tools/ # 操作注册表
402
+ │ └── service.py # 工具定义
403
+ ├── llm/ # LLM 集成层
404
+ └── mcp/ # MCP 集成
405
+ └── client.py # MCP 客户端连接
406
+ ```
407
+
408
+ ## 🔗 相关资源
409
+
410
+ - **GitHub**: https://github.com/browser-use/browser-use
411
+ - **文档**: https://docs.browser-use.com
412
+ - **Discord**: https://link.browser-use.com/discord
413
+ - **Cloud**: https://cloud.browser-use.com
414
+
415
+ ## 🤝 支持
416
+
417
+ - 查看 [GitHub Issues](https://github.com/browser-use/browser-use/issues)
418
+ - 在 [Discord 社区](https://link.browser-use.com/discord) 提问
419
+ - 企业支持:support@browser-use.com
@@ -0,0 +1,179 @@
1
+ ---
2
+ id: "cache-optimization-skill"
3
+ title: "Cache Optimization Skill"
4
+ category: "agent-engineering"
5
+ tags: ["cache optimization skill", "what the patches do", "installation status", "installed location", "patched cli", "usage", "cache health monitoring", "optimization strategy matrix", "troubleshooting", "restore from backup"]
6
+ triggers: []
7
+ dependencies: []
8
+ source: "E:/Bobo's Coding cache/.claude/skills/cache-optimization-skill"
9
+ ---
10
+
11
+ ---
12
+ name: cache-optimization-skill
13
+ description: Token cache optimization based on cc-cache-fix. Auto-applies 3 patches (attachment persistence, hash stability, 1h TTL) and monitors cache health. Use when starting sessions, resuming conversations, or auditing token usage.
14
+ ---
15
+
16
+ # Cache Optimization Skill
17
+
18
+ > **Source**: cc-cache-fix by Rangizingo
19
+ > **Effect**: ~60-70% token savings via 3 targeted patches
20
+ > **Status**: Installed as `claude-patched` (v2.1.81)
21
+
22
+ ## What The Patches Do
23
+
24
+ ### Patch 1: Attachment Persistence (db8 filter)
25
+ **Problem**: Claude Code drops `deferred_tools_delta` and `mcp_instructions_delta` attachments on save, breaking cache on resume.
26
+
27
+ **Fix**: Allow these attachment types through the filter:
28
+ ```javascript
29
+ // Before: only hook_additional_context passes
30
+ if(A.attachment.type==="hook_additional_context") return!0;
31
+ return!1;
32
+
33
+ // After: also allow delta types
34
+ if(A.attachment.type==="deferred_tools_delta") return!0;
35
+ if(A.attachment.type==="mcp_instructions_delta") return!0;
36
+ return!1;
37
+ ```
38
+
39
+ **Effect**: +30% cache hit rate on session resume.
40
+
41
+ ### Patch 1b: Fingerprint Meta Skip
42
+ **Problem**: First user message (including meta/system messages) is used for cache fingerprinting, causing different fingerprints for identical content.
43
+
44
+ **Fix**: Skip meta user messages in fingerprint selector:
45
+ ```javascript
46
+ // Before: finds first user message regardless of meta status
47
+ let q = A.find((_) => _.type === "user");
48
+
49
+ // After: skip meta messages
50
+ let q = A.find((_) => _.type === "user" && !("isMeta" in _ && _.isMeta));
51
+ ```
52
+
53
+ **Effect**: More stable cache keys across turns.
54
+
55
+ ### Patch 2: Force 1-Hour Cache TTL
56
+ **Problem**: Default 5-minute TTL is too short for most tasks. The `sjY()` function checks subscription/feature flags to gate 1h TTL.
57
+
58
+ **Fix**: Bypass the check entirely:
59
+ ```javascript
60
+ // Before: conditional TTL based on plan
61
+ function sjY(A) { if(QA()==="bedrock" ... }
62
+
63
+ // After: always allow 1h TTL
64
+ function sjY(A) { return!0; if(QA()==="bedrock" ... }
65
+ ```
66
+
67
+ **Effect**: Cache lives 12x longer, reducing recomputation.
68
+
69
+ ---
70
+
71
+ ## Installation Status
72
+
73
+ ```bash
74
+ # Installed location
75
+ E:/Bobo's Coding cache/cc-cache-fix/
76
+
77
+ # Patched CLI
78
+ claude-patched.cmd → node cli.js (patched v2.1.81)
79
+
80
+ # Usage
81
+ claude-patched # Start patched Claude Code
82
+ claude-patched --version # Verify: "2.1.81 (Claude Code)"
83
+ ```
84
+
85
+ ## Cache Health Monitoring
86
+
87
+ ### Quick Check
88
+ ```bash
89
+ cd "E:/Bobo's Coding cache/cc-cache-fix"
90
+ python test_cache.py
91
+ ```
92
+
93
+ ### Usage Audit
94
+ ```bash
95
+ python usage_audit.py
96
+ ```
97
+
98
+ ### Health Thresholds
99
+
100
+ | Metric | Green | Yellow | Red |
101
+ |--------|-------|--------|-----|
102
+ | Cache hit rate | >70% | 50-70% | <50% |
103
+ | Token efficiency | >65% | 45-65% | <45% |
104
+ | TTL utilization | >80% | 60-80% | <60% |
105
+
106
+ ---
107
+
108
+ ## Optimization Strategy Matrix
109
+
110
+ ### With cc-cache-fix (default)
111
+ ```
112
+ Strategy: Trust the cache, minimize re-reads
113
+ - Read files once, trust they'll be cached
114
+ - Resume sessions confidently (delta attachments preserved)
115
+ - Work in longer sessions (1h TTL)
116
+ ```
117
+
118
+ ### Without cc-cache-fix (fallback)
119
+ ```
120
+ Strategy: Minimize context, split sessions
121
+ - Use Grep instead of full file reads
122
+ - Split long tasks into 15-20 min sessions
123
+ - Compress context before it exceeds 70%
124
+ ```
125
+
126
+ ---
127
+
128
+ ## Combined with Other Optimizations
129
+
130
+ | Optimization | Token Savings | Requires |
131
+ |-------------|---------------|----------|
132
+ | **cc-cache-fix** | 60-70% | `claude-patched` |
133
+ | **Context compression** | 90-95% of context size | Manual trigger |
134
+ | **Session splitting** | 30-40% for long tasks | Task planning |
135
+ | **Cache warmup** | 30% on first operation | Session start |
136
+ | **Total combined** | ~80% overall | All above |
137
+
138
+ ---
139
+
140
+ ## Troubleshooting
141
+
142
+ ### Patch Not Applied
143
+ ```bash
144
+ cd "E:/Bobo's Coding cache/cc-cache-fix"
145
+ # Restore from backup
146
+ cp node/node_modules/@anthropic-ai/claude-code/cli.js.orig node/node_modules/@anthropic-ai/claude-code/cli.js
147
+ # Re-apply
148
+ python patches/apply-patches.py node/node_modules/@anthropic-ai/claude-code/cli.js
149
+ ```
150
+
151
+ ### Version Mismatch After Claude Code Update
152
+ ```bash
153
+ # The patch targets specific function names (db8, sjY, FA9)
154
+ # If these change in a new version, the patch will fail gracefully
155
+ # Check: python patches/apply-patches.py --dry-run <path-to-new-cli.js>
156
+ ```
157
+
158
+ ### Revert to Stock
159
+ ```bash
160
+ # Simply use 'claude' instead of 'claude-patched'
161
+ claude # Unpatched version
162
+ ```
163
+
164
+ ---
165
+
166
+ ## Maintenance
167
+
168
+ ### Weekly
169
+ - Run `usage_audit.py` to track cache efficiency trends
170
+ - Check for cc-cache-fix updates: `cd cc-cache-fix && git pull`
171
+
172
+ ### Monthly
173
+ - Verify patch status: `python test_cache.py`
174
+ - Re-run installer if Claude Code updated: `powershell -File install-windows.ps1`
175
+
176
+ ### On Claude Code Major Update
177
+ - Check if patches still apply
178
+ - Wait for cc-cache-fix update if function names changed
179
+ - Fall back to `claude` (stock) if patches fail