feat: add prioritize-model-mappings config option

Add a configuration option to control whether model mappings take
precedence over local API keys for Amp CLI requests.

- Add PrioritizeModelMappings field to AmpCode config struct
- When false (default): Local API keys take precedence (original behavior)
- When true: Model mappings take precedence over local API keys
- Add management API endpoints GET/PUT /prioritize-model-mappings

This allows users who want mapping priority to enable it explicitly
while preserving backward compatibility.

Config example:
  ampcode:
    model-mappings:
      - from: claude-opus-4-5-20251101
        to: gemini-claude-opus-4-5-thinking
    prioritize-model-mappings: true
This commit is contained in:
huynhgiabuu
2025-12-07 22:47:43 +07:00
parent 6cf1d8a947
commit afcab5efda
6 changed files with 90 additions and 29 deletions

View File

@@ -241,3 +241,11 @@ func (h *Handler) DeleteProxyURL(c *gin.Context) {
h.cfg.ProxyURL = ""
h.persist(c)
}
// Prioritize Model Mappings (for Amp CLI)
func (h *Handler) GetPrioritizeModelMappings(c *gin.Context) {
c.JSON(200, gin.H{"prioritize-model-mappings": h.cfg.AmpCode.PrioritizeModelMappings})
}
func (h *Handler) PutPrioritizeModelMappings(c *gin.Context) {
h.updateBoolField(c, func(v bool) { h.cfg.AmpCode.PrioritizeModelMappings = v })
}