Repository navigation
Expand file tree
/
Copy pathcodeguide.ts
More file actions
123 lines (111 loc) · 3.9 KB
/
Copy pathcodeguide.ts
File metadata and controls
123 lines (111 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import dotenv from 'dotenv'
import path from 'path'
// Load environment variables from project root
dotenv.config({
path: path.resolve(__dirname, '../../../.env'),
quiet: true,
})
import {
GenerationService,
ProjectService,
UsageService,
RepositoryAnalysisService,
TaskService,
ApiKeyEnhancedService,
SubscriptionService,
CancellationFunnelService,
CodespaceService,
ExternalTokenService,
SecurityKeysService,
UserService,
StarterKitsService,
ChatService,
DataManagementService,
PromptGenerationsService,
PlatformsService,
MCPServersService,
SkillsService,
} from './services'
import { APIServiceConfig, CodeGuideOptions } from './types'
export class CodeGuide {
public generation: GenerationService
public projects: ProjectService
public usage: UsageService
public repositoryAnalysis: RepositoryAnalysisService
public tasks: TaskService
public apiKeyEnhanced: ApiKeyEnhancedService
public subscription: SubscriptionService
public cancellationFunnel: CancellationFunnelService
public codespace: CodespaceService
public externalTokens: ExternalTokenService
public securityKeys: SecurityKeysService
public users: UserService
public starterKits: StarterKitsService
public chat: ChatService
public dataManagement: DataManagementService
public promptGenerations: PromptGenerationsService
public platforms: PlatformsService
public mcpServers: MCPServersService
public skills: SkillsService
private options: CodeGuideOptions
constructor(config: APIServiceConfig, options: CodeGuideOptions = {}) {
this.options = options
// Initialize all services with the same config
this.generation = new GenerationService(config)
this.projects = new ProjectService(config)
this.usage = new UsageService(config)
this.repositoryAnalysis = new RepositoryAnalysisService(config)
this.tasks = new TaskService(config)
this.apiKeyEnhanced = new ApiKeyEnhancedService(config)
this.subscription = new SubscriptionService(config)
this.cancellationFunnel = new CancellationFunnelService(config)
this.codespace = new CodespaceService(config)
this.externalTokens = new ExternalTokenService(config)
this.securityKeys = new SecurityKeysService(config)
this.users = new UserService(config)
this.starterKits = new StarterKitsService(config)
this.chat = new ChatService(config)
this.dataManagement = new DataManagementService(config)
this.promptGenerations = new PromptGenerationsService(config)
this.platforms = new PlatformsService(config)
this.mcpServers = new MCPServersService(config)
this.skills = new SkillsService(config)
}
// Convenience method for backward compatibility
async getGuidance(prompt: string): Promise<any> {
const request = {
user_prompt: prompt,
...(this.options.language && { language: this.options.language }),
...(this.options.context && { context: this.options.context }),
}
if (this.options.verbose) {
console.log('Sending request:', JSON.stringify(request, null, 2))
}
const response = await this.generation.refinePrompt(request)
if (this.options.verbose) {
console.log('Received response:', JSON.stringify(response, null, 2))
}
return {
id: Date.now().toString(),
response: response.refined_prompt,
timestamp: new Date().toISOString(),
language: this.options.language,
}
}
async isHealthy(): Promise<boolean> {
return this.usage.healthCheck()
}
// Helper method to create task group with codespace task integration
async createTaskGroupWithCodespace(request: {
name: string
description?: string
project_id: string
include_codespace_task?: boolean
project_description?: string
}): Promise<any> {
return this.tasks.createTaskGroupWithCodespace(request, this.codespace)
}
setOptions(options: Partial<CodeGuideOptions>): void {
this.options = { ...this.options, ...options }
}
}