hanuscode 1.0.0__py3-none-any.whl
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.
- hanus/__init__.py +5 -0
- hanus/__main__.py +10 -0
- hanus/action_handlers.py +76 -0
- hanus/action_parser.py +82 -0
- hanus/agent_runner.py +1445 -0
- hanus/analysis/__init__.py +5 -0
- hanus/analysis/debt.py +702 -0
- hanus/analysis/dependencies.py +475 -0
- hanus/cache/__init__.py +5 -0
- hanus/cache/response_cache.py +560 -0
- hanus/config.py +401 -0
- hanus/connectors/__init__.py +19 -0
- hanus/connectors/base.py +114 -0
- hanus/connectors/claude_connector.py +146 -0
- hanus/connectors/gemini_connector.py +141 -0
- hanus/connectors/glm_connector.py +160 -0
- hanus/connectors/ollama_connector.py +174 -0
- hanus/connectors/openai_connector.py +122 -0
- hanus/connectors/registry.py +26 -0
- hanus/context/__init__.py +7 -0
- hanus/context/manager.py +837 -0
- hanus/context/selective.py +626 -0
- hanus/error_recovery/__init__.py +5 -0
- hanus/error_recovery/auto_fix.py +605 -0
- hanus/hooks/__init__.py +5 -0
- hanus/hooks/manager.py +247 -0
- hanus/instincts/__init__.py +44 -0
- hanus/instincts/cli.py +372 -0
- hanus/instincts/detector.py +281 -0
- hanus/instincts/evolver.py +361 -0
- hanus/instincts/manager.py +343 -0
- hanus/instincts/types.py +253 -0
- hanus/logger.py +81 -0
- hanus/memory/__init__.py +8 -0
- hanus/memory/manager.py +265 -0
- hanus/memory/types.py +119 -0
- hanus/monitor.py +341 -0
- hanus/parallel/__init__.py +5 -0
- hanus/parallel/executor.py +300 -0
- hanus/permissions.py +182 -0
- hanus/plan/__init__.py +8 -0
- hanus/plan/mode.py +267 -0
- hanus/plan/models.py +152 -0
- hanus/plugin_manager.py +754 -0
- hanus/plugin_registry.py +391 -0
- hanus/plugins/__init__.py +1 -0
- hanus/plugins/arena.py +630 -0
- hanus/plugins/code_review.py +123 -0
- hanus/plugins/cortex.py +1750 -0
- hanus/plugins/deps_check.py +27 -0
- hanus/plugins/git_ops.py +33 -0
- hanus/plugins/metasploit.py +530 -0
- hanus/plugins/notes.py +583 -0
- hanus/plugins/search_code.py +59 -0
- hanus/plugins/searchsploit.py +495 -0
- hanus/plugins/strategist.py +175 -0
- hanus/plugins/webui.py +5200 -0
- hanus/profiles.py +479 -0
- hanus/profiles_builtin/__init__.py +0 -0
- hanus/profiles_builtin/architect/profile.yaml +12 -0
- hanus/profiles_builtin/architect/system_prompt.txt +71 -0
- hanus/profiles_builtin/deep/profile.yaml +12 -0
- hanus/profiles_builtin/deep/system_prompt.txt +66 -0
- hanus/profiles_builtin/developer/__init__.py +0 -0
- hanus/profiles_builtin/developer/profile.yaml +9 -0
- hanus/profiles_builtin/developer/system_prompt.txt +176 -0
- hanus/profiles_builtin/speed/profile.yaml +12 -0
- hanus/profiles_builtin/speed/system_prompt.txt +51 -0
- hanus/project_tools.py +177 -0
- hanus/query_engine.py +1594 -0
- hanus/rules/__init__.py +237 -0
- hanus/search/__init__.py +5 -0
- hanus/search/semantic.py +596 -0
- hanus/session_manager.py +547 -0
- hanus/skill_manager.py +702 -0
- hanus/skills/__init__.py +4 -0
- hanus/subagent/__init__.py +8 -0
- hanus/subagent/agents/__init__.py +253 -0
- hanus/subagent/manager.py +309 -0
- hanus/subagent/types.py +266 -0
- hanus/suggestions/__init__.py +5 -0
- hanus/suggestions/proactive.py +451 -0
- hanus/tasks/__init__.py +8 -0
- hanus/tasks/manager.py +330 -0
- hanus/tasks/models.py +106 -0
- hanus/terminal_prompt.py +166 -0
- hanus/tools.py +1849 -0
- hanus/ui.py +939 -0
- hanuscode-1.0.0.dist-info/METADATA +1151 -0
- hanuscode-1.0.0.dist-info/RECORD +93 -0
- hanuscode-1.0.0.dist-info/WHEEL +5 -0
- hanuscode-1.0.0.dist-info/entry_points.txt +2 -0
- hanuscode-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,1151 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hanuscode
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Agente de programación autónomo para la terminal — agnóstico de modelos IA
|
|
5
|
+
Author: CiTriX
|
|
6
|
+
Author-email: CiTriX <citrix@example.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Project-URL: Homepage, https://github.com/citrix/hanuscode
|
|
9
|
+
Project-URL: Documentation, https://github.com/citrix/hanuscode#readme
|
|
10
|
+
Project-URL: Repository, https://github.com/citrix/hanuscode
|
|
11
|
+
Project-URL: Issues, https://github.com/citrix/hanuscode/issues
|
|
12
|
+
Keywords: ai,agent,autonomous,coding,programming,llm,claude,openai,gemini,terminal,cli
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
24
|
+
Classifier: Topic :: Software Development
|
|
25
|
+
Classifier: Topic :: Software Development :: Code Generators
|
|
26
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
Requires-Dist: colorama>=0.4.6
|
|
30
|
+
Requires-Dist: requests>=2.28.0
|
|
31
|
+
Requires-Dist: pyyaml>=6.0
|
|
32
|
+
Provides-Extra: claude
|
|
33
|
+
Requires-Dist: anthropic>=0.25.0; extra == "claude"
|
|
34
|
+
Provides-Extra: openai
|
|
35
|
+
Requires-Dist: openai>=1.0.0; extra == "openai"
|
|
36
|
+
Provides-Extra: gemini
|
|
37
|
+
Requires-Dist: google-generativeai>=0.5.0; extra == "gemini"
|
|
38
|
+
Provides-Extra: all
|
|
39
|
+
Requires-Dist: anthropic>=0.25.0; extra == "all"
|
|
40
|
+
Requires-Dist: openai>=1.0.0; extra == "all"
|
|
41
|
+
Requires-Dist: google-generativeai>=0.5.0; extra == "all"
|
|
42
|
+
Requires-Dist: tiktoken>=0.5.0; extra == "all"
|
|
43
|
+
Dynamic: author
|
|
44
|
+
Dynamic: requires-python
|
|
45
|
+
|
|
46
|
+
<p align="center">
|
|
47
|
+
<img src="https://img.shields.io/badge/version-1.0.0-blue.svg" alt="Version">
|
|
48
|
+
<img src="https://img.shields.io/badge/python-3.9+-green.svg" alt="Python">
|
|
49
|
+
<img src="https://img.shields.io/badge/license-MIT-orange.svg" alt="License">
|
|
50
|
+
</p>
|
|
51
|
+
|
|
52
|
+
<h1 align="center">HANUS CODE</h1>
|
|
53
|
+
|
|
54
|
+
<p align="center">
|
|
55
|
+
<strong>Autonomous Programming Agent for Terminal and Web</strong><br>
|
|
56
|
+
<sub>AI Model Agnostic • Multi-provider • Extensible • SDK Included</sub>
|
|
57
|
+
</p>
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Table of Contents
|
|
62
|
+
|
|
63
|
+
- [Features](#features)
|
|
64
|
+
- [Installation](#installation)
|
|
65
|
+
- [Quick Start](#quick-start)
|
|
66
|
+
- [Terminal Usage](#terminal-usage)
|
|
67
|
+
- [Web Interface](#web-interface)
|
|
68
|
+
- [Project System](#project-system)
|
|
69
|
+
- [SDK for Custom Agents](#sdk-for-custom-agents)
|
|
70
|
+
- [Supported Providers](#supported-providers)
|
|
71
|
+
- [Profile System](#profile-system)
|
|
72
|
+
- [Commands](#commands)
|
|
73
|
+
- [Agent Tools](#agent-tools)
|
|
74
|
+
- [Plugins](#plugins)
|
|
75
|
+
- [Subagents](#subagents)
|
|
76
|
+
- [Skills](#skills)
|
|
77
|
+
- [Memory System](#memory-system)
|
|
78
|
+
- [Configuration](#configuration)
|
|
79
|
+
- [API Reference](#api-reference)
|
|
80
|
+
- [Project Structure](#project-structure)
|
|
81
|
+
- [Examples](#examples)
|
|
82
|
+
- [Roadmap](#roadmap)
|
|
83
|
+
- [License](#license)
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Features
|
|
88
|
+
|
|
89
|
+
- **Multi-provider** — Claude, OpenAI, Gemini, Ollama, GLM Cloud
|
|
90
|
+
- **Autonomous mode** — Completes tasks from start to finish without intervention
|
|
91
|
+
- **Web Interface** — Complete web panel with real-time chat, project management
|
|
92
|
+
- **Project system** — Create and manage projects with independent directories
|
|
93
|
+
- **Profile system** — Switch between roles: developer, architect, deep, speed
|
|
94
|
+
- **Subagents** — Delegate complex tasks to specialized agents
|
|
95
|
+
- **Persistent memory** — Remembers information between sessions
|
|
96
|
+
- **Real-time streaming** — Watch progress while working
|
|
97
|
+
- **Task system** — Automatic work tracking
|
|
98
|
+
- **Extensible plugins** — Add custom functionality
|
|
99
|
+
- **Complete SDK** — Create your own agents by importing modules
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Installation
|
|
104
|
+
|
|
105
|
+
### From PyPI
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install hanuscode
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### From Source
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
git clone https://github.com/hanuscode/hanuscode.git
|
|
115
|
+
cd hanuscode
|
|
116
|
+
pip install -e .
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Quick Start
|
|
122
|
+
|
|
123
|
+
### Terminal
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
cd my-project/
|
|
127
|
+
hanuscode
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Hanus analyzes the current directory and is ready to work.
|
|
131
|
+
|
|
132
|
+
### Web UI
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
hanuscode
|
|
136
|
+
> /webui start
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
Open http://localhost:8080 in your browser.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Terminal Usage
|
|
144
|
+
|
|
145
|
+
### Interactive Mode
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
cd my-project/
|
|
149
|
+
hanuscode
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Command Mode (Non-interactive)
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Execute a command and exit
|
|
156
|
+
hanuscode --cmd "Analyze the project and generate a README"
|
|
157
|
+
hanuscode -c "Create a POST /api/users endpoint with validation"
|
|
158
|
+
|
|
159
|
+
# Specify directory
|
|
160
|
+
hanuscode --path /path/to/project --cmd "Refactor the auth module"
|
|
161
|
+
|
|
162
|
+
# Combine with profile and model
|
|
163
|
+
hanuscode --profile architect --model ollama/llama3 -c "Design the API"
|
|
164
|
+
hanuscode --mode bypass -c "Run the tests" # No confirmations
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### CLI Arguments
|
|
168
|
+
|
|
169
|
+
| Argument | Description |
|
|
170
|
+
|----------|-------------|
|
|
171
|
+
| `--cmd`, `-c` | Command to execute (exits after completion) |
|
|
172
|
+
| `--path`, `-p` | Working directory (default: current directory) |
|
|
173
|
+
| `--profile` | Profile to use: developer, architect, deep, speed |
|
|
174
|
+
| `--model` | Model: provider/model (e.g., ollama/llama3, claude/claude-sonnet-4-6) |
|
|
175
|
+
| `--mode` | Permission mode: default, plan, bypass |
|
|
176
|
+
| `--version`, `-v` | Show version |
|
|
177
|
+
|
|
178
|
+
### Change settings within session
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
> /model ollama llama3 # Change provider/model
|
|
182
|
+
> /profile architect # Change to architect profile
|
|
183
|
+
> /mode bypass # Change permission mode
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Typical workflow
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
> Analyze the project structure
|
|
190
|
+
> The agent reads files, explores directories...
|
|
191
|
+
|
|
192
|
+
> Create a POST /api/users endpoint with validation
|
|
193
|
+
> The agent creates files, writes code, runs tests...
|
|
194
|
+
|
|
195
|
+
> Commit the changes
|
|
196
|
+
> The agent uses git for commit and push...
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Permission modes
|
|
200
|
+
|
|
201
|
+
- **default** — Asks for confirmation for risky actions
|
|
202
|
+
- **plan** — Only plans, doesn't execute
|
|
203
|
+
- **bypass** — Executes everything automatically
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
/mode bypass # Maximum autonomy
|
|
207
|
+
/mode default # Balanced
|
|
208
|
+
/mode plan # Planning only
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Web Interface
|
|
214
|
+
|
|
215
|
+
### Start web server
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
hanuscode
|
|
219
|
+
> /webui start # Port 8080 by default
|
|
220
|
+
> /webui start 3000 # Custom port
|
|
221
|
+
> /webui stop # Stop server
|
|
222
|
+
> /webui status # View status
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Web UI Features
|
|
226
|
+
|
|
227
|
+
- **Real-time chat** — Watch agent progress while working
|
|
228
|
+
- **Project management** — Create and select projects
|
|
229
|
+
- **Model selector** — Switch between models live
|
|
230
|
+
- **Profile selector** — Change agent behavior
|
|
231
|
+
- **Tool visualization** — See each tool executed
|
|
232
|
+
- **Statistics** — Tokens, costs, turns
|
|
233
|
+
- **Server logs** — Real-time debug
|
|
234
|
+
- **History** — Export conversations
|
|
235
|
+
|
|
236
|
+
### HTTP Endpoints
|
|
237
|
+
|
|
238
|
+
| Endpoint | Description |
|
|
239
|
+
|----------|-------------|
|
|
240
|
+
| `GET /` | Web HTML interface |
|
|
241
|
+
| `WS /ws` | WebSocket for real-time communication |
|
|
242
|
+
|
|
243
|
+
### WebSocket Messages
|
|
244
|
+
|
|
245
|
+
```javascript
|
|
246
|
+
// Send message
|
|
247
|
+
{ "type": "message", "content": "Your message" }
|
|
248
|
+
|
|
249
|
+
// Receive response
|
|
250
|
+
{ "type": "message", "role": "assistant", "content": "..." }
|
|
251
|
+
|
|
252
|
+
// Response streaming
|
|
253
|
+
{ "type": "stream", "content": "Partial text..." }
|
|
254
|
+
|
|
255
|
+
// Tool started
|
|
256
|
+
{ "type": "tool_start", "name": "read_file", "description": "Reading file: config.py" }
|
|
257
|
+
|
|
258
|
+
// Tool finished
|
|
259
|
+
{ "type": "tool_end", "name": "read_file", "result": "...", "success": true }
|
|
260
|
+
|
|
261
|
+
// Project management
|
|
262
|
+
{ "type": "create_project", "name": "My Project", "path": "/optional/path" }
|
|
263
|
+
{ "type": "select_project", "path": "/path/to/project" }
|
|
264
|
+
{ "type": "get_projects" }
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
---
|
|
268
|
+
|
|
269
|
+
## Project System
|
|
270
|
+
|
|
271
|
+
### Concept
|
|
272
|
+
|
|
273
|
+
Projects allow working on different directories in isolation. Each project has:
|
|
274
|
+
|
|
275
|
+
- Independent working directory
|
|
276
|
+
- Own configuration
|
|
277
|
+
- Saved sessions
|
|
278
|
+
- Project memory
|
|
279
|
+
|
|
280
|
+
### Terminal usage
|
|
281
|
+
|
|
282
|
+
```
|
|
283
|
+
> /project create my-app
|
|
284
|
+
> Creates project in ~/.hanus/projects/my-app
|
|
285
|
+
|
|
286
|
+
> /project open /path/to/my/project
|
|
287
|
+
> Opens existing project
|
|
288
|
+
|
|
289
|
+
> /project list
|
|
290
|
+
> Lists all projects
|
|
291
|
+
|
|
292
|
+
> /project current
|
|
293
|
+
> Shows active project
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### Web UI usage
|
|
297
|
+
|
|
298
|
+
- Project selector in sidebar
|
|
299
|
+
- "New" button to create project
|
|
300
|
+
- "Open" button to open existing directory
|
|
301
|
+
- Active project shown in real-time
|
|
302
|
+
|
|
303
|
+
### Project structure
|
|
304
|
+
|
|
305
|
+
```
|
|
306
|
+
~/.hanus/projects/my-project/
|
|
307
|
+
├── project.json # Project metadata
|
|
308
|
+
├── sessions/ # Saved sessions
|
|
309
|
+
├── memory/ # Project memory
|
|
310
|
+
└── notes/ # Agent notes
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
---
|
|
314
|
+
|
|
315
|
+
## SDK for Custom Agents
|
|
316
|
+
|
|
317
|
+
You can create your own agent by importing HanusCode modules.
|
|
318
|
+
|
|
319
|
+
**See [docs/custom_agent.md](docs/custom_agent.md) for complete guide on creating custom agents.**
|
|
320
|
+
|
|
321
|
+
### Basic example
|
|
322
|
+
|
|
323
|
+
```python
|
|
324
|
+
from hanus.config import HanusConfig
|
|
325
|
+
from hanus.query_engine import QueryEngine
|
|
326
|
+
from hanus.tools import ToolExecutor
|
|
327
|
+
from hanus.permissions import PermissionManager, PermissionMode
|
|
328
|
+
from hanus.session_manager import SessionManager
|
|
329
|
+
from hanus.connectors.registry import ConnectorRegistry
|
|
330
|
+
from pathlib import Path
|
|
331
|
+
|
|
332
|
+
# Configuration
|
|
333
|
+
config = HanusConfig.load()
|
|
334
|
+
config.provider = "ollama"
|
|
335
|
+
config.model_id = "llama3"
|
|
336
|
+
|
|
337
|
+
# Create connector
|
|
338
|
+
connector = ConnectorRegistry.get(config.provider, config.get_connector_config())
|
|
339
|
+
|
|
340
|
+
# Create tool executor
|
|
341
|
+
executor = ToolExecutor(
|
|
342
|
+
root_dir=Path.cwd(),
|
|
343
|
+
permission_manager=PermissionManager(mode=PermissionMode.AUTO)
|
|
344
|
+
)
|
|
345
|
+
|
|
346
|
+
# Create session
|
|
347
|
+
session = SessionManager()
|
|
348
|
+
session.new_session(str(Path.cwd()), config.provider, config.model_id)
|
|
349
|
+
|
|
350
|
+
# Create agent engine
|
|
351
|
+
engine = QueryEngine(
|
|
352
|
+
connector=connector,
|
|
353
|
+
tool_executor=executor,
|
|
354
|
+
session_manager=session,
|
|
355
|
+
)
|
|
356
|
+
|
|
357
|
+
# Configure system prompt
|
|
358
|
+
engine.set_system_prompt("You are a programming assistant.")
|
|
359
|
+
|
|
360
|
+
# Send message
|
|
361
|
+
response = engine.send("Analyze the current project")
|
|
362
|
+
print(response.text)
|
|
363
|
+
print(f"Tokens: {response.input_tokens} in, {response.output_tokens} out")
|
|
364
|
+
print(f"Cost: ${response.cost_usd:.4f}")
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## Supported Providers
|
|
370
|
+
|
|
371
|
+
| Provider | Free | Popular Models |
|
|
372
|
+
|----------|------|----------------|
|
|
373
|
+
| **Ollama** | ✅ | llama3, mistral, codellama, qwen2.5, glm-5 |
|
|
374
|
+
| **GLM Cloud** | ✅ | glm-4, glm-4-flash, glm-5 |
|
|
375
|
+
| **Anthropic** | 💰 | claude-sonnet-4-6, claude-opus-4-7 |
|
|
376
|
+
| **OpenAI** | 💰 | gpt-4o, o1, o3-mini |
|
|
377
|
+
| **Google** | 💰 | gemini-2.0-flash, gemini-2.5-pro |
|
|
378
|
+
|
|
379
|
+
### Change model in real-time
|
|
380
|
+
|
|
381
|
+
```
|
|
382
|
+
/model ollama llama3
|
|
383
|
+
/model claude claude-sonnet-4-6
|
|
384
|
+
/model glm glm-4
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### API Keys configuration
|
|
388
|
+
|
|
389
|
+
```bash
|
|
390
|
+
# Environment variables
|
|
391
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
392
|
+
export OPENAI_API_KEY=sk-...
|
|
393
|
+
export GEMINI_API_KEY=...
|
|
394
|
+
export GLM_API_KEY=...
|
|
395
|
+
|
|
396
|
+
# Or in config.yaml
|
|
397
|
+
provider: claude
|
|
398
|
+
api_key: sk-ant-...
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
---
|
|
402
|
+
|
|
403
|
+
## Profile System
|
|
404
|
+
|
|
405
|
+
Profiles change agent behavior based on context.
|
|
406
|
+
|
|
407
|
+
### Available profiles
|
|
408
|
+
|
|
409
|
+
| Profile | Description | Typical use |
|
|
410
|
+
|---------|-------------|-------------|
|
|
411
|
+
| **developer** | General development, refactoring, documentation | Daily coding |
|
|
412
|
+
| **architect** | System design, architecture planning | New projects |
|
|
413
|
+
| **deep** | Deep analysis, thorough investigation | Complex problems |
|
|
414
|
+
| **speed** | Fast responses, quick iterations | Rapid prototyping |
|
|
415
|
+
|
|
416
|
+
### Profile management
|
|
417
|
+
|
|
418
|
+
```
|
|
419
|
+
/profile list # View available profiles
|
|
420
|
+
/profile architect # Switch to architect profile
|
|
421
|
+
/profile developer # Switch to developer profile
|
|
422
|
+
/profile show # View current profile
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
### Create custom profile
|
|
426
|
+
|
|
427
|
+
```yaml
|
|
428
|
+
# ~/.hanus/profiles/my_profile.yaml
|
|
429
|
+
name: my_profile
|
|
430
|
+
display: My Profile
|
|
431
|
+
description: Custom profile for my project
|
|
432
|
+
system_prompt: |
|
|
433
|
+
You are an expert in {domain}.
|
|
434
|
+
Your main focus is {objective}.
|
|
435
|
+
Use these conventions: {conventions}
|
|
436
|
+
tools:
|
|
437
|
+
- read_file
|
|
438
|
+
- write_file
|
|
439
|
+
- exec_cmd
|
|
440
|
+
- web_search
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## Commands
|
|
446
|
+
|
|
447
|
+
### Session commands
|
|
448
|
+
|
|
449
|
+
| Command | Description |
|
|
450
|
+
|---------|-------------|
|
|
451
|
+
| `/help` | Show help |
|
|
452
|
+
| `/clear` | Reset conversation |
|
|
453
|
+
| `/save` | Save current session |
|
|
454
|
+
| `/sessions` | List saved sessions |
|
|
455
|
+
| `/resume [id]` | Resume previous session |
|
|
456
|
+
| `q` / `exit` / `quit` | Exit agent |
|
|
457
|
+
|
|
458
|
+
### Configuration commands
|
|
459
|
+
|
|
460
|
+
| Command | Description |
|
|
461
|
+
|---------|-------------|
|
|
462
|
+
| `/model [prov] [model]` | Change model |
|
|
463
|
+
| `/profile [name]` | Change profile |
|
|
464
|
+
| `/mode default\|plan\|bypass` | Change permission mode |
|
|
465
|
+
| `/budget [amount]` | Manage budget |
|
|
466
|
+
| `/config` | Show current configuration |
|
|
467
|
+
|
|
468
|
+
### Project commands
|
|
469
|
+
|
|
470
|
+
| Command | Description |
|
|
471
|
+
|---------|-------------|
|
|
472
|
+
| `/project create [name]` | Create new project |
|
|
473
|
+
| `/project open [path]` | Open existing project |
|
|
474
|
+
| `/project list` | List projects |
|
|
475
|
+
| `/project current` | Show active project |
|
|
476
|
+
|
|
477
|
+
### Memory commands
|
|
478
|
+
|
|
479
|
+
| Command | Description |
|
|
480
|
+
|---------|-------------|
|
|
481
|
+
| `/memory save [name]` | Save memory |
|
|
482
|
+
| `/memory search [query]` | Search memory |
|
|
483
|
+
| `/memory list` | List memories |
|
|
484
|
+
|
|
485
|
+
### Task commands
|
|
486
|
+
|
|
487
|
+
| Command | Description |
|
|
488
|
+
|---------|-------------|
|
|
489
|
+
| `/tasks` | View system tasks |
|
|
490
|
+
| `/task done [id]` | Mark task as completed |
|
|
491
|
+
|
|
492
|
+
### Plugin commands
|
|
493
|
+
|
|
494
|
+
| Command | Description |
|
|
495
|
+
|---------|-------------|
|
|
496
|
+
| `/plugins list` | List installed plugins |
|
|
497
|
+
| `/plugins available` | List available plugins in repository |
|
|
498
|
+
| `/plugins install <name>` | Install plugin from repository |
|
|
499
|
+
| `/plugins uninstall <name>` | Remove a plugin |
|
|
500
|
+
| `/plugins update <name>` | Update plugin to latest version |
|
|
501
|
+
| `/plugins enable <name>` | Enable a plugin |
|
|
502
|
+
| `/plugins disable <name>` | Disable a plugin |
|
|
503
|
+
| `/plugins reload [name]` | Reload plugin(s) |
|
|
504
|
+
|
|
505
|
+
### Remote control commands
|
|
506
|
+
|
|
507
|
+
| Command | Description |
|
|
508
|
+
|---------|-------------|
|
|
509
|
+
| `/telegram start` | Start Telegram bot |
|
|
510
|
+
| `/telegram stop` | Stop Telegram bot |
|
|
511
|
+
| `/telegram status` | Show bot status |
|
|
512
|
+
| `/telegram config` | Show setup instructions |
|
|
513
|
+
| `/webui start [port]` | Start web interface |
|
|
514
|
+
| `/webui stop` | Stop web interface |
|
|
515
|
+
| `/webui status` | Web server status |
|
|
516
|
+
|
|
517
|
+
### Special commands
|
|
518
|
+
|
|
519
|
+
| Command | Description |
|
|
520
|
+
|---------|-------------|
|
|
521
|
+
| `/reload` | Reload project context |
|
|
522
|
+
| `/multiline` | Enter multiline input mode |
|
|
523
|
+
| `/stats` | Show session statistics |
|
|
524
|
+
| `/logs` | View recent logs |
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
## Agent Tools
|
|
529
|
+
|
|
530
|
+
### File tools
|
|
531
|
+
|
|
532
|
+
| Tool | Description | Example |
|
|
533
|
+
|------|-------------|---------|
|
|
534
|
+
| `read_file` | Read file | `<read_file path="config.py"/>` |
|
|
535
|
+
| `write_file` | Create/overwrite file | `<write_file path="app.py">code</write_file>` |
|
|
536
|
+
| `edit_file` | Edit existing file | `<edit_file path="app.py" old="foo" new="bar"/>` |
|
|
537
|
+
| `append_to_file` | Append to end | `<append_to_file path="log.txt">entry</append_to_file>` |
|
|
538
|
+
| `glob_search` | Search files by pattern | `<glob_search pattern="**/*.py"/>` |
|
|
539
|
+
| `grep_search` | Search text in files | `<grep_search pattern="def.*:" path="src/"/>` |
|
|
540
|
+
|
|
541
|
+
### Execution tools
|
|
542
|
+
|
|
543
|
+
| Tool | Description | Example |
|
|
544
|
+
|------|-------------|---------|
|
|
545
|
+
| `exec_cmd` | Execute shell command | `<exec_cmd>npm test</exec_cmd>` |
|
|
546
|
+
| `bash` | Execute in bash | `<bash>git status</bash>` |
|
|
547
|
+
|
|
548
|
+
### Git tools
|
|
549
|
+
|
|
550
|
+
| Tool | Description |
|
|
551
|
+
|------|-------------|
|
|
552
|
+
| `git_status` | Repository status |
|
|
553
|
+
| `git_diff` | Differences |
|
|
554
|
+
| `git_commit` | Make commit |
|
|
555
|
+
| `git_push` | Push to remote |
|
|
556
|
+
|
|
557
|
+
### Web tools
|
|
558
|
+
|
|
559
|
+
| Tool | Description | Example |
|
|
560
|
+
|------|-------------|---------|
|
|
561
|
+
| `web_fetch` | Get web content | `<web_fetch url="https://..."/>` |
|
|
562
|
+
| `web_search` | Web search | `<web_search query="python asyncio"/>` |
|
|
563
|
+
|
|
564
|
+
### Management tools
|
|
565
|
+
|
|
566
|
+
| Tool | Description |
|
|
567
|
+
|------|-------------|
|
|
568
|
+
| `task_create` | Create task |
|
|
569
|
+
| `task_update` | Update task |
|
|
570
|
+
| `task_list` | List tasks |
|
|
571
|
+
| `task_get` | Get task |
|
|
572
|
+
|
|
573
|
+
### Interaction tools
|
|
574
|
+
|
|
575
|
+
| Tool | Description |
|
|
576
|
+
|------|-------------|
|
|
577
|
+
| `ask_user` | Ask user with options |
|
|
578
|
+
| `notebook_edit` | Edit Jupyter notebook cells |
|
|
579
|
+
|
|
580
|
+
### Advanced tools
|
|
581
|
+
|
|
582
|
+
| Tool | Description |
|
|
583
|
+
|------|-------------|
|
|
584
|
+
| `subagent` | Execute specialized subagent |
|
|
585
|
+
| `structured_output` | Generate structured output |
|
|
586
|
+
|
|
587
|
+
---
|
|
588
|
+
|
|
589
|
+
## Plugins
|
|
590
|
+
|
|
591
|
+
Plugins extend HanusCode capabilities with specialized functionality.
|
|
592
|
+
|
|
593
|
+
**See [docs/plugins.md](docs/plugins.md) for complete plugin development guide.**
|
|
594
|
+
|
|
595
|
+
### Plugin Management
|
|
596
|
+
|
|
597
|
+
| Command | Description |
|
|
598
|
+
|---------|-------------|
|
|
599
|
+
| `/plugins list` | List installed plugins |
|
|
600
|
+
| `/plugins available` | List plugins available in repository |
|
|
601
|
+
| `/plugins install <name>` | Install plugin from repository |
|
|
602
|
+
| `/plugins uninstall <name>` | Remove a plugin |
|
|
603
|
+
| `/plugins update <name>` | Update plugin to latest version |
|
|
604
|
+
| `/plugins enable <name>` | Enable a plugin |
|
|
605
|
+
| `/plugins disable <name>` | Disable a plugin |
|
|
606
|
+
| `/plugins reload [name]` | Reload plugin(s) |
|
|
607
|
+
|
|
608
|
+
### Official Plugin Repository
|
|
609
|
+
|
|
610
|
+
Browse and install plugins from the official repository:
|
|
611
|
+
```
|
|
612
|
+
https://github.com/hanuscode/hanuscode-plugins
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
```bash
|
|
616
|
+
# List available plugins
|
|
617
|
+
> /plugins available
|
|
618
|
+
|
|
619
|
+
# Install a plugin
|
|
620
|
+
> /plugins install telegram
|
|
621
|
+
|
|
622
|
+
# Update a plugin
|
|
623
|
+
> /plugins update telegram
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### Included plugins
|
|
627
|
+
|
|
628
|
+
| Plugin | Description | Usage |
|
|
629
|
+
|--------|-------------|-------|
|
|
630
|
+
| **arena** | CTF arena challenge management | `/arena start` |
|
|
631
|
+
| **binsmasher** | ELF/PE binary analysis and exploitation | `/binsmasher analyze ./binary` |
|
|
632
|
+
| **burpsuite** | Burp Suite integration | `/burpsuite scan` |
|
|
633
|
+
| **chrome** | Chrome browser integration | `/chrome start` |
|
|
634
|
+
| **code_review** | AI code review | `/review src/` |
|
|
635
|
+
| **cortex** | Semantic memory with knowledge graphs | `/cortex remember ...` |
|
|
636
|
+
| **deps_check** | Dependency analysis | `/deps_check requirements.txt` |
|
|
637
|
+
| **git_ops** | Advanced git operations | `/git_ops branches` |
|
|
638
|
+
| **metasploit** | Metasploit framework integration | `/metasploit list` |
|
|
639
|
+
| **notes** | Bidirectional note linking with graphs | `/notes new "Title"` |
|
|
640
|
+
| **search_code** | Search in files | `/search_code "pattern"` |
|
|
641
|
+
| **searchsploit** | Search exploits database | `/searchsploit apache` |
|
|
642
|
+
| **strategist** | Strategic planning | `/strategist plan` |
|
|
643
|
+
| **telegram** | Telegram bot for remote control | `/telegram start` |
|
|
644
|
+
| **weblearn** | Web learning and crawling | `/weblearn start` |
|
|
645
|
+
| **webui** | Web interface | `/webui start` |
|
|
646
|
+
|
|
647
|
+
### Remote Control Plugins
|
|
648
|
+
|
|
649
|
+
| Plugin | Description |
|
|
650
|
+
|--------|-------------|
|
|
651
|
+
| **telegram** | Control HanusCode from Telegram with real-time notifications |
|
|
652
|
+
| **webui** | Complete web interface with real-time chat and project management |
|
|
653
|
+
| **chrome** | Chrome extension integration for browser-based tasks |
|
|
654
|
+
|
|
655
|
+
### Telegram Plugin Setup
|
|
656
|
+
|
|
657
|
+
Control your HanusCode agent remotely via Telegram:
|
|
658
|
+
|
|
659
|
+
```bash
|
|
660
|
+
# 1. Create bot with @BotFather on Telegram
|
|
661
|
+
# 2. Set token
|
|
662
|
+
export HANUS_TELEGRAM_TOKEN="123456789:ABCdef..."
|
|
663
|
+
|
|
664
|
+
# 3. (Optional) Set authorized users
|
|
665
|
+
export HANUS_TELEGRAM_ADMIN_IDS="123456,789012"
|
|
666
|
+
|
|
667
|
+
# 4. Start the bot
|
|
668
|
+
> /telegram start
|
|
669
|
+
|
|
670
|
+
# 5. Find your bot on Telegram and send /start
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
### Create custom plugin
|
|
674
|
+
|
|
675
|
+
```python
|
|
676
|
+
# hanus/plugins/my_plugin.py
|
|
677
|
+
NAME = "my_plugin"
|
|
678
|
+
DESCRIPTION = "My custom plugin"
|
|
679
|
+
USAGE = "command [args]"
|
|
680
|
+
AGENT_DOC = """
|
|
681
|
+
Plugin that does X, Y, Z.
|
|
682
|
+
|
|
683
|
+
Commands:
|
|
684
|
+
- /my_plugin cmd1 — Description
|
|
685
|
+
- /my_plugin cmd2 — Description
|
|
686
|
+
"""
|
|
687
|
+
|
|
688
|
+
def run(args: str = "") -> str:
|
|
689
|
+
"""Execute the plugin."""
|
|
690
|
+
# Your logic here
|
|
691
|
+
return "Plugin result"
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
---
|
|
695
|
+
|
|
696
|
+
## Subagents
|
|
697
|
+
|
|
698
|
+
Subagents allow delegating complex tasks to specialized agents.
|
|
699
|
+
|
|
700
|
+
### Subagent types
|
|
701
|
+
|
|
702
|
+
| Type | Specialization | Use |
|
|
703
|
+
|------|----------------|-----|
|
|
704
|
+
| **explore** | Read-only, code exploration | Find files, understand structure |
|
|
705
|
+
| **review** | Code review, bugs, security | Audits, code review |
|
|
706
|
+
| **plan** | Planning and design | Architecture, system design |
|
|
707
|
+
| **test** | Writing and running tests | Automated testing |
|
|
708
|
+
| **general** | General purpose | Various tasks |
|
|
709
|
+
|
|
710
|
+
### Subagent usage
|
|
711
|
+
|
|
712
|
+
```
|
|
713
|
+
<subagent type="explore" task="Find all API endpoints"/>
|
|
714
|
+
<subagent type="review" task="Review auth.py for vulnerabilities"/>
|
|
715
|
+
<subagent type="plan" task="Design the payment system architecture"/>
|
|
716
|
+
<subagent type="test" task="Write tests for the users module"/>
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
---
|
|
720
|
+
|
|
721
|
+
## Skills
|
|
722
|
+
|
|
723
|
+
Skills are extensible commands installable from URLs.
|
|
724
|
+
|
|
725
|
+
### Included skills
|
|
726
|
+
|
|
727
|
+
| Skill | Description |
|
|
728
|
+
|-------|-------------|
|
|
729
|
+
| `/analyze` | Project structure analysis |
|
|
730
|
+
| `/explain` | Explain code in detail |
|
|
731
|
+
| `/todo` | Find TODOs, FIXMEs, HACKs |
|
|
732
|
+
| `/review` | Code review |
|
|
733
|
+
| `/deploy` | Deploy to server |
|
|
734
|
+
| `/test` | Run tests |
|
|
735
|
+
|
|
736
|
+
### Skill management
|
|
737
|
+
|
|
738
|
+
```
|
|
739
|
+
/skill list # List available
|
|
740
|
+
/skill install <url> # Install from URL
|
|
741
|
+
/skill create <name> <desc> # Create new
|
|
742
|
+
/skill remove <name> # Remove
|
|
743
|
+
```
|
|
744
|
+
|
|
745
|
+
---
|
|
746
|
+
|
|
747
|
+
## Memory System
|
|
748
|
+
|
|
749
|
+
The agent can save and retrieve information between sessions.
|
|
750
|
+
|
|
751
|
+
### Memory types
|
|
752
|
+
|
|
753
|
+
| Type | Description | Use |
|
|
754
|
+
|------|-------------|-----|
|
|
755
|
+
| **user** | User preferences | "User prefers TypeScript" |
|
|
756
|
+
| **feedback** | Lessons learned | "Don't use X, caused problems" |
|
|
757
|
+
| **project** | Project information | "Project uses JWT for auth" |
|
|
758
|
+
| **reference** | Pointers to resources | "Bugs are in Linear project ING" |
|
|
759
|
+
|
|
760
|
+
### Memory usage
|
|
761
|
+
|
|
762
|
+
```
|
|
763
|
+
> Save in memory that the project uses FastAPI with PostgreSQL
|
|
764
|
+
> <memory_save name="stack" type="project">
|
|
765
|
+
The project uses FastAPI with PostgreSQL.
|
|
766
|
+
Database: postgresql://localhost:5432/myapp
|
|
767
|
+
Migrations: Alembic
|
|
768
|
+
</memory_save>
|
|
769
|
+
|
|
770
|
+
> What database does the project use?
|
|
771
|
+
> <memory_search query="database"/>
|
|
772
|
+
> (Retrieves saved information)
|
|
773
|
+
```
|
|
774
|
+
|
|
775
|
+
---
|
|
776
|
+
|
|
777
|
+
## Configuration
|
|
778
|
+
|
|
779
|
+
### Configuration file
|
|
780
|
+
|
|
781
|
+
`~/.hanus/config.yaml`:
|
|
782
|
+
|
|
783
|
+
```yaml
|
|
784
|
+
# Provider and model
|
|
785
|
+
provider: ollama
|
|
786
|
+
model_id: llama3
|
|
787
|
+
|
|
788
|
+
# Working directory
|
|
789
|
+
root_dir: /home/user/projects/myapp
|
|
790
|
+
|
|
791
|
+
# Permissions
|
|
792
|
+
permission_mode: default # default, plan, bypass
|
|
793
|
+
|
|
794
|
+
# Budget
|
|
795
|
+
budget_usd: 10.0
|
|
796
|
+
|
|
797
|
+
# Sessions
|
|
798
|
+
auto_save_session: true
|
|
799
|
+
session_dir: ~/.hanus/sessions
|
|
800
|
+
|
|
801
|
+
# Context
|
|
802
|
+
context_max_files: 50
|
|
803
|
+
context_include_content: true
|
|
804
|
+
context_preview_chars: 500
|
|
805
|
+
|
|
806
|
+
# Specific connectors
|
|
807
|
+
ollama_url: http://localhost:11434
|
|
808
|
+
anthropic_api_key: ${ANTHROPIC_API_KEY}
|
|
809
|
+
openai_api_key: ${OPENAI_API_KEY}
|
|
810
|
+
|
|
811
|
+
# Logging
|
|
812
|
+
log_level: INFO
|
|
813
|
+
log_file: ~/.hanus/hanus.log
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
### Environment variables
|
|
817
|
+
|
|
818
|
+
```bash
|
|
819
|
+
# Provider
|
|
820
|
+
export HANUS_PROVIDER=claude
|
|
821
|
+
export HANUS_MODEL=claude-sonnet-4-6
|
|
822
|
+
|
|
823
|
+
# API Keys
|
|
824
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
825
|
+
export OPENAI_API_KEY=sk-...
|
|
826
|
+
export GEMINI_API_KEY=...
|
|
827
|
+
export GLM_API_KEY=...
|
|
828
|
+
|
|
829
|
+
# Ollama
|
|
830
|
+
export OLLAMA_URL=http://localhost:11434
|
|
831
|
+
|
|
832
|
+
# Budget
|
|
833
|
+
export HANUS_BUDGET=10.0
|
|
834
|
+
|
|
835
|
+
# Permission mode
|
|
836
|
+
export HANUS_PERMISSION_MODE=bypass
|
|
837
|
+
```
|
|
838
|
+
|
|
839
|
+
---
|
|
840
|
+
|
|
841
|
+
## API Reference
|
|
842
|
+
|
|
843
|
+
### Configuration
|
|
844
|
+
|
|
845
|
+
```python
|
|
846
|
+
from hanus.config import HanusConfig
|
|
847
|
+
|
|
848
|
+
# Load configuration
|
|
849
|
+
config = HanusConfig.load()
|
|
850
|
+
|
|
851
|
+
# Attributes
|
|
852
|
+
config.provider # "ollama", "claude", "openai", etc.
|
|
853
|
+
config.model_id # Model ID
|
|
854
|
+
config.root_dir # Working directory
|
|
855
|
+
config.permission_mode # "default", "plan", "bypass"
|
|
856
|
+
config.budget_usd # Budget in dollars
|
|
857
|
+
config.ollama_url # Ollama URL
|
|
858
|
+
config.context_max_files # Max files in context
|
|
859
|
+
|
|
860
|
+
# Methods
|
|
861
|
+
config.get_connector_config() # Config for connector
|
|
862
|
+
config.load_system_prompt() # Load system prompt
|
|
863
|
+
config.save() # Save configuration
|
|
864
|
+
```
|
|
865
|
+
|
|
866
|
+
### QueryEngine
|
|
867
|
+
|
|
868
|
+
```python
|
|
869
|
+
from hanus.query_engine import QueryEngine
|
|
870
|
+
|
|
871
|
+
engine = QueryEngine(
|
|
872
|
+
connector=connector, # AI connector
|
|
873
|
+
tool_executor=executor, # Tool executor
|
|
874
|
+
session_manager=session, # Session manager
|
|
875
|
+
permission_manager=perms, # Permission manager
|
|
876
|
+
plugin_manager=plugins, # Plugin manager (optional)
|
|
877
|
+
stream_callback=on_token, # Streaming callback (optional)
|
|
878
|
+
tool_start_callback=on_start, # Tool start callback (optional)
|
|
879
|
+
tool_end_callback=on_end, # Tool end callback (optional)
|
|
880
|
+
budget_usd=10.0, # Budget (optional)
|
|
881
|
+
)
|
|
882
|
+
|
|
883
|
+
# Methods
|
|
884
|
+
engine.set_system_prompt(prompt) # Set system prompt
|
|
885
|
+
engine.inject_context(context) # Inject project context
|
|
886
|
+
engine.send(message) # Send message, return Response
|
|
887
|
+
|
|
888
|
+
# Response
|
|
889
|
+
response.text # Response text
|
|
890
|
+
response.input_tokens # Input tokens
|
|
891
|
+
response.output_tokens # Output tokens
|
|
892
|
+
response.cost_usd # Cost in dollars
|
|
893
|
+
response.stop_reason # Stop reason
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
---
|
|
897
|
+
|
|
898
|
+
## Project Structure
|
|
899
|
+
|
|
900
|
+
```
|
|
901
|
+
hanus/
|
|
902
|
+
├── __init__.py # Package entry point
|
|
903
|
+
├── __main__.py # Entry point for python -m hanus
|
|
904
|
+
├── agent_runner.py # Main agent loop
|
|
905
|
+
├── query_engine.py # Agent engine (QueryEngine)
|
|
906
|
+
├── tools.py # Tools (ToolExecutor)
|
|
907
|
+
├── ui.py # Terminal interface
|
|
908
|
+
├── config.py # Configuration management
|
|
909
|
+
├── permissions.py # Permission system
|
|
910
|
+
├── session_manager.py # Session manager
|
|
911
|
+
├── profiles.py # Profile system
|
|
912
|
+
├── action_parser.py # XML action parser
|
|
913
|
+
├── action_handlers.py # Action handlers
|
|
914
|
+
├── logger.py # Logging system
|
|
915
|
+
├── monitor.py # Event monitor
|
|
916
|
+
├── terminal_prompt.py # Interactive prompt
|
|
917
|
+
├── project_tools.py # Project tools
|
|
918
|
+
├── skill_manager.py # Skill manager
|
|
919
|
+
│
|
|
920
|
+
├── connectors/ # AI provider connectors
|
|
921
|
+
│ ├── __init__.py
|
|
922
|
+
│ ├── base.py # Base class
|
|
923
|
+
│ ├── registry.py # Connector registry
|
|
924
|
+
│ ├── ollama.py # Ollama connector
|
|
925
|
+
│ ├── anthropic.py # Anthropic connector
|
|
926
|
+
│ ├── openai.py # OpenAI connector
|
|
927
|
+
│ ├── google.py # Google connector
|
|
928
|
+
│ └── glm_cloud.py # GLM Cloud connector
|
|
929
|
+
│
|
|
930
|
+
├── profiles_builtin/ # Built-in profiles
|
|
931
|
+
│ ├── developer/
|
|
932
|
+
│ ├── architect/
|
|
933
|
+
│ ├── deep/
|
|
934
|
+
│ └── speed/
|
|
935
|
+
│
|
|
936
|
+
├── plugins/ # Included plugins
|
|
937
|
+
│ ├── arena.py # CTF arena
|
|
938
|
+
│ ├── binsmasher.py # Binary analysis
|
|
939
|
+
│ ├── burpsuite.py # Burp Suite integration
|
|
940
|
+
│ ├── chrome.py # Chrome browser integration
|
|
941
|
+
│ ├── code_review.py # AI code review
|
|
942
|
+
│ ├── cortex.py # Semantic memory
|
|
943
|
+
│ ├── deps_check.py # Dependency analysis
|
|
944
|
+
│ ├── git_ops.py # Git operations
|
|
945
|
+
│ ├── metasploit.py # Metasploit integration
|
|
946
|
+
│ ├── notes.py # Note-taking with graphs
|
|
947
|
+
│ ├── search_code.py # Code search
|
|
948
|
+
│ ├── searchsploit.py # Exploits database
|
|
949
|
+
│ ├── strategist.py # Strategic planning
|
|
950
|
+
│ ├── telegram.py # Telegram bot
|
|
951
|
+
│ ├── weblearn.py # Web learning
|
|
952
|
+
│ └── webui.py # Web interface
|
|
953
|
+
│
|
|
954
|
+
├── analysis/ # Code analysis
|
|
955
|
+
│ ├── __init__.py
|
|
956
|
+
│ └── dependencies.py # Dependency graph
|
|
957
|
+
│
|
|
958
|
+
├── memory/ # Memory system
|
|
959
|
+
│ ├── __init__.py
|
|
960
|
+
│ └── manager.py
|
|
961
|
+
│
|
|
962
|
+
├── subagent/ # Subagent system
|
|
963
|
+
│ ├── __init__.py
|
|
964
|
+
│ ├── manager.py
|
|
965
|
+
│ └── types.py
|
|
966
|
+
│
|
|
967
|
+
├── plan/ # Planning mode
|
|
968
|
+
│ ├── __init__.py
|
|
969
|
+
│ └── planner.py
|
|
970
|
+
│
|
|
971
|
+
├── context/ # Context compression
|
|
972
|
+
│ ├── __init__.py
|
|
973
|
+
│ └── compressor.py
|
|
974
|
+
│
|
|
975
|
+
└── tasks/ # Task system
|
|
976
|
+
├── __init__.py
|
|
977
|
+
└── manager.py
|
|
978
|
+
```
|
|
979
|
+
|
|
980
|
+
---
|
|
981
|
+
|
|
982
|
+
## Examples
|
|
983
|
+
|
|
984
|
+
### General development
|
|
985
|
+
|
|
986
|
+
```
|
|
987
|
+
> Create a REST endpoint for user management with full CRUD
|
|
988
|
+
> The agent creates files, writes code, adds validations...
|
|
989
|
+
|
|
990
|
+
> Add unit tests for the authentication service
|
|
991
|
+
> The agent creates tests, runs them, fixes errors...
|
|
992
|
+
|
|
993
|
+
> Document the API with OpenAPI/Swagger
|
|
994
|
+
> The agent generates documentation, creates swagger files...
|
|
995
|
+
|
|
996
|
+
> Refactor the users module to use repository pattern
|
|
997
|
+
> The agent restructures code, maintains functionality...
|
|
998
|
+
```
|
|
999
|
+
|
|
1000
|
+
### Code audit
|
|
1001
|
+
|
|
1002
|
+
```
|
|
1003
|
+
> /profile deep
|
|
1004
|
+
|
|
1005
|
+
> Find SQL injection vulnerabilities in the code
|
|
1006
|
+
> The agent analyzes files, finds dangerous patterns...
|
|
1007
|
+
|
|
1008
|
+
> Find hardcoded secrets in the project
|
|
1009
|
+
> The agent searches for API keys, passwords, tokens in code...
|
|
1010
|
+
|
|
1011
|
+
> Review dependencies for known vulnerabilities
|
|
1012
|
+
> The agent uses /deps_check to analyze requirements.txt...
|
|
1013
|
+
```
|
|
1014
|
+
|
|
1015
|
+
### SDK development
|
|
1016
|
+
|
|
1017
|
+
```python
|
|
1018
|
+
#!/usr/bin/env python3
|
|
1019
|
+
"""Automatic documentation agent."""
|
|
1020
|
+
from hanus.config import HanusConfig
|
|
1021
|
+
from hanus.query_engine import QueryEngine
|
|
1022
|
+
from hanus.tools import ToolExecutor
|
|
1023
|
+
from hanus.permissions import PermissionManager, PermissionMode
|
|
1024
|
+
from hanus.session_manager import SessionManager
|
|
1025
|
+
from hanus.connectors.registry import ConnectorRegistry
|
|
1026
|
+
from pathlib import Path
|
|
1027
|
+
|
|
1028
|
+
class DocGenerator:
|
|
1029
|
+
def __init__(self, project_path: str):
|
|
1030
|
+
self.project_path = Path(project_path)
|
|
1031
|
+
self.config = HanusConfig.load()
|
|
1032
|
+
|
|
1033
|
+
self.engine = QueryEngine(
|
|
1034
|
+
connector=ConnectorRegistry.get(
|
|
1035
|
+
self.config.provider,
|
|
1036
|
+
self.config.get_connector_config()
|
|
1037
|
+
),
|
|
1038
|
+
tool_executor=ToolExecutor(
|
|
1039
|
+
self.project_path,
|
|
1040
|
+
PermissionManager(mode=PermissionMode.BYPASS)
|
|
1041
|
+
),
|
|
1042
|
+
session_manager=SessionManager(),
|
|
1043
|
+
)
|
|
1044
|
+
|
|
1045
|
+
self.engine.set_system_prompt("""
|
|
1046
|
+
You are a documentation generator. Your job is:
|
|
1047
|
+
1. Analyze source code
|
|
1048
|
+
2. Generate clear and complete documentation
|
|
1049
|
+
3. Create READMEs, docstrings, and guides
|
|
1050
|
+
|
|
1051
|
+
Supported formats: Markdown, reStructuredText, Google Style.
|
|
1052
|
+
""")
|
|
1053
|
+
|
|
1054
|
+
def generate_readme(self) -> str:
|
|
1055
|
+
return self.engine.send("""
|
|
1056
|
+
Analyze the project and generate a complete README.md with:
|
|
1057
|
+
- Project description
|
|
1058
|
+
- Installation
|
|
1059
|
+
- Usage
|
|
1060
|
+
- API Reference
|
|
1061
|
+
- Examples
|
|
1062
|
+
- Contributing
|
|
1063
|
+
""")
|
|
1064
|
+
|
|
1065
|
+
def generate_api_docs(self) -> str:
|
|
1066
|
+
return self.engine.send("""
|
|
1067
|
+
Generate API documentation for all endpoints.
|
|
1068
|
+
Include: methods, parameters, responses, examples.
|
|
1069
|
+
""")
|
|
1070
|
+
|
|
1071
|
+
if __name__ == "__main__":
|
|
1072
|
+
import sys
|
|
1073
|
+
project = sys.argv[1] if len(sys.argv) > 1 else "."
|
|
1074
|
+
gen = DocGenerator(project)
|
|
1075
|
+
readme = gen.generate_readme()
|
|
1076
|
+
print(readme)
|
|
1077
|
+
```
|
|
1078
|
+
|
|
1079
|
+
---
|
|
1080
|
+
|
|
1081
|
+
## Roadmap
|
|
1082
|
+
|
|
1083
|
+
- [x] Multi-provider (Ollama, Claude, OpenAI, Gemini, etc.)
|
|
1084
|
+
- [x] Profile system
|
|
1085
|
+
- [x] Extensible plugins
|
|
1086
|
+
- [x] Plugin repository and installation system
|
|
1087
|
+
- [x] Subagents
|
|
1088
|
+
- [x] Persistent memory
|
|
1089
|
+
- [x] Web interface
|
|
1090
|
+
- [x] Project system
|
|
1091
|
+
- [x] SDK for custom agents
|
|
1092
|
+
- [x] Telegram bot integration
|
|
1093
|
+
- [x] Chrome browser integration
|
|
1094
|
+
- [x] Semantic memory (Cortex)
|
|
1095
|
+
- [x] Dependency graph analysis
|
|
1096
|
+
- [ ] IDE integration (VS Code, JetBrains)
|
|
1097
|
+
- [ ] Team collaboration mode
|
|
1098
|
+
- [x] Advanced web dashboard
|
|
1099
|
+
- [ ] CI/CD integration
|
|
1100
|
+
- [ ] Complete REST API
|
|
1101
|
+
- [ ] Webhooks for events
|
|
1102
|
+
- [ ] Discord bot integration
|
|
1103
|
+
|
|
1104
|
+
---
|
|
1105
|
+
|
|
1106
|
+
## Contributing
|
|
1107
|
+
|
|
1108
|
+
1. Fork the repository
|
|
1109
|
+
2. Create a feature branch (`git checkout -b feature/my-feature`)
|
|
1110
|
+
3. Commit your changes (`git commit -am 'Add my feature'`)
|
|
1111
|
+
4. Push to the branch (`git push origin feature/my-feature`)
|
|
1112
|
+
5. Open a Pull Request
|
|
1113
|
+
|
|
1114
|
+
### Contribution guidelines
|
|
1115
|
+
|
|
1116
|
+
- Follow existing code style
|
|
1117
|
+
- Add tests for new features
|
|
1118
|
+
- Document public APIs
|
|
1119
|
+
- Update README if necessary
|
|
1120
|
+
|
|
1121
|
+
---
|
|
1122
|
+
|
|
1123
|
+
## License
|
|
1124
|
+
|
|
1125
|
+
MIT License
|
|
1126
|
+
|
|
1127
|
+
Copyright (c) 2026 CiTriX
|
|
1128
|
+
|
|
1129
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
1130
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
1131
|
+
in the Software without restriction, including without limitation the rights
|
|
1132
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
1133
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
1134
|
+
furnished to do so, subject to the following conditions:
|
|
1135
|
+
|
|
1136
|
+
The above copyright notice and this permission notice shall be included in all
|
|
1137
|
+
copies or substantial portions of the Software.
|
|
1138
|
+
|
|
1139
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
1140
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
1141
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
1142
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
1143
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
1144
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1145
|
+
SOFTWARE.
|
|
1146
|
+
|
|
1147
|
+
---
|
|
1148
|
+
|
|
1149
|
+
<p align="center">
|
|
1150
|
+
<strong>Hanus Code</strong> — Code smarter, not harder.
|
|
1151
|
+
</p>
|