diff --git a/src/palette.ts b/src/palette.ts index 25fc1cd..0d1f890 100644 --- a/src/palette.ts +++ b/src/palette.ts @@ -47,8 +47,11 @@ export function loadTheme(definitionPath: string, dokiRepoRoot: string): ThemeCo const variant = hasVariant ? nameParts[nameParts.length - 1] : null; - // Series directory is 4 levels up when a variant dir exists, 2 levels up otherwise - const series = hasVariant ? parts[parts.length - 4] : parts[parts.length - 2]; + // Series is always the first directory after 'definitions/' regardless of depth. + // Counting from the end is fragile because definitions can be 2, 3 or 4 segments + // deep (series/file, series/char/file, series/char/variant/file). + const defsIdx = parts.lastIndexOf('definitions'); + const series = parts[defsIdx + 1]; const internalName = ['doki', sanitize(series), sanitize(def.displayName), variant ? sanitize(variant) : null] .filter(Boolean)