@claude-flow/cli 3.0.0-alpha.142 → 3.0.0-alpha.144

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.
@@ -0,0 +1,182 @@
1
+ # Browser Agent Configuration
2
+ # AI-powered web browser automation using agent-browser
3
+ #
4
+ # Capabilities:
5
+ # - Web navigation and interaction
6
+ # - AI-optimized snapshots with element refs
7
+ # - Form filling and submission
8
+ # - Screenshot capture
9
+ # - Network interception
10
+ # - Multi-session coordination
11
+
12
+ name: browser-agent
13
+ description: Web automation specialist using agent-browser with AI-optimized snapshots
14
+ version: 1.0.0
15
+
16
+ # Routing configuration
17
+ routing:
18
+ complexity: medium
19
+ model: sonnet # Good at visual reasoning and DOM interpretation
20
+ priority: normal
21
+ keywords:
22
+ - browser
23
+ - web
24
+ - scrape
25
+ - screenshot
26
+ - navigate
27
+ - login
28
+ - form
29
+ - click
30
+ - automate
31
+
32
+ # Agent capabilities
33
+ capabilities:
34
+ - web-navigation
35
+ - form-interaction
36
+ - screenshot-capture
37
+ - data-extraction
38
+ - network-interception
39
+ - session-management
40
+ - multi-tab-coordination
41
+
42
+ # Available tools (MCP tools with browser/ prefix)
43
+ tools:
44
+ navigation:
45
+ - browser/open
46
+ - browser/back
47
+ - browser/forward
48
+ - browser/reload
49
+ - browser/close
50
+ snapshot:
51
+ - browser/snapshot
52
+ - browser/screenshot
53
+ - browser/pdf
54
+ interaction:
55
+ - browser/click
56
+ - browser/fill
57
+ - browser/type
58
+ - browser/press
59
+ - browser/hover
60
+ - browser/select
61
+ - browser/check
62
+ - browser/uncheck
63
+ - browser/scroll
64
+ - browser/upload
65
+ info:
66
+ - browser/get-text
67
+ - browser/get-html
68
+ - browser/get-value
69
+ - browser/get-attr
70
+ - browser/get-title
71
+ - browser/get-url
72
+ - browser/get-count
73
+ state:
74
+ - browser/is-visible
75
+ - browser/is-enabled
76
+ - browser/is-checked
77
+ wait:
78
+ - browser/wait
79
+ eval:
80
+ - browser/eval
81
+ storage:
82
+ - browser/cookies-get
83
+ - browser/cookies-set
84
+ - browser/cookies-clear
85
+ - browser/localstorage-get
86
+ - browser/localstorage-set
87
+ network:
88
+ - browser/network-route
89
+ - browser/network-unroute
90
+ - browser/network-requests
91
+ tabs:
92
+ - browser/tab-list
93
+ - browser/tab-new
94
+ - browser/tab-switch
95
+ - browser/tab-close
96
+ - browser/session-list
97
+ settings:
98
+ - browser/set-viewport
99
+ - browser/set-device
100
+ - browser/set-geolocation
101
+ - browser/set-offline
102
+ - browser/set-media
103
+ debug:
104
+ - browser/trace-start
105
+ - browser/trace-stop
106
+ - browser/console
107
+ - browser/errors
108
+ - browser/highlight
109
+ - browser/state-save
110
+ - browser/state-load
111
+ find:
112
+ - browser/find-role
113
+ - browser/find-text
114
+ - browser/find-label
115
+ - browser/find-testid
116
+
117
+ # Memory configuration
118
+ memory:
119
+ namespace: browser-sessions
120
+ persist: true
121
+ patterns:
122
+ - login-flows
123
+ - form-submissions
124
+ - scraping-patterns
125
+ - navigation-sequences
126
+
127
+ # Swarm integration
128
+ swarm:
129
+ roles:
130
+ - navigator # Handles authentication and navigation
131
+ - scraper # Extracts data using snapshots
132
+ - validator # Verifies extracted data
133
+ - tester # Runs automated tests
134
+ - monitor # Watches for errors and network issues
135
+ topology: hierarchical # Coordinator manages browser agents
136
+ max_sessions: 5
137
+
138
+ # Hooks integration
139
+ hooks:
140
+ pre_task:
141
+ - route # Get optimal routing
142
+ - memory_search # Check for similar patterns
143
+ post_task:
144
+ - memory_store # Save successful patterns
145
+ - post_edit # Train on outcomes
146
+
147
+ # Default configuration
148
+ defaults:
149
+ timeout: 30000
150
+ headless: true
151
+ viewport:
152
+ width: 1280
153
+ height: 720
154
+
155
+ # Example workflows
156
+ workflows:
157
+ login:
158
+ description: Authenticate to a website
159
+ steps:
160
+ - open: "{url}/login"
161
+ - snapshot: { interactive: true }
162
+ - fill: { target: "@e1", value: "{username}" }
163
+ - fill: { target: "@e2", value: "{password}" }
164
+ - click: "@e3"
165
+ - wait: { url: "**/dashboard" }
166
+ - state-save: "auth-state.json"
167
+
168
+ scrape_list:
169
+ description: Extract data from a list page
170
+ steps:
171
+ - open: "{url}"
172
+ - snapshot: { interactive: true, compact: true }
173
+ - eval: "Array.from(document.querySelectorAll('{selector}')).map(el => el.textContent)"
174
+
175
+ form_submit:
176
+ description: Fill and submit a form
177
+ steps:
178
+ - open: "{url}"
179
+ - snapshot: { interactive: true }
180
+ - fill_fields: "{fields}"
181
+ - click: "{submit_button}"
182
+ - wait: { text: "{success_text}" }
@@ -0,0 +1,204 @@
1
+ ---
2
+ name: browser
3
+ description: Web browser automation with AI-optimized snapshots for claude-flow agents
4
+ version: 1.0.0
5
+ triggers:
6
+ - /browser
7
+ - browse
8
+ - web automation
9
+ - scrape
10
+ - navigate
11
+ - screenshot
12
+ tools:
13
+ - browser/open
14
+ - browser/snapshot
15
+ - browser/click
16
+ - browser/fill
17
+ - browser/screenshot
18
+ - browser/close
19
+ ---
20
+
21
+ # Browser Automation Skill
22
+
23
+ Web browser automation using agent-browser with AI-optimized snapshots. Reduces context by 93% using element refs (@e1, @e2) instead of full DOM.
24
+
25
+ ## Core Workflow
26
+
27
+ ```bash
28
+ # 1. Navigate to page
29
+ agent-browser open <url>
30
+
31
+ # 2. Get accessibility tree with element refs
32
+ agent-browser snapshot -i # -i = interactive elements only
33
+
34
+ # 3. Interact using refs from snapshot
35
+ agent-browser click @e2
36
+ agent-browser fill @e3 "text"
37
+
38
+ # 4. Re-snapshot after page changes
39
+ agent-browser snapshot -i
40
+ ```
41
+
42
+ ## Quick Reference
43
+
44
+ ### Navigation
45
+ | Command | Description |
46
+ |---------|-------------|
47
+ | `open <url>` | Navigate to URL |
48
+ | `back` | Go back |
49
+ | `forward` | Go forward |
50
+ | `reload` | Reload page |
51
+ | `close` | Close browser |
52
+
53
+ ### Snapshots (AI-Optimized)
54
+ | Command | Description |
55
+ |---------|-------------|
56
+ | `snapshot` | Full accessibility tree |
57
+ | `snapshot -i` | Interactive elements only (buttons, links, inputs) |
58
+ | `snapshot -c` | Compact (remove empty elements) |
59
+ | `snapshot -d 3` | Limit depth to 3 levels |
60
+ | `screenshot [path]` | Capture screenshot (base64 if no path) |
61
+
62
+ ### Interaction
63
+ | Command | Description |
64
+ |---------|-------------|
65
+ | `click <sel>` | Click element |
66
+ | `fill <sel> <text>` | Clear and fill input |
67
+ | `type <sel> <text>` | Type with key events |
68
+ | `press <key>` | Press key (Enter, Tab, etc.) |
69
+ | `hover <sel>` | Hover element |
70
+ | `select <sel> <val>` | Select dropdown option |
71
+ | `check/uncheck <sel>` | Toggle checkbox |
72
+ | `scroll <dir> [px]` | Scroll page |
73
+
74
+ ### Get Info
75
+ | Command | Description |
76
+ |---------|-------------|
77
+ | `get text <sel>` | Get text content |
78
+ | `get html <sel>` | Get innerHTML |
79
+ | `get value <sel>` | Get input value |
80
+ | `get attr <sel> <attr>` | Get attribute |
81
+ | `get title` | Get page title |
82
+ | `get url` | Get current URL |
83
+
84
+ ### Wait
85
+ | Command | Description |
86
+ |---------|-------------|
87
+ | `wait <selector>` | Wait for element |
88
+ | `wait <ms>` | Wait milliseconds |
89
+ | `wait --text "text"` | Wait for text |
90
+ | `wait --url "pattern"` | Wait for URL |
91
+ | `wait --load networkidle` | Wait for load state |
92
+
93
+ ### Sessions
94
+ | Command | Description |
95
+ |---------|-------------|
96
+ | `--session <name>` | Use isolated session |
97
+ | `session list` | List active sessions |
98
+
99
+ ## Selectors
100
+
101
+ ### Element Refs (Recommended)
102
+ ```bash
103
+ # Get refs from snapshot
104
+ agent-browser snapshot -i
105
+ # Output: button "Submit" [ref=e2]
106
+
107
+ # Use ref to interact
108
+ agent-browser click @e2
109
+ ```
110
+
111
+ ### CSS Selectors
112
+ ```bash
113
+ agent-browser click "#submit"
114
+ agent-browser fill ".email-input" "test@test.com"
115
+ ```
116
+
117
+ ### Semantic Locators
118
+ ```bash
119
+ agent-browser find role button click --name "Submit"
120
+ agent-browser find label "Email" fill "test@test.com"
121
+ agent-browser find testid "login-btn" click
122
+ ```
123
+
124
+ ## Examples
125
+
126
+ ### Login Flow
127
+ ```bash
128
+ agent-browser open https://example.com/login
129
+ agent-browser snapshot -i
130
+ agent-browser fill @e2 "user@example.com"
131
+ agent-browser fill @e3 "password123"
132
+ agent-browser click @e4
133
+ agent-browser wait --url "**/dashboard"
134
+ ```
135
+
136
+ ### Form Submission
137
+ ```bash
138
+ agent-browser open https://example.com/contact
139
+ agent-browser snapshot -i
140
+ agent-browser fill @e1 "John Doe"
141
+ agent-browser fill @e2 "john@example.com"
142
+ agent-browser fill @e3 "Hello, this is my message"
143
+ agent-browser click @e4
144
+ agent-browser wait --text "Thank you"
145
+ ```
146
+
147
+ ### Data Extraction
148
+ ```bash
149
+ agent-browser open https://example.com/products
150
+ agent-browser snapshot -i
151
+ # Iterate through product refs
152
+ agent-browser get text @e1 # Product name
153
+ agent-browser get text @e2 # Price
154
+ agent-browser get attr @e3 href # Link
155
+ ```
156
+
157
+ ### Multi-Session (Swarm)
158
+ ```bash
159
+ # Session 1: Navigator
160
+ agent-browser --session nav open https://example.com
161
+ agent-browser --session nav state save auth.json
162
+
163
+ # Session 2: Scraper (uses same auth)
164
+ agent-browser --session scrape state load auth.json
165
+ agent-browser --session scrape open https://example.com/data
166
+ agent-browser --session scrape snapshot -i
167
+ ```
168
+
169
+ ## Integration with Claude Flow
170
+
171
+ ### MCP Tools
172
+ All browser operations are available as MCP tools with `browser/` prefix:
173
+ - `browser/open`
174
+ - `browser/snapshot`
175
+ - `browser/click`
176
+ - `browser/fill`
177
+ - `browser/screenshot`
178
+ - etc.
179
+
180
+ ### Memory Integration
181
+ ```bash
182
+ # Store successful patterns
183
+ npx @claude-flow/cli memory store --namespace browser-patterns --key "login-flow" --value "snapshot->fill->click->wait"
184
+
185
+ # Retrieve before similar task
186
+ npx @claude-flow/cli memory search --query "login automation"
187
+ ```
188
+
189
+ ### Hooks
190
+ ```bash
191
+ # Pre-browse hook (get context)
192
+ npx @claude-flow/cli hooks pre-edit --file "browser-task.ts"
193
+
194
+ # Post-browse hook (record success)
195
+ npx @claude-flow/cli hooks post-task --task-id "browse-1" --success true
196
+ ```
197
+
198
+ ## Tips
199
+
200
+ 1. **Always use snapshots** - They're optimized for AI with refs
201
+ 2. **Prefer `-i` flag** - Gets only interactive elements, smaller output
202
+ 3. **Use refs, not selectors** - More reliable, deterministic
203
+ 4. **Re-snapshot after navigation** - Page state changes
204
+ 5. **Use sessions for parallel work** - Each session is isolated
package/README.md CHANGED
@@ -301,6 +301,18 @@ npx claude-flow@v3alpha --agent coder --task "Implement user authentication"
301
301
  npx claude-flow@v3alpha --list
