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:
@@ -3,6 +3,7 @@ package storage
|
||||
var migrations = []string{
|
||||
divacodeSchema,
|
||||
companionSchema,
|
||||
addReasoningColumn,
|
||||
}
|
||||
|
||||
const divacodeSchema = `
|
||||
@@ -17,6 +18,7 @@ CREATE TABLE IF NOT EXISTS messages (
|
||||
conversation_id TEXT NOT NULL REFERENCES conversations(id),
|
||||
role TEXT NOT NULL CHECK(role IN ('user','assistant','system','tool')),
|
||||
content TEXT NOT NULL,
|
||||
reasoning TEXT,
|
||||
tool_call TEXT,
|
||||
token_count INTEGER,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
@@ -111,3 +113,5 @@ CREATE TABLE IF NOT EXISTS agent_strategies (
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
`
|
||||
|
||||
const addReasoningColumn = `ALTER TABLE messages ADD COLUMN reasoning TEXT;`
|
||||
|
||||
@@ -29,7 +29,12 @@ func Open(path string) (*DB, error) {
|
||||
|
||||
func (db *DB) Migrate() error {
|
||||
for _, m := range migrations {
|
||||
if err := db.Exec(m); err != nil {
|
||||
err := db.Exec(m)
|
||||
if err != nil && m == addReasoningColumn {
|
||||
// may already exist on fresh DBs
|
||||
continue
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user