up-coding-agent
v2.0.0
Published
UP Coding Agent - Intelligent TypeScript-based coding agent with LLM integration support
Maintainers
Readme
UP Coding Agent
UP Coding Agent - An intelligent TypeScript-based coding agent with LLM integration support.
Created by Martin Yeung
🚀 Features
Core Features
- Code Analysis: Automatic symbol extraction, complexity calculation, multi-language support
- Intelligent Completion: Context-aware variable/function completion, syntax suggestions
- Code Refactoring: Quick fixes, optimization suggestions, import organization
- Batch Processing: Multi-file analysis, cross-file symbol lookup
LLM Integration (NEW!)
- Multi-Provider Support: OpenAI, Anthropic, and more
- Code Generation: Generate secure, high-performance code using LLMs
- Security Analysis: Advanced vulnerability detection using AI
- Performance Optimization: Intelligent code optimization suggestions
- Flexible Configuration: Use LLM when needed, fallback to traditional methods
📦 Installation
npm install up-coding-agent🎯 Quick Start
Basic Usage (Without LLM)
import { CodingAgent } from 'up-coding-agent';
const agent = new CodingAgent();
// Analyze code
const analysis = await agent.analyzeFile(code, 'file.ts');
console.log(analysis.symbols);
// Get completions
const completions = await agent.getCompletions(code, position, 'file.ts');Advanced Usage (With LLM)
import { CodingAgent } from 'up-coding-agent';
const agent = new CodingAgent({ enableLLM: true });
// Configure LLM provider
agent.registerLLMProvider('openai', {
provider: 'openai',
apiKey: 'your-api-key',
modelName: 'gpt-4'
});
// Generate code using LLM
const generatedCode = await agent.generateCodeWithLLM({
language: 'typescript',
prompt: 'Create a secure authentication service',
constraints: ['Use bcrypt', 'Implement rate limiting']
});
// Security analysis using LLM
const securityResult = await agent.analyzeSecurityWithLLM({
code: yourCode,
language: 'javascript',
checkTypes: ['injection', 'auth', 'all']
});🔧 LLM Provider Setup
Environment Variables
Set your API keys in environment variables:
# OpenAI
export OPENAI_API_KEY="sk-your-openai-key"
export OPENAI_MODEL="gpt-4" # optional
# Anthropic
export ANTHROPIC_API_KEY="sk-your-anthropic-key"
export ANTHROPIC_MODEL="claude-3-opus-20240229" # optionalSupported Providers
- OpenAI: GPT-4, GPT-3.5 Turbo
- Anthropic: Claude 3 Opus, Sonnet, Haiku
- Custom: Any compatible API endpoint
📚 API Reference
CodingAgent Class
Constructor Options
interface AgentConfig {
maxContextLength: number; // Maximum context length
supportLanguages: string[]; // Supported languages
enableAutoImport: boolean; // Auto-import suggestions
enableCodeGeneration: boolean; // Code generation features
enableLLM: boolean; // Enable LLM features (default: true)
temperature: number; // Temperature for generation (0-1)
}LLM Methods
// Check if LLM is available
agent.isLLMAvailable(): boolean
// Register LLM provider
agent.registerLLMProvider(name: string, config: LLMConfig): void
// Generate code with LLM
agent.generateCodeWithLLM(request: CodeGenerationRequest): Promise<string>
// Security analysis with LLM
agent.analyzeSecurityWithLLM(request: SecurityAnalysisRequest): Promise<SecurityAnalysisResult>
// Performance optimization with LLM
agent.optimizePerformanceWithLLM(request: PerformanceOptimizationRequest): Promise<PerformanceOptimizationResult>
// Chat with LLM
agent.chatWithLLM(messages: Array, options?: LLMOptions): Promise<any>🧪 Testing
npm test📚 Examples
Run the included examples:
# Basic example
npm run example
# Advanced features
npm run advanced
# Real-world scenarios
npm run realworld
# LLM integration demo
npm run llm-example🌟 Supported Languages
- TypeScript/JavaScript (TS, TSX, JS, JSX)
- Python (PY)
- Java (JAVA)
- C/C++ (CPP, CC, CXX, C, H)
- C# (CS)
🔧 Configuration
Traditional Mode (No LLM)
const agent = new CodingAgent({
enableLLM: false, // Disable LLM features
maxContextLength: 4096
});LLM Mode
const agent = new CodingAgent({
enableLLM: true, // Enable LLM features
temperature: 0.7
});
// Configure providers
agent.registerLLMProvider('openai', {
provider: 'openai',
apiKey: process.env.OPENAI_API_KEY,
modelName: 'gpt-4'
});🛠️ Development
Setup Development Environment
git clone https://github.com/martinyeung/up-coding-agent.git
cd up-coding-agent
npm installBuild
npm run buildPublish
npm publish🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Inspired by Cursor and other intelligent programming assistants
- Built with TypeScript for type safety and better developer experience
- Designed to be lightweight and extensible
- LLM integration allows for even more powerful code analysis and generation
📞 Support
For issues and questions, please visit our GitHub Issues.
Made by Martin Yeung
UP Coding Agent - Your intelligent coding companion with LLM-powered features!
