mycontext-cli 0.4.8 โ 0.4.9
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/README.md +101 -35
- package/dist/agents/communication/AgentCommunicationManager.d.ts +27 -0
- package/dist/agents/communication/AgentCommunicationManager.d.ts.map +1 -0
- package/dist/agents/communication/AgentCommunicationManager.js +293 -0
- package/dist/agents/communication/AgentCommunicationManager.js.map +1 -0
- package/dist/agents/evolution/CodeEvolutionEngine.d.ts +92 -0
- package/dist/agents/evolution/CodeEvolutionEngine.d.ts.map +1 -0
- package/dist/agents/evolution/CodeEvolutionEngine.js +639 -0
- package/dist/agents/evolution/CodeEvolutionEngine.js.map +1 -0
- package/dist/agents/implementations/ArchitectAgent.d.ts +39 -0
- package/dist/agents/implementations/ArchitectAgent.d.ts.map +1 -0
- package/dist/agents/implementations/ArchitectAgent.js +345 -0
- package/dist/agents/implementations/ArchitectAgent.js.map +1 -0
- package/dist/agents/implementations/CodeGenSubAgent.d.ts +12 -0
- package/dist/agents/implementations/CodeGenSubAgent.d.ts.map +1 -1
- package/dist/agents/implementations/CodeGenSubAgent.js +296 -43
- package/dist/agents/implementations/CodeGenSubAgent.js.map +1 -1
- package/dist/agents/implementations/PromptConstructorAgent.d.ts +50 -0
- package/dist/agents/implementations/PromptConstructorAgent.d.ts.map +1 -0
- package/dist/agents/implementations/PromptConstructorAgent.js +481 -0
- package/dist/agents/implementations/PromptConstructorAgent.js.map +1 -0
- package/dist/agents/implementations/SecurityAgent.d.ts +31 -0
- package/dist/agents/implementations/SecurityAgent.d.ts.map +1 -0
- package/dist/agents/implementations/SecurityAgent.js +453 -0
- package/dist/agents/implementations/SecurityAgent.js.map +1 -0
- package/dist/agents/intelligence/ProjectIntelligence.d.ts +127 -0
- package/dist/agents/intelligence/ProjectIntelligence.d.ts.map +1 -0
- package/dist/agents/intelligence/ProjectIntelligence.js +456 -0
- package/dist/agents/intelligence/ProjectIntelligence.js.map +1 -0
- package/dist/agents/interfaces/AgentCommunication.d.ts +65 -0
- package/dist/agents/interfaces/AgentCommunication.d.ts.map +1 -0
- package/dist/agents/interfaces/AgentCommunication.js +13 -0
- package/dist/agents/interfaces/AgentCommunication.js.map +1 -0
- package/dist/agents/learning/CrossProjectLearning.d.ts +99 -0
- package/dist/agents/learning/CrossProjectLearning.d.ts.map +1 -0
- package/dist/agents/learning/CrossProjectLearning.js +517 -0
- package/dist/agents/learning/CrossProjectLearning.js.map +1 -0
- package/dist/cli.js +47 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/agent-flow.d.ts +21 -0
- package/dist/commands/agent-flow.d.ts.map +1 -0
- package/dist/commands/agent-flow.js +225 -0
- package/dist/commands/agent-flow.js.map +1 -0
- package/dist/commands/generate-components.d.ts +0 -13
- package/dist/commands/generate-components.d.ts.map +1 -1
- package/dist/commands/generate-components.js +23 -385
- package/dist/commands/generate-components.js.map +1 -1
- package/dist/commands/generate.d.ts +4 -1
- package/dist/commands/generate.d.ts.map +1 -1
- package/dist/commands/generate.js +173 -1
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/predict.d.ts +36 -0
- package/dist/commands/predict.d.ts.map +1 -0
- package/dist/commands/predict.js +539 -0
- package/dist/commands/predict.js.map +1 -0
- package/dist/utils/clean.d.ts +6 -0
- package/dist/utils/clean.d.ts.map +1 -0
- package/dist/utils/clean.js +220 -0
- package/dist/utils/clean.js.map +1 -0
- package/dist/utils/githubModelsClient.d.ts.map +1 -1
- package/dist/utils/githubModelsClient.js +11 -12
- package/dist/utils/githubModelsClient.js.map +1 -1
- package/dist/utils/hybridAIClient.d.ts +1 -0
- package/dist/utils/hybridAIClient.d.ts.map +1 -1
- package/dist/utils/hybridAIClient.js +23 -9
- package/dist/utils/hybridAIClient.js.map +1 -1
- package/dist/utils/ollamaClient.d.ts.map +1 -1
- package/dist/utils/ollamaClient.js +6 -4
- package/dist/utils/ollamaClient.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# mycontext CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**๐ง The AI That Actually Understands Your Project** ๐
|
|
4
4
|
|
|
5
|
-
mycontext CLI
|
|
5
|
+
mycontext CLI is the first **agentic AI development tool** with specialized intelligence agents that understand your codebase, predict your needs, and generate production-ready components. **BETA READY** with complete agentic AI architecture and Ollama fallback.
|
|
6
|
+
|
|
7
|
+
**โ
WORKING NOW**: Ollama fallback provides unlimited component generation without API keys when GitHub Models is rate-limited.
|
|
6
8
|
|
|
7
9
|
## ๐ Quick Start
|
|
8
10
|
|
|
@@ -22,69 +24,106 @@ mycontext update
|
|
|
22
24
|
mycontext --up
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
### Ollama Setup (Recommended for Unlimited Generation)
|
|
28
|
+
|
|
29
|
+
For unlimited component generation without API rate limits:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Install Ollama (one-time setup)
|
|
33
|
+
curl -fsSL https://ollama.ai/install.sh | sh
|
|
34
|
+
|
|
35
|
+
# Pull the specialized MyContext model
|
|
36
|
+
ollama pull llama3.2:3b
|
|
37
|
+
|
|
38
|
+
# Verify installation
|
|
39
|
+
mycontext model status
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
**Benefits:**
|
|
43
|
+
|
|
44
|
+
- โ
**Zero API costs** - Generate unlimited components
|
|
45
|
+
- โ
**Works offline** - No internet required after setup
|
|
46
|
+
- โ
**No rate limits** - Generate as much as you want
|
|
47
|
+
- โ
**Complete privacy** - Your code stays local
|
|
26
48
|
|
|
27
|
-
|
|
49
|
+
## ๐ง **ENHANCED AI ARCHITECTURE**
|
|
28
50
|
|
|
29
|
-
|
|
30
|
-
- **Project Setup & Validation** - Complete project initialization
|
|
31
|
-
- **Basic Component Generation** - Simple component scaffolding
|
|
32
|
-
- **Preview System** - Live component previews
|
|
33
|
-
- **Model Management** - GitHub Models integration
|
|
51
|
+
### โ
**Complete Agentic System (Production Ready)**
|
|
34
52
|
|
|
35
|
-
|
|
53
|
+
- **ProjectIntelligence Engine** - Deep codebase analysis and pattern learning
|
|
54
|
+
- **Multi-Agent Architecture** - ArchitectAgent, SecurityAgent, QAAgent, DocsAgent
|
|
55
|
+
- **Predictive Development** - `mycontext predict` commands for intelligent suggestions
|
|
56
|
+
- **Code Evolution Engine** - Automated refactoring and optimization recommendations
|
|
57
|
+
- **Cross-Project Learning** - Knowledge sharing across projects and patterns
|
|
58
|
+
- **Context Generation** - PRD, types, branding, component planning
|
|
59
|
+
- **Component Generation** - Production-ready React components
|
|
60
|
+
- **Enhanced CLI** - Complete agentic command interface
|
|
36
61
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
- **
|
|
40
|
-
- **
|
|
41
|
-
- **
|
|
62
|
+
### ๐ **Enhanced Features (Available Now)**
|
|
63
|
+
|
|
64
|
+
- **Intelligent Predictions** - Next steps, dependencies, patterns, issues, optimizations
|
|
65
|
+
- **Architectural Insights** - System design analysis and scalability recommendations
|
|
66
|
+
- **Security Analysis** - Vulnerability scanning and compliance checking
|
|
67
|
+
- **Quality Assurance** - Automated code review and quality scoring
|
|
68
|
+
- **Documentation Generation** - Comprehensive docs with JSDoc and usage examples
|
|
69
|
+
- **Auto-Cleanup** - `mycontext clean` command for project maintenance
|
|
42
70
|
|
|
43
71
|
### ๐ **Coming Soon**
|
|
44
72
|
|
|
45
|
-
- **VS Code Extension** - Visual
|
|
46
|
-
- **
|
|
47
|
-
- **
|
|
48
|
-
- **
|
|
73
|
+
- **VS Code Extension** - Visual agent management and live preview
|
|
74
|
+
- **Real-time Collaboration** - Multi-user agentic workflows
|
|
75
|
+
- **Advanced Learning** - Enhanced cross-project intelligence
|
|
76
|
+
- **Custom AI Agents** - Build your own specialized agents
|
|
49
77
|
|
|
50
|
-
### **
|
|
78
|
+
### **Enhanced Agentic Workflow (Production Ready)**
|
|
51
79
|
|
|
52
80
|
```bash
|
|
53
|
-
# 1) Initialize project
|
|
54
|
-
mycontext init my-app
|
|
81
|
+
# 1) Initialize project with ProjectIntelligence
|
|
82
|
+
mycontext init my-app --description "AI-powered platform"
|
|
55
83
|
cd my-app
|
|
56
84
|
|
|
57
|
-
# Enable GitHub Models
|
|
85
|
+
# Optional: Enable GitHub Models for faster generation
|
|
58
86
|
echo 'MYCONTEXT_GITHUB_TOKEN=ghp_xxx' > .mycontext/.env
|
|
59
87
|
|
|
60
|
-
# 2) Generate comprehensive context
|
|
88
|
+
# 2) Generate comprehensive context with multi-agent analysis
|
|
61
89
|
mycontext generate context --description "Your project description"
|
|
62
90
|
mycontext generate types
|
|
63
91
|
mycontext generate brand
|
|
64
92
|
mycontext generate components-list
|
|
65
93
|
|
|
66
|
-
# 3)
|
|
94
|
+
# 3) Experience the enhanced agentic features
|
|
95
|
+
mycontext predict next # AI predicts next development steps
|
|
96
|
+
mycontext predict dependencies # Suggests optimal packages and tools
|
|
97
|
+
mycontext predict patterns # Identifies architectural patterns
|
|
98
|
+
mycontext predict issues # Forecasts potential problems
|
|
99
|
+
mycontext predict optimization # Recommends performance improvements
|
|
100
|
+
|
|
101
|
+
# 4) Generate production-ready components with AI agents
|
|
67
102
|
mycontext generate-components all --local --with-tests
|
|
68
103
|
|
|
69
|
-
#
|
|
104
|
+
# 5) Clean and maintain your project intelligently
|
|
105
|
+
mycontext clean # Auto-fix malformed files and issues
|
|
106
|
+
|
|
107
|
+
# 6) Preview and iterate
|
|
70
108
|
mycontext preview components
|
|
71
109
|
mycontext list components --local
|
|
72
110
|
```
|
|
73
111
|
|
|
74
|
-
### **Advanced
|
|
112
|
+
### **Advanced Intelligence Commands**
|
|
75
113
|
|
|
76
114
|
```bash
|
|
77
|
-
#
|
|
115
|
+
# Core component management (design anchor)
|
|
78
116
|
mycontext core generate BrandComp
|
|
79
117
|
mycontext core refine --desc "Improve spacing and colors"
|
|
80
118
|
mycontext core ready
|
|
81
119
|
|
|
82
|
-
#
|
|
83
|
-
mycontext generate-
|
|
120
|
+
# Specialized agent workflows
|
|
121
|
+
mycontext agent-flow generate-context # Multi-agent context generation
|
|
122
|
+
mycontext agent-flow validate-workflow # Test agent communication
|
|
84
123
|
|
|
85
|
-
#
|
|
86
|
-
mycontext
|
|
87
|
-
mycontext
|
|
124
|
+
# Project intelligence and analysis
|
|
125
|
+
mycontext status --detailed # Comprehensive project analysis
|
|
126
|
+
mycontext validate prd --interactive # AI-powered PRD validation
|
|
88
127
|
```
|
|
89
128
|
|
|
90
129
|
## ๐ฆ Outputs
|
|
@@ -106,6 +145,7 @@ Numbered aliases for easy sorting (display-only):
|
|
|
106
145
|
- `.mycontext/02-types.ts`
|
|
107
146
|
- `.mycontext/03-branding.md`
|
|
108
147
|
- `.mycontext/04-component-list.json`
|
|
148
|
+
- `.mycontext/05-project-structure.md` โ Next.js project structure with dialog/datatable prioritization
|
|
109
149
|
|
|
110
150
|
## ๐ง Complete Command Reference
|
|
111
151
|
|
|
@@ -121,6 +161,7 @@ mycontext generate context [--description "text"] # PRD + user stories
|
|
|
121
161
|
mycontext generate types # TypeScript interfaces
|
|
122
162
|
mycontext generate brand # Design system
|
|
123
163
|
mycontext generate components-list # Component planning
|
|
164
|
+
mycontext generate project-structure # Next.js project structure (NEW!)
|
|
124
165
|
mycontext validate prd [--interactive] # PRD validation
|
|
125
166
|
|
|
126
167
|
# Core Component (Brand Anchor)
|
|
@@ -180,6 +221,27 @@ mycontext model reset [--force] # Reset to clean state
|
|
|
180
221
|
mycontext model stats [--detailed] [--last 30d] # Usage statistics
|
|
181
222
|
```
|
|
182
223
|
|
|
224
|
+
### **๐ง Enhanced Intelligence Commands**
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# Predictive Development (Production Ready)
|
|
228
|
+
mycontext predict next # Predict next development steps
|
|
229
|
+
mycontext predict dependencies # Suggest optimal packages and tools
|
|
230
|
+
mycontext predict patterns # Identify architectural patterns
|
|
231
|
+
mycontext predict issues # Forecast potential problems
|
|
232
|
+
mycontext predict optimization # Recommend performance improvements
|
|
233
|
+
|
|
234
|
+
# Agent Communication & Auto-Generation
|
|
235
|
+
mycontext agent-flow generate-context # Multi-agent context generation
|
|
236
|
+
mycontext agent-flow validate-workflow # Test agent communication system
|
|
237
|
+
mycontext clean # Auto-fix malformed files and issues
|
|
238
|
+
|
|
239
|
+
# Intelligence Options
|
|
240
|
+
--detailed # Show comprehensive analysis
|
|
241
|
+
--format json|table # Output format
|
|
242
|
+
--scope next|dependencies|patterns|issues|optimization # Prediction scope
|
|
243
|
+
```
|
|
244
|
+
|
|
183
245
|
### **Utilities & Maintenance**
|
|
184
246
|
|
|
185
247
|
```bash
|
|
@@ -219,8 +281,12 @@ mycontext help # Detailed help
|
|
|
219
281
|
### **Authentication & Models**
|
|
220
282
|
|
|
221
283
|
```bash
|
|
222
|
-
# GitHub Models (
|
|
223
|
-
MYCONTEXT_GITHUB_TOKEN=ghp_xxx # Set in .mycontext/.env
|
|
284
|
+
# GitHub Models (optional - provides faster generation when available)
|
|
285
|
+
MYCONTEXT_GITHUB_TOKEN=ghp_xxx # Set in .mycontext/.env for faster generation
|
|
286
|
+
|
|
287
|
+
# Ollama (automatic fallback - works without API keys)
|
|
288
|
+
# Install Ollama locally for unlimited component generation
|
|
289
|
+
# No API keys required - works offline when GitHub Models is rate-limited
|
|
224
290
|
|
|
225
291
|
# Alternative providers (optional)
|
|
226
292
|
HUGGINGFACE_API_KEY=hf_xxx # Hugging Face fallback
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AgentMessage, AgentIntent, AgentContext, AgentCommunicationHandler, IntentResolver, WorkflowConfig } from "../interfaces/AgentCommunication";
|
|
2
|
+
import { SubAgentOrchestrator } from "../orchestrator/SubAgentOrchestrator";
|
|
3
|
+
export declare class AgentCommunicationManager implements AgentCommunicationHandler {
|
|
4
|
+
private messageHistory;
|
|
5
|
+
private orchestrator;
|
|
6
|
+
private intentResolver;
|
|
7
|
+
constructor(orchestrator: SubAgentOrchestrator, intentResolver?: IntentResolver);
|
|
8
|
+
sendMessage(message: AgentMessage): Promise<void>;
|
|
9
|
+
receiveMessage(agentName: string): Promise<AgentMessage | null>;
|
|
10
|
+
broadcastMessage(message: Omit<AgentMessage, "to">): Promise<void>;
|
|
11
|
+
getMessageHistory(agentName?: string): Promise<AgentMessage[]>;
|
|
12
|
+
clearHistory(): Promise<void>;
|
|
13
|
+
private saveMessageLog;
|
|
14
|
+
runAutoWorkflow(initialAgent: string, context: AgentContext, config: WorkflowConfig): Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
outputs: Record<string, any>;
|
|
17
|
+
messages: AgentMessage[];
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export declare class DefaultIntentResolver implements IntentResolver {
|
|
21
|
+
analyzeOutput(output: any, context: AgentContext): Promise<AgentIntent>;
|
|
22
|
+
shouldTriggerNextAgent(intent: AgentIntent, context: AgentContext): Promise<boolean>;
|
|
23
|
+
getNextAgent(intent: AgentIntent, context: AgentContext): Promise<string | null>;
|
|
24
|
+
createStarterPrompt(intent: AgentIntent, context: AgentContext): Promise<string>;
|
|
25
|
+
private calculateConfidence;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=AgentCommunicationManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentCommunicationManager.d.ts","sourceRoot":"","sources":["../../../src/agents/communication/AgentCommunicationManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EAEZ,yBAAyB,EACzB,cAAc,EAEd,cAAc,EACf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAI5E,qBAAa,yBAA0B,YAAW,yBAAyB;IACzE,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,cAAc,CAAiB;gBAGrC,YAAY,EAAE,oBAAoB,EAClC,cAAc,CAAC,EAAE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2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.DefaultIntentResolver = exports.AgentCommunicationManager = void 0;
|
|
40
|
+
const fs = __importStar(require("fs-extra"));
|
|
41
|
+
const path_1 = __importDefault(require("path"));
|
|
42
|
+
class AgentCommunicationManager {
|
|
43
|
+
constructor(orchestrator, intentResolver) {
|
|
44
|
+
this.messageHistory = [];
|
|
45
|
+
this.orchestrator = orchestrator;
|
|
46
|
+
this.intentResolver = intentResolver || new DefaultIntentResolver();
|
|
47
|
+
}
|
|
48
|
+
async sendMessage(message) {
|
|
49
|
+
this.messageHistory.push({
|
|
50
|
+
...message,
|
|
51
|
+
timestamp: new Date().toISOString(),
|
|
52
|
+
});
|
|
53
|
+
// Save communication log for debugging
|
|
54
|
+
await this.saveMessageLog(message);
|
|
55
|
+
}
|
|
56
|
+
async receiveMessage(agentName) {
|
|
57
|
+
// Get the latest message for this agent
|
|
58
|
+
const messages = this.messageHistory.filter((m) => m.to === agentName);
|
|
59
|
+
return messages.length > 0 ? messages[messages.length - 1] : null;
|
|
60
|
+
}
|
|
61
|
+
async broadcastMessage(message) {
|
|
62
|
+
const agentNames = this.orchestrator.listAgents();
|
|
63
|
+
for (const agentName of agentNames) {
|
|
64
|
+
await this.sendMessage({
|
|
65
|
+
...message,
|
|
66
|
+
to: agentName,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async getMessageHistory(agentName) {
|
|
71
|
+
if (!agentName)
|
|
72
|
+
return this.messageHistory;
|
|
73
|
+
return this.messageHistory.filter((m) => m.from === agentName || m.to === agentName);
|
|
74
|
+
}
|
|
75
|
+
async clearHistory() {
|
|
76
|
+
this.messageHistory = [];
|
|
77
|
+
}
|
|
78
|
+
async saveMessageLog(message) {
|
|
79
|
+
try {
|
|
80
|
+
const logDir = path_1.default.join(process.cwd(), ".mycontext", "agent-logs");
|
|
81
|
+
await fs.ensureDir(logDir);
|
|
82
|
+
const logFile = path_1.default.join(logDir, `communication-${new Date().toISOString().split("T")[0]}.json`);
|
|
83
|
+
let logs = [];
|
|
84
|
+
if (await fs.pathExists(logFile)) {
|
|
85
|
+
logs = await fs.readJson(logFile);
|
|
86
|
+
}
|
|
87
|
+
logs.push(message);
|
|
88
|
+
await fs.writeJson(logFile, logs, { spaces: 2 });
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
// Silent fail - logging shouldn't break the workflow
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Auto workflow orchestration
|
|
95
|
+
async runAutoWorkflow(initialAgent, context, config) {
|
|
96
|
+
let currentAgent = initialAgent;
|
|
97
|
+
let outputs = {};
|
|
98
|
+
let retryCount = 0;
|
|
99
|
+
let attempts = 0;
|
|
100
|
+
const maxAttempts = config.agents.length * 2; // Safety limit
|
|
101
|
+
while (currentAgent && attempts < maxAttempts) {
|
|
102
|
+
attempts++;
|
|
103
|
+
try {
|
|
104
|
+
// Execute current agent
|
|
105
|
+
const agentOutput = await this.orchestrator.executeAgent(currentAgent, {
|
|
106
|
+
context,
|
|
107
|
+
previousOutputs: outputs,
|
|
108
|
+
retryCount,
|
|
109
|
+
});
|
|
110
|
+
outputs[currentAgent] = agentOutput;
|
|
111
|
+
// Analyze output and determine next action
|
|
112
|
+
const intent = await this.intentResolver.analyzeOutput(agentOutput, context);
|
|
113
|
+
// Send completion message
|
|
114
|
+
await this.sendMessage({
|
|
115
|
+
id: `${currentAgent}-${Date.now()}`,
|
|
116
|
+
from: currentAgent,
|
|
117
|
+
to: "coordinator",
|
|
118
|
+
type: "completion",
|
|
119
|
+
payload: { output: agentOutput, intent },
|
|
120
|
+
timestamp: new Date().toISOString(),
|
|
121
|
+
});
|
|
122
|
+
// Check if we should trigger next agent
|
|
123
|
+
if (config.enableAutoTransition &&
|
|
124
|
+
(await this.intentResolver.shouldTriggerNextAgent(intent, context))) {
|
|
125
|
+
const nextAgent = await this.intentResolver.getNextAgent(intent, context);
|
|
126
|
+
if (nextAgent) {
|
|
127
|
+
// Create starter prompt for next agent
|
|
128
|
+
const starterPrompt = await this.intentResolver.createStarterPrompt(intent, context);
|
|
129
|
+
// Update context with new starter prompt
|
|
130
|
+
context = {
|
|
131
|
+
...context,
|
|
132
|
+
userPrompt: starterPrompt,
|
|
133
|
+
previousOutputs: outputs,
|
|
134
|
+
};
|
|
135
|
+
// Send request to next agent
|
|
136
|
+
await this.sendMessage({
|
|
137
|
+
id: `transition-${Date.now()}`,
|
|
138
|
+
from: currentAgent,
|
|
139
|
+
to: nextAgent,
|
|
140
|
+
type: "request",
|
|
141
|
+
payload: {
|
|
142
|
+
starterPrompt,
|
|
143
|
+
context: context,
|
|
144
|
+
intent,
|
|
145
|
+
},
|
|
146
|
+
timestamp: new Date().toISOString(),
|
|
147
|
+
});
|
|
148
|
+
currentAgent = nextAgent;
|
|
149
|
+
retryCount = 0;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// No next agent, workflow complete
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
else if (intent.action === "refine" &&
|
|
157
|
+
retryCount < config.retryLimit) {
|
|
158
|
+
// Same agent needs to retry/refine
|
|
159
|
+
retryCount++;
|
|
160
|
+
context = {
|
|
161
|
+
...context,
|
|
162
|
+
userPrompt: intent.nextSteps?.join(" ") || "Please refine the output",
|
|
163
|
+
previousOutputs: outputs,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// Workflow complete or max retries reached
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
await this.sendMessage({
|
|
173
|
+
id: `error-${Date.now()}`,
|
|
174
|
+
from: currentAgent,
|
|
175
|
+
to: "coordinator",
|
|
176
|
+
type: "error",
|
|
177
|
+
payload: { error: error.message, retryCount },
|
|
178
|
+
timestamp: new Date().toISOString(),
|
|
179
|
+
});
|
|
180
|
+
if (retryCount < config.retryLimit) {
|
|
181
|
+
retryCount++;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return {
|
|
189
|
+
success: Object.keys(outputs).length > 0,
|
|
190
|
+
outputs,
|
|
191
|
+
messages: this.messageHistory,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
exports.AgentCommunicationManager = AgentCommunicationManager;
|
|
196
|
+
// Default intent resolver implementation
|
|
197
|
+
class DefaultIntentResolver {
|
|
198
|
+
async analyzeOutput(output, context) {
|
|
199
|
+
// Simple heuristic-based analysis
|
|
200
|
+
const confidence = this.calculateConfidence(output);
|
|
201
|
+
if (confidence < 0.3) {
|
|
202
|
+
return {
|
|
203
|
+
action: "refine",
|
|
204
|
+
reason: "Output quality below threshold",
|
|
205
|
+
confidence,
|
|
206
|
+
nextSteps: ["Improve output quality", "Add missing details"],
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
if (confidence > 0.8) {
|
|
210
|
+
return {
|
|
211
|
+
action: "complete",
|
|
212
|
+
reason: "High quality output achieved",
|
|
213
|
+
confidence,
|
|
214
|
+
nextSteps: ["Proceed to next stage"],
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
return {
|
|
218
|
+
action: "generate",
|
|
219
|
+
reason: "Acceptable output, continue workflow",
|
|
220
|
+
confidence,
|
|
221
|
+
nextSteps: ["Continue to next agent"],
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
async shouldTriggerNextAgent(intent, context) {
|
|
225
|
+
return (intent.action === "complete" ||
|
|
226
|
+
(intent.action === "generate" && intent.confidence > 0.6));
|
|
227
|
+
}
|
|
228
|
+
async getNextAgent(intent, context) {
|
|
229
|
+
// Simple sequential flow for now
|
|
230
|
+
const sequence = ["CodeGenSubAgent", "QASubAgent", "DocsSubAgent"];
|
|
231
|
+
// Find current agent in sequence (based on context)
|
|
232
|
+
if (context.previousOutputs) {
|
|
233
|
+
const completed = Object.keys(context.previousOutputs);
|
|
234
|
+
for (let i = 0; i < sequence.length; i++) {
|
|
235
|
+
if (!completed.includes(sequence[i])) {
|
|
236
|
+
return sequence[i];
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return sequence[0]; // Default to first agent
|
|
241
|
+
}
|
|
242
|
+
async createStarterPrompt(intent, context) {
|
|
243
|
+
const basePrompt = context.userPrompt || "Generate high-quality output";
|
|
244
|
+
if (intent.action === "refine") {
|
|
245
|
+
return `${basePrompt}\n\nPlease refine the previous output with these improvements:\n${intent.nextSteps?.join("\n") || ""}`;
|
|
246
|
+
}
|
|
247
|
+
if (context.previousOutputs &&
|
|
248
|
+
Object.keys(context.previousOutputs).length > 0) {
|
|
249
|
+
const previousContext = Object.entries(context.previousOutputs)
|
|
250
|
+
.map(([agent, output]) => `${agent}: ${typeof output === "string"
|
|
251
|
+
? output.substring(0, 200) + "..."
|
|
252
|
+
: "Generated output"}`)
|
|
253
|
+
.join("\n");
|
|
254
|
+
return `${basePrompt}\n\nBuild upon previous agent outputs:\n${previousContext}`;
|
|
255
|
+
}
|
|
256
|
+
return basePrompt;
|
|
257
|
+
}
|
|
258
|
+
calculateConfidence(output) {
|
|
259
|
+
if (!output)
|
|
260
|
+
return 0;
|
|
261
|
+
if (typeof output === "string") {
|
|
262
|
+
// Simple heuristics for string output
|
|
263
|
+
const length = output.length;
|
|
264
|
+
const hasStructure = output.includes("\n") || output.includes("```");
|
|
265
|
+
const hasDetails = length > 100;
|
|
266
|
+
let score = 0.5;
|
|
267
|
+
if (hasStructure)
|
|
268
|
+
score += 0.2;
|
|
269
|
+
if (hasDetails)
|
|
270
|
+
score += 0.2;
|
|
271
|
+
if (length > 500)
|
|
272
|
+
score += 0.1;
|
|
273
|
+
return Math.min(score, 1.0);
|
|
274
|
+
}
|
|
275
|
+
if (typeof output === "object") {
|
|
276
|
+
// Object-based output confidence
|
|
277
|
+
const keys = Object.keys(output);
|
|
278
|
+
const hasCode = "code" in output;
|
|
279
|
+
const hasMetadata = "metadata" in output;
|
|
280
|
+
let score = 0.6;
|
|
281
|
+
if (hasCode)
|
|
282
|
+
score += 0.2;
|
|
283
|
+
if (hasMetadata)
|
|
284
|
+
score += 0.1;
|
|
285
|
+
if (keys.length > 3)
|
|
286
|
+
score += 0.1;
|
|
287
|
+
return Math.min(score, 1.0);
|
|
288
|
+
}
|
|
289
|
+
return 0.5; // Default confidence
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
exports.DefaultIntentResolver = DefaultIntentResolver;
|
|
293
|
+
//# sourceMappingURL=AgentCommunicationManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentCommunicationManager.js","sourceRoot":"","sources":["../../../src/agents/communication/AgentCommunicationManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,6CAA+B;AAC/B,gDAAwB;AAExB,MAAa,yBAAyB;IAKpC,YACE,YAAkC,EAClC,cAA+B;QANzB,mBAAc,GAAmB,EAAE,CAAC;QAQ1C,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,IAAI,qBAAqB,EAAE,CAAC;IACtE,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,OAAqB;QACrC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC;YACvB,GAAG,OAAO;YACV,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACpC,CAAC,CAAC;QAEH,uCAAuC;QACvC,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,SAAiB;QACpC,wCAAwC;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,CAAC,CAAC;QACvE,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CA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;gBAAE,KAAK,IAAI,GAAG,CAAC;YAE/B,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,iCAAiC;YACjC,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACjC,MAAM,OAAO,GAAG,MAAM,IAAI,MAAM,CAAC;YACjC,MAAM,WAAW,GAAG,UAAU,IAAI,MAAM,CAAC;YAEzC,IAAI,KAAK,GAAG,GAAG,CAAC;YAChB,IAAI,OAAO;gBAAE,KAAK,IAAI,GAAG,CAAC;YAC1B,IAAI,WAAW;gBAAE,KAAK,IAAI,GAAG,CAAC;YAC9B,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;gBAAE,KAAK,IAAI,GAAG,CAAC;YAElC,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9B,CAAC;QAED,OAAO,GAAG,CAAC,CAAC,qBAAqB;IACnC,CAAC;CACF;AAlID,sDAkIC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export interface CodeEvolutionEngine {
|
|
2
|
+
refactoringSuggestions: RefactoringSuggestion[];
|
|
3
|
+
performanceOptimizations: PerformanceOptimization[];
|
|
4
|
+
securityHardening: SecurityHardening[];
|
|
5
|
+
accessibilityEnhancements: AccessibilityEnhancement[];
|
|
6
|
+
}
|
|
7
|
+
export interface RefactoringSuggestion {
|
|
8
|
+
id: string;
|
|
9
|
+
file: string;
|
|
10
|
+
type: "extract-component" | "simplify-logic" | "reduce-complexity" | "improve-naming" | "consolidate-imports";
|
|
11
|
+
priority: "low" | "medium" | "high" | "critical";
|
|
12
|
+
description: string;
|
|
13
|
+
before: string;
|
|
14
|
+
after: string;
|
|
15
|
+
benefits: string[];
|
|
16
|
+
confidence: number;
|
|
17
|
+
estimatedEffort: string;
|
|
18
|
+
}
|
|
19
|
+
export interface PerformanceOptimization {
|
|
20
|
+
id: string;
|
|
21
|
+
file: string;
|
|
22
|
+
type: "memoization" | "lazy-loading" | "bundle-splitting" | "image-optimization" | "virtualization";
|
|
23
|
+
impact: "low" | "medium" | "high";
|
|
24
|
+
description: string;
|
|
25
|
+
implementation: string;
|
|
26
|
+
metrics: {
|
|
27
|
+
beforeScore: number;
|
|
28
|
+
afterScore: number;
|
|
29
|
+
improvement: string;
|
|
30
|
+
};
|
|
31
|
+
confidence: number;
|
|
32
|
+
}
|
|
33
|
+
export interface SecurityHardening {
|
|
34
|
+
id: string;
|
|
35
|
+
file: string;
|
|
36
|
+
vulnerability: string;
|
|
37
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
38
|
+
fix: string;
|
|
39
|
+
automated: boolean;
|
|
40
|
+
compliance: string[];
|
|
41
|
+
}
|
|
42
|
+
export interface AccessibilityEnhancement {
|
|
43
|
+
id: string;
|
|
44
|
+
file: string;
|
|
45
|
+
issue: string;
|
|
46
|
+
wcagLevel: "A" | "AA" | "AAA";
|
|
47
|
+
fix: string;
|
|
48
|
+
automated: boolean;
|
|
49
|
+
userImpact: string;
|
|
50
|
+
}
|
|
51
|
+
export declare class CodeEvolutionEngineImpl implements CodeEvolutionEngine {
|
|
52
|
+
refactoringSuggestions: RefactoringSuggestion[];
|
|
53
|
+
performanceOptimizations: PerformanceOptimization[];
|
|
54
|
+
securityHardening: SecurityHardening[];
|
|
55
|
+
accessibilityEnhancements: AccessibilityEnhancement[];
|
|
56
|
+
private intelligence;
|
|
57
|
+
private architectAgent;
|
|
58
|
+
private securityAgent;
|
|
59
|
+
constructor(projectPath?: string);
|
|
60
|
+
analyzeAndEvolve(): Promise<CodeEvolutionEngine>;
|
|
61
|
+
private generateRefactoringSuggestions;
|
|
62
|
+
private analyzeFileForRefactoring;
|
|
63
|
+
private generatePerformanceOptimizations;
|
|
64
|
+
private analyzeFileForPerformance;
|
|
65
|
+
private generateSecurityHardening;
|
|
66
|
+
private analyzeFileForSecurity;
|
|
67
|
+
private generateAccessibilityEnhancements;
|
|
68
|
+
private analyzeFileForAccessibility;
|
|
69
|
+
private extractHighComplexitySection;
|
|
70
|
+
private suggestComponentExtraction;
|
|
71
|
+
private findLongParameterFunctions;
|
|
72
|
+
private generateObjectParameterVersion;
|
|
73
|
+
private findDuplicateCode;
|
|
74
|
+
private findPoorNaming;
|
|
75
|
+
private suggestBetterName;
|
|
76
|
+
private isDisplayComponent;
|
|
77
|
+
private generateMemoImplementation;
|
|
78
|
+
private findHeavyComputations;
|
|
79
|
+
private generateUseMemoImplementation;
|
|
80
|
+
private hasLargeList;
|
|
81
|
+
private generateVirtualizationImplementation;
|
|
82
|
+
private findImageOptimizations;
|
|
83
|
+
private canAutomate;
|
|
84
|
+
private getComplianceStandards;
|
|
85
|
+
private extractComponentName;
|
|
86
|
+
applyRefactoring(suggestionId: string): Promise<boolean>;
|
|
87
|
+
applyPerformanceOptimization(optimizationId: string): Promise<boolean>;
|
|
88
|
+
generateReport(): Promise<string>;
|
|
89
|
+
private getHighPriorityItems;
|
|
90
|
+
private getQuickWins;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=CodeEvolutionEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeEvolutionEngine.d.ts","sourceRoot":"","sources":["../../../src/agents/evolution/CodeEvolutionEngine.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,mBAAmB;IAClC,sBAAsB,EAAE,qBAAqB,EAAE,CAAC;IAChD,wBAAwB,EAAE,uBAAuB,EAAE,CAAC;IACpD,iBAAiB,EAAE,iBAAiB,EAAE,CAAC;IACvC,yBAAyB,EAAE,wBAAwB,EAAE,CAAC;CACvD;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EACA,mBAAmB,GACnB,gBAAgB,GAChB,mBAAmB,GACnB,gBAAgB,GAChB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