feat(templates): recover local override support for role templates
Cherry-picked from lost commit 123d0b2b. Adds ability to override
embedded role templates at town or rig level:
- Town: <townRoot>/templates/roles/<role>.md.tmpl
- Rig: <rigPath>/templates/roles/<role>.md.tmpl
New APIs:
- NewWithOverrides(townRoot, rigPath string)
- HasRoleOverride(role string) bool
- RoleOverrideCount() int
Recovered by: gt-vjhf
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,8 +18,14 @@ import (
|
||||
|
||||
// outputPrimeContext outputs the role-specific context using templates or fallback.
|
||||
func outputPrimeContext(ctx RoleContext) error {
|
||||
// Try to use templates first
|
||||
tmpl, err := templates.New()
|
||||
// Calculate rig path for template overrides
|
||||
var rigPath string
|
||||
if ctx.Rig != "" && ctx.TownRoot != "" {
|
||||
rigPath = filepath.Join(ctx.TownRoot, ctx.Rig)
|
||||
}
|
||||
|
||||
// Try to use templates with override support
|
||||
tmpl, err := templates.NewWithOverrides(ctx.TownRoot, rigPath)
|
||||
if err != nil {
|
||||
// Fall back to hardcoded output if templates fail
|
||||
return outputPrimeContextFallback(ctx)
|
||||
|
||||
Reference in New Issue
Block a user