From 2a191950d7dc6d01d98d4a7da1b1c3abd27e8ea6 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 15 Dec 2025 12:10:01 +0800 Subject: [PATCH] Refactor AIGC ID Handling in Load Function - Renamed the ID generation function to `aigcID` for clarity and added a new function to parse AIGC IDs from file paths. - Implemented special handling for `.ai.yml` and `.ai.yaml` extensions to correctly format the AIGC ID by removing the "_ai" suffix, improving ID accuracy in the loading process. --- aigc/load.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/aigc/load.go b/aigc/load.go index a7995689..c3c99857 100644 --- a/aigc/load.go +++ b/aigc/load.go @@ -28,7 +28,7 @@ func Load(cfg config.Config) error { return nil } - id := share.ID(root, file) + id := aigcID(root, file) _, err := LoadFile(file, id) if err != nil { messages = append(messages, err.Error()) @@ -48,6 +48,17 @@ func Load(cfg config.Config) error { return nil } +// aigcID parses AIGC ID from file path +// Special handling for .ai.yml and .ai.yaml extensions +// e.g., "aigcs/translate.ai.yml" -> "translate" +func aigcID(root, file string) string { + id := share.ID(root, file) + // Remove "_ai" suffix caused by .ai.yml/.ai.yaml extension + // share.ID treats .yml/.yaml as single extension, so "translate.ai.yml" becomes "translate_ai" + id = strings.TrimSuffix(id, "_ai") + return id +} + // LoadFile load AIGC by file func LoadFile(file string, id string) (*DSL, error) {