mirror of
https://github.com/csunny/DB-GPT.git
synced 2026-07-16 17:15:22 +00:00
feat:dbgpt skill
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"metadata": {
|
||||
"name": "data_analysis_assistant",
|
||||
"description": "Data analysis assistant for processing and visualizing data",
|
||||
"version": "1.0.0",
|
||||
"author": "DB-GPT Team",
|
||||
"skill_type": "data_analysis",
|
||||
"tags": ["data", "analysis", "visualization"]
|
||||
},
|
||||
"prompt_template": "You are a data analysis assistant. Help users analyze data, generate insights, and create visualizations. Use the available tools to process data and generate reports.",
|
||||
"required_tools": ["python_interpreter", "plotting_tool"],
|
||||
"required_knowledge": ["statistics", "data_science"],
|
||||
"config": {
|
||||
"max_dataframe_rows": 10000,
|
||||
"enable_auto_visualization": true
|
||||
}
|
||||
}
|
||||
@@ -1,246 +0,0 @@
|
||||
---
|
||||
name: code-review
|
||||
description: Systematic approach to reviewing code quality and best practices
|
||||
version: 1.0.0
|
||||
author: DB-GPT Team
|
||||
skill_type: coding
|
||||
tags: [code, review, quality]
|
||||
allowed-tools:
|
||||
license: MIT
|
||||
---
|
||||
|
||||
# Code Review Skill
|
||||
|
||||
## When to Use
|
||||
- User requests code review
|
||||
- Need to evaluate code quality
|
||||
- Looking for bugs or issues
|
||||
- Checking for best practices
|
||||
- Assessing security vulnerabilities
|
||||
- Reviewing performance considerations
|
||||
|
||||
## Code Review Checklist
|
||||
|
||||
### Functionality
|
||||
- [ ] Does the code implement the required features?
|
||||
- [ ] Are edge cases handled properly?
|
||||
- [ ] Does it handle errors gracefully?
|
||||
- [ ] Are there any obvious bugs?
|
||||
|
||||
### Code Quality
|
||||
- [ ] Is the code readable and well-structured?
|
||||
- [ ] Are variable and function names descriptive?
|
||||
- [ ] Is there unnecessary code duplication?
|
||||
- [ ] Are comments clear and helpful?
|
||||
|
||||
### Performance
|
||||
- [ ] Are there any performance bottlenecks?
|
||||
- [ ] Are data structures chosen appropriately?
|
||||
- [ ] Are there inefficient loops or operations?
|
||||
- [ ] Is caching appropriate?
|
||||
|
||||
### Security
|
||||
- [ ] Are there any security vulnerabilities?
|
||||
- [ ] Is user input properly validated?
|
||||
- [ ] Are sensitive data handled correctly?
|
||||
- [ ] Are there injection risks?
|
||||
|
||||
### Best Practices
|
||||
- [ ] Does it follow language conventions?
|
||||
- [ ] Are common patterns used appropriately?
|
||||
- [ ] Is the code modular and reusable?
|
||||
- [ ] Are dependencies managed properly?
|
||||
|
||||
## Review Structure
|
||||
|
||||
### 1. Summary
|
||||
- Brief overview of what the code does
|
||||
- Overall impression
|
||||
- Key strengths and weaknesses
|
||||
|
||||
### 2. Issues by Category
|
||||
|
||||
#### Critical Issues
|
||||
```markdown
|
||||
**Issue**: [Brief description]
|
||||
**Location**: [File:Line]
|
||||
**Impact**: [Why this matters]
|
||||
**Suggestion**: [How to fix]
|
||||
```
|
||||
|
||||
#### Style and Convention Issues
|
||||
```markdown
|
||||
**Issue**: [Brief description]
|
||||
**Location**: [File:Line]
|
||||
**Suggestion**: [How to fix]
|
||||
```
|
||||
|
||||
#### Optimization Opportunities
|
||||
```markdown
|
||||
**Opportunity**: [Brief description]
|
||||
**Location**: [File:Line]
|
||||
**Current**: [Current approach]
|
||||
**Suggested**: [Better approach]
|
||||
**Impact**: [Expected improvement]
|
||||
```
|
||||
|
||||
#### Best Practices
|
||||
```markdown
|
||||
**Suggestion**: [Improvement]
|
||||
**Location**: [File:Line]
|
||||
**Reason**: [Why this is better]
|
||||
```
|
||||
|
||||
### 3. Positive Feedback
|
||||
- Well-implemented features
|
||||
- Good practices observed
|
||||
- Notable strengths
|
||||
|
||||
### 4. Recommendations
|
||||
- Prioritized list of improvements
|
||||
- Long-term suggestions
|
||||
- Additional resources
|
||||
|
||||
## Common Patterns to Check
|
||||
|
||||
### Python
|
||||
- Use list comprehensions appropriately
|
||||
- Follow PEP 8 guidelines
|
||||
- Use context managers (`with` statements)
|
||||
- Implement `__str__` and `__repr__`
|
||||
- Use type hints
|
||||
- Handle exceptions properly
|
||||
- Avoid mutable default arguments
|
||||
|
||||
### JavaScript/TypeScript
|
||||
- Use `const` and `let` instead of `var`
|
||||
- Use arrow functions appropriately
|
||||
- Handle promises correctly
|
||||
- Avoid implicit globals
|
||||
- Use modern ES6+ features
|
||||
- Properly scope variables
|
||||
|
||||
### SQL
|
||||
- Use parameterized queries
|
||||
- Index common query columns
|
||||
- Avoid SELECT *
|
||||
- Use appropriate JOIN types
|
||||
- Handle NULL values correctly
|
||||
- Optimize subqueries
|
||||
|
||||
## Security Checks
|
||||
|
||||
### Input Validation
|
||||
```python
|
||||
# Bad
|
||||
user_input = request.form.get('data')
|
||||
# Direct use without validation
|
||||
|
||||
# Good
|
||||
user_input = request.form.get('data', '').strip()
|
||||
if not is_valid_input(user_input):
|
||||
raise ValueError("Invalid input")
|
||||
```
|
||||
|
||||
### SQL Injection
|
||||
```python
|
||||
# Bad
|
||||
query = f"SELECT * FROM users WHERE name = '{name}'"
|
||||
|
||||
# Good
|
||||
query = "SELECT * FROM users WHERE name = %s"
|
||||
cursor.execute(query, (name,))
|
||||
```
|
||||
|
||||
### XSS Prevention
|
||||
```python
|
||||
# Bad
|
||||
return f"<div>{user_content}</div>"
|
||||
|
||||
# Good
|
||||
from markupsafe import escape
|
||||
return f"<div>{escape(user_content)}</div>"
|
||||
```
|
||||
|
||||
## Code Review Principles
|
||||
|
||||
1. **Be Constructive**: Focus on improvement, not criticism
|
||||
2. **Be Specific**: Point to exact locations and issues
|
||||
3. **Provide Context**: Explain why something is a problem
|
||||
4. **Offer Solutions**: Suggest how to fix issues
|
||||
5. **Be Thorough**: Don't miss important issues
|
||||
6. **Be Timely**: Review code while it's fresh
|
||||
7. **Be Respectful**: Consider the author's perspective
|
||||
|
||||
## Performance Considerations
|
||||
|
||||
### Time Complexity
|
||||
- Identify O(n²) operations that could be O(n log n) or O(n)
|
||||
- Check nested loops
|
||||
- Look for unnecessary repeated computations
|
||||
|
||||
### Space Complexity
|
||||
- Check for memory leaks
|
||||
- Consider using generators instead of lists
|
||||
- Release resources when done
|
||||
|
||||
### Database Queries
|
||||
- N+1 query problems
|
||||
- Missing indexes
|
||||
- Unnecessary joins
|
||||
- Fetching too much data
|
||||
|
||||
## Example Review Output
|
||||
|
||||
```markdown
|
||||
# Code Review: user_authentication.py
|
||||
|
||||
## Summary
|
||||
The code implements user authentication with JWT tokens. Overall, it's well-structured
|
||||
but has some security concerns and opportunities for improvement.
|
||||
|
||||
## Critical Issues
|
||||
|
||||
**Issue**: Hardcoded secret key
|
||||
**Location**: Line 15
|
||||
**Impact**: Security vulnerability - JWT secret should be in environment
|
||||
**Suggestion**: Move to `os.environ.get('JWT_SECRET_KEY')`
|
||||
|
||||
**Issue**: SQL injection vulnerability
|
||||
**Location**: Line 42
|
||||
**Impact**: Attackers could execute arbitrary SQL
|
||||
**Suggestion**: Use parameterized queries
|
||||
|
||||
## Style and Convention Issues
|
||||
|
||||
**Issue**: Missing type hints
|
||||
**Location**: Functions throughout
|
||||
**Suggestion**: Add type hints for better IDE support and documentation
|
||||
|
||||
## Optimization Opportunities
|
||||
|
||||
**Opportunity**: Repeated password hashing
|
||||
**Location**: Line 58
|
||||
**Current**: Hashing password on every validation
|
||||
**Suggested**: Cache hashed password or use constant-time comparison
|
||||
**Impact**: Performance improvement for authentication
|
||||
|
||||
## Positive Feedback
|
||||
- Good error handling overall
|
||||
- Clean function separation
|
||||
- Good use of logging
|
||||
|
||||
## Recommendations (Prioritized)
|
||||
1. Fix security vulnerabilities immediately
|
||||
2. Add comprehensive tests
|
||||
3. Add type hints throughout
|
||||
4. Consider using a password hashing library
|
||||
5. Add rate limiting
|
||||
```
|
||||
|
||||
## Resources
|
||||
|
||||
- [PEP 8 - Style Guide](https://peps.python.org/pep-0008/)
|
||||
- [Clean Code](https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882)
|
||||
- [Effective Java](https://www.amazon.com/Effective-Java-Joshua-Bloch/dp/0134685997)
|
||||
- [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)
|
||||
@@ -1,97 +0,0 @@
|
||||
---
|
||||
name: web-research
|
||||
description: Structured approach to conducting thorough web research
|
||||
version: 1.0.0
|
||||
author: DB-GPT Team
|
||||
skill_type: research
|
||||
tags: [web, research, analysis]
|
||||
allowed-tools: web-search
|
||||
license: MIT
|
||||
---
|
||||
|
||||
# Web Research Skill
|
||||
|
||||
## When to Use
|
||||
- User asks you to research a topic
|
||||
- You need to gather information from the web
|
||||
- Research requires a structured approach
|
||||
- User wants comprehensive information on a subject
|
||||
|
||||
## Workflow
|
||||
|
||||
### 1. Define Research Scope
|
||||
- Clarify the research topic
|
||||
- Identify key questions to answer
|
||||
- Determine time period and geographic scope
|
||||
- Note any constraints or preferences
|
||||
|
||||
### 2. Search for Information
|
||||
- Use web-search tools to find relevant sources
|
||||
- Search for multiple keywords and phrases
|
||||
- Include both popular and specialized sources
|
||||
- Search across different domains (news, academic, blogs)
|
||||
|
||||
### 3. Evaluate Sources
|
||||
- Check source credibility and authority
|
||||
- Identify potential biases
|
||||
- Verify information across multiple sources
|
||||
- Consider publication dates for currency
|
||||
|
||||
### 4. Synthesize Findings
|
||||
- Organize information by theme
|
||||
- Identify common patterns and disagreements
|
||||
- Highlight key insights and statistics
|
||||
- Note gaps in available information
|
||||
|
||||
### 5. Present Results
|
||||
- Structure findings clearly
|
||||
- Use headings and bullet points for readability
|
||||
- Include sources and citations
|
||||
- Provide summary and conclusions
|
||||
|
||||
## Best Practices
|
||||
|
||||
- Start with broad searches, then narrow down
|
||||
- Cross-reference information from multiple sources
|
||||
- Be transparent about uncertainty
|
||||
- Cite sources when possible
|
||||
- Use quotes for key information
|
||||
- Organize findings logically
|
||||
|
||||
## Example Output Structure
|
||||
|
||||
```markdown
|
||||
# Research: [Topic]
|
||||
|
||||
## Overview
|
||||
[Brief summary of findings]
|
||||
|
||||
## Key Findings
|
||||
- Finding 1
|
||||
- Finding 2
|
||||
- Finding 3
|
||||
|
||||
## Details
|
||||
[Detailed information organized by theme]
|
||||
|
||||
## Sources
|
||||
- Source 1
|
||||
- Source 2
|
||||
```
|
||||
|
||||
## Tips for Deep Research
|
||||
|
||||
- Use specific search terms for better results
|
||||
- Try variations of keywords
|
||||
- Look for both recent and foundational sources
|
||||
- Check for opposing viewpoints
|
||||
- Consider searching in different languages if relevant
|
||||
- Look for official reports and studies
|
||||
|
||||
## Common Mistakes to Avoid
|
||||
|
||||
- Relying on a single source
|
||||
- Ignoring source credibility
|
||||
- Not verifying facts
|
||||
- Overlooking recent developments
|
||||
- Misrepresenting source information
|
||||
@@ -514,6 +514,109 @@ const HtmlTabbedRenderer: React.FC<{ code?: ExecutionOutput; html: ExecutionOutp
|
||||
|
||||
HtmlTabbedRenderer.displayName = 'HtmlTabbedRenderer';
|
||||
|
||||
/** Tabbed code-execution renderer: shows images vs code+results as switchable tabs when images exist */
|
||||
const CodeExecutionRenderer: React.FC<{
|
||||
group: { codes: ExecutionOutput[]; results: ExecutionOutput[]; images: ExecutionOutput[] };
|
||||
}> = memo(({ group }) => {
|
||||
const hasImages = group.images.length > 0;
|
||||
const [activeTab, setActiveTab] = useState<'chart' | 'code'>(hasImages ? 'chart' : 'code');
|
||||
|
||||
const codeContent = (
|
||||
<>
|
||||
<div className='relative overflow-auto flex-1 min-h-[100px]'>
|
||||
<span className='sticky top-0 right-0 float-right z-10 text-[10px] text-gray-400 bg-gray-800/80 px-2 py-0.5 rounded mr-2 mt-2'>
|
||||
代码
|
||||
</span>
|
||||
<CodePreview
|
||||
code={group.codes.map(c => String(c.content)).join('\n')}
|
||||
language='python'
|
||||
customStyle={{ background: '#0f172a', margin: 0, borderRadius: 0 }}
|
||||
/>
|
||||
</div>
|
||||
{group.results.length > 0 && (
|
||||
<>
|
||||
<div className='border-t border-gray-700/50 shrink-0' />
|
||||
<div className='relative overflow-auto bg-gray-900 flex-1 min-h-[60px]'>
|
||||
<span className='sticky top-0 right-0 float-right z-10 text-[10px] text-gray-400 bg-gray-800/80 px-2 py-0.5 rounded mr-2 mt-2'>
|
||||
执行结果
|
||||
</span>
|
||||
<div className='px-4 py-3 text-sm text-green-400 font-mono whitespace-pre-wrap leading-relaxed'>
|
||||
{group.results.map(r => String(r.content)).join('\n')}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
||||
const imageContent = (
|
||||
<div className='p-3 space-y-2 bg-gray-50 dark:bg-gray-900/50 flex-1 min-h-0 overflow-auto'>
|
||||
{group.images.map((img, imgIdx) => (
|
||||
<div key={`img-${imgIdx}`} className='rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700'>
|
||||
<img
|
||||
src={resolveImageUrl(
|
||||
typeof img.content === 'string' ? img.content : img.content?.url || img.content?.src || String(img.content),
|
||||
)}
|
||||
alt='Generated chart'
|
||||
className='w-full h-auto object-contain'
|
||||
style={{ maxHeight: 600 }}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
|
||||
// No images — just code + results, no tabs
|
||||
if (!hasImages) {
|
||||
return (
|
||||
<div className='rounded-xl overflow-hidden border border-gray-700/50 flex flex-col flex-1 min-h-0'>
|
||||
{codeContent}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Images exist — tabbed view
|
||||
return (
|
||||
<div className='rounded-xl overflow-hidden border border-gray-200 dark:border-gray-700 flex flex-col flex-1 min-h-0'>
|
||||
<div className='flex items-center gap-0 bg-white dark:bg-[#111217] border-b border-gray-200 dark:border-gray-700 shrink-0'>
|
||||
<button
|
||||
onClick={() => setActiveTab('chart')}
|
||||
className={classNames(
|
||||
'px-4 py-2 text-xs font-medium transition-colors relative',
|
||||
activeTab === 'chart'
|
||||
? 'text-gray-900 dark:text-gray-100'
|
||||
: 'text-gray-400 hover:text-gray-600 dark:hover:text-gray-300',
|
||||
)}
|
||||
>
|
||||
<FileImageOutlined className='mr-1.5' />
|
||||
图表
|
||||
{activeTab === 'chart' && (
|
||||
<div className='absolute bottom-0 left-0 right-0 h-[2px] bg-gray-900 dark:bg-gray-100 rounded-full' />
|
||||
)}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setActiveTab('code')}
|
||||
className={classNames(
|
||||
'px-4 py-2 text-xs font-medium transition-colors relative',
|
||||
activeTab === 'code'
|
||||
? 'text-gray-900 dark:text-gray-100'
|
||||
: 'text-gray-400 hover:text-gray-600 dark:hover:text-gray-300',
|
||||
)}
|
||||
>
|
||||
<CodeOutlined className='mr-1.5' />
|
||||
代码
|
||||
{activeTab === 'code' && (
|
||||
<div className='absolute bottom-0 left-0 right-0 h-[2px] bg-gray-900 dark:bg-gray-100 rounded-full' />
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
{activeTab === 'chart' ? imageContent : codeContent}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
CodeExecutionRenderer.displayName = 'CodeExecutionRenderer';
|
||||
|
||||
// Main Component
|
||||
const ManusRightPanel: React.FC<ManusRightPanelProps> = ({
|
||||
activeStep,
|
||||
@@ -896,50 +999,7 @@ const ManusRightPanel: React.FC<ManusRightPanelProps> = ({
|
||||
<div className='flex-1 min-h-0 p-4 flex flex-col space-y-3 overflow-y-auto'>
|
||||
{outputGroups.map((group, gIdx) =>
|
||||
group.type === 'code-execution' ? (
|
||||
<div key={`group-${gIdx}`} className='rounded-xl overflow-hidden border border-gray-700/50 flex flex-col flex-1 min-h-0'>
|
||||
<div className='relative overflow-auto flex-1 min-h-[100px]'>
|
||||
<span className='sticky top-0 right-0 float-right z-10 text-[10px] text-gray-400 bg-gray-800/80 px-2 py-0.5 rounded mr-2 mt-2'>
|
||||
代码
|
||||
</span>
|
||||
<CodePreview
|
||||
code={group.codes.map(c => String(c.content)).join('\n')}
|
||||
language='python'
|
||||
customStyle={{ background: '#0f172a', margin: 0, borderRadius: 0 }}
|
||||
/>
|
||||
</div>
|
||||
{group.results.length > 0 && (
|
||||
<>
|
||||
<div className='border-t border-gray-700/50 shrink-0' />
|
||||
<div className='relative overflow-auto bg-gray-900 flex-1 min-h-[60px]'>
|
||||
<span className='sticky top-0 right-0 float-right z-10 text-[10px] text-gray-400 bg-gray-800/80 px-2 py-0.5 rounded mr-2 mt-2'>
|
||||
执行结果
|
||||
</span>
|
||||
<div className='px-4 py-3 text-sm text-green-400 font-mono whitespace-pre-wrap leading-relaxed'>
|
||||
{group.results.map(r => String(r.content)).join('\n')}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{group.images.length > 0 && (
|
||||
<>
|
||||
<div className='border-t border-gray-700/50 shrink-0' />
|
||||
<div className='p-3 space-y-2 bg-gray-50 dark:bg-gray-900/50'>
|
||||
{group.images.map((img, imgIdx) => (
|
||||
<div key={`img-${imgIdx}`} className='rounded-lg overflow-hidden border border-gray-200 dark:border-gray-700'>
|
||||
<img
|
||||
src={resolveImageUrl(
|
||||
typeof img.content === 'string' ? img.content : img.content?.url || img.content?.src || String(img.content),
|
||||
)}
|
||||
alt='Generated chart'
|
||||
className='w-full h-auto object-contain'
|
||||
style={{ maxHeight: 600 }}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<CodeExecutionRenderer key={`group-${gIdx}`} group={group} />
|
||||
) : group.type === 'html-tabbed' ? (
|
||||
<HtmlTabbedRenderer key={`html-tabbed-${gIdx}`} code={group.code} html={group.html} />
|
||||
) : (
|
||||
|
||||
@@ -1781,7 +1781,7 @@ const Playground: NextPage = () => {
|
||||
{/* Top Header */}
|
||||
<div className='h-16 flex items-center justify-between px-8 border-b border-gray-200 dark:border-gray-800 bg-white/80 dark:bg-[#111217]/80 backdrop-blur sticky top-0 z-20'>
|
||||
<div className='flex items-center gap-2 text-sm font-medium text-gray-700 dark:text-gray-300 px-2 py-1 rounded-md'>
|
||||
<span>DB-GPT 0.6.0 Data Edition</span>
|
||||
<span>DB-GPT</span>
|
||||
</div>
|
||||
<div className='flex items-center gap-4'>
|
||||
{messages.length > 0 && (
|
||||
|
||||
Reference in New Issue
Block a user