cyclic-dependency-fixer
Version:
AI-powered tool to detect and fix circular dependencies in JavaScript/TypeScript projects. Features intelligent refactoring with Claude/GPT-4, codebase pattern learning, and context-aware fix recommendations
64 lines • 2.5 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AnthropicProvider = void 0;
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
class AnthropicProvider {
constructor(apiKey) {
this.apiKey = apiKey;
this.name = 'Anthropic Claude';
this.client = null;
if (this.apiKey) {
this.client = new sdk_1.default({ apiKey: this.apiKey });
}
}
isAvailable() {
return !!this.apiKey && !!this.client;
}
async analyze(request) {
if (!this.client) {
throw new Error('Anthropic API key not configured');
}
const message = await this.client.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: request.maxTokens || 4096,
temperature: request.temperature || 0.3,
system: request.systemPrompt || this.getDefaultSystemPrompt(),
messages: [
{
role: 'user',
content: request.prompt,
},
],
});
const content = message.content[0];
const textContent = content.type === 'text' ? content.text : '';
return {
content: textContent,
tokensUsed: message.usage.input_tokens + message.usage.output_tokens,
provider: this.name,
};
}
async generateCode(request) {
const codeRequest = {
...request,
systemPrompt: request.systemPrompt ||
'You are an expert TypeScript developer. Generate clean, type-safe code following SOLID principles.',
};
return this.analyze(codeRequest);
}
getDefaultSystemPrompt() {
return `You are an expert software architect specializing in code quality and dependency management.
Your role is to analyze circular dependencies and provide intelligent, context-aware recommendations for fixing them.
Focus on:
1. Understanding the root cause of circular dependencies
2. Recommending the most appropriate fix strategy
3. Providing specific, actionable refactoring steps
4. Considering the overall architecture and patterns in the codebase
5. Ensuring type safety and following SOLID principles`;
}
}
exports.AnthropicProvider = AnthropicProvider;
//# sourceMappingURL=AnthropicProvider.js.map