From 3c51f16d959f2636a1b8eb471631f46efaad1213 Mon Sep 17 00:00:00 2001 From: Max Date: Mon, 24 Feb 2025 14:33:04 +0800 Subject: [PATCH] Refactor assistant script loading and improve error diagnostics - Comment out assistant script loading in script package - Enhance global variable error message with detailed type information - Prepare for moving assistant script loading to a dedicated package --- neo/assistant/object.go | 2 +- script/script.go | 35 +++++++++++++++++------------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/neo/assistant/object.go b/neo/assistant/object.go index 2ab2095a..ef18de3e 100644 --- a/neo/assistant/object.go +++ b/neo/assistant/object.go @@ -283,7 +283,7 @@ func global(info *v8go.FunctionCallbackInfo) (global *GlobalVariables, err error global, ok := goGlobal.(*GlobalVariables) if !ok { - return nil, fmt.Errorf("global is not a valid GlobalVariables") + return nil, fmt.Errorf("global is not a valid GlobalVariables. %#v", goGlobal) } return global, nil diff --git a/script/script.go b/script/script.go index 15d25c81..18b5fe48 100644 --- a/script/script.go +++ b/script/script.go @@ -2,7 +2,6 @@ package script import ( "fmt" - "strings" "github.com/yaoapp/gou/application" v8 "github.com/yaoapp/gou/runtime/v8" @@ -26,26 +25,26 @@ func Load(cfg config.Config) error { return err } - // Load assistants - err = application.App.Walk("assistants", func(root, file string, isdir bool) error { - if isdir { - return nil - } + // Load assistants - Move to the neo assistant package + // err = application.App.Walk("assistants", func(root, file string, isdir bool) error { + // if isdir { + // return nil + // } - // Keep the src.index only - if !strings.HasSuffix(file, "src/index.ts") { - return nil - } + // // Keep the src.index only + // if !strings.HasSuffix(file, "src/index.ts") { + // return nil + // } - id := fmt.Sprintf("assistants.%s", share.ID(root, file)) - id = strings.TrimSuffix(id, ".src.index") - _, err := v8.Load(file, id) - return err - }, exts...) + // id := fmt.Sprintf("assistants.%s", share.ID(root, file)) + // id = strings.TrimSuffix(id, ".src.index") + // _, err := v8.Load(file, id) + // return err + // }, exts...) - if err != nil { - return err - } + // if err != nil { + // return err + // } return application.App.Walk("services", func(root, file string, isdir bool) error { if isdir {