diff --git a/cmd/dragonscale/main.go b/cmd/dragonscale/main.go index 76c8e8a23..d7cdbff26 100644 --- a/cmd/dragonscale/main.go +++ b/cmd/dragonscale/main.go @@ -21,6 +21,7 @@ import ( "strings" "time" + "github.com/ZanzyTHEbar/dragonscale/pkg" "github.com/ZanzyTHEbar/dragonscale/pkg/agent" "github.com/ZanzyTHEbar/dragonscale/pkg/auth" "github.com/ZanzyTHEbar/dragonscale/pkg/bus" @@ -159,7 +160,7 @@ func main() { installer := skills.NewSkillInstaller(skillsDir) cfgDir, _ := config.ConfigDir() globalSkillsDir := filepath.Join(cfgDir, "skills") - builtinSkillsDir := filepath.Join(cfgDir, "dragonscale", "skills") + builtinSkillsDir := filepath.Join(cfgDir, pkg.NAME, "skills") skillsLoader := skills.NewSkillsLoader(skillsDir, globalSkillsDir, builtinSkillsDir) switch subcommand { @@ -611,7 +612,7 @@ func gatewayCmd() { execTimeout := time.Duration(cfg.Tools.Cron.ExecTimeoutMinutes) * time.Minute var cronOpts []cron.CronOption if del := agentLoop.MemoryDelegate(); del != nil { - cronOpts = append(cronOpts, cron.WithCronDelegate(del, "dragonscale")) + cronOpts = append(cronOpts, cron.WithCronDelegate(del, pkg.NAME)) } cronService := setupCronTool(appCtx, agentLoop, msgBus, cfg.SandboxPath(), cfg.RestrictToSandbox(), execTimeout, cronOpts...) @@ -644,7 +645,7 @@ func gatewayCmd() { return tools.SilentResult(response) }) if del := agentLoop.MemoryDelegate(); del != nil { - obligations := tools.NewObligationTool(del, "dragonscale") + obligations := tools.NewObligationTool(del, pkg.NAME) heartbeatService.SetDueContextProvider(func(now time.Time) (string, error) { ctx, cancel := context.WithTimeout(appCtx, 10*time.Second) defer cancel() @@ -685,7 +686,7 @@ func gatewayCmd() { } // Inject channel manager into agent loop for command handling - agentLoop.SetChannelManager(channelManager) + agent.WithChannelManager(channelManager)(agentLoop) var transcriber *voice.GroqTranscriber if cfg.Providers.Groq.APIKey != "" { @@ -832,7 +833,7 @@ func memoryMigrateSessions() { } sessionsDir := filepath.Join(cfg.SandboxPath(), "sessions") - stats, err := picomemory.MigrateFileSessions(ctx, del, "dragonscale", sessionsDir) + stats, err := picomemory.MigrateFileSessions(ctx, del, pkg.NAME, sessionsDir) if err != nil { fmt.Printf("Migration error: %v\n", err) os.Exit(1) diff --git a/pkg/auth/oauth.go b/pkg/auth/oauth.go index 04827d97f..5f4de70fc 100644 --- a/pkg/auth/oauth.go +++ b/pkg/auth/oauth.go @@ -16,6 +16,7 @@ import ( "strings" "time" + "github.com/ZanzyTHEbar/dragonscale/pkg" jsonv2 "github.com/go-json-experiment/json" "github.com/go-json-experiment/json/jsontext" ) @@ -313,7 +314,7 @@ func buildAuthorizeURL(cfg OAuthProviderConfig, pkce PKCECodes, state, redirectU "state": {state}, } if strings.Contains(strings.ToLower(cfg.Issuer), "auth.openai.com") { - params.Set("originator", "dragonscale") + params.Set("originator", pkg.NAME) } if cfg.Originator != "" { params.Set("originator", cfg.Originator) diff --git a/pkg/channels/dingtalk.go b/pkg/channels/dingtalk.go index 9aae253e7..7b7b78999 100644 --- a/pkg/channels/dingtalk.go +++ b/pkg/channels/dingtalk.go @@ -8,6 +8,7 @@ import ( "fmt" "sync" + "github.com/ZanzyTHEbar/dragonscale/pkg" "github.com/ZanzyTHEbar/dragonscale/pkg/bus" "github.com/ZanzyTHEbar/dragonscale/pkg/config" "github.com/ZanzyTHEbar/dragonscale/pkg/logger" @@ -175,7 +176,7 @@ func (c *DingTalkChannel) SendDirectReply(ctx context.Context, sessionWebhook, c // Convert string content to []byte for the API contentBytes := []byte(content) - titleBytes := []byte("DragonScale") + titleBytes := []byte(pkg.NAME) // Send markdown formatted reply err := replier.SimpleReplyMarkdown( diff --git a/pkg/fantasy/factory.go b/pkg/fantasy/factory.go index 88833c12b..8d24f7e32 100644 --- a/pkg/fantasy/factory.go +++ b/pkg/fantasy/factory.go @@ -15,6 +15,7 @@ import ( "charm.land/fantasy" "charm.land/fantasy/providers/openaicompat" + "github.com/ZanzyTHEbar/dragonscale/pkg" "github.com/ZanzyTHEbar/dragonscale/pkg/config" "github.com/openai/openai-go/v2/option" ) @@ -333,7 +334,7 @@ func defaultIfEmpty(val, fallback string) string { func providerNameOrDefault(name string) string { if name == "" { - return "dragonscale" + return pkg.NAME } return name } diff --git a/pkg/memory/delegate/sqlite_integration_test.go b/pkg/memory/delegate/sqlite_integration_test.go index a835f7523..6ae0949da 100644 --- a/pkg/memory/delegate/sqlite_integration_test.go +++ b/pkg/memory/delegate/sqlite_integration_test.go @@ -2,9 +2,11 @@ package delegate import ( "context" - jsonv2 "github.com/go-json-experiment/json" "testing" + jsonv2 "github.com/go-json-experiment/json" + + "github.com/ZanzyTHEbar/dragonscale/pkg" "github.com/ZanzyTHEbar/dragonscale/pkg/ids" "github.com/ZanzyTHEbar/dragonscale/pkg/memory" "github.com/stretchr/testify/assert" @@ -14,7 +16,7 @@ import ( func TestCronKVBackend_Roundtrip(t *testing.T) { d := newTestDelegate(t) ctx := context.Background() - agentID := "dragonscale" + agentID := pkg.NAME kvKey := "cron:store" type cronStore struct { @@ -61,7 +63,7 @@ func TestCronKVBackend_Roundtrip(t *testing.T) { func TestCronKVBackend_UpdatePreservesShape(t *testing.T) { d := newTestDelegate(t) ctx := context.Background() - agentID := "dragonscale" + agentID := pkg.NAME kvKey := "cron:store" v1 := `{"version":1,"jobs":[{"id":"j1","name":"test","enabled":true}]}` @@ -78,7 +80,7 @@ func TestCronKVBackend_UpdatePreservesShape(t *testing.T) { func TestCronKVBackend_PrefixScan(t *testing.T) { d := newTestDelegate(t) ctx := context.Background() - agentID := "dragonscale" + agentID := pkg.NAME require.NoError(t, d.UpsertKV(ctx, agentID, "cron:store", "{}")) require.NoError(t, d.UpsertKV(ctx, agentID, "cron:lock", "held")) diff --git a/pkg/memory/migrate_sessions_test.go b/pkg/memory/migrate_sessions_test.go index 5d5cf62be..e2ee209ca 100644 --- a/pkg/memory/migrate_sessions_test.go +++ b/pkg/memory/migrate_sessions_test.go @@ -2,12 +2,14 @@ package memory import ( "context" - jsonv2 "github.com/go-json-experiment/json" "os" "path/filepath" "testing" "time" + jsonv2 "github.com/go-json-experiment/json" + + "github.com/ZanzyTHEbar/dragonscale/pkg" "github.com/ZanzyTHEbar/dragonscale/pkg/ids" ) @@ -134,7 +136,7 @@ func TestMigrateFileSessions_Basic(t *testing.T) { }, }) - result, err := MigrateFileSessions(context.Background(), del, "dragonscale", sessDir) + result, err := MigrateFileSessions(t.Context(), del, pkg.NAME, sessDir) if err != nil { t.Fatalf("MigrateFileSessions: %v", err) } @@ -170,7 +172,7 @@ func TestMigrateFileSessions_Basic(t *testing.T) { } // Check summary was stored as working context - wc, err := del.GetWorkingContext(context.Background(), "dragonscale", "session-2") + wc, err := del.GetWorkingContext(t.Context(), pkg.NAME, "session-2") if err != nil { t.Fatalf("GetWorkingContext: %v", err) } @@ -191,7 +193,7 @@ func TestMigrateFileSessions_Idempotent(t *testing.T) { }) // First run - result1, err := MigrateFileSessions(context.Background(), del, "dragonscale", sessDir) + result1, err := MigrateFileSessions(t.Context(), del, pkg.NAME, sessDir) if err != nil { t.Fatalf("first migration: %v", err) } @@ -200,7 +202,7 @@ func TestMigrateFileSessions_Idempotent(t *testing.T) { } // Second run should be a no-op (marker file exists) - result2, err := MigrateFileSessions(context.Background(), del, "dragonscale", sessDir) + result2, err := MigrateFileSessions(t.Context(), del, pkg.NAME, sessDir) if err != nil { t.Fatalf("second migration: %v", err) } @@ -218,7 +220,7 @@ func TestMigrateFileSessions_EmptyDir(t *testing.T) { sessDir := t.TempDir() del := newMockDelegate() - result, err := MigrateFileSessions(context.Background(), del, "dragonscale", sessDir) + result, err := MigrateFileSessions(t.Context(), del, pkg.NAME, sessDir) if err != nil { t.Fatalf("MigrateFileSessions: %v", err) } @@ -230,7 +232,7 @@ func TestMigrateFileSessions_EmptyDir(t *testing.T) { func TestMigrateFileSessions_NonexistentDir(t *testing.T) { del := newMockDelegate() - result, err := MigrateFileSessions(context.Background(), del, "dragonscale", "/nonexistent/path") + result, err := MigrateFileSessions(t.Context(), del, pkg.NAME, "/nonexistent/path") if err != nil { t.Fatalf("MigrateFileSessions: %v", err) } @@ -252,7 +254,7 @@ func TestMigrateFileSessions_SkipsEmptyMessages(t *testing.T) { }, }) - result, err := MigrateFileSessions(context.Background(), del, "dragonscale", sessDir) + result, err := MigrateFileSessions(t.Context(), del, pkg.NAME, sessDir) if err != nil { t.Fatalf("MigrateFileSessions: %v", err) } @@ -273,7 +275,7 @@ func TestMigrateFileSessions_FallbackKey(t *testing.T) { }, }) - result, err := MigrateFileSessions(context.Background(), del, "dragonscale", sessDir) + result, err := MigrateFileSessions(t.Context(), del, pkg.NAME, sessDir) if err != nil { t.Fatalf("MigrateFileSessions: %v", err) } @@ -300,7 +302,7 @@ func TestMigrateFileSessions_MalformedJSON(t *testing.T) { }, }) - result, err := MigrateFileSessions(context.Background(), del, "dragonscale", sessDir) + result, err := MigrateFileSessions(t.Context(), del, pkg.NAME, sessDir) if err != nil { t.Fatalf("MigrateFileSessions: %v", err) } diff --git a/pkg/runtime/runtime_test.go b/pkg/runtime/runtime_test.go index cad5a82c4..f7af7c813 100644 --- a/pkg/runtime/runtime_test.go +++ b/pkg/runtime/runtime_test.go @@ -7,6 +7,7 @@ import ( "testing" "time" + "github.com/ZanzyTHEbar/dragonscale/pkg" "github.com/ZanzyTHEbar/dragonscale/pkg/bus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -31,7 +32,7 @@ func TestResolveBaseConfigPath_PrefersXDGOverLegacy(t *testing.T) { t.Setenv("HOME", home) t.Setenv("XDG_CONFIG_HOME", xdg) - xdgPath := filepath.Join(xdg, "dragonscale", "config.json") + xdgPath := filepath.Join(xdg, pkg.NAME, "config.json") legacyPath := filepath.Join(home, ".dragonscale", "config.json") require.NoError(t, os.MkdirAll(filepath.Dir(xdgPath), 0o755)) require.NoError(t, os.MkdirAll(filepath.Dir(legacyPath), 0o755)) diff --git a/pkg/state/state.go b/pkg/state/state.go index 8e0733a48..155fe1e2c 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -12,10 +12,11 @@ import ( jsonv2 "github.com/go-json-experiment/json" "github.com/go-json-experiment/json/jsontext" + "github.com/ZanzyTHEbar/dragonscale/pkg" "github.com/ZanzyTHEbar/dragonscale/pkg/memory" ) -const kvAgentID = "dragonscale" +var kvAgentID = pkg.NAME // State represents the persistent state for a workspace. // It includes information about the last active channel/chat. diff --git a/pkg/tools/focus.go b/pkg/tools/focus.go index 4835e772f..a13402415 100644 --- a/pkg/tools/focus.go +++ b/pkg/tools/focus.go @@ -8,6 +8,7 @@ import ( jsonv2 "github.com/go-json-experiment/json" + "github.com/ZanzyTHEbar/dragonscale/pkg" "github.com/ZanzyTHEbar/dragonscale/pkg/logger" "github.com/ZanzyTHEbar/dragonscale/pkg/messages" "github.com/ZanzyTHEbar/dragonscale/pkg/session" @@ -23,9 +24,10 @@ type KVStore interface { const ( focusKVPrefix = "focus:" knowledgeKVPrefix = "knowledge:" - focusAgentID = "dragonscale" ) +var focusAgentID = pkg.NAME + // FocusState tracks an active focus investigation. type FocusState struct { Topic string `json:"topic"` diff --git a/pkg/tools/map_runtime_integration_test.go b/pkg/tools/map_runtime_integration_test.go index a8c4a82ee..48818cd4e 100644 --- a/pkg/tools/map_runtime_integration_test.go +++ b/pkg/tools/map_runtime_integration_test.go @@ -11,6 +11,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/ZanzyTHEbar/dragonscale/pkg" "github.com/ZanzyTHEbar/dragonscale/pkg/bus" "github.com/ZanzyTHEbar/dragonscale/pkg/ids" "github.com/ZanzyTHEbar/dragonscale/pkg/memory/delegate" @@ -76,7 +77,7 @@ func newMapRuntimeForTest(t *testing.T, llm fantasy.LanguageModel, manager *Suba require.NoError(t, d.Init(context.Background())) t.Cleanup(func() { _ = d.Close() }) - return NewMapRuntime(d.Queries(), "dragonscale", llm, "mock-map-llm", manager) + return NewMapRuntime(d.Queries(), pkg.NAME, llm, "mock-map-llm", manager) } func decodeResultMap(t *testing.T, result *ToolResult) map[string]interface{} {