From 9cb9ee48a710312b8b582a99479777a6171addc2 Mon Sep 17 00:00:00 2001 From: Eric Rakestraw Date: Wed, 5 Aug 2026 00:38:55 +0000 Subject: [PATCH] Centralize scene planning and description assets --- .../prompts/dnd.scene_descriptions.yaml | 0 .../prompts/instructions.md | 0 .../dnd/scene-descriptions}/prompts/task.md | 0 .../dnd_scene_descriptions_llm.v1.json | 0 .../dnd/scenes}/prompts/dnd.scenes.yaml | 0 .../dnd/scenes}/prompts/instructions.md | 0 .../dnd/scenes}/prompts/task.md | 0 .../dnd/scenes}/schemas/dnd_scenes.v1.json | 0 internal/modules/dnd/chunk/scenes/assets.go | 6 ---- .../modules/dnd/chunk/scenes/prompt_assets.go | 35 +++++++++++++++---- internal/modules/dnd/chunk/scenes/schema.go | 8 +++-- .../dnd/extract/scenedescriptions/assets.go | 6 ---- .../scenedescriptions/prompt_assets.go | 35 +++++++++++++++---- .../dnd/extract/scenedescriptions/schema.go | 8 +++-- 14 files changed, 70 insertions(+), 28 deletions(-) rename {internal/modules/dnd/extract/scenedescriptions/assets => assets/dnd/scene-descriptions}/prompts/dnd.scene_descriptions.yaml (100%) rename {internal/modules/dnd/extract/scenedescriptions/assets => assets/dnd/scene-descriptions}/prompts/instructions.md (100%) rename {internal/modules/dnd/extract/scenedescriptions/assets => assets/dnd/scene-descriptions}/prompts/task.md (100%) rename {internal/modules/dnd/extract/scenedescriptions/assets => assets/dnd/scene-descriptions}/schemas/dnd_scene_descriptions_llm.v1.json (100%) rename {internal/modules/dnd/chunk/scenes/assets => assets/dnd/scenes}/prompts/dnd.scenes.yaml (100%) rename {internal/modules/dnd/chunk/scenes/assets => assets/dnd/scenes}/prompts/instructions.md (100%) rename {internal/modules/dnd/chunk/scenes/assets => assets/dnd/scenes}/prompts/task.md (100%) rename {internal/modules/dnd/chunk/scenes/assets => assets/dnd/scenes}/schemas/dnd_scenes.v1.json (100%) delete mode 100644 internal/modules/dnd/chunk/scenes/assets.go delete mode 100644 internal/modules/dnd/extract/scenedescriptions/assets.go diff --git a/internal/modules/dnd/extract/scenedescriptions/assets/prompts/dnd.scene_descriptions.yaml b/assets/dnd/scene-descriptions/prompts/dnd.scene_descriptions.yaml similarity index 100% rename from internal/modules/dnd/extract/scenedescriptions/assets/prompts/dnd.scene_descriptions.yaml rename to assets/dnd/scene-descriptions/prompts/dnd.scene_descriptions.yaml diff --git a/internal/modules/dnd/extract/scenedescriptions/assets/prompts/instructions.md b/assets/dnd/scene-descriptions/prompts/instructions.md similarity index 100% rename from internal/modules/dnd/extract/scenedescriptions/assets/prompts/instructions.md rename to assets/dnd/scene-descriptions/prompts/instructions.md diff --git a/internal/modules/dnd/extract/scenedescriptions/assets/prompts/task.md b/assets/dnd/scene-descriptions/prompts/task.md similarity index 100% rename from internal/modules/dnd/extract/scenedescriptions/assets/prompts/task.md rename to assets/dnd/scene-descriptions/prompts/task.md diff --git a/internal/modules/dnd/extract/scenedescriptions/assets/schemas/dnd_scene_descriptions_llm.v1.json b/assets/dnd/scene-descriptions/schemas/dnd_scene_descriptions_llm.v1.json similarity index 100% rename from internal/modules/dnd/extract/scenedescriptions/assets/schemas/dnd_scene_descriptions_llm.v1.json rename to assets/dnd/scene-descriptions/schemas/dnd_scene_descriptions_llm.v1.json diff --git a/internal/modules/dnd/chunk/scenes/assets/prompts/dnd.scenes.yaml b/assets/dnd/scenes/prompts/dnd.scenes.yaml similarity index 100% rename from internal/modules/dnd/chunk/scenes/assets/prompts/dnd.scenes.yaml rename to assets/dnd/scenes/prompts/dnd.scenes.yaml diff --git a/internal/modules/dnd/chunk/scenes/assets/prompts/instructions.md b/assets/dnd/scenes/prompts/instructions.md similarity index 100% rename from internal/modules/dnd/chunk/scenes/assets/prompts/instructions.md rename to assets/dnd/scenes/prompts/instructions.md diff --git a/internal/modules/dnd/chunk/scenes/assets/prompts/task.md b/assets/dnd/scenes/prompts/task.md similarity index 100% rename from internal/modules/dnd/chunk/scenes/assets/prompts/task.md rename to assets/dnd/scenes/prompts/task.md diff --git a/internal/modules/dnd/chunk/scenes/assets/schemas/dnd_scenes.v1.json b/assets/dnd/scenes/schemas/dnd_scenes.v1.json similarity index 100% rename from internal/modules/dnd/chunk/scenes/assets/schemas/dnd_scenes.v1.json rename to assets/dnd/scenes/schemas/dnd_scenes.v1.json diff --git a/internal/modules/dnd/chunk/scenes/assets.go b/internal/modules/dnd/chunk/scenes/assets.go deleted file mode 100644 index 8fd77b0..0000000 --- a/internal/modules/dnd/chunk/scenes/assets.go +++ /dev/null @@ -1,6 +0,0 @@ -package scenes - -import "embed" - -//go:embed assets/schemas/*.json assets/prompts/*.yaml assets/prompts/*.md -var embeddedAssets embed.FS diff --git a/internal/modules/dnd/chunk/scenes/prompt_assets.go b/internal/modules/dnd/chunk/scenes/prompt_assets.go index bfce692..ca49c5e 100644 --- a/internal/modules/dnd/chunk/scenes/prompt_assets.go +++ b/internal/modules/dnd/chunk/scenes/prompt_assets.go @@ -2,8 +2,10 @@ package scenes import ( "fmt" + "io/fs" "sync" + rootassets "gitea.maximumdirect.net/eric/notarius/assets" "gitea.maximumdirect.net/eric/notarius/internal/framework/llm" "gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs" "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared" @@ -14,9 +16,9 @@ const promptAssetRoot = "assets/prompts" var promptAssetManifest = shared.PromptAssetManifest{ ModuleDir: "dnd.scenes", ModuleFiles: []promptfs.ModulePromptFile{ - {Name: "dnd.scenes.yaml", Path: "assets/prompts/dnd.scenes.yaml"}, - {Name: "task.md", Path: "assets/prompts/task.md"}, - {Name: "instructions.md", Path: "assets/prompts/instructions.md"}, + {Name: "dnd.scenes.yaml", Path: "prompts/dnd.scenes.yaml"}, + {Name: "task.md", Path: "prompts/task.md"}, + {Name: "instructions.md", Path: "prompts/instructions.md"}, }, SharedFiles: []string{ "common-dnd-system.md", @@ -25,20 +27,41 @@ var promptAssetManifest = shared.PromptAssetManifest{ }, } +func moduleAssetFS() (fs.FS, error) { + assets, err := fs.Sub(rootassets.FS(), "dnd/scenes") + if err != nil { + return nil, fmt.Errorf("scope scene assets: %w", err) + } + return assets, nil +} + func RegisterPromptAssets(registry *llm.AssetRegistry) error { - promptFS, err := promptAssetManifest.PromptFS(embeddedAssets) + assets, err := moduleAssetFS() + if err != nil { + return err + } + promptFS, err := promptAssetManifest.PromptFS(assets) if err != nil { return fmt.Errorf("prepare scene prompt assets: %w", err) } if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil { return err } - return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas") + schemas, err := fs.Sub(assets, "schemas") + if err != nil { + return fmt.Errorf("scope scene schemas: %w", err) + } + return registry.RegisterSchemaFS(schemas, ".") } func promptAssetMetadata() (string, error) { promptAssetHashOnce.Do(func() { - promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets) + assets, err := moduleAssetFS() + if err != nil { + promptAssetHashErr = err + return + } + promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets) }) return promptAssetHash, promptAssetHashErr } diff --git a/internal/modules/dnd/chunk/scenes/schema.go b/internal/modules/dnd/chunk/scenes/schema.go index bd2e4fb..38e309a 100644 --- a/internal/modules/dnd/chunk/scenes/schema.go +++ b/internal/modules/dnd/chunk/scenes/schema.go @@ -11,11 +11,15 @@ const ( ) func loadResponseSchema() (llm.ResponseSchema, error) { - return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{ + assets, err := moduleAssetFS() + if err != nil { + return llm.ResponseSchema{}, err + } + return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{ Key: ResponseSchemaKey, ID: ResponseSchemaID, Version: ResponseSchemaVersion, Name: ResponseSchemaName, - AssetPath: "assets/schemas/dnd_scenes.v1.json", + AssetPath: "schemas/dnd_scenes.v1.json", }) } diff --git a/internal/modules/dnd/extract/scenedescriptions/assets.go b/internal/modules/dnd/extract/scenedescriptions/assets.go deleted file mode 100644 index d298053..0000000 --- a/internal/modules/dnd/extract/scenedescriptions/assets.go +++ /dev/null @@ -1,6 +0,0 @@ -package scenedescriptions - -import "embed" - -//go:embed assets/schemas/dnd_scene_descriptions_llm.v1.json assets/prompts/*.yaml assets/prompts/*.md -var embeddedAssets embed.FS diff --git a/internal/modules/dnd/extract/scenedescriptions/prompt_assets.go b/internal/modules/dnd/extract/scenedescriptions/prompt_assets.go index 1bd9b21..1c2d56a 100644 --- a/internal/modules/dnd/extract/scenedescriptions/prompt_assets.go +++ b/internal/modules/dnd/extract/scenedescriptions/prompt_assets.go @@ -2,8 +2,10 @@ package scenedescriptions import ( "fmt" + "io/fs" "sync" + rootassets "gitea.maximumdirect.net/eric/notarius/assets" "gitea.maximumdirect.net/eric/notarius/internal/framework/llm" "gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs" "gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared" @@ -14,9 +16,9 @@ const promptAssetRoot = "assets/prompts" var promptAssetManifest = shared.PromptAssetManifest{ ModuleDir: "dnd.scene_descriptions", ModuleFiles: []promptfs.ModulePromptFile{ - {Name: "dnd.scene_descriptions.yaml", Path: "assets/prompts/dnd.scene_descriptions.yaml"}, - {Name: "task.md", Path: "assets/prompts/task.md"}, - {Name: "instructions.md", Path: "assets/prompts/instructions.md"}, + {Name: "dnd.scene_descriptions.yaml", Path: "prompts/dnd.scene_descriptions.yaml"}, + {Name: "task.md", Path: "prompts/task.md"}, + {Name: "instructions.md", Path: "prompts/instructions.md"}, }, SharedFiles: []string{ "common-dnd-system.md", @@ -26,20 +28,41 @@ var promptAssetManifest = shared.PromptAssetManifest{ }, } +func moduleAssetFS() (fs.FS, error) { + assets, err := fs.Sub(rootassets.FS(), "dnd/scene-descriptions") + if err != nil { + return nil, fmt.Errorf("scope scene-description assets: %w", err) + } + return assets, nil +} + func RegisterPromptAssets(registry *llm.AssetRegistry) error { - promptFS, err := promptAssetManifest.PromptFS(embeddedAssets) + assets, err := moduleAssetFS() + if err != nil { + return err + } + promptFS, err := promptAssetManifest.PromptFS(assets) if err != nil { return fmt.Errorf("prepare scene-description prompt assets: %w", err) } if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil { return err } - return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas") + schemas, err := fs.Sub(assets, "schemas") + if err != nil { + return fmt.Errorf("scope scene-description schemas: %w", err) + } + return registry.RegisterSchemaFS(schemas, ".") } func promptAssetMetadata() (string, error) { promptAssetHashOnce.Do(func() { - promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets) + assets, err := moduleAssetFS() + if err != nil { + promptAssetHashErr = err + return + } + promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets) }) return promptAssetHash, promptAssetHashErr } diff --git a/internal/modules/dnd/extract/scenedescriptions/schema.go b/internal/modules/dnd/extract/scenedescriptions/schema.go index 86a8351..143ae45 100644 --- a/internal/modules/dnd/extract/scenedescriptions/schema.go +++ b/internal/modules/dnd/extract/scenedescriptions/schema.go @@ -12,11 +12,15 @@ const ( ) func loadResponseSchema() (llm.ResponseSchema, error) { - return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{ + assets, err := moduleAssetFS() + if err != nil { + return llm.ResponseSchema{}, err + } + return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{ Key: ResponseSchemaKey, ID: ResponseSchemaID, Version: SchemaVersion, Name: ResponseSchemaName, - AssetPath: "assets/schemas/dnd_scene_descriptions_llm.v1.json", + AssetPath: "schemas/dnd_scene_descriptions_llm.v1.json", }) }