MCPcopy Create free account
hub / github.com/codag-megalith/codag-visualizer / detectWorkflow

Method detectWorkflow

frontend/src/analyzer.ts:190–223  ·  view source on GitHub ↗
(content: string, filePath?: string)

Source from the content-addressed store, hash-verified

188 }
189
190 static detectWorkflow(content: string, filePath?: string): boolean {
191 // Two-pass detection: AST-based (accurate) → Direct LLM patterns (fallback)
192
193 // Pass 1: AST-based detection (most accurate)
194 if (filePath) {
195 try {
196 const analysis = staticAnalyzer.analyze(content, filePath);
197 if (analysis.locations.length > 0 || analysis.llmRelatedVariables.size > 0) {
198 return true;
199 }
200 } catch (error) {
201 console.warn('AST parsing failed, falling back to regex:', error);
202 }
203 }
204
205 // Pass 2: Direct LLM usage detection (regex fallback)
206 const hasLLMClient = ALL_IMPORT_PATTERNS.some(pattern => pattern.test(content));
207 const hasLLMCalls = ALL_CALL_PATTERNS.some(pattern => pattern.test(content));
208 const hasFramework = LLM_FRAMEWORKS.some(f => f.importPatterns.some(p => p.test(content)));
209
210 if ((hasLLMClient && hasLLMCalls) || hasFramework) {
211 return true;
212 }
213
214 // Pass 3: AI Service API detection (non-LLM AI services using HTTP)
215 const hasAIServiceDomain = AI_SERVICE_DOMAINS.some(pattern => pattern.test(content));
216 const hasAIEndpoint = AI_ENDPOINT_PATTERNS.some(pattern => pattern.test(content));
217
218 if (hasAIServiceDomain || hasAIEndpoint) {
219 return true;
220 }
221
222 return false;
223 }
224
225 static detectFramework(content: string): string | null {
226 // Check each provider's import patterns

Callers 3

detectInWorkspaceMethod · 0.95
detectFrameworkMethod · 0.95
performLocalUpdateFunction · 0.80

Calls 1

analyzeMethod · 0.80

Tested by

no test coverage detected