302
302
  ```
303
303
 
304
+ ### Upgrading
305
+
306
+ ```bash
307
+ # Update helpers and statusline (preserves your data)
308
+ npx claude-flow@v3alpha init upgrade
309
+
310
+ # Update AND add any missing skills/agents/commands
311
+ npx claude-flow@v3alpha init upgrade --add-missing
312
+ ```
313
+
314
+ The `--add-missing` flag automatically detects and installs new skills, agents, and commands that were added in newer versions, without overwriting your existing customizations.
315
+
304
316
  ### Claude Code MCP Integration
305
317
 
306
318
  Add claude-flow as an MCP server for seamless integration:
@@ -4494,6 +4506,7 @@ Domain-Driven Design with bounded contexts, clean architecture, and measured per
4494
4506
  | `@claude-flow/testing` | Quality assurance | London School TDD, Vitest, fixtures, mocks |
4495
4507
  | `@claude-flow/deployment` | Release automation | Versioning, changelogs, NPM publishing |
4496
4508
  | `@claude-flow/shared` | Common utilities | Types, validation schemas, constants |
4509
+ | `@claude-flow/browser` | Browser automation | 59 MCP tools, element refs, trajectory learning |
4497
4510
 
4498
4511
  ### Architecture Principles
4499
4512
 
@@ -4533,6 +4546,93 @@ Domain-Driven Design with bounded contexts, clean architecture, and measured per
4533
4546
 
4534
4547
  ---
4535
4548
 
4549
+ <details>
4550
+ <summary><strong>🌐 Browser Automation — @claude-flow/browser</strong></summary>
4551
+
4552
+ [![npm version](https://img.shields.io/npm/v/@claude-flow/browser?color=blue&label=npm)](https://www.npmjs.com/package/@claude-flow/browser)
4553
+
4554
+ AI-optimized browser automation integrating [agent-browser](https://github.com/AugmentCode/agent-browser) with claude-flow for intelligent web automation, trajectory learning, and multi-agent browser coordination.
4555
+
4556
+ ### Installation
4557
+
4558
+ ```bash
4559
+ npm install @claude-flow/browser
4560
+
4561
+ # agent-browser CLI (auto-suggested on install, or install manually)
4562
+ npm install -g agent-browser@latest
4563
+ ```
4564
+
4565
+ ### Quick Start
4566
+
4567
+ ```typescript
4568
+ import { createBrowserService } from '@claude-flow/browser';
4569
+
4570
+ const browser = createBrowserService({
4571
+ sessionId: 'my-session',
4572
+ enableSecurity: true, // URL/PII scanning
4573
+ enableMemory: true, // Trajectory learning
4574
+ });
4575
+
4576
+ // Track actions for ReasoningBank/SONA learning
4577
+ browser.startTrajectory('Login to dashboard');
4578
+
4579
+ await browser.open('https://example.com/login');
4580
+
4581
+ // Use element refs (93% context reduction vs CSS selectors)
4582
+ const snapshot = await browser.snapshot({ interactive: true });
4583
+ await browser.fill('@e1', 'user@example.com');
4584
+ await browser.fill('@e2', 'password');
4585
+ await browser.click('@e3');
4586
+
4587
+ await browser.endTrajectory(true, 'Login successful');
4588
+ await browser.close();
4589
+ ```
4590
+
4591
+ ### Key Features
4592
+
4593
+ | Feature | Description |
4594
+ |---------|-------------|
4595
+ | **59 MCP Tools** | Complete browser automation via MCP protocol |
4596
+ | **Element Refs** | 93% context reduction with `@e1`, `@e2` refs |
4597
+ | **Trajectory Learning** | Records actions for ReasoningBank/SONA |
4598
+ | **Security Scanning** | URL validation, PII detection, XSS/SQL injection prevention |
4599
+ | **9 Workflow Templates** | Login, OAuth, scraping, testing, monitoring |
4600
+ | **Swarm Coordination** | Multi-session parallel browser automation |
4601
+
4602
+ ### Security Integration
4603
+
4604
+ ```typescript
4605
+ import { getSecurityScanner, isUrlSafe, containsPII } from '@claude-flow/browser';
4606
+
4607
+ // URL threat detection
4608
+ const scanner = getSecurityScanner({ requireHttps: true });
4609
+ const result = await scanner.scanUrl('https://example.com');
4610
+ // { safe: true, threats: [], score: 1.0 }
4611
+
4612
+ // PII detection
4613
+ containsPII('SSN: 123-45-6789'); // true
4614
+
4615
+ // Input validation (XSS, SQL injection)
4616
+ scanner.validateInput('<script>alert(1)</script>', 'comment');
4617
+ // { safe: false, threats: [{type: 'xss', ...}] }
4618
+ ```
4619
+
4620
+ ### Workflow Templates
4621
+
4622
+ ```typescript
4623
+ import { listWorkflows, getWorkflow } from '@claude-flow/browser';
4624
+
4625
+ listWorkflows(); // ['login-basic', 'login-oauth', 'scrape-table', ...]
4626
+ const template = getWorkflow('login-basic');
4627
+ // { steps: [{action: 'open'}, {action: 'fill'}, ...], variables: [...] }
4628
+ ```
4629
+
4630
+ 📖 [Full Documentation](./v3/@claude-flow/browser/README.md)
4631
+
4632
+ </details>
4633
+
4634
+ ---
4635
+
4536
4636
  <details>
4537
4637
  <summary><h2>📦 Release Management — @claude-flow/deployment</h2></summary>
4538
4638
 
@@ -5784,6 +5884,7 @@ cp -r ./data-backup-v2 ./data
5784
5884
  | `@claude-flow/performance` | Benchmarking & optimization | [Source](./v3/@claude-flow/performance/) |
5785
5885
  | `@claude-flow/deployment` | Release & CI/CD | [Source](./v3/@claude-flow/deployment/) |
5786
5886
  | `@claude-flow/shared` | Shared utilities, types & V3ProgressService | [Source](./v3/@claude-flow/shared/) |
5887
+ | `@claude-flow/browser` | AI-optimized browser automation with agent-browser | [README](./v3/@claude-flow/browser/README.md) |
5787
5888
 
5788
5889
  ### Additional Resources
5789
5890
 
@@ -1 +1 @@
1
- {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,aAAa,CAAC;AAwuB1E,eAAO,MAAM,WAAW,EAAE,OAiFzB,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAiC,MAAM,aAAa,CAAC;AA4xB1E,eAAO,MAAM,WAAW,EAAE,OAiFzB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -6,7 +6,7 @@ import { output } from '../output.js';
6
6
  import { confirm, select, multiSelect, input } from '../prompt.js';
7
7
  import * as fs from 'fs';
8
8
  import * as path from 'path';
9
- import { executeInit, executeUpgrade, DEFAULT_INIT_OPTIONS, MINIMAL_INIT_OPTIONS, FULL_INIT_OPTIONS, } from '../init/index.js';
9
+ import { executeInit, executeUpgrade, executeUpgradeWithMissing, DEFAULT_INIT_OPTIONS, MINIMAL_INIT_OPTIONS, FULL_INIT_OPTIONS, } from '../init/index.js';
10
10
  // Check if project is already initialized
11
11
  function isInitialized(cwd) {
12
12
  const claudePath = path.join(cwd, '.claude', 'settings.json');
@@ -517,6 +517,7 @@ const skillsCommand = {
517
517
  agentdb: ctx.flags.agentdb,
518
518
  github: ctx.flags.github,
519
519
  flowNexus: false,
520
+ browser: false,
520
521
  v3: ctx.flags.v3,
521
522
  },
522
523
  };
@@ -600,16 +601,31 @@ const upgradeCommand = {
600
601
  type: 'boolean',
601
602
  default: false,
602
603
  },
604
+ {
605
+ name: 'add-missing',
606
+ short: 'a',
607
+ description: 'Add any new skills, agents, and commands that are missing',
608
+ type: 'boolean',
609
+ default: false,
610
+ },
603
611
  ],
604
612
  action: async (ctx) => {
613
+ const addMissing = ctx.flags['add-missing'];
605
614
  output.writeln();
606
615
  output.writeln(output.bold('Upgrading Claude Flow'));
607
- output.writeln(output.dim('Updates helpers while preserving your existing data'));
616
+ if (addMissing) {
617
+ output.writeln(output.dim('Updates helpers and adds any missing skills/agents/commands'));
618
+ }
619
+ else {
620
+ output.writeln(output.dim('Updates helpers while preserving your existing data'));
621
+ }
608
622
  output.writeln();
609
- const spinner = output.createSpinner({ text: 'Upgrading...' });
623
+ const spinner = output.createSpinner({ text: addMissing ? 'Upgrading and adding missing assets...' : 'Upgrading...' });
610
624
  spinner.start();
611
625
  try {
612
- const result = await executeUpgrade(ctx.cwd);
626
+ const result = addMissing
627
+ ? await executeUpgradeWithMissing(ctx.cwd)
628
+ : await executeUpgrade(ctx.cwd);
613
629
  if (!result.success) {
614
630
  spinner.fail('Upgrade failed');
615
631
  for (const error of result.errors) {
@@ -638,8 +654,31 @@ const upgradeCommand = {
638
654
  output.printInfo(`Preserved ${result.preserved.length} existing data files`);
639
655
  output.writeln();
640
656
  }
657
+ // Show added assets (when --add-missing flag is used)
658
+ if (result.addedSkills && result.addedSkills.length > 0) {
659
+ output.printBox(result.addedSkills.map(s => `+ ${s}`).join('\n'), `Added Skills (${result.addedSkills.length} new)`);
660
+ output.writeln();
661
+ }
662
+ if (result.addedAgents && result.addedAgents.length > 0) {
663
+ output.printBox(result.addedAgents.map(a => `+ ${a}`).join('\n'), `Added Agents (${result.addedAgents.length} new)`);
664
+ output.writeln();
665
+ }
666
+ if (result.addedCommands && result.addedCommands.length > 0) {
667
+ output.printBox(result.addedCommands.map(c => `+ ${c}`).join('\n'), `Added Commands (${result.addedCommands.length} new)`);
668
+ output.writeln();
669
+ }
641
670
  output.printSuccess('Your statusline helper has been updated to the latest version');
642
671
  output.printInfo('Existing metrics and learning data were preserved');
672
+ // Show summary for --add-missing
673
+ if (addMissing) {
674
+ const totalAdded = (result.addedSkills?.length || 0) + (result.addedAgents?.length || 0) + (result.addedCommands?.length || 0);
675
+ if (totalAdded > 0) {
676
+ output.printSuccess(`Added ${totalAdded} missing assets to your project`);
677
+ }
678
+ else {
679
+ output.printInfo('All skills, agents, and commands are already up to date');
680
+ }
681
+ }
643
682
  if (ctx.flags.format === 'json') {
644
683
  output.printJson(result);
645
684
  }