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

@@ -36,6 +36,9 @@ type Config struct {
MemoryTopK int
MemoryMinScore float64
// Chat template
ChatTemplate string
// Embedding
EmbeddingModel string
@@ -76,6 +79,8 @@ func Load() *Config {
MemoryTopK: getEnvInt("MEMORY_TOP_K", 5),
MemoryMinScore: getEnvFloat("MEMORY_MIN_SCORE", 0.6),
ChatTemplate: getEnv("CHAT_TEMPLATE", "chatml"),
EmbeddingModel: getEnv("EMBEDDING_MODEL", ""),
TraitChangeMaxDaily: getEnvFloat("TRAIT_CHANGE_MAX_DAILY", 0.005),
@@ -104,6 +109,11 @@ func (c *Config) Validate() error {
if c.DiaryHour < 0 || c.DiaryHour > 23 {
return fmt.Errorf("DIARY_HOUR must be 0-23")
}
switch c.ChatTemplate {
case "chatml", "llama3", "none":
default:
return fmt.Errorf("CHAT_TEMPLATE must be chatml, llama3, or none")
}
return nil
}