additional tools

This commit is contained in:
Kujtim Hoxha 2025-03-25 13:04:36 +01:00
parent 005b8ac167
commit 904061c243
33 changed files with 3258 additions and 236 deletions

View file

@ -10,6 +10,7 @@ import (
"github.com/kujtimiihoxha/termai/internal/db"
"github.com/kujtimiihoxha/termai/internal/llm/models"
"github.com/kujtimiihoxha/termai/internal/tui"
zone "github.com/lrstanley/bubblezone"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
@ -37,9 +38,11 @@ var rootCmd = &cobra.Command{
app := app.New(ctx, conn)
app.Logger.Info("Starting termai...")
zone.NewGlobal()
tui := tea.NewProgram(
tui.New(app),
tea.WithAltScreen(),
tea.WithMouseCellMotion(),
)
app.Logger.Info("Setting up subscriptions...")
ch, unsub := setupSubscriptions(app)
@ -102,6 +105,16 @@ func setupSubscriptions(app *app.App) (chan tea.Msg, func()) {
wg.Done()
}()
}
{
sub := app.Permissions.Subscribe(ctx)
wg.Add(1)
go func() {
for ev := range sub {
ch <- ev
}
wg.Done()
}()
}
return ch, func() {
cancel()
wg.Wait()
@ -130,6 +143,7 @@ func loadConfig() {
// LLM
viper.SetDefault("models.big", string(models.DefaultBigModel))
viper.SetDefault("models.small", string(models.DefaultLittleModel))
viper.SetDefault("providers.openai.key", os.Getenv("OPENAI_API_KEY"))
viper.SetDefault("providers.anthropic.key", os.Getenv("ANTHROPIC_API_KEY"))
viper.SetDefault("providers.groq.key", os.Getenv("GROQ_API_KEY"))