Centralize shared D&D LLM assets

This commit is contained in:
2026-08-05 00:37:19 +00:00
parent a57f83e30d
commit 08954f17e2
15 changed files with 69 additions and 34 deletions

View File

@@ -111,7 +111,7 @@ func TestPromptAssetManifestRejectsMissingModuleFile(t *testing.T) {
func TestPromptAssetManifestRejectsMissingSharedFile(t *testing.T) {
const name = "missing-for-test.md"
const path = "assets/prompts/missing-for-test.md"
const path = "prompts/missing-for-test.md"
previous, existed := sharedPromptPaths[name]
sharedPromptPaths[name] = path
t.Cleanup(func() {
@@ -157,11 +157,15 @@ func TestPromptAssetManifestHashMatchesManifestParts(t *testing.T) {
if err != nil {
t.Fatalf("Hash() error = %v, want nil", err)
}
sharedFS, err := sharedAssetFS()
if err != nil {
t.Fatalf("sharedAssetFS() error = %v, want nil", err)
}
want, err := llm.HashAssets([]llm.AssetHashPart{
{FS: moduleFS, Path: "assets/prompts/dnd.test.yaml"},
{FS: moduleFS, Path: "assets/prompts/task.md"},
{FS: embeddedAssets, Path: "assets/prompts/common-dnd-transcript.md"},
{FS: embeddedAssets, Path: "assets/prompts/common-dnd-system.md"},
{FS: sharedFS, Path: "prompts/common-dnd-transcript.md"},
{FS: sharedFS, Path: "prompts/common-dnd-system.md"},
})
if err != nil {
t.Fatalf("HashAssets() error = %v, want nil", err)
@@ -172,9 +176,9 @@ func TestPromptAssetManifestHashMatchesManifestParts(t *testing.T) {
withUnused, err := llm.HashAssets([]llm.AssetHashPart{
{FS: moduleFS, Path: "assets/prompts/dnd.test.yaml"},
{FS: moduleFS, Path: "assets/prompts/task.md"},
{FS: embeddedAssets, Path: "assets/prompts/common-dnd-transcript.md"},
{FS: embeddedAssets, Path: "assets/prompts/common-dnd-system.md"},
{FS: embeddedAssets, Path: "assets/prompts/common-dnd-npcs.md"},
{FS: sharedFS, Path: "prompts/common-dnd-transcript.md"},
{FS: sharedFS, Path: "prompts/common-dnd-system.md"},
{FS: sharedFS, Path: "prompts/common-dnd-npcs.md"},
})
if err != nil {
t.Fatalf("HashAssets() with unused asset error = %v, want nil", err)
@@ -195,7 +199,7 @@ func TestSharedPromptDescriptorsReturnFreshCopies(t *testing.T) {
}
first[0].Name = "changed.md"
first[0].Path = "changed.md"
if reflect.DeepEqual(first, second) || second[0].Name != "common-dnd-system.md" || second[0].Path != "assets/prompts/common-dnd-system.md" {
if reflect.DeepEqual(first, second) || second[0].Name != "common-dnd-system.md" || second[0].Path != "prompts/common-dnd-system.md" {
t.Fatalf("resolveSharedPromptFiles() reused descriptor state: first=%#v second=%#v", first, second)
}
}