feat: Phase 2 — chat templates, reasoning parser, collapsible TUI, mouse support

- internal/llama/template.go: ChatML/Llama3 template engine with stop tokens
- internal/agent/reasoning.go: parse <think>/<reasoning> tags from LLM output
- companion/promptbuilder.go: output structured BuildResult, add date/time context
- agent/agent.go: wire templates + reasoning split into message loop
- storage: add reasoning TEXT column to messages table + migration
- channel/tui.go: collapsible reasoning (tab toggle), mouse scroll, polished dimmed style
- config: CHAT_TEMPLATE env var (chatml|llama3|none)
- plan.md: mark Phase 2 complete, add themes TODO
This commit is contained in:
2026-06-10 09:42:45 +03:30
parent f57b42fd6e
commit 3895ca68c0
14 changed files with 327 additions and 144 deletions

View File

@@ -45,7 +45,7 @@ func NewEngine(cfg *config.Config, db *storage.DB) *Engine {
}
}
func (e *Engine) BuildPrompt(ctx context.Context, input *PromptInput) (string, error) {
func (e *Engine) BuildPrompt(ctx context.Context, input *PromptInput) (*BuildResult, error) {
e.mu.Lock()
defer e.mu.Unlock()
@@ -54,7 +54,7 @@ func (e *Engine) BuildPrompt(ctx context.Context, input *PromptInput) (string, e
mood := e.mood.Current()
observations := e.reflection.RecentObservations(5)
prompt := e.promptBuilder.Build(&BuildInput{
result := e.promptBuilder.Build(&BuildInput{
SystemPrompt: e.cfg.SystemPrompt,
Traits: traits,
Relationship: rel,
@@ -66,7 +66,7 @@ func (e *Engine) BuildPrompt(ctx context.Context, input *PromptInput) (string, e
})
e.lastContact = time.Now()
return prompt, nil
return result, nil
}
func (e *Engine) WriteDiary(ctx context.Context) error {