getAgenticEngine returns the agentic engine for the given engine setting
(engineSetting string)
| 580 | |
| 581 | // getAgenticEngine returns the agentic engine for the given engine setting |
| 582 | func (c *Compiler) getAgenticEngine(engineSetting string) (CodingAgentEngine, error) { |
| 583 | if engineSetting == "" { |
| 584 | defaultEngine := c.engineRegistry.GetDefaultEngine() |
| 585 | engineLog.Printf("Using default engine: %s", defaultEngine.GetID()) |
| 586 | return defaultEngine, nil |
| 587 | } |
| 588 | |
| 589 | engineLog.Printf("Getting agentic engine for setting: %s", engineSetting) |
| 590 | |
| 591 | // First try exact match |
| 592 | if c.engineRegistry.IsValidEngine(engineSetting) { |
| 593 | engine, err := c.engineRegistry.GetEngine(engineSetting) |
| 594 | if err == nil { |
| 595 | engineLog.Printf("Found engine by exact match: %s", engine.GetID()) |
| 596 | } |
| 597 | return engine, err |
| 598 | } |
| 599 | |
| 600 | // Try prefix match for backward compatibility |
| 601 | engine, err := c.engineRegistry.GetEngineByPrefix(engineSetting) |
| 602 | if err == nil { |
| 603 | engineLog.Printf("Found engine by prefix match: %s", engine.GetID()) |
| 604 | return engine, nil |
| 605 | } |
| 606 | |
| 607 | engineLog.Printf("Failed to find engine for setting %s: %v", engineSetting, err) |
| 608 | |
| 609 | validEngines := c.engineRegistry.GetSupportedEngines() |
| 610 | suggestions := parser.FindClosestMatches(engineSetting, validEngines, 1) |
| 611 | enginesStr := strings.Join(validEngines, ", ") |
| 612 | |
| 613 | errMsg := fmt.Sprintf("invalid engine: %s. Valid engines are: %s.\n\nExample:\nengine: copilot\n\nSee: %s", |
| 614 | engineSetting, enginesStr, constants.DocsEnginesURL) |
| 615 | if len(suggestions) > 0 { |
| 616 | errMsg = fmt.Sprintf("invalid engine: %s. Valid engines are: %s.\n\nDid you mean: %s?\n\nExample:\nengine: copilot\n\nSee: %s", |
| 617 | engineSetting, enginesStr, suggestions[0], constants.DocsEnginesURL) |
| 618 | } |
| 619 | |
| 620 | return nil, errors.New(errMsg) |
| 621 | } |
| 622 | |
| 623 | // extractEngineConfigFromJSON parses engine configuration from JSON string (from included files) |
| 624 | func (c *Compiler) extractEngineConfigFromJSON(engineJSON string) (*EngineConfig, error) { |