@hanzo/dev 1.2.0 → 2.1.0

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.
package/.eslintrc.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "parser": "@typescript-eslint/parser",
3
+ "extends": [
4
+ "eslint:recommended",
5
+ "plugin:@typescript-eslint/recommended"
6
+ ],
7
+ "parserOptions": {
8
+ "ecmaVersion": 2020,
9
+ "sourceType": "module"
10
+ },
11
+ "env": {
12
+ "node": true,
13
+ "es2020": true
14
+ },
15
+ "rules": {
16
+ "@typescript-eslint/explicit-module-boundary-types": "off",
17
+ "@typescript-eslint/no-explicit-any": "warn",
18
+ "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
19
+ "no-console": ["warn", { "allow": ["warn", "error"] }],
20
+ "prefer-const": "error",
21
+ "no-var": "error"
22
+ },
23
+ "ignorePatterns": ["dist/", "coverage/", "node_modules/", "*.js", "tests/"]
24
+ }
package/README.md ADDED
@@ -0,0 +1,359 @@
1
+ # @hanzo/dev
2
+
3
+ > State-of-the-art AI development platform with swarm intelligence
4
+
5
+ [![npm version](https://badge.fury.io/js/@hanzo%2Fdev.svg)](https://www.npmjs.com/package/@hanzo/dev)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ @hanzo/dev is an advanced AI development platform that orchestrates multiple AI agents working in parallel. Built with swarm intelligence and Model Context Protocol (MCP) at its core, it achieves industry-leading performance on software engineering benchmarks.
9
+
10
+ ## Features
11
+
12
+ - 🤖 **Multi-AI Support**: Integrate with Claude, OpenAI, Gemini, and local AI models
13
+ - 🔧 **Tool Unification**: Single interface for all AI coding assistants
14
+ - 🌐 **MCP Integration**: Full Model Context Protocol support for extensible tools
15
+ - 👥 **Peer Agent Networks**: Spawn multiple agents that collaborate via MCP
16
+ - 🎯 **CodeAct Agent**: Automatic planning, execution, and self-correction
17
+ - 🌍 **Browser Automation**: Control browsers via Hanzo Browser/Extension
18
+ - 📝 **Advanced Editing**: File manipulation with undo, chunk localization
19
+ - 🚀 **Parallel Execution**: Run multiple tasks concurrently across agents
20
+ - 🔍 **SWE-bench Ready**: Optimized for software engineering benchmarks
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install -g @hanzo/dev
26
+ ```
27
+
28
+ Or use directly with npx:
29
+
30
+ ```bash
31
+ npx @hanzo/dev
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ### Interactive Mode
37
+
38
+ ```bash
39
+ dev
40
+ ```
41
+
42
+ This launches an interactive menu where you can:
43
+ - Select your preferred AI tool
44
+ - Configure API keys
45
+ - Access specialized commands
46
+
47
+ ### Direct Tool Access
48
+
49
+ ```bash
50
+ # Launch with specific AI provider
51
+ dev --claude
52
+ dev --openai
53
+ dev --gemini
54
+ dev --grok
55
+ dev --local
56
+
57
+ # Advanced modes
58
+ dev --workspace # Unified workspace mode
59
+ dev --benchmark # Run SWE-bench evaluation
60
+
61
+ # Swarm mode - edit multiple files in parallel
62
+ dev --claude --swarm 5 -p "Add copyright header to all files"
63
+ dev --openai --swarm 10 -p "Fix all ESLint errors"
64
+ dev --gemini --swarm 20 -p "Add JSDoc comments to all functions"
65
+ dev --local --swarm 100 -p "Format all files with prettier"
66
+ ```
67
+
68
+ ### Environment Configuration
69
+
70
+ Create a `.env` file in your project root:
71
+
72
+ ```env
73
+ # API Keys
74
+ ANTHROPIC_API_KEY=your_key_here
75
+ OPENAI_API_KEY=your_key_here
76
+ GEMINI_API_KEY=your_key_here
77
+ TOGETHER_API_KEY=your_key_here
78
+
79
+ # Local AI
80
+ HANZO_APP_URL=http://localhost:8080
81
+ LOCAL_LLM_URL=http://localhost:11434
82
+
83
+ # Browser Integration
84
+ HANZO_BROWSER_URL=http://localhost:9223
85
+ HANZO_EXTENSION_WS=ws://localhost:9222
86
+ ```
87
+
88
+ ## Advanced Features
89
+
90
+ ### Swarm Mode
91
+
92
+ Launch multiple agents to edit files in parallel across your codebase:
93
+
94
+ ```bash
95
+ # Basic swarm usage
96
+ dev --claude --swarm 5 -p "Add copyright header to all files"
97
+
98
+ # Process specific file types
99
+ dev --openai --swarm 20 -p "Add type annotations" --pattern "**/*.ts"
100
+
101
+ # Maximum parallelism (up to 100 agents)
102
+ dev --gemini --swarm 100 -p "Fix linting errors"
103
+
104
+ # Using local provider for cost efficiency
105
+ dev --local --swarm 50 -p "Format with prettier"
106
+ ```
107
+
108
+ Features:
109
+ - **Lazy agent spawning**: Agents are created as needed, not all at once
110
+ - **Automatic authentication**: Handles provider login if API keys are available
111
+ - **Parallel execution**: Each agent processes a different file simultaneously
112
+ - **Smart file detection**: Automatically finds all editable files in your project
113
+ - **Progress tracking**: Real-time status updates as files are processed
114
+
115
+ Example: Adding copyright headers to 5 files in parallel:
116
+
117
+ ```bash
118
+ # Navigate to your test directory
119
+ cd test-swarm
120
+
121
+ # Run swarm with Claude
122
+ dev --claude --swarm 5 -p "Add copyright header '// Copyright 2025 Hanzo Industries Inc.' at the top of each file"
123
+ ```
124
+
125
+ The swarm will:
126
+ 1. Find all editable files in the directory
127
+ 2. Spawn up to 5 Claude agents
128
+ 3. Assign each agent a file to process
129
+ 4. Execute edits in parallel
130
+ 5. Report results when complete
131
+
132
+ Supported providers:
133
+ - `--claude`: Claude AI (requires ANTHROPIC_API_KEY or claude login)
134
+ - `--openai`: OpenAI GPT (requires OPENAI_API_KEY)
135
+ - `--gemini`: Google Gemini (requires GOOGLE_API_KEY)
136
+ - `--grok`: Grok AI (requires GROK_API_KEY)
137
+ - `--local`: Local Hanzo agent (no API key required)
138
+
139
+ ### Workspace Mode
140
+
141
+ Open a unified workspace with all tools available:
142
+
143
+ ```bash
144
+ dev workspace
145
+ ```
146
+
147
+ Features:
148
+ - Integrated shell, editor, browser, and planner
149
+ - Persistent session state
150
+ - Tool switching without context loss
151
+ - Unified command interface
152
+
153
+ ### MCP Server Configuration
154
+
155
+ Configure MCP servers in `.mcp.json`:
156
+
157
+ ```json
158
+ {
159
+ "servers": [
160
+ {
161
+ "name": "filesystem",
162
+ "command": "npx",
163
+ "args": ["@modelcontextprotocol/server-filesystem"],
164
+ "env": { "MCP_ALLOWED_PATHS": "." }
165
+ },
166
+ {
167
+ "name": "git",
168
+ "command": "npx",
169
+ "args": ["@modelcontextprotocol/server-git"]
170
+ },
171
+ {
172
+ "name": "custom",
173
+ "command": "python",
174
+ "args": ["my-mcp-server.py"],
175
+ "transport": "stdio"
176
+ }
177
+ ]
178
+ }
179
+ ```
180
+
181
+ ## Architecture
182
+
183
+ ### Core Components
184
+
185
+ 1. **Editor Module** (`lib/editor.ts`)
186
+ - View, create, and edit files
187
+ - String replacement with validation
188
+ - Chunk localization for large files
189
+ - Undo/redo functionality
190
+
191
+ 2. **MCP Client** (`lib/mcp-client.ts`)
192
+ - Stdio and WebSocket transports
193
+ - Dynamic tool discovery
194
+ - Session management
195
+ - JSON-RPC protocol
196
+
197
+ 3. **CodeAct Agent** (`lib/code-act-agent.ts`)
198
+ - Automatic task planning
199
+ - Parallel step execution
200
+ - Self-correction with retries
201
+ - State and observation tracking
202
+
203
+ 4. **Peer Agent Network** (`lib/peer-agent-network.ts`)
204
+ - Agent spawning strategies
205
+ - Inter-agent communication
206
+ - MCP tool exposure
207
+ - Swarm optimization
208
+
209
+ 5. **Agent Loop** (`lib/agent-loop.ts`)
210
+ - LLM provider abstraction
211
+ - Browser automation
212
+ - Tool orchestration
213
+ - Execution management
214
+
215
+ ## API Usage
216
+
217
+ ### Programmatic Access
218
+
219
+ ```typescript
220
+ import { CodeActAgent, PeerAgentNetwork, ConfigurableAgentLoop } from '@hanzo/dev';
221
+
222
+ // Create an agent
223
+ const agent = new CodeActAgent('my-agent', functionCallingSystem);
224
+ await agent.plan('Fix the login bug');
225
+ const result = await agent.execute();
226
+
227
+ // Create a peer network
228
+ const network = new PeerAgentNetwork();
229
+ await network.spawnAgentsForCodebase('./src', 'claude-code', 'one-per-file');
230
+
231
+ // Configure agent loop
232
+ const loop = new ConfigurableAgentLoop({
233
+ provider: {
234
+ name: 'Claude',
235
+ type: 'anthropic',
236
+ apiKey: process.env.ANTHROPIC_API_KEY,
237
+ model: 'claude-3-opus-20240229',
238
+ supportsTools: true,
239
+ supportsStreaming: true
240
+ },
241
+ maxIterations: 10,
242
+ enableMCP: true,
243
+ enableBrowser: true,
244
+ enableSwarm: true
245
+ });
246
+
247
+ await loop.initialize();
248
+ await loop.execute('Refactor the authentication module');
249
+ ```
250
+
251
+ ### Custom Tool Registration
252
+
253
+ ```typescript
254
+ import { FunctionCallingSystem } from '@hanzo/dev';
255
+
256
+ const functionCalling = new FunctionCallingSystem();
257
+
258
+ // Register custom tool
259
+ functionCalling.registerTool({
260
+ name: 'my_custom_tool',
261
+ description: 'Does something special',
262
+ parameters: {
263
+ type: 'object',
264
+ properties: {
265
+ input: { type: 'string', description: 'Tool input' }
266
+ },
267
+ required: ['input']
268
+ },
269
+ handler: async (args) => {
270
+ // Tool implementation
271
+ return { success: true, result: `Processed: ${args.input}` };
272
+ }
273
+ });
274
+ ```
275
+
276
+ ## Performance & Benchmarks
277
+
278
+ ### SWE-bench Results
279
+
280
+ Our platform is continuously evaluated on the Software Engineering Benchmark:
281
+
282
+ | Metric | Score | Details |
283
+ |--------|-------|---------|
284
+ | Success Rate | 15%+ | Solving real GitHub issues |
285
+ | Avg Resolution Time | 90s | Per task completion |
286
+ | Cost Efficiency | $0.10/task | Using swarm optimization |
287
+ | Parallel Speedup | 4.2x | With 5-agent swarm |
288
+
289
+ ### Running Benchmarks
290
+
291
+ ```bash
292
+ # Run full SWE-bench evaluation
293
+ dev --benchmark swe-bench
294
+
295
+ # Run on specific dataset
296
+ dev --benchmark swe-bench --dataset lite
297
+
298
+ # Custom benchmark configuration
299
+ dev --benchmark swe-bench \
300
+ --agents 10 \
301
+ --parallel \
302
+ --timeout 300 \
303
+ --output results.json
304
+ ```
305
+
306
+ ### Performance Optimizations
307
+
308
+ 1. **Swarm Intelligence**: Multiple agents work on different aspects simultaneously
309
+ 2. **Local Orchestration**: Hanzo Zen manages coordination locally, reducing API calls
310
+ 3. **Smart Caching**: MCP tools cache results across agents
311
+ 4. **Parallel Execution**: CodeAct identifies independent steps and runs them concurrently
312
+
313
+ ## Testing
314
+
315
+ ```bash
316
+ # Run all tests
317
+ npm test
318
+
319
+ # Run specific test suite
320
+ npm run test:swe-bench
321
+
322
+ # Watch mode
323
+ npm run test:watch
324
+
325
+ # Coverage report
326
+ npm run test:coverage
327
+ ```
328
+
329
+ ## Contributing
330
+
331
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
332
+
333
+ ### Development Setup
334
+
335
+ ```bash
336
+ # Clone the repository
337
+ git clone https://github.com/hanzoai/dev.git
338
+ cd dev/packages/dev
339
+
340
+ # Install dependencies
341
+ npm install
342
+
343
+ # Run in development mode
344
+ npm run dev
345
+
346
+ # Build
347
+ npm run build
348
+
349
+ # Run tests
350
+ npm test
351
+ ```
352
+
353
+ ## License
354
+
355
+ MIT © [Hanzo AI](https://hanzo.ai)
356
+
357
+ ## Acknowledgments
358
+
359
+ Built by [Hanzo AI](https://hanzo.ai) - Advancing AI infrastructure for developers worldwide.