feat(templates): Add local override support for role templates
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 Rig-level overrides take precedence over town-level. This enables customizing polecat (or other role) behavior per-rig without modifying gastown source, following the same 3-tier override pattern as role configs. New APIs: - NewWithOverrides(townRoot, rigPath string) - loads templates with overrides - HasRoleOverride(role string) bool - check if role has override - RoleOverrideCount() int - count of loaded overrides Implements sc-6ghhn 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