moflo 4.8.11 → 4.8.12

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,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
@@ -0,0 +1,9 @@
1
+ {
2
+ "tasksCreated": true,
3
+ "taskCount": 2,
4
+ "memorySearched": false,
5
+ "sessionStart": "2026-03-22T21:38:40.085Z",
6
+ "memoryRequired": true,
7
+ "interactionCount": 9,
8
+ "lastBlockedAt": "2026-03-22T21:51:54.015Z"
9
+ }
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  /**
3
3
  * Index guidance files into claude-flow memory with full RAG linked segments
4
4
  *
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  /**
3
3
  * Index test files into claude-flow memory under the `tests` namespace
4
4
  *
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  /**
3
3
  * Semantic search using 384-dim embeddings (Xenova/all-MiniLM-L6-v2 or hash fallback)
4
4
  *
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  /**
3
3
  * MoFlo Project Setup
4
4
  *
@@ -29,67 +29,57 @@ const args = process.argv.slice(2);
29
29
  const updateOnly = args.includes('--update');
30
30
  const checkOnly = args.includes('--check');
31
31
 
32
- // Markers for idempotent CLAUDE.md updates
33
- const MARKER_START = '<!-- MOFLO:SUBAGENT-PROTOCOL:START -->';
34
- const MARKER_END = '<!-- MOFLO:SUBAGENT-PROTOCOL:END -->';
32
+ // Markers for idempotent CLAUDE.md updates — keep in sync with claudemd-generator.ts
33
+ const MARKER_START = '<!-- MOFLO:INJECTED:START -->';
34
+ const MARKER_END = '<!-- MOFLO:INJECTED:END -->';
35
+ // Legacy markers to detect and replace
36
+ const LEGACY_STARTS = ['<!-- MOFLO:SUBAGENT-PROTOCOL:START -->', '<!-- MOFLO:START -->'];
37
+ const LEGACY_ENDS = ['<!-- MOFLO:SUBAGENT-PROTOCOL:END -->', '<!-- MOFLO:END -->'];
35
38
 
39
+ // Minimal injection — just enough for Claude to work with moflo.
40
+ // All detailed docs live in .claude/guidance/shipped/moflo.md.
36
41
  const CLAUDE_MD_SECTION = `${MARKER_START}
37
- ## FIRST ACTION ON EVERY PROMPT: Search Memory
42
+ ## MoFlo AI Agent Orchestration
38
43
 
39
- Your first tool call for every new user prompt MUST be a memory search. Do this BEFORE Glob, Grep, Read, or any file exploration. No exceptions.
44
+ This project uses [MoFlo](https://github.com/eric-cielo/moflo) for AI-assisted development workflows.
40
45
 
41
- WHY: Memory contains curated solutions, patterns, and architectural context from previous work. Without it, you will miss existing solutions, repeat mistakes that were already solved, and waste time re-discovering what is already known. Memory search is faster than file scanning.
46
+ ### FIRST ACTION ON EVERY PROMPT: Search Memory
42
47
 
43
- HOW: Use ToolSearch to load \`mcp__moflo__memory_search\`, then call it with a query describing your task. If MCP is unavailable, use:
44
- \`node bin/semantic-search.mjs "[task description]" --namespace guidance\`
48
+ Your first tool call for every new user prompt MUST be a memory search. Do this BEFORE Glob, Grep, Read, or any file exploration.
45
49
 
46
- ### Namespaces to search:
50
+ \`\`\`
51
+ mcp__moflo__memory_search — query: "<task description>", namespace: "guidance" or "patterns" or "code-map"
52
+ \`\`\`
47
53
 
48
- | Namespace | When to search | What it returns |
49
- |-----------|---------------|-----------------|
50
- | \`guidance\` | Always — understanding patterns, rules, conventions | Guidance docs, coding rules, domain context |
51
- | \`patterns\` | Always — prior solutions and implementation patterns | Learned patterns from previous task execution |
52
- | \`code-map\` | Finding where code lives (files, types, services) | Type-to-file mappings, directory contents, project overviews |
54
+ Search \`guidance\` and \`patterns\` namespaces on every prompt. Search \`code-map\` when navigating the codebase.
55
+ When the user asks you to remember something: \`mcp__moflo__memory_store\` with namespace \`knowledge\`.
53
56
 
54
- **Always search both \`guidance\` and \`patterns\` namespaces.** The \`patterns\` namespace contains solutions to problems already solved — skipping it means repeating past mistakes.
57
+ ### Workflow Gates (enforced automatically)
55
58
 
56
- For **codebase navigation** (finding where a type/service/component lives), also search the \`code-map\` namespace.
59
+ - **Memory-first**: Must search memory before Glob/Grep/Read
60
+ - **TaskCreate-first**: Must call TaskCreate before spawning Agent tool
57
61
 
58
- ## Memory System Access (MoFlo)
62
+ ### MCP Tools (preferred over CLI)
59
63
 
60
- ### Primary: MCP Tools (preferred)
61
- \`\`\`
62
- mcp__moflo__memory_search query, namespace
63
- mcp__moflo__memory_store key, value, namespace
64
- mcp__moflo__memory_retrieve key, namespace
65
- mcp__moflo__memory_list — namespace, limit
66
- \`\`\`
67
- Load via ToolSearch first: \`+claude-flow memory\`
64
+ | Tool | Purpose |
65
+ |------|---------|
66
+ | \`mcp__moflo__memory_search\` | Semantic search across indexed knowledge |
67
+ | \`mcp__moflo__memory_store\` | Store patterns and decisions |
68
+ | \`mcp__moflo__hooks_route\` | Route task to optimal agent type |
69
+ | \`mcp__moflo__hooks_pre-task\` | Record task start |
70
+ | \`mcp__moflo__hooks_post-task\` | Record task completion for learning |
71
+
72
+ ### CLI Fallback
68
73
 
69
- ### Fallback: CLI Scripts
70
74
  \`\`\`bash
71
75
  npx flo-search "[query]" --namespace guidance # Semantic search
72
- npx flo-embeddings # Rebuild embeddings
73
- npx flo-index # Re-index guidance docs
74
- npx flo-codemap --force # Regenerate code-map
76
+ npx flo doctor --fix # Health check
75
77
  \`\`\`
76
78
 
77
- ### Where Content Goes
78
-
79
- | Content Type | Destination | How to Write |
80
- |-------------|-------------|--------------|
81
- | Debugging lessons (bug found, root cause, fix) | Memory DB — \`patterns\` namespace | \`mcp__moflo__memory_store\` |
82
- | Architectural decisions (chose X over Y, why) | Memory DB — \`decisions\` namespace | \`mcp__moflo__memory_store\` |
83
- | Learned patterns (task succeeded/failed, what worked) | Memory DB — \`patterns\` namespace | \`mcp__moflo__memory_store\` |
84
- | Coding rules (always/never do X in code) | \`.claude/guidance/\` files | Edit directly |
85
- | Process/workflow rules (CI, PR, gates) | \`CLAUDE.md\` | Edit directly |
86
-
87
- ## Subagent Protocol (MoFlo)
79
+ ### Full Reference
88
80
 
89
- All subagents MUST read \`.claude/guidance/moflo-bootstrap.md\` before starting any work.
90
- It contains the memory-first protocol, discovery storage rules, and universal conventions.
91
-
92
- If \`.claude/guidance/agent-bootstrap.md\` also exists, read it next for project-specific rules.
81
+ For CLI commands, hooks, agents, swarm config, memory commands, and moflo.yaml options, see:
82
+ \`.claude/guidance/shipped/moflo.md\`
93
83
  ${MARKER_END}`;
94
84
 
95
85
  function log(msg) {
@@ -180,28 +170,35 @@ function updateClaudeMd(projectRoot) {
180
170
 
181
171
  const content = readFileSync(claudeMdPath, 'utf-8');
182
172
 
183
- // Check if markers already exist
184
- if (content.includes(MARKER_START)) {
185
- // Extract existing section and compare
186
- const startIdx = content.indexOf(MARKER_START);
187
- const endIdx = content.indexOf(MARKER_END);
173
+ // Check for current or legacy markers and replace
174
+ const allStarts = [MARKER_START, ...LEGACY_STARTS];
175
+ const allEnds = [MARKER_END, ...LEGACY_ENDS];
176
+
177
+ for (let i = 0; i < allStarts.length; i++) {
178
+ if (content.includes(allStarts[i])) {
179
+ const startIdx = content.indexOf(allStarts[i]);
180
+ const endIdx = content.indexOf(allEnds[i]);
181
+
182
+ if (endIdx > startIdx) {
183
+ // If current markers and content matches, we're up to date
184
+ if (i === 0) {
185
+ const existingSection = content.substring(startIdx, endIdx + allEnds[i].length);
186
+ if (existingSection === CLAUDE_MD_SECTION) {
187
+ log('✅ CLAUDE.md moflo section is current');
188
+ return true;
189
+ }
190
+ }
188
191
 
189
- if (endIdx > startIdx) {
190
- const existingSection = content.substring(startIdx, endIdx + MARKER_END.length);
191
- if (existingSection === CLAUDE_MD_SECTION) {
192
- log('✅ CLAUDE.md subagent section is current');
192
+ // Replace (current or legacy) with new section
193
+ if (!checkOnly) {
194
+ const updated = content.substring(0, startIdx) + CLAUDE_MD_SECTION + content.substring(endIdx + allEnds[i].length);
195
+ writeFileSync(claudeMdPath, updated, 'utf-8');
196
+ log(i === 0 ? '📝 Updated CLAUDE.md moflo section' : '📝 Replaced legacy CLAUDE.md section with minimal moflo injection');
197
+ } else {
198
+ log('⚠️ CLAUDE.md moflo section needs update');
199
+ }
193
200
  return true;
194
201
  }
195
-
196
- // Update existing section
197
- if (!checkOnly) {
198
- const updated = content.substring(0, startIdx) + CLAUDE_MD_SECTION + content.substring(endIdx + MARKER_END.length);
199
- writeFileSync(claudeMdPath, updated, 'utf-8');
200
- log('📝 Updated CLAUDE.md subagent protocol section');
201
- } else {
202
- log('⚠️ CLAUDE.md subagent section needs update');
203
- }
204
- return true;
205
202
  }
206
203
  }
207
204
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "moflo",
3
- "version": "4.8.11",
3
+ "version": "4.8.12",
4
4
  "description": "MoFlo — AI agent orchestration for Claude Code. Forked from ruflo/claude-flow with patches applied to source, plus feature-level orchestration.",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -85,7 +85,7 @@
85
85
  "@types/bcrypt": "^5.0.2",
86
86
  "@types/node": "^20.19.37",
87
87
  "eslint": "^8.0.0",
88
- "moflo": "^4.8.9",
88
+ "moflo": "^4.8.11",
89
89
  "tsx": "^4.21.0",
90
90
  "typescript": "^5.9.3",
91
91
  "vitest": "^4.0.0"
@@ -1,25 +1,30 @@
1
- /**
2
- * CLAUDE.md Generator
3
- * Generates enforceable, analyzer-optimized Claude Code configuration
4
- * with template variants for different usage patterns.
5
- *
6
- * Templates: minimal | standard | full | security | performance | solo
7
- * All templates use bullet-format rules with imperative keywords for enforceability.
8
- */
9
- import type { InitOptions, ClaudeMdTemplate } from './types.js';
10
- /**
11
- * Generate CLAUDE.md content based on init options and template.
12
- * Template is determined by: options.runtime.claudeMdTemplate > explicit param > 'standard'
13
- */
14
- export declare function generateClaudeMd(options: InitOptions, template?: ClaudeMdTemplate): string;
15
- /**
16
- * Generate minimal CLAUDE.md content (backward-compatible alias).
17
- */
18
- export declare function generateMinimalClaudeMd(options: InitOptions): string;
19
- /** Available template names for CLI wizard */
20
- export declare const CLAUDE_MD_TEMPLATES: Array<{
21
- name: ClaudeMdTemplate;
22
- description: string;
23
- }>;
24
- export default generateClaudeMd;
1
+ /**
2
+ * CLAUDE.md Generator
3
+ *
4
+ * Generates ONLY the MoFlo section to inject into a project's CLAUDE.md.
5
+ * This must be minimal — just enough for Claude to work with moflo.
6
+ * All detailed docs live in .claude/guidance/shipped/moflo.md (copied at install).
7
+ *
8
+ * Principle: we are guests in the user's CLAUDE.md. Keep it small.
9
+ */
10
+ import type { InitOptions, ClaudeMdTemplate } from './types.js';
11
+ declare const MARKER_START = "<!-- MOFLO:INJECTED:START -->";
12
+ declare const MARKER_END = "<!-- MOFLO:INJECTED:END -->";
13
+ export { MARKER_START, MARKER_END };
14
+ /**
15
+ * Generate the MoFlo section to inject into CLAUDE.md.
16
+ * Template parameter is accepted for backward compatibility but ignored —
17
+ * all templates now produce the same minimal injection.
18
+ */
19
+ export declare function generateClaudeMd(_options: InitOptions, _template?: ClaudeMdTemplate): string;
20
+ /**
21
+ * Generate minimal CLAUDE.md content (backward-compatible alias).
22
+ */
23
+ export declare function generateMinimalClaudeMd(options: InitOptions): string;
24
+ /** Available template names for CLI wizard (kept for backward compat, all produce same output) */
25
+ export declare const CLAUDE_MD_TEMPLATES: Array<{
26
+ name: ClaudeMdTemplate;
27
+ description: string;
28
+ }>;
29
+ export default generateClaudeMd;
25
30
  //# sourceMappingURL=claudemd-generator.d.ts.map