File size: 5,551 Bytes
eca5751
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# Skills Documentation

Nexus Coder v0.2 có 15 skills chuyên môn, được tổ chức theo 5 categories.

## Categories

| Category | Skills |
|----------|--------|
| CODE | code_generation, code_review, code_refactor, debugging, documentation, testing |
| REASONING | algorithm_design, reasoning, math_skill |
| LANGUAGE | translation, summarization |
| DATA | data_analysis, sql_generation |
| SECURITY | security_audit |
| DEVOPS | performance_optimization |

## Skill List

### 1. code_generation
- **Category**: CODE
- **Priority**: HIGH
- **Description**: Sinh code từ mô tả tự nhiên
- **Languages**: Python, JavaScript, TypeScript, Go, Rust, C++, Java, SQL
- **Example**: "Viết hàm Python tính fibonacci"

### 2. code_review
- **Category**: CODE
- **Priority**: HIGH
- **Description**: Review code toàn diện
- **Checks**: bugs, security, performance, style, error handling, type safety
- **Example**: "Review đoạn code này giúp tôi"

### 3. code_refactor
- **Category**: CODE
- **Priority**: MEDIUM
- **Description**: Refactor code an toàn
- **Patterns**: Extract Method/Class, Rename, Move, Replace Conditional, etc.
- **Example**: "Refactor hàm này cho clean hơn"

### 4. debugging
- **Category**: CODE
- **Priority**: CRITICAL
- **Description**: Debug code với 7-step protocol
- **Supports**: Python, JavaScript, Java, Go, Rust, C++, Ruby
- **Example**: "Fix lỗi IndexError trong hàm này"

### 5. documentation
- **Category**: CODE
- **Priority**: MEDIUM
- **Description**: Sinh tài liệu tự động
- **Types**: Docstrings (Google/NumPy/Sphinx), README, API ref, tutorials
- **Example**: "Sinh docstring cho hàm này"

### 6. testing
- **Category**: CODE
- **Priority**: HIGH
- **Description**: Sinh tests
- **Types**: unit, integration, E2E, property-based, mutation, fuzz, snapshot
- **Frameworks**: pytest, unittest, jest, vitest, mocha, cargo test, JUnit
- **Example**: "Viết unit tests cho class User"

### 7. algorithm_design
- **Category**: REASONING
- **Priority**: MEDIUM
- **Description**: Thiết kế thuật toán
- **Approaches**: Brute force, Greedy, D&C, DP, Backtracking, Graph algorithms
- **Example**: "Tối ưu thuật toán này từ O(n²) xuống O(n log n)"

### 8. data_analysis
- **Category**: DATA
- **Priority**: MEDIUM
- **Description**: Phân tích dữ liệu
- **Steps**: Loading, cleaning, statistics, correlation, outliers, visualization
- **Libraries**: pandas, numpy, scipy, matplotlib, seaborn, plotly
- **Example**: "Phân tích dataset này và tìm insights"

### 9. translation
- **Category**: LANGUAGE
- **Priority**: MEDIUM
- **Description**: Dịch song ngữ Việt-Anh
- **Pairs**: vi↔en, vi↔zh, vi↔ja, vi↔ko, vi↔fr
- **Example**: "Dịch đoạn văn này sang tiếng Anh"

### 10. summarization
- **Category**: LANGUAGE
- **Priority**: MEDIUM
- **Description**: Tóm tắt văn bản
- **Methods**: extractive, abstractive, key phrase, topic modeling
- **Example**: "Tóm tắt bài viết này trong 3 câu"

### 11. reasoning
- **Category**: REASONING
- **Priority**: HIGH
- **Description**: Suy luận đa bước
- **Strategies**: CoT, ToT, Self-Consistency, Reflexion, ReAct, Least-to-Most
- **Example**: "Tại sao bầu trời màu xanh?"

### 12. math_skill
- **Category**: REASONING
- **Priority**: HIGH
- **Description**: Giải toán đa cấp
- **Domains**: arithmetic, algebra, calculus, linear algebra, probability, statistics
- **Tools**: sympy, numpy, scipy
- **Example**: "Tính đạo hàm của x³ + 2x²"

### 13. sql_generation
- **Category**: DATA
- **Priority**: HIGH
- **Description**: Sinh SQL queries
- **Dialects**: PostgreSQL, MySQL, SQLite, SQL Server, Oracle, BigQuery, Snowflake
- **Example**: "Viết SQL tìm top 10 khách hàng"

### 14. security_audit
- **Category**: SECURITY
- **Priority**: CRITICAL
- **Description**: Audit bảo mật
- **Standards**: OWASP Top 10, SAST, dependency vulnerabilities
- **Tools**: bandit, semgrep, safety, pip-audit, trufflehog
- **Example**: "Audit code này cho security issues"

### 15. performance_optimization
- **Category**: DEVOPS
- **Priority**: MEDIUM
- **Description**: Tối ưu hiệu năng
- **Categories**: algorithmic, memory, concurrency, caching, I/O, Python-specific
- **Tools**: cProfile, line_profiler, memory_profiler, py-spy
- **Example**: "Tối ưu hàm này đang chạy chậm"

## Usage

```python
from nexus.skills import get_global_registry
from nexus.skills.base import SkillContext

registry = get_global_registry()

# List all skills
print(registry.list_skills())

# Route prompt to best skill
skill = registry.route("Viết hàm Python tính giai thừa")
print(f"Selected: {skill.name}")

# Execute skill
context = SkillContext(prompt="Viết hàm Python tính giai thừa")
result = skill.execute(context)
print(result.output)
```

## Custom Skills

Tạo skill tùy chỉnh:

```python
from nexus.skills.base import Skill, SkillResult, SkillContext, SkillCategory, SkillPriority

class MyCustomSkill(Skill):
    category = SkillCategory.CODE
    priority = SkillPriority.MEDIUM
    keywords = ["custom", "riêng"]
    
    @property
    def name(self) -> str:
        return "my_custom_skill"
    
    @property
    def description(self) -> str:
        return "My custom skill description"
    
    def execute(self, context: SkillContext) -> SkillResult:
        return SkillResult(success=True, output="Custom result")

# Register
from nexus.skills import get_global_registry
get_global_registry().register(MyCustomSkill())
```