@gotza02/sequential-thinking 10000.1.5 → 10000.1.7
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/CLAUDE.md +215 -0
- package/README.md +24 -1
- package/dist/dashboard/server.js +97 -0
- package/dist/index.js +2 -0
- package/dist/intelligent-code.d.ts +157 -0
- package/dist/intelligent-code.js +779 -0
- package/dist/tools/intelligent-code.d.ts +7 -0
- package/dist/tools/intelligent-code.js +387 -0
- package/dist/tools/sports/tools/match.js +221 -166
- package/package.json +3 -2
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# SmartAgent Elite Controller - System Instructions
|
|
2
|
+
|
|
3
|
+
You are an AI assistant powered by the Sequential Thinking MCP server (@gotza02/sequential-thinking@10000.1.7).
|
|
4
|
+
|
|
5
|
+
## Critical Prime Directives
|
|
6
|
+
|
|
7
|
+
1. **ALWAYS use sequentialthinking tool for complex tasks**
|
|
8
|
+
- Flow: Analysis → Planning → [Critique] → Execution → Observation → Reflection
|
|
9
|
+
- Confidence scoring: Track your certainty level (0-100)
|
|
10
|
+
- Block-based context: Group related thoughts
|
|
11
|
+
|
|
12
|
+
2. **NEVER hallucinate information**
|
|
13
|
+
- Use web search (Brave/Exa/DuckDuckGo) for up-to-date facts
|
|
14
|
+
- Use sports APIs for match data
|
|
15
|
+
- Cache results appropriately
|
|
16
|
+
|
|
17
|
+
3. **Safety protocols are mandatory**
|
|
18
|
+
- Auto-backup before file edits via deep_code_edit
|
|
19
|
+
- Ask human approval for destructive actions
|
|
20
|
+
- Path traversal checks enforced
|
|
21
|
+
|
|
22
|
+
## Complete Tool Reference
|
|
23
|
+
|
|
24
|
+
### 🧠 Sequential Thinking Tools
|
|
25
|
+
| Tool | Purpose | When to Use |
|
|
26
|
+
|------|---------|-------------|
|
|
27
|
+
| `sequentialthinking` | Structured problem-solving | Complex tasks requiring multiple steps |
|
|
28
|
+
| `analysis` | Break down requirements | Understanding the problem |
|
|
29
|
+
| `planning` | Formulate execution plan | Before taking action |
|
|
30
|
+
| `critique` | Review plan for risks | High-stakes decisions |
|
|
31
|
+
| `execution` | Perform tool calls | During implementation |
|
|
32
|
+
| `observation` | Record tool outputs | After each tool call |
|
|
33
|
+
| `reflection` | Self-review and adjust | When stuck or after errors |
|
|
34
|
+
| `hypothesis` | Form new theories | Based on observations |
|
|
35
|
+
|
|
36
|
+
### ⚽ Sports Intelligence Tools
|
|
37
|
+
| Tool | Purpose | When to Use |
|
|
38
|
+
|------|---------|-------------|
|
|
39
|
+
| `analyze_football_match_v2` | Comprehensive match analysis | Need detailed text analysis |
|
|
40
|
+
| `analyze_football_match_structured` | JSON output with probabilities | Need programmatic data |
|
|
41
|
+
| `get_live_scores` | Live football scores | Real-time match updates |
|
|
42
|
+
| `get_match_details` | Match info by ID | Have specific match ID |
|
|
43
|
+
| `get_team_stats` | Team performance data | Team analysis needed |
|
|
44
|
+
| `compare_teams` | H2H team comparison | Compare two teams |
|
|
45
|
+
| `get_player_stats` | Player statistics | Individual player analysis |
|
|
46
|
+
| `odds_comparison` | Betting odds across markets | Find best odds |
|
|
47
|
+
| `value_bet_calculator` | Kelly Criterion calculation | Betting recommendations |
|
|
48
|
+
| `track_prediction` | Log bet/prediction | Start tracking a pick |
|
|
49
|
+
| `resolve_prediction` | Update bet result | Mark win/loss/void |
|
|
50
|
+
| `analyze_roi` | Performance analytics | Review betting history |
|
|
51
|
+
| `get_pending_predictions` | List unresolved bets | Check open positions |
|
|
52
|
+
|
|
53
|
+
**Sports Tool Priority:**
|
|
54
|
+
1. Try `analyze_football_match_structured` first (gives JSON with confidence ranges)
|
|
55
|
+
2. Fall back to `analyze_football_match_v2` for detailed narrative
|
|
56
|
+
3. Use `value_bet_calculator` for specific betting math
|
|
57
|
+
4. Always `track_prediction` after making picks
|
|
58
|
+
|
|
59
|
+
### 🔍 Web Search & Research Tools
|
|
60
|
+
| Tool | Purpose | API Key Required |
|
|
61
|
+
|------|---------|------------------|
|
|
62
|
+
| `brave_web_search` | General web search | BRAVE_API_KEY |
|
|
63
|
+
| `exa_web_search` | Neural/semantic search | EXA_API_KEY |
|
|
64
|
+
| `duckduckgo_search` | Anonymous search | None |
|
|
65
|
+
| `web_read` | Extract URL content | None |
|
|
66
|
+
| `web_extract` | Structured data extraction | None |
|
|
67
|
+
|
|
68
|
+
**Search Strategy:**
|
|
69
|
+
- Current events/news → `brave_web_search`
|
|
70
|
+
- Research/technical → `exa_web_search`
|
|
71
|
+
- Fallback/no key → `duckduckgo_search`
|
|
72
|
+
- Deep dive → `web_read` on top results
|
|
73
|
+
|
|
74
|
+
### 💻 Code Management Tools
|
|
75
|
+
| Tool | Purpose | Safety Features |
|
|
76
|
+
|------|---------|-----------------|
|
|
77
|
+
| `deep_code_edit` | Structural code changes | Auto-backup, validation |
|
|
78
|
+
| `add_code_snippet` | Store reusable patterns | Indexed for search |
|
|
79
|
+
| `search_code` | Semantic code search | Graph-based relationships |
|
|
80
|
+
| `get_project_graph` | Codebase structure analysis | File dependencies |
|
|
81
|
+
| `get_file_relationships` | Find related files | Import/dependency graph |
|
|
82
|
+
|
|
83
|
+
### 🧠 Intelligent Code Analysis Tools (v10000.1.7+)
|
|
84
|
+
| Tool | Purpose | Features |
|
|
85
|
+
|------|---------|----------|
|
|
86
|
+
| `intelligent_code_analyze` | Deep code analysis | Quality scoring, metrics, issue detection |
|
|
87
|
+
| `intelligent_impact_analysis` | Change prediction | Risk score, affected files, test recommendations |
|
|
88
|
+
| `intelligent_semantic_search` | Concept-based search | Find code by meaning, not just text |
|
|
89
|
+
| `intelligent_refactor_suggest` | Refactoring ideas | AI suggestions with before/after code |
|
|
90
|
+
| `intelligent_code_compare` | Code comparison | Diff analysis with statistics |
|
|
91
|
+
| `intelligent_code_autofix` | Auto-fix code issues | Trailing whitespace, semicolons, imports |
|
|
92
|
+
|
|
93
|
+
**Intelligent Code Analysis Protocol:**
|
|
94
|
+
1. Before major changes → `intelligent_impact_analysis` (know the risk)
|
|
95
|
+
2. Understanding code → `intelligent_code_analyze` (quality + metrics)
|
|
96
|
+
3. Finding related code → `intelligent_semantic_search` (concept search)
|
|
97
|
+
4. Improving code → `intelligent_refactor_suggest` (actionable ideas)
|
|
98
|
+
5. Code reviews → `intelligent_code_compare` (detailed diffs)
|
|
99
|
+
6. Clean up issues → `intelligent_code_autofix` (dryRun first, then apply)
|
|
100
|
+
7. Monitor quality → Check `http://localhost:3001/api/code-quality` for project overview
|
|
101
|
+
|
|
102
|
+
**Code Edit Protocol:**
|
|
103
|
+
1. Before changes: Run `intelligent_impact_analysis` to assess risk
|
|
104
|
+
2. Always use `deep_code_edit` (not raw file writes)
|
|
105
|
+
3. Review backup location if rollback needed
|
|
106
|
+
4. Use `search_code` first to understand context
|
|
107
|
+
5. Validate changes with `get_project_graph`
|
|
108
|
+
|
|
109
|
+
### 📝 Knowledge & Notes Tools
|
|
110
|
+
| Tool | Purpose | Persistence |
|
|
111
|
+
|------|---------|-------------|
|
|
112
|
+
| `add_note` | Create/store notes | Saved to disk |
|
|
113
|
+
| `search_notes` | Find existing notes | Full-text search |
|
|
114
|
+
| `get_note` | Retrieve specific note | By ID |
|
|
115
|
+
| `update_note` | Modify existing note | Versioned |
|
|
116
|
+
| `create_knowledge_node` | Add to knowledge graph | With relationships |
|
|
117
|
+
| `query_knowledge_graph` | Traverse relationships | Multi-hop queries |
|
|
118
|
+
| `add_knowledge_edge` | Connect nodes | Weighted relationships |
|
|
119
|
+
|
|
120
|
+
### 👤 Human Interface Tools
|
|
121
|
+
| Tool | Purpose | Use When |
|
|
122
|
+
|------|---------|----------|
|
|
123
|
+
| `ask_human` | Request clarification | Ambiguous requirements |
|
|
124
|
+
| `request_workflow_approval` | Multi-step approval | Destructive workflows |
|
|
125
|
+
| `send_notification` | Alert human user | Important updates |
|
|
126
|
+
|
|
127
|
+
### 🛠️ Utility Tools
|
|
128
|
+
| Tool | Purpose | Notes |
|
|
129
|
+
|------|---------|-------|
|
|
130
|
+
| `get_caller_info` | Get current context | Debug/diagnostics |
|
|
131
|
+
| `get_server_metrics` | Performance stats | Resource monitoring |
|
|
132
|
+
| `validate_path` | Security check | Path traversal prevention |
|
|
133
|
+
| `generate_cache_key` | Create cache keys | Consistent hashing |
|
|
134
|
+
|
|
135
|
+
## Tool Selection Flowchart
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
Need information?
|
|
139
|
+
├── Time-sensitive/current → web_search (Brave/Exa)
|
|
140
|
+
├── Sports data → analyze_football_match_*
|
|
141
|
+
├── Code understanding → search_code / get_project_graph
|
|
142
|
+
├── Past notes → search_notes
|
|
143
|
+
└── General knowledge → sequentialthinking
|
|
144
|
+
|
|
145
|
+
Need to take action?
|
|
146
|
+
├── Code changes → deep_code_edit
|
|
147
|
+
├── Code analysis → intelligent_code_analyze
|
|
148
|
+
├── Impact prediction → intelligent_impact_analysis
|
|
149
|
+
├── Refactoring ideas → intelligent_refactor_suggest
|
|
150
|
+
├── Auto-fix issues → intelligent_code_autofix
|
|
151
|
+
├── Store knowledge → add_note / create_knowledge_node
|
|
152
|
+
├── Track sports bet → track_prediction
|
|
153
|
+
└── Complex workflow → sequentialthinking → execution
|
|
154
|
+
|
|
155
|
+
Need human input?
|
|
156
|
+
├── Quick question → ask_human
|
|
157
|
+
├── Destructive action → request_workflow_approval
|
|
158
|
+
└── Important update → send_notification
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Environment Variables
|
|
162
|
+
|
|
163
|
+
Required for full functionality:
|
|
164
|
+
- `BRAVE_API_KEY` - Brave Search (web search)
|
|
165
|
+
- `EXA_API_KEY` - Exa Neural Search (research)
|
|
166
|
+
- `API_FOOTBALL_KEY` - API-Football (sports data)
|
|
167
|
+
- `FOOTBALL_DATA_KEY` - Football-Data.org (backup sports)
|
|
168
|
+
|
|
169
|
+
Optional:
|
|
170
|
+
- `SPORTS_DB_KEY` - TheSportsDB (additional sports)
|
|
171
|
+
- `GOOGLE_SEARCH_API_KEY` - Google Custom Search
|
|
172
|
+
- `GOOGLE_SEARCH_CX` - Google Search Engine ID
|
|
173
|
+
|
|
174
|
+
## Confidence Scoring Protocol
|
|
175
|
+
|
|
176
|
+
Track your certainty level in sequential thinking:
|
|
177
|
+
- **100-90**: Very high confidence, proceed directly
|
|
178
|
+
- **89-70**: High confidence, brief verification
|
|
179
|
+
- **69-50**: Medium confidence, use observation step
|
|
180
|
+
- **49-30**: Low confidence, ask_human for clarification
|
|
181
|
+
- **29-0**: Very low confidence, STOP and reflect
|
|
182
|
+
|
|
183
|
+
## Loop Prevention Rules
|
|
184
|
+
|
|
185
|
+
1. If same error occurs 3 times → STOP and ask_human
|
|
186
|
+
2. If confidence drops below 50 → Use reflection step
|
|
187
|
+
3. If stuck for 5+ thought cycles → Branch or ask_human
|
|
188
|
+
4. If tool fails repeatedly → Try alternative tool
|
|
189
|
+
|
|
190
|
+
## Response Format Guidelines
|
|
191
|
+
|
|
192
|
+
For sports analysis:
|
|
193
|
+
```
|
|
194
|
+
📊 Data Quality: XX/100
|
|
195
|
+
🏠 Home: X% (range: X%-X%)
|
|
196
|
+
🤝 Draw: X% (range: X%-X%)
|
|
197
|
+
✈️ Away: X% (range: X%-X%)
|
|
198
|
+
💎 Value Bets: [list if any]
|
|
199
|
+
🏆 Best Bet: [selection]
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
For code changes:
|
|
203
|
+
```
|
|
204
|
+
📝 Files Modified: [list]
|
|
205
|
+
💾 Backup Location: [path]
|
|
206
|
+
✅ Validation: [tests/status]
|
|
207
|
+
🔍 Impact Analysis: [use intelligent_impact_analysis]
|
|
208
|
+
📊 Code Quality: [use intelligent_code_analyze for metrics]
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Error Recovery
|
|
212
|
+
|
|
213
|
+
Tool failure → Log error → Try alternative → If stuck, ask_human
|
|
214
|
+
API limit → Switch provider → Use cache → If exhausted, inform user
|
|
215
|
+
Path error → Validate_path → Check permissions → If persists, ask_human
|
package/README.md
CHANGED
|
@@ -115,6 +115,16 @@ Add to your `~/.claude/CLAUDE.md` or project-specific `.claude/CLAUDE.md`:
|
|
|
115
115
|
| `search_code` | Semantic code search |
|
|
116
116
|
| `get_project_graph` | Analyze codebase structure |
|
|
117
117
|
|
|
118
|
+
### 🧠 Intelligent Code Analysis (v10000.1.7+)
|
|
119
|
+
| Tool | Description |
|
|
120
|
+
|------|-------------|
|
|
121
|
+
| `intelligent_code_analyze` | AI-powered code analysis with quality scoring, metrics, and issue detection |
|
|
122
|
+
| `intelligent_impact_analysis` | Predict impact of code changes with risk scoring and affected files |
|
|
123
|
+
| `intelligent_semantic_search` | Search code by concept/meaning, not just text |
|
|
124
|
+
| `intelligent_refactor_suggest` | Get intelligent refactoring suggestions with code examples |
|
|
125
|
+
| `intelligent_code_compare` | Compare two code snippets or files with detailed diff analysis |
|
|
126
|
+
| `intelligent_code_autofix` | Auto-fix common issues (trailing whitespace, missing semicolons, optimize imports) |
|
|
127
|
+
|
|
118
128
|
### 📝 Knowledge & Notes Tools
|
|
119
129
|
| Tool | Description |
|
|
120
130
|
|------|-------------|
|
|
@@ -129,6 +139,10 @@ Add to your `~/.claude/CLAUDE.md` or project-specific `.claude/CLAUDE.md`:
|
|
|
129
139
|
| `ask_human` | Request human input/clarification |
|
|
130
140
|
| `request_workflow_approval` | Get approval for multi-step workflows |
|
|
131
141
|
|
|
142
|
+
## 📋 System Instructions
|
|
143
|
+
|
|
144
|
+
**Quick Start:** Copy [`CLAUDE.md`](./CLAUDE.md) to your `~/.claude/CLAUDE.md` or project root.
|
|
145
|
+
|
|
132
146
|
## 🤖 System Instructions for Claude Code
|
|
133
147
|
|
|
134
148
|
Add this to your Claude Code settings for optimal use:
|
|
@@ -146,13 +160,22 @@ CRITICAL DIRECTIVES:
|
|
|
146
160
|
- Use analyze_football_match_structured for JSON/probability data
|
|
147
161
|
- Check value_bet_calculator for betting recommendations
|
|
148
162
|
4. Use deep_code_edit for structural code changes (creates backups)
|
|
149
|
-
5.
|
|
163
|
+
5. For intelligent code analysis:
|
|
164
|
+
- Use intelligent_code_analyze for quality scoring and metrics
|
|
165
|
+
- Use intelligent_impact_analysis before making changes
|
|
166
|
+
- Use intelligent_semantic_search to find related code
|
|
167
|
+
- Use intelligent_refactor_suggest for improvement ideas
|
|
168
|
+
- Use intelligent_code_autofix to clean up common issues (dryRun first!)
|
|
169
|
+
6. Track predictions with track_prediction for ROI analysis
|
|
170
|
+
7. Check code quality dashboard at http://localhost:3001/api/code-quality
|
|
150
171
|
|
|
151
172
|
TOOL PRIORITY:
|
|
152
173
|
- Information needed → web_search (Brave/Exa/DuckDuckGo)
|
|
153
174
|
- Problem solving → sequentialthinking
|
|
154
175
|
- Sports data → analyze_football_match_* tools
|
|
155
176
|
- Code editing → deep_code_edit
|
|
177
|
+
- Code analysis → intelligent_code_analyze
|
|
178
|
+
- Change impact → intelligent_impact_analysis
|
|
156
179
|
- Human input → ask_human
|
|
157
180
|
|
|
158
181
|
SAFETY PROTOCOLS:
|
package/dist/dashboard/server.js
CHANGED
|
@@ -2,6 +2,8 @@ import * as http from 'http';
|
|
|
2
2
|
import * as fs from 'fs';
|
|
3
3
|
import * as path from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
+
import { ProjectKnowledgeGraph } from '../graph.js';
|
|
6
|
+
import { getIntelligentAnalyzer } from '../intelligent-code.js';
|
|
5
7
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
8
|
const __dirname = path.dirname(__filename);
|
|
7
9
|
export function startDashboard(port, historyPath) {
|
|
@@ -43,6 +45,10 @@ export function startDashboard(port, historyPath) {
|
|
|
43
45
|
res.end(data);
|
|
44
46
|
});
|
|
45
47
|
}
|
|
48
|
+
else if (req.url === '/api/code-quality') {
|
|
49
|
+
// Code Quality Dashboard API
|
|
50
|
+
handleCodeQualityRequest(res);
|
|
51
|
+
}
|
|
46
52
|
else {
|
|
47
53
|
res.writeHead(404);
|
|
48
54
|
res.end('Not found');
|
|
@@ -65,3 +71,94 @@ export function startDashboard(port, historyPath) {
|
|
|
65
71
|
});
|
|
66
72
|
});
|
|
67
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Handle code quality dashboard API request
|
|
76
|
+
*/
|
|
77
|
+
async function handleCodeQualityRequest(res) {
|
|
78
|
+
try {
|
|
79
|
+
// Find TypeScript/JavaScript files in src directory
|
|
80
|
+
const srcDir = path.join(process.cwd(), 'src');
|
|
81
|
+
const files = await findCodeFiles(srcDir);
|
|
82
|
+
// Analyze top 10 largest files
|
|
83
|
+
const fileStats = await Promise.all(files.map(async (file) => {
|
|
84
|
+
const stats = await fs.promises.stat(file);
|
|
85
|
+
return { file, size: stats.size };
|
|
86
|
+
}));
|
|
87
|
+
const largestFiles = fileStats
|
|
88
|
+
.sort((a, b) => b.size - a.size)
|
|
89
|
+
.slice(0, 10)
|
|
90
|
+
.map(f => f.file);
|
|
91
|
+
// Analyze each file
|
|
92
|
+
const graph = new ProjectKnowledgeGraph();
|
|
93
|
+
const analyzer = getIntelligentAnalyzer(graph);
|
|
94
|
+
const results = await Promise.all(largestFiles.map(async (file) => {
|
|
95
|
+
try {
|
|
96
|
+
const analysis = await analyzer.analyzeFile(file);
|
|
97
|
+
return {
|
|
98
|
+
file: path.relative(process.cwd(), file),
|
|
99
|
+
metrics: analysis.metrics,
|
|
100
|
+
quality: {
|
|
101
|
+
overall: analysis.quality.overall,
|
|
102
|
+
maintainability: analysis.quality.maintainability,
|
|
103
|
+
security: analysis.quality.security,
|
|
104
|
+
performance: analysis.quality.performance,
|
|
105
|
+
},
|
|
106
|
+
issueCount: analysis.quality.issues.length,
|
|
107
|
+
symbolCount: analysis.symbols.length,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
catch (e) {
|
|
111
|
+
return {
|
|
112
|
+
file: path.relative(process.cwd(), file),
|
|
113
|
+
error: 'Analysis failed',
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}));
|
|
117
|
+
// Calculate summary
|
|
118
|
+
const validResults = results.filter(r => !r.error);
|
|
119
|
+
const summary = {
|
|
120
|
+
totalFiles: files.length,
|
|
121
|
+
analyzedFiles: validResults.length,
|
|
122
|
+
averageComplexity: validResults.reduce((sum, r) => sum + r.metrics.complexity, 0) / validResults.length || 0,
|
|
123
|
+
averageMaintainability: validResults.reduce((sum, r) => sum + r.quality.maintainability, 0) / validResults.length || 0,
|
|
124
|
+
totalIssues: validResults.reduce((sum, r) => sum + r.issueCount, 0),
|
|
125
|
+
};
|
|
126
|
+
const response = {
|
|
127
|
+
summary,
|
|
128
|
+
files: results,
|
|
129
|
+
generatedAt: new Date().toISOString(),
|
|
130
|
+
};
|
|
131
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
132
|
+
res.end(JSON.stringify(response, null, 2));
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
res.writeHead(500, { 'Content-Type': 'application/json' });
|
|
136
|
+
res.end(JSON.stringify({
|
|
137
|
+
error: 'Failed to analyze code quality',
|
|
138
|
+
message: error instanceof Error ? error.message : String(error),
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Find all code files in directory
|
|
144
|
+
*/
|
|
145
|
+
async function findCodeFiles(dir) {
|
|
146
|
+
const files = [];
|
|
147
|
+
async function scan(currentDir) {
|
|
148
|
+
const entries = await fs.promises.readdir(currentDir, { withFileTypes: true });
|
|
149
|
+
for (const entry of entries) {
|
|
150
|
+
const fullPath = path.join(currentDir, entry.name);
|
|
151
|
+
if (entry.isDirectory()) {
|
|
152
|
+
// Skip node_modules, dist, etc.
|
|
153
|
+
if (!['node_modules', 'dist', '.git', 'coverage'].includes(entry.name)) {
|
|
154
|
+
await scan(fullPath);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
else if (entry.isFile() && /\.(ts|js|tsx|jsx)$/.test(entry.name) && !entry.name.endsWith('.d.ts')) {
|
|
158
|
+
files.push(fullPath);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
await scan(dir);
|
|
163
|
+
return files;
|
|
164
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { registerCodingTools } from './tools/coding.js';
|
|
|
19
19
|
import { registerCodeDbTools } from './tools/codestore.js';
|
|
20
20
|
import { registerHumanTools } from './tools/human.js';
|
|
21
21
|
import { registerSportsTools } from './tools/sports.js';
|
|
22
|
+
import { registerIntelligentCodeTools } from './tools/intelligent-code.js';
|
|
22
23
|
import { startDashboard } from './dashboard/server.js';
|
|
23
24
|
const __filename = fileURLToPath(import.meta.url);
|
|
24
25
|
const __dirname = dirname(__filename);
|
|
@@ -48,6 +49,7 @@ registerCodingTools(server, knowledgeGraph);
|
|
|
48
49
|
registerCodeDbTools(server, codeDb);
|
|
49
50
|
registerHumanTools(server);
|
|
50
51
|
registerSportsTools(server);
|
|
52
|
+
registerIntelligentCodeTools(server, knowledgeGraph);
|
|
51
53
|
async function runServer() {
|
|
52
54
|
const transport = new StdioServerTransport();
|
|
53
55
|
await server.connect(transport);
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* INTELLIGENT CODE MODULE
|
|
3
|
+
* AI-powered code analysis, semantic search, and smart refactoring
|
|
4
|
+
*/
|
|
5
|
+
import ts from 'typescript';
|
|
6
|
+
import { ProjectKnowledgeGraph } from './graph.js';
|
|
7
|
+
export interface CodeMetrics {
|
|
8
|
+
complexity: number;
|
|
9
|
+
linesOfCode: number;
|
|
10
|
+
commentRatio: number;
|
|
11
|
+
functionCount: number;
|
|
12
|
+
maxNestingDepth: number;
|
|
13
|
+
duplicateCode: number;
|
|
14
|
+
testCoverage?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface CodeQualityScore {
|
|
17
|
+
overall: number;
|
|
18
|
+
maintainability: number;
|
|
19
|
+
reliability: number;
|
|
20
|
+
security: number;
|
|
21
|
+
performance: number;
|
|
22
|
+
issues: QualityIssue[];
|
|
23
|
+
}
|
|
24
|
+
export interface QualityIssue {
|
|
25
|
+
type: 'error' | 'warning' | 'info';
|
|
26
|
+
category: 'complexity' | 'style' | 'security' | 'performance' | 'maintainability';
|
|
27
|
+
message: string;
|
|
28
|
+
line?: number;
|
|
29
|
+
column?: number;
|
|
30
|
+
severity: number;
|
|
31
|
+
suggestion?: string;
|
|
32
|
+
autoFixable: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface RefactoringSuggestion {
|
|
35
|
+
type: 'extract-method' | 'rename' | 'reorder' | 'simplify' | 'optimize-imports' | 'add-types';
|
|
36
|
+
description: string;
|
|
37
|
+
currentCode: string;
|
|
38
|
+
suggestedCode: string;
|
|
39
|
+
confidence: number;
|
|
40
|
+
impact: 'low' | 'medium' | 'high';
|
|
41
|
+
effort: 'quick' | 'moderate' | 'extensive';
|
|
42
|
+
benefits: string[];
|
|
43
|
+
}
|
|
44
|
+
export interface ImpactAnalysis {
|
|
45
|
+
filePath: string;
|
|
46
|
+
directImpacts: string[];
|
|
47
|
+
indirectImpacts: string[];
|
|
48
|
+
testFiles: string[];
|
|
49
|
+
riskScore: number;
|
|
50
|
+
breakingChanges: boolean;
|
|
51
|
+
estimatedReviewTime: number;
|
|
52
|
+
}
|
|
53
|
+
export interface SemanticSearchResult {
|
|
54
|
+
filePath: string;
|
|
55
|
+
relevance: number;
|
|
56
|
+
context: string;
|
|
57
|
+
matchedConcepts: string[];
|
|
58
|
+
codeSnippet: string;
|
|
59
|
+
}
|
|
60
|
+
export interface CodePattern {
|
|
61
|
+
name: string;
|
|
62
|
+
description: string;
|
|
63
|
+
examples: string[];
|
|
64
|
+
antiPattern?: string;
|
|
65
|
+
solution: string;
|
|
66
|
+
confidence: number;
|
|
67
|
+
}
|
|
68
|
+
export declare class IntelligentCodeAnalyzer {
|
|
69
|
+
private graph;
|
|
70
|
+
private program?;
|
|
71
|
+
private typeChecker?;
|
|
72
|
+
constructor(graph: ProjectKnowledgeGraph);
|
|
73
|
+
/**
|
|
74
|
+
* Comprehensive code analysis with metrics and quality scoring
|
|
75
|
+
*/
|
|
76
|
+
analyzeFile(filePath: string): Promise<{
|
|
77
|
+
metrics: CodeMetrics;
|
|
78
|
+
quality: CodeQualityScore;
|
|
79
|
+
ast: ts.SourceFile | null;
|
|
80
|
+
symbols: SymbolAnalysis[];
|
|
81
|
+
}>;
|
|
82
|
+
private calculateMetrics;
|
|
83
|
+
private analyzeQuality;
|
|
84
|
+
private analyzeSymbols;
|
|
85
|
+
private analyzeFunction;
|
|
86
|
+
private analyzeClass;
|
|
87
|
+
private analyzeInterface;
|
|
88
|
+
private extractJSDoc;
|
|
89
|
+
/**
|
|
90
|
+
* Smart impact analysis - predicts what will be affected by changes
|
|
91
|
+
*/
|
|
92
|
+
analyzeImpact(filePath: string, changeDescription?: string): Promise<ImpactAnalysis>;
|
|
93
|
+
private findRelatedTests;
|
|
94
|
+
/**
|
|
95
|
+
* Generate intelligent refactoring suggestions
|
|
96
|
+
*/
|
|
97
|
+
suggestRefactoring(filePath: string): Promise<RefactoringSuggestion[]>;
|
|
98
|
+
private findLongFunctions;
|
|
99
|
+
private findNestedConditionals;
|
|
100
|
+
private findAnyUsages;
|
|
101
|
+
/**
|
|
102
|
+
* Semantic code search - find code by concept, not just text
|
|
103
|
+
*/
|
|
104
|
+
semanticSearch(query: string, options?: {
|
|
105
|
+
filePattern?: string;
|
|
106
|
+
maxResults?: number;
|
|
107
|
+
}): Promise<SemanticSearchResult[]>;
|
|
108
|
+
private extractConcepts;
|
|
109
|
+
private calculateRelevance;
|
|
110
|
+
private extractRelevantSnippet;
|
|
111
|
+
private extractContext;
|
|
112
|
+
private getMatchingFiles;
|
|
113
|
+
/**
|
|
114
|
+
* Auto-fix common code issues
|
|
115
|
+
*/
|
|
116
|
+
autoFix(filePath: string, options?: {
|
|
117
|
+
fixUnusedImports?: boolean;
|
|
118
|
+
fixTrailingWhitespace?: boolean;
|
|
119
|
+
fixMissingSemicolons?: boolean;
|
|
120
|
+
optimizeImports?: boolean;
|
|
121
|
+
dryRun?: boolean;
|
|
122
|
+
}): Promise<{
|
|
123
|
+
fixes: Array<{
|
|
124
|
+
type: string;
|
|
125
|
+
line: number;
|
|
126
|
+
original: string;
|
|
127
|
+
fixed: string;
|
|
128
|
+
}>;
|
|
129
|
+
applied: boolean;
|
|
130
|
+
}>;
|
|
131
|
+
/**
|
|
132
|
+
* Detect code patterns and anti-patterns
|
|
133
|
+
*/
|
|
134
|
+
detectPatterns(filePath: string, sourceFile: ts.SourceFile): CodePattern[];
|
|
135
|
+
}
|
|
136
|
+
interface SymbolAnalysis {
|
|
137
|
+
name: string;
|
|
138
|
+
kind: 'function' | 'class' | 'interface' | 'method' | 'type';
|
|
139
|
+
params?: {
|
|
140
|
+
name: string;
|
|
141
|
+
type: string;
|
|
142
|
+
optional?: boolean;
|
|
143
|
+
}[];
|
|
144
|
+
returnType?: string;
|
|
145
|
+
isAsync?: boolean;
|
|
146
|
+
complexity?: number;
|
|
147
|
+
isExported: boolean;
|
|
148
|
+
documentation?: string;
|
|
149
|
+
methods?: SymbolAnalysis[];
|
|
150
|
+
properties?: {
|
|
151
|
+
name: string;
|
|
152
|
+
type: string;
|
|
153
|
+
optional?: boolean;
|
|
154
|
+
}[];
|
|
155
|
+
}
|
|
156
|
+
export declare function getIntelligentAnalyzer(graph: ProjectKnowledgeGraph): IntelligentCodeAnalyzer;
|
|
157
|
+
export {};
|