on main help sign in
add initial git support
bd2ec29Kujtim Hoxha
.gitignore+1
@@ -43,3 +43,4 @@ debug.log
43
43
44.termai
44.termai
45
45
46+internal/assets/diff/index.mjs
README.md+13
@@ -102,6 +102,9 @@ TermAI is built with a modular architecture:
102git clone https://github.com/kujtimiihoxha/termai.git
102git clone https://github.com/kujtimiihoxha/termai.git
103cd termai
103cd termai
104
104
105+# Build the diff script first
106+go run cmd/diff/main.go
107+
105# Build
108# Build
106go build -o termai
109go build -o termai
107
110
@@ -109,6 +112,16 @@ go build -o termai
109./termai
112./termai
110```
113```
111
114
115+### Important: Building the Diff Script
116+
117+Before building or running the application, you must first build the diff script by running:
118+
119+```bash
120+go run cmd/diff/main.go
121+```
122+
123+This command generates the necessary JavaScript file (`index.mjs`) used by the diff functionality in the application.
124+
112## Acknowledgments
125## Acknowledgments
113
126
114TermAI builds upon the work of several open source projects and developers:
127TermAI builds upon the work of several open source projects and developers:
cmd/diff/main.gonew file+102
@@ -0,0 +1,102 @@
1+package main
2+
3+import (
4+ "fmt"
5+ "io"
6+ "os"
7+ "os/exec"
8+ "path/filepath"
9+)
10+
11+func main() {
12+ // Create a temporary directory
13+ tempDir, err := os.MkdirTemp("", "git-split-diffs")
14+ if err != nil {
15+ fmt.Printf("Error creating temp directory: %v\n", err)
16+ os.Exit(1)
17+ }
18+ defer func() {
19+ fmt.Printf("Cleaning up temporary directory: %s\n", tempDir)
20+ os.RemoveAll(tempDir)
21+ }()
22+ fmt.Printf("Created temporary directory: %s\n", tempDir)
23+
24+ // Clone the repository with minimum depth
25+ fmt.Println("Cloning git-split-diffs repository with minimum depth...")
26+ cmd := exec.Command("git", "clone", "--depth=1", "https://github.com/kujtimiihoxha/git-split-diffs", tempDir)
27+ cmd.Stdout = os.Stdout
28+ cmd.Stderr = os.Stderr
29+ if err := cmd.Run(); err != nil {
30+ fmt.Printf("Error cloning repository: %v\n", err)
31+ os.Exit(1)
32+ }
33+
34+ // Run npm install
35+ fmt.Println("Running npm install...")
36+ cmdNpmInstall := exec.Command("npm", "install")
37+ cmdNpmInstall.Dir = tempDir
38+ cmdNpmInstall.Stdout = os.Stdout
39+ cmdNpmInstall.Stderr = os.Stderr
40+ if err := cmdNpmInstall.Run(); err != nil {
41+ fmt.Printf("Error running npm install: %v\n", err)
42+ os.Exit(1)
43+ }
44+
45+ // Run npm run build
46+ fmt.Println("Running npm run build...")
47+ cmdNpmBuild := exec.Command("npm", "run", "build")
48+ cmdNpmBuild.Dir = tempDir
49+ cmdNpmBuild.Stdout = os.Stdout
50+ cmdNpmBuild.Stderr = os.Stderr
51+ if err := cmdNpmBuild.Run(); err != nil {
52+ fmt.Printf("Error running npm run build: %v\n", err)
53+ os.Exit(1)
54+ }
55+
56+ destDir := filepath.Join(".", "internal", "assets", "diff")
57+ destFile := filepath.Join(destDir, "index.mjs")
58+
59+ // Make sure the destination directory exists
60+ if err := os.MkdirAll(destDir, 0o755); err != nil {
61+ fmt.Printf("Error creating destination directory: %v\n", err)
62+ os.Exit(1)
63+ }
64+
65+ // Copy the file
66+ srcFile := filepath.Join(tempDir, "build", "index.mjs")
67+ fmt.Printf("Copying %s to %s\n", srcFile, destFile)
68+ if err := copyFile(srcFile, destFile); err != nil {
69+ fmt.Printf("Error copying file: %v\n", err)
70+ os.Exit(1)
71+ }
72+
73+ fmt.Println("Successfully completed the process!")
74+}
75+
76+// copyFile copies a file from src to dst
77+func copyFile(src, dst string) error {
78+ sourceFile, err := os.Open(src)
79+ if err != nil {
80+ return err
81+ }
82+ defer sourceFile.Close()
83+
84+ destFile, err := os.Create(dst)
85+ if err != nil {
86+ return err
87+ }
88+ defer destFile.Close()
89+
90+ _, err = io.Copy(destFile, sourceFile)
91+ if err != nil {
92+ return err
93+ }
94+
95+ // Make sure the file is written to disk
96+ err = destFile.Sync()
97+ if err != nil {
98+ return err
99+ }
100+
101+ return nil
102+}
cmd/git/main.gonew file+4
@@ -0,0 +1,4 @@
1+package main
2+
3+func main() {
4+}
cmd/root.go+6
@@ -8,6 +8,7 @@ import (
8
8
9 tea "github.com/charmbracelet/bubbletea"
9 tea "github.com/charmbracelet/bubbletea"
10 "github.com/kujtimiihoxha/termai/internal/app"
10 "github.com/kujtimiihoxha/termai/internal/app"
11+ "github.com/kujtimiihoxha/termai/internal/assets"
11 "github.com/kujtimiihoxha/termai/internal/config"
12 "github.com/kujtimiihoxha/termai/internal/config"
12 "github.com/kujtimiihoxha/termai/internal/db"
13 "github.com/kujtimiihoxha/termai/internal/db"
13 "github.com/kujtimiihoxha/termai/internal/llm/agent"
14 "github.com/kujtimiihoxha/termai/internal/llm/agent"
@@ -28,6 +29,9 @@ var rootCmd = &cobra.Command{
28 }
29 }
29 debug, _ := cmd.Flags().GetBool("debug")
30 debug, _ := cmd.Flags().GetBool("debug")
30 err := config.Load(debug)
31 err := config.Load(debug)
32+ if err != nil {
33+ return err
34+ }
31 cfg := config.Get()
35 cfg := config.Get()
32 defaultLevel := slog.LevelInfo
36 defaultLevel := slog.LevelInfo
33 if cfg.Debug {
37 if cfg.Debug {
@@ -38,9 +42,11 @@ var rootCmd = &cobra.Command{
38 }))
42 }))
39 slog.SetDefault(logger)
43 slog.SetDefault(logger)
40
44
45+ err = assets.WriteAssets()
41 if err != nil {
46 if err != nil {
42 return err
47 return err
43 }
48 }
49+
44 conn, err := db.Connect()
50 conn, err := db.Connect()
45 if err != nil {
51 if err != nil {
46 return err
52 return err
go.mod+16−4
@@ -17,6 +17,7 @@ require (
17 github.com/charmbracelet/lipgloss v1.1.0
17 github.com/charmbracelet/lipgloss v1.1.0
18 github.com/charmbracelet/x/ansi v0.8.0
18 github.com/charmbracelet/x/ansi v0.8.0
19 github.com/fsnotify/fsnotify v1.8.0
19 github.com/fsnotify/fsnotify v1.8.0
20+ github.com/go-git/go-git/v5 v5.15.0
20 github.com/go-logfmt/logfmt v0.6.0
21 github.com/go-logfmt/logfmt v0.6.0
21 github.com/golang-migrate/migrate/v4 v4.18.2
22 github.com/golang-migrate/migrate/v4 v4.18.2
22 github.com/google/generative-ai-go v0.19.0
23 github.com/google/generative-ai-go v0.19.0
@@ -45,6 +46,9 @@ require (
45 cloud.google.com/go/auth/oauth2adapt v0.2.6 // indirect
46 cloud.google.com/go/auth/oauth2adapt v0.2.6 // indirect
46 cloud.google.com/go/compute/metadata v0.6.0 // indirect
47 cloud.google.com/go/compute/metadata v0.6.0 // indirect
47 cloud.google.com/go/longrunning v0.5.7 // indirect
48 cloud.google.com/go/longrunning v0.5.7 // indirect
49+ dario.cat/mergo v1.0.0 // indirect
50+ github.com/Microsoft/go-winio v0.6.2 // indirect
51+ github.com/ProtonMail/go-crypto v1.1.6 // indirect
48 github.com/alecthomas/chroma/v2 v2.15.0 // indirect
52 github.com/alecthomas/chroma/v2 v2.15.0 // indirect
49 github.com/andybalholm/cascadia v1.3.2 // indirect
53 github.com/andybalholm/cascadia v1.3.2 // indirect
50 github.com/atotto/clipboard v0.1.4 // indirect
54 github.com/atotto/clipboard v0.1.4 // indirect
@@ -68,15 +72,20 @@ require (
68 github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
72 github.com/charmbracelet/x/cellbuf v0.0.13-0.20250311204145-2c3ea96c31dd // indirect
69 github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
73 github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
70 github.com/charmbracelet/x/term v0.2.1 // indirect
74 github.com/charmbracelet/x/term v0.2.1 // indirect
75+ github.com/cloudflare/circl v1.6.1 // indirect
76+ github.com/cyphar/filepath-securejoin v0.4.1 // indirect
71 github.com/davecgh/go-spew v1.1.1 // indirect
77 github.com/davecgh/go-spew v1.1.1 // indirect
72 github.com/dlclark/regexp2 v1.11.4 // indirect
78 github.com/dlclark/regexp2 v1.11.4 // indirect
73 github.com/dustin/go-humanize v1.0.1 // indirect
79 github.com/dustin/go-humanize v1.0.1 // indirect
80+ github.com/emirpasic/gods v1.18.1 // indirect
74 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
81 github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
75 github.com/felixge/httpsnoop v1.0.4 // indirect
82 github.com/felixge/httpsnoop v1.0.4 // indirect
83+ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
84+ github.com/go-git/go-billy/v5 v5.6.2 // indirect
76 github.com/go-logr/logr v1.4.2 // indirect
85 github.com/go-logr/logr v1.4.2 // indirect
77 github.com/go-logr/stdr v1.2.2 // indirect
86 github.com/go-logr/stdr v1.2.2 // indirect
78 github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
87 github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
79− github.com/google/go-cmp v0.7.0 // indirect
88+ github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
80 github.com/google/s2a-go v0.1.8 // indirect
89 github.com/google/s2a-go v0.1.8 // indirect
81 github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
90 github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
82 github.com/googleapis/gax-go/v2 v2.14.1 // indirect
91 github.com/googleapis/gax-go/v2 v2.14.1 // indirect
@@ -84,6 +93,8 @@ require (
84 github.com/hashicorp/errwrap v1.1.0 // indirect
93 github.com/hashicorp/errwrap v1.1.0 // indirect
85 github.com/hashicorp/go-multierror v1.1.1 // indirect
94 github.com/hashicorp/go-multierror v1.1.1 // indirect
86 github.com/inconshreveable/mousetrap v1.1.0 // indirect
95 github.com/inconshreveable/mousetrap v1.1.0 // indirect
96+ github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
97+ github.com/kevinburke/ssh_config v1.2.0 // indirect
87 github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
98 github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
88 github.com/mattn/go-isatty v0.0.20 // indirect
99 github.com/mattn/go-isatty v0.0.20 // indirect
89 github.com/mattn/go-localereader v0.0.1 // indirect
100 github.com/mattn/go-localereader v0.0.1 // indirect
@@ -91,11 +102,12 @@ require (
91 github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
102 github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
92 github.com/muesli/cancelreader v0.2.2 // indirect
103 github.com/muesli/cancelreader v0.2.2 // indirect
93 github.com/pelletier/go-toml/v2 v2.2.3 // indirect
104 github.com/pelletier/go-toml/v2 v2.2.3 // indirect
105+ github.com/pjbgf/sha1cd v0.3.2 // indirect
94 github.com/pmezard/go-difflib v1.0.0 // indirect
106 github.com/pmezard/go-difflib v1.0.0 // indirect
95 github.com/rivo/uniseg v0.4.7 // indirect
107 github.com/rivo/uniseg v0.4.7 // indirect
96− github.com/rogpeppe/go-internal v1.14.1 // indirect
97 github.com/sagikazarmark/locafero v0.7.0 // indirect
108 github.com/sagikazarmark/locafero v0.7.0 // indirect
98 github.com/sahilm/fuzzy v0.1.1 // indirect
109 github.com/sahilm/fuzzy v0.1.1 // indirect
110+ github.com/skeema/knownhosts v1.3.1 // indirect
99 github.com/sourcegraph/conc v0.3.0 // indirect
111 github.com/sourcegraph/conc v0.3.0 // indirect
100 github.com/spf13/afero v1.12.0 // indirect
112 github.com/spf13/afero v1.12.0 // indirect
101 github.com/spf13/cast v1.7.1 // indirect
113 github.com/spf13/cast v1.7.1 // indirect
@@ -105,6 +117,7 @@ require (
105 github.com/tidwall/match v1.1.1 // indirect
117 github.com/tidwall/match v1.1.1 // indirect
106 github.com/tidwall/pretty v1.2.1 // indirect
118 github.com/tidwall/pretty v1.2.1 // indirect
107 github.com/tidwall/sjson v1.2.5 // indirect
119 github.com/tidwall/sjson v1.2.5 // indirect
120+ github.com/xanzy/ssh-agent v0.3.3 // indirect
108 github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
121 github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
109 github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
122 github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
110 github.com/yuin/goldmark v1.7.8 // indirect
123 github.com/yuin/goldmark v1.7.8 // indirect
@@ -118,7 +131,6 @@ require (
118 go.uber.org/multierr v1.9.0 // indirect
131 go.uber.org/multierr v1.9.0 // indirect
119 golang.design/x/clipboard v0.7.0 // indirect
132 golang.design/x/clipboard v0.7.0 // indirect
120 golang.org/x/crypto v0.37.0 // indirect
133 golang.org/x/crypto v0.37.0 // indirect
121− golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
122 golang.org/x/exp/shiny v0.0.0-20250305212735-054e65f0b394 // indirect
134 golang.org/x/exp/shiny v0.0.0-20250305212735-054e65f0b394 // indirect
123 golang.org/x/image v0.14.0 // indirect
135 golang.org/x/image v0.14.0 // indirect
124 golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a // indirect
136 golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a // indirect
@@ -132,6 +144,6 @@ require (
132 google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
144 google.golang.org/genproto/googleapis/rpc v0.0.0-20241223144023-3abc09e42ca8 // indirect
133 google.golang.org/grpc v1.67.3 // indirect
145 google.golang.org/grpc v1.67.3 // indirect
134 google.golang.org/protobuf v1.36.1 // indirect
146 google.golang.org/protobuf v1.36.1 // indirect
135− gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
147+ gopkg.in/warnings.v0 v0.1.2 // indirect
136 gopkg.in/yaml.v3 v3.0.1 // indirect
148 gopkg.in/yaml.v3 v3.0.1 // indirect
137)
149)
go.sum+56−1
@@ -10,10 +10,17 @@ cloud.google.com/go/compute/metadata v0.6.0 h1:A6hENjEsCDtC1k8byVsgwvVcioamEHvZ4
10cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=
10cloud.google.com/go/compute/metadata v0.6.0/go.mod h1:FjyFAW1MW0C203CEOMDTu3Dk1FlqW3Rga40jzHL4hfg=
11cloud.google.com/go/longrunning v0.5.7 h1:WLbHekDbjK1fVFD3ibpFFVoyizlLRl73I7YKuAKilhU=
11cloud.google.com/go/longrunning v0.5.7 h1:WLbHekDbjK1fVFD3ibpFFVoyizlLRl73I7YKuAKilhU=
12cloud.google.com/go/longrunning v0.5.7/go.mod h1:8GClkudohy1Fxm3owmBGid8W0pSgodEMwEAztp38Xng=
12cloud.google.com/go/longrunning v0.5.7/go.mod h1:8GClkudohy1Fxm3owmBGid8W0pSgodEMwEAztp38Xng=
13+dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
14+dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
13github.com/JohannesKaufmann/html-to-markdown v1.6.0 h1:04VXMiE50YYfCfLboJCLcgqF5x+rHJnb1ssNmqpLH/k=
15github.com/JohannesKaufmann/html-to-markdown v1.6.0 h1:04VXMiE50YYfCfLboJCLcgqF5x+rHJnb1ssNmqpLH/k=
14github.com/JohannesKaufmann/html-to-markdown v1.6.0/go.mod h1:NUI78lGg/a7vpEJTz/0uOcYMaibytE4BUOQS8k78yPQ=
16github.com/JohannesKaufmann/html-to-markdown v1.6.0/go.mod h1:NUI78lGg/a7vpEJTz/0uOcYMaibytE4BUOQS8k78yPQ=
15github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
17github.com/MakeNowJust/heredoc v1.0.0 h1:cXCdzVdstXyiTqTvfqk9SDHpKNjxuom+DOlyEeQ4pzQ=
16github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
18github.com/MakeNowJust/heredoc v1.0.0/go.mod h1:mG5amYoWBHf8vpLOuehzbGGw0EHxpZZ6lCpQ4fNJ8LE=
19+github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
20+github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERoyfY=
21+github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
22+github.com/ProtonMail/go-crypto v1.1.6 h1:ZcV+Ropw6Qn0AX9brlQLAUXfqLBc7Bl+f/DmNxpLfdw=
23+github.com/ProtonMail/go-crypto v1.1.6/go.mod h1:rA3QumHc/FZ8pAHreoekgiAbzpNsfQAosU5td4SnOrE=
17github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE=
24github.com/PuerkitoBio/goquery v1.9.2 h1:4/wZksC3KgkQw7SQgkKotmKljk0M6V8TUvA8Wb4yPeE=
18github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk=
25github.com/PuerkitoBio/goquery v1.9.2/go.mod h1:GHPCaP0ODyyxqcNoFGYlAprUFH81NuRPd0GX3Zu2Mvk=
19github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
26github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
@@ -24,8 +31,12 @@ github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc
24github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
31github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
25github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
32github.com/andybalholm/cascadia v1.3.2 h1:3Xi6Dw5lHF15JtdcmAHD3i1+T8plmv7BQ/nsViSLyss=
26github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
33github.com/andybalholm/cascadia v1.3.2/go.mod h1:7gtRlve5FxPPgIgX36uWBX58OdBsSS6lUvCFb+h7KvU=
34+github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFIImctFaOjnTIavg87rW78vTPkQqLI8=
35+github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
27github.com/anthropics/anthropic-sdk-go v0.2.0-beta.2 h1:h7qxtumNjKPWFv1QM/HJy60MteeW23iKeEtBoY7bYZk=
36github.com/anthropics/anthropic-sdk-go v0.2.0-beta.2 h1:h7qxtumNjKPWFv1QM/HJy60MteeW23iKeEtBoY7bYZk=
28github.com/anthropics/anthropic-sdk-go v0.2.0-beta.2/go.mod h1:AapDW22irxK2PSumZiQXYUFvsdQgkwIWlpESweWZI/c=
37github.com/anthropics/anthropic-sdk-go v0.2.0-beta.2/go.mod h1:AapDW22irxK2PSumZiQXYUFvsdQgkwIWlpESweWZI/c=
38+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
39+github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
29github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
40github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
30github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
41github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
31github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY=
42github.com/aws/aws-sdk-go-v2 v1.30.3 h1:jUeBtG0Ih+ZIFH0F4UkmL9w3cSpaMv9tYYDbzILP8dY=
@@ -88,7 +99,11 @@ github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 h1:qko
88github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ=
99github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0/go.mod h1:pBhA0ybfXv6hDjQUZ7hk1lVxBiUbupdw5R31yPUViVQ=
89github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
100github.com/charmbracelet/x/term v0.2.1 h1:AQeHeLZ1OqSXhrAWpYUtZyX1T3zVxfpZuEQMIQaGIAQ=
90github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
101github.com/charmbracelet/x/term v0.2.1/go.mod h1:oQ4enTYFV7QN4m0i9mzHrViD7TQKvNEEkHUMCmsxdUg=
102+github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
103+github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
91github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
104github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
105+github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s=
106+github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
92github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
107github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
93github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
108github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
94github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
109github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -96,6 +111,10 @@ github.com/dlclark/regexp2 v1.11.4 h1:rPYF9/LECdNymJufQKmri9gV604RvvABwgOA8un7yA
96github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
111github.com/dlclark/regexp2 v1.11.4/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
97github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
112github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
98github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
113github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
114+github.com/elazarl/goproxy v1.7.2 h1:Y2o6urb7Eule09PjlhQRGNsqRfPmYI3KKQLFpCAV3+o=
115+github.com/elazarl/goproxy v1.7.2/go.mod h1:82vkLNir0ALaW14Rc399OTTjyNREgmdL2cVoIbS6XaE=
116+github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
117+github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
99github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
118github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f h1:Y/CXytFA4m6baUTXGLOoWe4PQhGxaX0KpnayAqC48p4=
100github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
119github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f/go.mod h1:vw97MGsxSvLiUE2X8qFplwetxpGLQrlU1Q9AUEIzCaM=
101github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
120github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
@@ -104,6 +123,16 @@ github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHk
104github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
123github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
105github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
124github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
106github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
125github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
126+github.com/gliderlabs/ssh v0.3.8 h1:a4YXD1V7xMF9g5nTkdfnja3Sxy1PVDCj1Zg4Wb8vY6c=
127+github.com/gliderlabs/ssh v0.3.8/go.mod h1:xYoytBv1sV0aL3CavoDuJIQNURXkkfPA/wxQ1pL1fAU=
128+github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
129+github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
130+github.com/go-git/go-billy/v5 v5.6.2 h1:6Q86EsPXMa7c3YZ3aLAQsMA0VlWmy43r6FHqa/UNbRM=
131+github.com/go-git/go-billy/v5 v5.6.2/go.mod h1:rcFC2rAsp/erv7CMz9GczHcuD0D32fWzH+MJAU+jaUU=
132+github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
133+github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
134+github.com/go-git/go-git/v5 v5.15.0 h1:f5Qn0W0F7ry1iN0ZwIU5m/n7/BKB4hiZfc+zlZx7ly0=
135+github.com/go-git/go-git/v5 v5.15.0/go.mod h1:4Ge4alE/5gPs30F2H1esi2gPd69R0C39lolkucHBOp8=
107github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
136github.com/go-logfmt/logfmt v0.6.0 h1:wGYYu3uicYdqXVgoYbvnkrPVXkuLM1p1ifugDMEdRi4=
108github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
137github.com/go-logfmt/logfmt v0.6.0/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs=
109github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
138github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
@@ -115,6 +144,8 @@ github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIx
115github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
144github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
116github.com/golang-migrate/migrate/v4 v4.18.2 h1:2VSCMz7x7mjyTXx3m2zPokOY82LTRgxK1yQYKo6wWQ8=
145github.com/golang-migrate/migrate/v4 v4.18.2 h1:2VSCMz7x7mjyTXx3m2zPokOY82LTRgxK1yQYKo6wWQ8=
117github.com/golang-migrate/migrate/v4 v4.18.2/go.mod h1:2CM6tJvn2kqPXwnXO/d3rAQYiyoIm180VsO8PRX6Rpk=
146github.com/golang-migrate/migrate/v4 v4.18.2/go.mod h1:2CM6tJvn2kqPXwnXO/d3rAQYiyoIm180VsO8PRX6Rpk=
147+github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 h1:f+oWsMOmNPc8JmEHVZIycC7hBoQxHH9pNKQORJNozsQ=
148+github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8/go.mod h1:wcDNUvekVysuuOpQKo3191zZyTpiI6se1N1ULghS0sw=
118github.com/google/generative-ai-go v0.19.0 h1:R71szggh8wHMCUlEMsW2A/3T+5LdEIkiaHSYgSpUgdg=
149github.com/google/generative-ai-go v0.19.0 h1:R71szggh8wHMCUlEMsW2A/3T+5LdEIkiaHSYgSpUgdg=
119github.com/google/generative-ai-go v0.19.0/go.mod h1:JYolL13VG7j79kM5BtHz4qwONHkeJQzOCkKXnpqtS/E=
150github.com/google/generative-ai-go v0.19.0/go.mod h1:JYolL13VG7j79kM5BtHz4qwONHkeJQzOCkKXnpqtS/E=
120github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
151github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
@@ -138,8 +169,11 @@ github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUq
138github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
169github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
139github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
170github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
140github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
171github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
172+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A=
173+github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo=
174+github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
175+github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
141github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
176github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
142−github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
143github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
177github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
144github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
178github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
145github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
179github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -179,11 +213,17 @@ github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
179github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
213github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
180github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
214github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc=
181github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
215github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
216+github.com/onsi/gomega v1.34.1 h1:EUMJIKUjM8sKjYbtxQI9A4z2o+rruxnzNvpknOXie6k=
217+github.com/onsi/gomega v1.34.1/go.mod h1:kU1QgUvBDLXBJq618Xvm2LUX6rSAfRaFRTcdOeDLwwY=
182github.com/openai/openai-go v0.1.0-beta.2 h1:Ra5nCFkbEl9w+UJwAciC4kqnIBUCcJazhmMA0/YN894=
218github.com/openai/openai-go v0.1.0-beta.2 h1:Ra5nCFkbEl9w+UJwAciC4kqnIBUCcJazhmMA0/YN894=
183github.com/openai/openai-go v0.1.0-beta.2/go.mod h1:g461MYGXEXBVdV5SaR/5tNzNbSfwTBBefwc+LlDCK0Y=
219github.com/openai/openai-go v0.1.0-beta.2/go.mod h1:g461MYGXEXBVdV5SaR/5tNzNbSfwTBBefwc+LlDCK0Y=
184github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
220github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
185github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
221github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
222+github.com/pjbgf/sha1cd v0.3.2 h1:a9wb0bp1oC2TGwStyn0Umc/IGKQnEgF0vVaZ8QF8eo4=
223+github.com/pjbgf/sha1cd v0.3.2/go.mod h1:zQWigSxVmsHEZow5qaLtPYxpcKMMQpa09ixqBxuCS6A=
186github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
224github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
225+github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
226+github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
187github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
227github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
188github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
228github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
189github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
229github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
@@ -203,6 +243,9 @@ github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAm
203github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
243github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
204github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
244github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
205github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
245github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG0E7Rwjx0REVgAGH58e96+X0MeOfepqsbeW4=
246+github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
247+github.com/skeema/knownhosts v1.3.1 h1:X2osQ+RAjK76shCbvhHHHVl3ZlgDm8apHEHFqRjnBY8=
248+github.com/skeema/knownhosts v1.3.1/go.mod h1:r7KTdC8l4uxWRyK2TpQZ/1o5HaSzh06ePQNxPwTcfiY=
206github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
249github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
207github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
250github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
208github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
251github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
@@ -216,6 +259,7 @@ github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An
216github.com/spf13/viper v1.20.0 h1:zrxIyR3RQIOsarIrgL8+sAvALXul9jeEPa06Y0Ph6vY=
259github.com/spf13/viper v1.20.0 h1:zrxIyR3RQIOsarIrgL8+sAvALXul9jeEPa06Y0Ph6vY=
217github.com/spf13/viper v1.20.0/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
260github.com/spf13/viper v1.20.0/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
218github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
261github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
262+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
219github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
263github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
220github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
264github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
221github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
265github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
@@ -232,6 +276,8 @@ github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
232github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
276github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
233github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
277github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
234github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
278github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
279+github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=
280+github.com/xanzy/ssh-agent v0.3.3/go.mod h1:6dzNDKs0J9rVPHPhaGCukekBHKqfl+L3KghI1Bc68Uw=
235github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
281github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no=
236github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
282github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM=
237github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
283github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4=
@@ -260,6 +306,7 @@ golang.design/x/clipboard v0.7.0 h1:4Je8M/ys9AJumVnl8m+rZnIvstSnYj1fvzqYrU3TXvo=
260golang.design/x/clipboard v0.7.0/go.mod h1:PQIvqYO9GP29yINEfsEn5zSQKAz3UgXmZKzDA6dnq2E=
306golang.design/x/clipboard v0.7.0/go.mod h1:PQIvqYO9GP29yINEfsEn5zSQKAz3UgXmZKzDA6dnq2E=
261golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
307golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
262golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
308golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
309+golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
263golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
310golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
264golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
311golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M=
265golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
312golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
@@ -277,6 +324,7 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91
277golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
324golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
278golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
325golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
279golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
326golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
327+golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
280golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
328golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
281golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
329golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
282golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
330golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
@@ -294,10 +342,14 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
294golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
342golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610=
295golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
343golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
296golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
344golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
345+golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
297golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
346golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
347+golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
348+golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
298golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
349golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
299golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
350golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
300golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
351golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
352+golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
301golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
353golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
302golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
354golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
303golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
355golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@@ -320,6 +372,7 @@ golang.org/x/term v0.31.0 h1:erwDkOK1Msy6offm1mOgvspSkslFnIGsFnxOKoufg3o=
320golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
372golang.org/x/term v0.31.0/go.mod h1:R4BeIy7D95HzImkxGkTW1UQTtP54tio2RyHz7PwK0aw=
321golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
373golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
322golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
374golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
375+golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
323golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
376golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
324golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
377golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
325golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
378golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
@@ -348,6 +401,8 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8
348gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
401gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
349gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
402gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
350gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
403gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
404+gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
405+gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
351gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
406gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
352gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
407gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
353gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
408gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
internal/assets/diff/themes/dark.jsonnew file+73
@@ -0,0 +1,73 @@
1+{
2+ "SYNTAX_HIGHLIGHTING_THEME": "dark-plus",
3+ "DEFAULT_COLOR": {
4+ "color": "#ffffff",
5+ "backgroundColor": "#212121"
6+ },
7+ "COMMIT_HEADER_COLOR": {
8+ "color": "#cccccc"
9+ },
10+ "COMMIT_HEADER_LABEL_COLOR": {
11+ "color": "#00000022"
12+ },
13+ "COMMIT_SHA_COLOR": {
14+ "color": "#00eeaa"
15+ },
16+ "COMMIT_AUTHOR_COLOR": {
17+ "color": "#00aaee"
18+ },
19+ "COMMIT_DATE_COLOR": {
20+ "color": "#cccccc"
21+ },
22+ "COMMIT_MESSAGE_COLOR": {
23+ "color": "#cccccc"
24+ },
25+ "COMMIT_TITLE_COLOR": {
26+ "modifiers": [
27+ "bold"
28+ ]
29+ },
30+ "FILE_NAME_COLOR": {
31+ "color": "#ffdd99"
32+ },
33+ "BORDER_COLOR": {
34+ "color": "#ffdd9966",
35+ "modifiers": [
36+ "dim"
37+ ]
38+ },
39+ "HUNK_HEADER_COLOR": {
40+ "modifiers": [
41+ "dim"
42+ ]
43+ },
44+ "DELETED_WORD_COLOR": {
45+ "color": "#ffcccc",
46+ "backgroundColor": "#ff000033"
47+ },
48+ "INSERTED_WORD_COLOR": {
49+ "color": "#ccffcc",
50+ "backgroundColor": "#00ff0033"
51+ },
52+ "DELETED_LINE_NO_COLOR": {
53+ "color": "#00000022",
54+ "backgroundColor": "#00000022"
55+ },
56+ "INSERTED_LINE_NO_COLOR": {
57+ "color": "#00000022",
58+ "backgroundColor": "#00000022"
59+ },
60+ "UNMODIFIED_LINE_NO_COLOR": {
61+ "color": "#666666"
62+ },
63+ "DELETED_LINE_COLOR": {
64+ "color": "#cc6666",
65+ "backgroundColor": "#3a3030"
66+ },
67+ "INSERTED_LINE_COLOR": {
68+ "color": "#66cc66",
69+ "backgroundColor": "#303a30"
70+ },
71+ "UNMODIFIED_LINE_COLOR": {},
72+ "MISSING_LINE_COLOR": {}
73+}
internal/assets/embed.gonew file+6
@@ -0,0 +1,6 @@
1+package assets
2+
3+import "embed"
4+
5+//go:embed diff
6+var FS embed.FS
internal/assets/write.gonew file+60
@@ -0,0 +1,60 @@
1+package assets
2+
3+import (
4+ "os"
5+ "path/filepath"
6+
7+ "github.com/kujtimiihoxha/termai/internal/config"
8+)
9+
10+func WriteAssets() error {
11+ appCfg := config.Get()
12+ appWd := config.WorkingDirectory()
13+ scriptDir := filepath.Join(
14+ appWd,
15+ appCfg.Data.Directory,
16+ "diff",
17+ )
18+ scriptPath := filepath.Join(scriptDir, "index.mjs")
19+ // Before, run the script in cmd/diff/main.go to build this file
20+ if _, err := os.Stat(scriptPath); err != nil {
21+ scriptData, err := FS.ReadFile("diff/index.mjs")
22+ if err != nil {
23+ return err
24+ }
25+
26+ err = os.MkdirAll(scriptDir, 0o755)
27+ if err != nil {
28+ return err
29+ }
30+ err = os.WriteFile(scriptPath, scriptData, 0o755)
31+ if err != nil {
32+ return err
33+ }
34+ }
35+
36+ themeDir := filepath.Join(
37+ appWd,
38+ appCfg.Data.Directory,
39+ "themes",
40+ )
41+
42+ themePath := filepath.Join(themeDir, "dark.json")
43+
44+ if _, err := os.Stat(themePath); err != nil {
45+ themeData, err := FS.ReadFile("diff/themes/dark.json")
46+ if err != nil {
47+ return err
48+ }
49+
50+ err = os.MkdirAll(themeDir, 0o755)
51+ if err != nil {
52+ return err
53+ }
54+ err = os.WriteFile(themePath, themeData, 0o755)
55+ if err != nil {
56+ return err
57+ }
58+ }
59+ return nil
60+}
internal/git/diff.gonew file+265
@@ -0,0 +1,265 @@
1+package git
2+
3+import (
4+ "bytes"
5+ "fmt"
6+ "os"
7+ "os/exec"
8+ "path/filepath"
9+ "strings"
10+ "time"
11+
12+ "github.com/go-git/go-git/v5"
13+ "github.com/go-git/go-git/v5/plumbing/object"
14+ "github.com/kujtimiihoxha/termai/internal/config"
15+)
16+
17+type DiffStats struct {
18+ Additions int
19+ Removals int
20+}
21+
22+func GenerateGitDiff(filePath string, contentBefore string, contentAfter string) (string, error) {
23+ tempDir, err := os.MkdirTemp("", "git-diff-temp")
24+ if err != nil {
25+ return "", fmt.Errorf("failed to create temp dir: %w", err)
26+ }
27+ defer os.RemoveAll(tempDir)
28+
29+ repo, err := git.PlainInit(tempDir, false)
30+ if err != nil {
31+ return "", fmt.Errorf("failed to initialize git repo: %w", err)
32+ }
33+
34+ wt, err := repo.Worktree()
35+ if err != nil {
36+ return "", fmt.Errorf("failed to get worktree: %w", err)
37+ }
38+
39+ fullPath := filepath.Join(tempDir, filePath)
40+ if err = os.MkdirAll(filepath.Dir(fullPath), 0o755); err != nil {
41+ return "", fmt.Errorf("failed to create directories: %w", err)
42+ }
43+ if err = os.WriteFile(fullPath, []byte(contentBefore), 0o644); err != nil {
44+ return "", fmt.Errorf("failed to write 'before' content: %w", err)
45+ }
46+
47+ _, err = wt.Add(filePath)
48+ if err != nil {
49+ return "", fmt.Errorf("failed to add file to git: %w", err)
50+ }
51+
52+ beforeCommit, err := wt.Commit("Before", &git.CommitOptions{
53+ Author: &object.Signature{
54+ Name: "OpenCode",
55+ Email: "coder@opencode.ai",
56+ When: time.Now(),
57+ },
58+ })
59+ if err != nil {
60+ return "", fmt.Errorf("failed to commit 'before' version: %w", err)
61+ }
62+
63+ if err = os.WriteFile(fullPath, []byte(contentAfter), 0o644); err != nil {
64+ return "", fmt.Errorf("failed to write 'after' content: %w", err)
65+ }
66+
67+ _, err = wt.Add(filePath)
68+ if err != nil {
69+ return "", fmt.Errorf("failed to add updated file to git: %w", err)
70+ }
71+
72+ afterCommit, err := wt.Commit("After", &git.CommitOptions{
73+ Author: &object.Signature{
74+ Name: "OpenCode",
75+ Email: "coder@opencode.ai",
76+ When: time.Now(),
77+ },
78+ })
79+ if err != nil {
80+ return "", fmt.Errorf("failed to commit 'after' version: %w", err)
81+ }
82+
83+ beforeCommitObj, err := repo.CommitObject(beforeCommit)
84+ if err != nil {
85+ return "", fmt.Errorf("failed to get 'before' commit: %w", err)
86+ }
87+
88+ afterCommitObj, err := repo.CommitObject(afterCommit)
89+ if err != nil {
90+ return "", fmt.Errorf("failed to get 'after' commit: %w", err)
91+ }
92+
93+ patch, err := beforeCommitObj.Patch(afterCommitObj)
94+ if err != nil {
95+ return "", fmt.Errorf("failed to generate patch: %w", err)
96+ }
97+
98+ return patch.String(), nil
99+}
100+
101+func GenerateGitDiffWithStats(filePath string, contentBefore string, contentAfter string) (string, DiffStats, error) {
102+ tempDir, err := os.MkdirTemp("", "git-diff-temp")
103+ if err != nil {
104+ return "", DiffStats{}, fmt.Errorf("failed to create temp dir: %w", err)
105+ }
106+ defer os.RemoveAll(tempDir)
107+
108+ repo, err := git.PlainInit(tempDir, false)
109+ if err != nil {
110+ return "", DiffStats{}, fmt.Errorf("failed to initialize git repo: %w", err)
111+ }
112+
113+ wt, err := repo.Worktree()
114+ if err != nil {
115+ return "", DiffStats{}, fmt.Errorf("failed to get worktree: %w", err)
116+ }
117+
118+ fullPath := filepath.Join(tempDir, filePath)
119+ if err = os.MkdirAll(filepath.Dir(fullPath), 0o755); err != nil {
120+ return "", DiffStats{}, fmt.Errorf("failed to create directories: %w", err)
121+ }
122+ if err = os.WriteFile(fullPath, []byte(contentBefore), 0o644); err != nil {
123+ return "", DiffStats{}, fmt.Errorf("failed to write 'before' content: %w", err)
124+ }
125+
126+ _, err = wt.Add(filePath)
127+ if err != nil {
128+ return "", DiffStats{}, fmt.Errorf("failed to add file to git: %w", err)
129+ }
130+
131+ beforeCommit, err := wt.Commit("Before", &git.CommitOptions{
132+ Author: &object.Signature{
133+ Name: "OpenCode",
134+ Email: "coder@opencode.ai",
135+ When: time.Now(),
136+ },
137+ })
138+ if err != nil {
139+ return "", DiffStats{}, fmt.Errorf("failed to commit 'before' version: %w", err)
140+ }
141+
142+ if err = os.WriteFile(fullPath, []byte(contentAfter), 0o644); err != nil {
143+ return "", DiffStats{}, fmt.Errorf("failed to write 'after' content: %w", err)
144+ }
145+
146+ _, err = wt.Add(filePath)
147+ if err != nil {
148+ return "", DiffStats{}, fmt.Errorf("failed to add updated file to git: %w", err)
149+ }
150+
151+ afterCommit, err := wt.Commit("After", &git.CommitOptions{
152+ Author: &object.Signature{
153+ Name: "OpenCode",
154+ Email: "coder@opencode.ai",
155+ When: time.Now(),
156+ },
157+ })
158+ if err != nil {
159+ return "", DiffStats{}, fmt.Errorf("failed to commit 'after' version: %w", err)
160+ }
161+
162+ beforeCommitObj, err := repo.CommitObject(beforeCommit)
163+ if err != nil {
164+ return "", DiffStats{}, fmt.Errorf("failed to get 'before' commit: %w", err)
165+ }
166+
167+ afterCommitObj, err := repo.CommitObject(afterCommit)
168+ if err != nil {
169+ return "", DiffStats{}, fmt.Errorf("failed to get 'after' commit: %w", err)
170+ }
171+
172+ patch, err := beforeCommitObj.Patch(afterCommitObj)
173+ if err != nil {
174+ return "", DiffStats{}, fmt.Errorf("failed to generate patch: %w", err)
175+ }
176+
177+ stats := DiffStats{}
178+ for _, fileStat := range patch.Stats() {
179+ stats.Additions += fileStat.Addition
180+ stats.Removals += fileStat.Deletion
181+ }
182+
183+ return patch.String(), stats, nil
184+}
185+
186+func FormatDiff(diffText string, width int) (string, error) {
187+ if isSplitDiffsAvailable() {
188+ return formatWithSplitDiffs(diffText, width)
189+ }
190+
191+ return formatSimple(diffText), nil
192+}
193+
194+func isSplitDiffsAvailable() bool {
195+ _, err := exec.LookPath("node")
196+ return err == nil
197+}
198+
199+func formatWithSplitDiffs(diffText string, width int) (string, error) {
200+ var cmd *exec.Cmd
201+
202+ appCfg := config.Get()
203+ appWd := config.WorkingDirectory()
204+ script := filepath.Join(
205+ appWd,
206+ appCfg.Data.Directory,
207+ "diff",
208+ "index.mjs",
209+ )
210+
211+ cmd = exec.Command("node", script, "--color")
212+
213+ cmd.Env = append(os.Environ(), fmt.Sprintf("COLUMNS=%d", width))
214+
215+ cmd.Stdin = strings.NewReader(diffText)
216+
217+ var out bytes.Buffer
218+ cmd.Stdout = &out
219+
220+ var stderr bytes.Buffer
221+ cmd.Stderr = &stderr
222+
223+ err := cmd.Run()
224+ if err != nil {
225+ return "", fmt.Errorf("git-split-diffs error: %v, stderr: %s", err, stderr.String())
226+ }
227+
228+ return out.String(), nil
229+}
230+
231+func formatSimple(diffText string) string {
232+ lines := strings.Split(diffText, "\n")
233+ var result strings.Builder
234+
235+ for _, line := range lines {
236+ if len(line) == 0 {
237+ result.WriteString("\n")
238+ continue
239+ }
240+
241+ switch line[0] {
242+ case '+':
243+ result.WriteString("\033[32m" + line + "\033[0m\n")
244+ case '-':
245+ result.WriteString("\033[31m" + line + "\033[0m\n")
246+ case '@':
247+ result.WriteString("\033[36m" + line + "\033[0m\n")
248+ case 'd':
249+ if strings.HasPrefix(line, "diff --git") {
250+ result.WriteString("\033[1m" + line + "\033[0m\n")
251+ } else {
252+ result.WriteString(line + "\n")
253+ }
254+ default:
255+ result.WriteString(line + "\n")
256+ }
257+ }
258+
259+ if !strings.HasSuffix(diffText, "\n") {
260+ output := result.String()
261+ return output[:len(output)-1]
262+ }
263+
264+ return result.String()
265+}
internal/llm/agent/agent.go+3
@@ -246,6 +246,7 @@ func (c *agent) handleToolExecution(
246}
246}
247
247
248func (c *agent) generate(ctx context.Context, sessionID string, content string) error {
248func (c *agent) generate(ctx context.Context, sessionID string, content string) error {
249+ ctx = context.WithValue(ctx, tools.SessionIDContextKey, sessionID)
249 messages, err := c.Messages.List(sessionID)
250 messages, err := c.Messages.List(sessionID)
250 if err != nil {
251 if err != nil {
251 return err
252 return err
@@ -310,6 +311,8 @@ func (c *agent) generate(ctx context.Context, sessionID string, content string)
310 if err != nil {
311 if err != nil {
311 return err
312 return err
312 }
313 }
314+
315+ ctx = context.WithValue(ctx, tools.MessageIDContextKey, assistantMsg.ID)
313 for event := range eventChan {
316 for event := range eventChan {
314 err = c.processEvent(sessionID, &assistantMsg, event)
317 err = c.processEvent(sessionID, &assistantMsg, event)
315 if err != nil {
318 if err != nil {
internal/llm/tools/bash.go+2−2
@@ -22,7 +22,7 @@ type BashPermissionsParams struct {
22 Timeout int `json:"timeout"`
22 Timeout int `json:"timeout"`
23}
23}
24
24
25−type BashToolResponseMetadata struct {
25+type BashResponseMetadata struct {
26 Took int64 `json:"took"`
26 Took int64 `json:"took"`
27}
27}
28type bashTool struct {
28type bashTool struct {
@@ -310,7 +310,7 @@ func (b *bashTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
310 stdout += "\n" + errorMessage
310 stdout += "\n" + errorMessage
311 }
311 }
312
312
313− metadata := BashToolResponseMetadata{
313+ metadata := BashResponseMetadata{
314 Took: took,
314 Took: took,
315 }
315 }
316 if stdout == "" {
316 if stdout == "" {
internal/llm/tools/edit.go+122−112
@@ -10,9 +10,9 @@ import (
10 "time"
10 "time"
11
11
12 "github.com/kujtimiihoxha/termai/internal/config"
12 "github.com/kujtimiihoxha/termai/internal/config"
13+ "github.com/kujtimiihoxha/termai/internal/git"
13 "github.com/kujtimiihoxha/termai/internal/lsp"
14 "github.com/kujtimiihoxha/termai/internal/lsp"
14 "github.com/kujtimiihoxha/termai/internal/permission"
15 "github.com/kujtimiihoxha/termai/internal/permission"
15− "github.com/sergi/go-diff/diffmatchpatch"
16)
16)
17
17
18type EditParams struct {
18type EditParams struct {
@@ -22,10 +22,13 @@ type EditParams struct {
22}
22}
23
23
24type EditPermissionsParams struct {
24type EditPermissionsParams struct {
25− FilePath string `json:"file_path"`
25+ FilePath string `json:"file_path"`
26− OldString string `json:"old_string"`
27− NewString string `json:"new_string"`
28− Diff string `json:"diff"`
26+ Diff string `json:"diff"`
27+}
28+
29+type EditResponseMetadata struct {
30+ Additions int `json:"additions"`
31+ Removals int `json:"removals"`
29}
32}
30
33
31type editTool struct {
34type editTool struct {
@@ -129,48 +132,77 @@ func (e *editTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error)
129 }
132 }
130
133
131 if params.OldString == "" {
134 if params.OldString == "" {
132− result, err := e.createNewFile(params.FilePath, params.NewString)
135+ result, err := e.createNewFile(ctx, params.FilePath, params.NewString)
133 if err != nil {
136 if err != nil {
134 return NewTextErrorResponse(fmt.Sprintf("error creating file: %s", err)), nil
137 return NewTextErrorResponse(fmt.Sprintf("error creating file: %s", err)), nil
135 }
138 }
136− return NewTextResponse(result), nil
139+ return WithResponseMetadata(NewTextResponse(result.text), EditResponseMetadata{
140+ Additions: result.additions,
141+ Removals: result.removals,
142+ }), nil
137 }
143 }
138
144
139 if params.NewString == "" {
145 if params.NewString == "" {
140− result, err := e.deleteContent(params.FilePath, params.OldString)
146+ result, err := e.deleteContent(ctx, params.FilePath, params.OldString)
141 if err != nil {
147 if err != nil {
142 return NewTextErrorResponse(fmt.Sprintf("error deleting content: %s", err)), nil
148 return NewTextErrorResponse(fmt.Sprintf("error deleting content: %s", err)), nil
143 }
149 }
144− return NewTextResponse(result), nil
150+ return WithResponseMetadata(NewTextResponse(result.text), EditResponseMetadata{
151+ Additions: result.additions,
152+ Removals: result.removals,
153+ }), nil
145 }
154 }
146
155
147− result, err := e.replaceContent(params.FilePath, params.OldString, params.NewString)
156+ result, err := e.replaceContent(ctx, params.FilePath, params.OldString, params.NewString)
148 if err != nil {
157 if err != nil {
149 return NewTextErrorResponse(fmt.Sprintf("error replacing content: %s", err)), nil
158 return NewTextErrorResponse(fmt.Sprintf("error replacing content: %s", err)), nil
150 }
159 }
151
160
152 waitForLspDiagnostics(ctx, params.FilePath, e.lspClients)
161 waitForLspDiagnostics(ctx, params.FilePath, e.lspClients)
153− result = fmt.Sprintf("<result>\n%s\n</result>\n", result)
162+ text := fmt.Sprintf("<result>\n%s\n</result>\n", result.text)
154− result += appendDiagnostics(params.FilePath, e.lspClients)
163+ text += appendDiagnostics(params.FilePath, e.lspClients)
155− return NewTextResponse(result), nil
164+ return WithResponseMetadata(NewTextResponse(text), EditResponseMetadata{
165+ Additions: result.additions,
166+ Removals: result.removals,
167+ }), nil
168+}
169+
170+type editResponse struct {
171+ text string
172+ additions int
173+ removals int
156}
174}
157
175
158−func (e *editTool) createNewFile(filePath, content string) (string, error) {
176+func (e *editTool) createNewFile(ctx context.Context, filePath, content string) (editResponse, error) {
177+ er := editResponse{}
159 fileInfo, err := os.Stat(filePath)
178 fileInfo, err := os.Stat(filePath)
160 if err == nil {
179 if err == nil {
161 if fileInfo.IsDir() {
180 if fileInfo.IsDir() {
162− return "", fmt.Errorf("path is a directory, not a file: %s", filePath)
181+ return er, fmt.Errorf("path is a directory, not a file: %s", filePath)
163 }
182 }
164− return "", fmt.Errorf("file already exists: %s. Use the Replace tool to overwrite an existing file", filePath)
183+ return er, fmt.Errorf("file already exists: %s. Use the Replace tool to overwrite an existing file", filePath)
165 } else if !os.IsNotExist(err) {
184 } else if !os.IsNotExist(err) {
166− return "", fmt.Errorf("failed to access file: %w", err)
185+ return er, fmt.Errorf("failed to access file: %w", err)
167 }
186 }
168
187
169 dir := filepath.Dir(filePath)
188 dir := filepath.Dir(filePath)
170 if err = os.MkdirAll(dir, 0o755); err != nil {
189 if err = os.MkdirAll(dir, 0o755); err != nil {
171− return "", fmt.Errorf("failed to create parent directories: %w", err)
190+ return er, fmt.Errorf("failed to create parent directories: %w", err)
172 }
191 }
173
192
193+ sessionID, messageID := getContextValues(ctx)
194+ if sessionID == "" || messageID == "" {
195+ return er, fmt.Errorf("session ID and message ID are required for creating a new file")
196+ }
197+
198+ diff, stats, err := git.GenerateGitDiffWithStats(
199+ removeWorkingDirectoryPrefix(filePath),
200+ "",
201+ content,
202+ )
203+ if err != nil {
204+ return er, fmt.Errorf("failed to get file diff: %w", err)
205+ }
174 p := e.permissions.Request(
206 p := e.permissions.Request(
175 permission.CreatePermissionRequest{
207 permission.CreatePermissionRequest{
176 Path: filepath.Dir(filePath),
208 Path: filepath.Dir(filePath),
@@ -178,71 +210,88 @@ func (e *editTool) createNewFile(filePath, content string) (string, error) {
178 Action: "create",
210 Action: "create",
179 Description: fmt.Sprintf("Create file %s", filePath),
211 Description: fmt.Sprintf("Create file %s", filePath),
180 Params: EditPermissionsParams{
212 Params: EditPermissionsParams{
181− FilePath: filePath,
213+ FilePath: filePath,
182− OldString: "",
214+ Diff: diff,
183− NewString: content,
184− Diff: GenerateDiff("", content),
185 },
215 },
186 },
216 },
187 )
217 )
188 if !p {
218 if !p {
189− return "", fmt.Errorf("permission denied")
219+ return er, fmt.Errorf("permission denied")
190 }
220 }
191
221
192 err = os.WriteFile(filePath, []byte(content), 0o644)
222 err = os.WriteFile(filePath, []byte(content), 0o644)
193 if err != nil {
223 if err != nil {
194− return "", fmt.Errorf("failed to write file: %w", err)
224+ return er, fmt.Errorf("failed to write file: %w", err)
195 }
225 }
196
226
197 recordFileWrite(filePath)
227 recordFileWrite(filePath)
198 recordFileRead(filePath)
228 recordFileRead(filePath)
199
229
200− return "File created: " + filePath, nil
230+ er.text = "File created: " + filePath
231+ er.additions = stats.Additions
232+ er.removals = stats.Removals
233+ return er, nil
201}
234}
202
235
203−func (e *editTool) deleteContent(filePath, oldString string) (string, error) {
236+func (e *editTool) deleteContent(ctx context.Context, filePath, oldString string) (editResponse, error) {
237+ er := editResponse{}
204 fileInfo, err := os.Stat(filePath)
238 fileInfo, err := os.Stat(filePath)
205 if err != nil {
239 if err != nil {
206 if os.IsNotExist(err) {
240 if os.IsNotExist(err) {
207− return "", fmt.Errorf("file not found: %s", filePath)
241+ return er, fmt.Errorf("file not found: %s", filePath)
208 }
242 }
209− return "", fmt.Errorf("failed to access file: %w", err)
243+ return er, fmt.Errorf("failed to access file: %w", err)
210 }
244 }
211
245
212 if fileInfo.IsDir() {
246 if fileInfo.IsDir() {
213− return "", fmt.Errorf("path is a directory, not a file: %s", filePath)
247+ return er, fmt.Errorf("path is a directory, not a file: %s", filePath)
214 }
248 }
215
249
216 if getLastReadTime(filePath).IsZero() {
250 if getLastReadTime(filePath).IsZero() {
217− return "", fmt.Errorf("you must read the file before editing it. Use the View tool first")
251+ return er, fmt.Errorf("you must read the file before editing it. Use the View tool first")
218 }
252 }
219
253
220 modTime := fileInfo.ModTime()
254 modTime := fileInfo.ModTime()
221 lastRead := getLastReadTime(filePath)
255 lastRead := getLastReadTime(filePath)
222 if modTime.After(lastRead) {
256 if modTime.After(lastRead) {
223− return "", fmt.Errorf("file %s has been modified since it was last read (mod time: %s, last read: %s)",
257+ return er, fmt.Errorf("file %s has been modified since it was last read (mod time: %s, last read: %s)",
224 filePath, modTime.Format(time.RFC3339), lastRead.Format(time.RFC3339))
258 filePath, modTime.Format(time.RFC3339), lastRead.Format(time.RFC3339))
225 }
259 }
226
260
227 content, err := os.ReadFile(filePath)
261 content, err := os.ReadFile(filePath)
228 if err != nil {
262 if err != nil {
229− return "", fmt.Errorf("failed to read file: %w", err)
263+ return er, fmt.Errorf("failed to read file: %w", err)
230 }
264 }
231
265
232 oldContent := string(content)
266 oldContent := string(content)
233
267
234 index := strings.Index(oldContent, oldString)
268 index := strings.Index(oldContent, oldString)
235 if index == -1 {
269 if index == -1 {
236− return "", fmt.Errorf("old_string not found in file. Make sure it matches exactly, including whitespace and line breaks")
270+ return er, fmt.Errorf("old_string not found in file. Make sure it matches exactly, including whitespace and line breaks")
237 }
271 }
238
272
239 lastIndex := strings.LastIndex(oldContent, oldString)
273 lastIndex := strings.LastIndex(oldContent, oldString)
240 if index != lastIndex {
274 if index != lastIndex {
241− return "", fmt.Errorf("old_string appears multiple times in the file. Please provide more context to ensure a unique match")
275+ return er, fmt.Errorf("old_string appears multiple times in the file. Please provide more context to ensure a unique match")
242 }
276 }
243
277
244 newContent := oldContent[:index] + oldContent[index+len(oldString):]
278 newContent := oldContent[:index] + oldContent[index+len(oldString):]
245
279
280+ sessionID, messageID := getContextValues(ctx)
281+
282+ if sessionID == "" || messageID == "" {
283+ return er, fmt.Errorf("session ID and message ID are required for creating a new file")
284+ }
285+
286+ diff, stats, err := git.GenerateGitDiffWithStats(
287+ removeWorkingDirectoryPrefix(filePath),
288+ oldContent,
289+ newContent,
290+ )
291+ if err != nil {
292+ return er, fmt.Errorf("failed to get file diff: %w", err)
293+ }
294+
246 p := e.permissions.Request(
295 p := e.permissions.Request(
247 permission.CreatePermissionRequest{
296 permission.CreatePermissionRequest{
248 Path: filepath.Dir(filePath),
297 Path: filepath.Dir(filePath),
@@ -250,76 +299,85 @@ func (e *editTool) deleteContent(filePath, oldString string) (string, error) {
250 Action: "delete",
299 Action: "delete",
251 Description: fmt.Sprintf("Delete content from file %s", filePath),
300 Description: fmt.Sprintf("Delete content from file %s", filePath),
252 Params: EditPermissionsParams{
301 Params: EditPermissionsParams{
253− FilePath: filePath,
302+ FilePath: filePath,
254− OldString: oldString,
303+ Diff: diff,
255− NewString: "",
256− Diff: GenerateDiff(oldContent, newContent),
257 },
304 },
258 },
305 },
259 )
306 )
260 if !p {
307 if !p {
261− return "", fmt.Errorf("permission denied")
308+ return er, fmt.Errorf("permission denied")
262 }
309 }
263
310
264 err = os.WriteFile(filePath, []byte(newContent), 0o644)
311 err = os.WriteFile(filePath, []byte(newContent), 0o644)
265 if err != nil {
312 if err != nil {
266− return "", fmt.Errorf("failed to write file: %w", err)
313+ return er, fmt.Errorf("failed to write file: %w", err)
267 }
314 }
268−
269 recordFileWrite(filePath)
315 recordFileWrite(filePath)
270 recordFileRead(filePath)
316 recordFileRead(filePath)
271
317
272− return "Content deleted from file: " + filePath, nil
318+ er.text = "Content deleted from file: " + filePath
319+ er.additions = stats.Additions
320+ er.removals = stats.Removals
321+ return er, nil
273}
322}
274
323
275−func (e *editTool) replaceContent(filePath, oldString, newString string) (string, error) {
324+func (e *editTool) replaceContent(ctx context.Context, filePath, oldString, newString string) (editResponse, error) {
325+ er := editResponse{}
276 fileInfo, err := os.Stat(filePath)
326 fileInfo, err := os.Stat(filePath)
277 if err != nil {
327 if err != nil {
278 if os.IsNotExist(err) {
328 if os.IsNotExist(err) {
279− return "", fmt.Errorf("file not found: %s", filePath)
329+ return er, fmt.Errorf("file not found: %s", filePath)
280 }
330 }
281− return "", fmt.Errorf("failed to access file: %w", err)
331+ return er, fmt.Errorf("failed to access file: %w", err)
282 }
332 }
283
333
284 if fileInfo.IsDir() {
334 if fileInfo.IsDir() {
285− return "", fmt.Errorf("path is a directory, not a file: %s", filePath)
335+ return er, fmt.Errorf("path is a directory, not a file: %s", filePath)
286 }
336 }
287
337
288 if getLastReadTime(filePath).IsZero() {
338 if getLastReadTime(filePath).IsZero() {
289− return "", fmt.Errorf("you must read the file before editing it. Use the View tool first")
339+ return er, fmt.Errorf("you must read the file before editing it. Use the View tool first")
290 }
340 }
291
341
292 modTime := fileInfo.ModTime()
342 modTime := fileInfo.ModTime()
293 lastRead := getLastReadTime(filePath)
343 lastRead := getLastReadTime(filePath)
294 if modTime.After(lastRead) {
344 if modTime.After(lastRead) {
295− return "", fmt.Errorf("file %s has been modified since it was last read (mod time: %s, last read: %s)",
345+ return er, fmt.Errorf("file %s has been modified since it was last read (mod time: %s, last read: %s)",
296 filePath, modTime.Format(time.RFC3339), lastRead.Format(time.RFC3339))
346 filePath, modTime.Format(time.RFC3339), lastRead.Format(time.RFC3339))
297 }
347 }
298
348
299 content, err := os.ReadFile(filePath)
349 content, err := os.ReadFile(filePath)
300 if err != nil {
350 if err != nil {
301− return "", fmt.Errorf("failed to read file: %w", err)
351+ return er, fmt.Errorf("failed to read file: %w", err)
302 }
352 }
303
353
304 oldContent := string(content)
354 oldContent := string(content)
305
355
306 index := strings.Index(oldContent, oldString)
356 index := strings.Index(oldContent, oldString)
307 if index == -1 {
357 if index == -1 {
308− return "", fmt.Errorf("old_string not found in file. Make sure it matches exactly, including whitespace and line breaks")
358+ return er, fmt.Errorf("old_string not found in file. Make sure it matches exactly, including whitespace and line breaks")
309 }
359 }
310
360
311 lastIndex := strings.LastIndex(oldContent, oldString)
361 lastIndex := strings.LastIndex(oldContent, oldString)
312 if index != lastIndex {
362 if index != lastIndex {
313− return "", fmt.Errorf("old_string appears multiple times in the file. Please provide more context to ensure a unique match")
363+ return er, fmt.Errorf("old_string appears multiple times in the file. Please provide more context to ensure a unique match")
314 }
364 }
315
365
316 newContent := oldContent[:index] + newString + oldContent[index+len(oldString):]
366 newContent := oldContent[:index] + newString + oldContent[index+len(oldString):]
317
367
318− startIndex := max(0, index-3)
368+ sessionID, messageID := getContextValues(ctx)
319− oldEndIndex := min(len(oldContent), index+len(oldString)+3)
320− newEndIndex := min(len(newContent), index+len(newString)+3)
321
369
322− diff := GenerateDiff(oldContent[startIndex:oldEndIndex], newContent[startIndex:newEndIndex])
370+ if sessionID == "" || messageID == "" {
371+ return er, fmt.Errorf("session ID and message ID are required for creating a new file")
372+ }
373+ diff, stats, err := git.GenerateGitDiffWithStats(
374+ removeWorkingDirectoryPrefix(filePath),
375+ oldContent,
376+ newContent,
377+ )
378+ if err != nil {
379+ return er, fmt.Errorf("failed to get file diff: %w", err)
380+ }
323
381
324 p := e.permissions.Request(
382 p := e.permissions.Request(
325 permission.CreatePermissionRequest{
383 permission.CreatePermissionRequest{
@@ -328,75 +386,27 @@ func (e *editTool) replaceContent(filePath, oldString, newString string) (string
328 Action: "replace",
386 Action: "replace",
329 Description: fmt.Sprintf("Replace content in file %s", filePath),
387 Description: fmt.Sprintf("Replace content in file %s", filePath),
330 Params: EditPermissionsParams{
388 Params: EditPermissionsParams{
331− FilePath: filePath,
389+ FilePath: filePath,
332− OldString: oldString,
390+
333− NewString: newString,
334− Diff: diff,
391+ Diff: diff,
335 },
392 },
336 },
393 },
337 )
394 )
338 if !p {
395 if !p {
339− return "", fmt.Errorf("permission denied")
396+ return er, fmt.Errorf("permission denied")
340 }
397 }
341
398
342 err = os.WriteFile(filePath, []byte(newContent), 0o644)
399 err = os.WriteFile(filePath, []byte(newContent), 0o644)
343 if err != nil {
400 if err != nil {
344− return "", fmt.Errorf("failed to write file: %w", err)
401+ return er, fmt.Errorf("failed to write file: %w", err)
345 }
402 }
346
403
347 recordFileWrite(filePath)
404 recordFileWrite(filePath)
348 recordFileRead(filePath)
405 recordFileRead(filePath)
406+ er.text = "Content replaced in file: " + filePath
407+ er.additions = stats.Additions
408+ er.removals = stats.Removals
349
409
350− return "Content replaced in file: " + filePath, nil
410+ return er, nil
351}
411}
352
412
353−func GenerateDiff(oldContent, newContent string) string {
354− dmp := diffmatchpatch.New()
355− fileAdmp, fileBdmp, dmpStrings := dmp.DiffLinesToChars(oldContent, newContent)
356− diffs := dmp.DiffMain(fileAdmp, fileBdmp, false)
357− diffs = dmp.DiffCharsToLines(diffs, dmpStrings)
358− diffs = dmp.DiffCleanupSemantic(diffs)
359− buff := strings.Builder{}
360−
361− buff.WriteString("Changes:\n")
362−
363− for _, diff := range diffs {
364− text := diff.Text
365−
366− switch diff.Type {
367− case diffmatchpatch.DiffInsert:
368− for line := range strings.SplitSeq(text, "\n") {
369− if line == "" {
370− continue
371− }
372− _, _ = buff.WriteString("+ " + line + "\n")
373− }
374− case diffmatchpatch.DiffDelete:
375− for line := range strings.SplitSeq(text, "\n") {
376− if line == "" {
377− continue
378− }
379− _, _ = buff.WriteString("- " + line + "\n")
380− }
381− case diffmatchpatch.DiffEqual:
382− lines := strings.Split(text, "\n")
383− if len(lines) > 3 {
384− if lines[0] != "" {
385− _, _ = buff.WriteString(" " + lines[0] + "\n")
386− }
387− _, _ = buff.WriteString(" ...\n")
388− if lines[len(lines)-1] != "" {
389− _, _ = buff.WriteString(" " + lines[len(lines)-1] + "\n")
390− }
391− } else {
392− for _, line := range lines {
393− if line == "" {
394− continue
395− }
396− _, _ = buff.WriteString(" " + line + "\n")
397− }
398− }
399− }
400− }
401− return buff.String()
402−}
internal/llm/tools/edit_test.go−48
@@ -459,51 +459,3 @@ func TestEditTool_Run(t *testing.T) {
459 assert.Equal(t, initialContent, string(fileContent))
459 assert.Equal(t, initialContent, string(fileContent))
460 })
460 })
461}
461}
462−
463−func TestGenerateDiff(t *testing.T) {
464− testCases := []struct {
465− name string
466− oldContent string
467− newContent string
468− expectedDiff string
469− }{
470− {
471− name: "add content",
472− oldContent: "Line 1\nLine 2\n",
473− newContent: "Line 1\nLine 2\nLine 3\n",
474− expectedDiff: "Changes:\n Line 1\n Line 2\n+ Line 3\n",
475− },
476− {
477− name: "remove content",
478− oldContent: "Line 1\nLine 2\nLine 3\n",
479− newContent: "Line 1\nLine 3\n",
480− expectedDiff: "Changes:\n Line 1\n- Line 2\n Line 3\n",
481− },
482− {
483− name: "replace content",
484− oldContent: "Line 1\nLine 2\nLine 3\n",
485− newContent: "Line 1\nModified Line\nLine 3\n",
486− expectedDiff: "Changes:\n Line 1\n- Line 2\n+ Modified Line\n Line 3\n",
487− },
488− {
489− name: "empty to content",
490− oldContent: "",
491− newContent: "Line 1\nLine 2\n",
492− expectedDiff: "Changes:\n+ Line 1\n+ Line 2\n",
493− },
494− {
495− name: "content to empty",
496− oldContent: "Line 1\nLine 2\n",
497− newContent: "",
498− expectedDiff: "Changes:\n- Line 1\n- Line 2\n",
499− },
500− }
501−
502− for _, tc := range testCases {
503− t.Run(tc.name, func(t *testing.T) {
504− diff := GenerateDiff(tc.oldContent, tc.newContent)
505− assert.Contains(t, diff, tc.expectedDiff)
506− })
507− }
508−}
509−
internal/llm/tools/file.go+10
@@ -3,6 +3,8 @@ package tools
3import (
3import (
4 "sync"
4 "sync"
5 "time"
5 "time"
6+
7+ "github.com/kujtimiihoxha/termai/internal/config"
6)
8)
7
9
8// File record to track when files were read/written
10// File record to track when files were read/written
@@ -17,6 +19,14 @@ var (
17 fileRecordMutex sync.RWMutex
19 fileRecordMutex sync.RWMutex
18)
20)
19
21
22+func removeWorkingDirectoryPrefix(path string) string {
23+ wd := config.WorkingDirectory()
24+ if len(path) > len(wd) && path[:len(wd)] == wd {
25+ return path[len(wd)+1:]
26+ }
27+ return path
28+}
29+
20func recordFileRead(path string) {
30func recordFileRead(path string) {
21 fileRecordMutex.Lock()
31 fileRecordMutex.Lock()
22 defer fileRecordMutex.Unlock()
32 defer fileRecordMutex.Unlock()
internal/llm/tools/tools.go+15
@@ -17,6 +17,9 @@ type toolResponseType string
17const (
17const (
18 ToolResponseTypeText toolResponseType = "text"
18 ToolResponseTypeText toolResponseType = "text"
19 ToolResponseTypeImage toolResponseType = "image"
19 ToolResponseTypeImage toolResponseType = "image"
20+
21+ SessionIDContextKey = "session_id"
22+ MessageIDContextKey = "message_id"
20)
23)
21
24
22type ToolResponse struct {
25type ToolResponse struct {
@@ -62,3 +65,15 @@ type BaseTool interface {
62 Info() ToolInfo
65 Info() ToolInfo
63 Run(ctx context.Context, params ToolCall) (ToolResponse, error)
66 Run(ctx context.Context, params ToolCall) (ToolResponse, error)
64}
67}
68+
69+func getContextValues(ctx context.Context) (string, string) {
70+ sessionID := ctx.Value(SessionIDContextKey)
71+ messageID := ctx.Value(MessageIDContextKey)
72+ if sessionID == nil {
73+ return "", ""
74+ }
75+ if messageID == nil {
76+ return sessionID.(string), ""
77+ }
78+ return sessionID.(string), messageID.(string)
79+}
internal/llm/tools/write.go+26−3
@@ -9,6 +9,7 @@ import (
9 "time"
9 "time"
10
10
11 "github.com/kujtimiihoxha/termai/internal/config"
11 "github.com/kujtimiihoxha/termai/internal/config"
12+ "github.com/kujtimiihoxha/termai/internal/git"
12 "github.com/kujtimiihoxha/termai/internal/lsp"
13 "github.com/kujtimiihoxha/termai/internal/lsp"
13 "github.com/kujtimiihoxha/termai/internal/permission"
14 "github.com/kujtimiihoxha/termai/internal/permission"
14)
15)
@@ -20,7 +21,7 @@ type WriteParams struct {
20
21
21type WritePermissionsParams struct {
22type WritePermissionsParams struct {
22 FilePath string `json:"file_path"`
23 FilePath string `json:"file_path"`
23− Content string `json:"content"`
24+ Diff string `json:"diff"`
24}
25}
25
26
26type writeTool struct {
27type writeTool struct {
@@ -28,6 +29,11 @@ type writeTool struct {
28 permissions permission.Service
29 permissions permission.Service
29}
30}
30
31
32+type WriteResponseMetadata struct {
33+ Additions int `json:"additions"`
34+ Removals int `json:"removals"`
35+}
36+
31const (
37const (
32 WriteToolName = "write"
38 WriteToolName = "write"
33 writeDescription = `File writing tool that creates or updates files in the filesystem, allowing you to save or modify text content.
39 writeDescription = `File writing tool that creates or updates files in the filesystem, allowing you to save or modify text content.
@@ -138,6 +144,18 @@ func (w *writeTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error
138 }
144 }
139 }
145 }
140
146
147+ sessionID, messageID := getContextValues(ctx)
148+ if sessionID == "" || messageID == "" {
149+ return NewTextErrorResponse("session ID or message ID is missing"), nil
150+ }
151+ diff, stats, err := git.GenerateGitDiffWithStats(
152+ removeWorkingDirectoryPrefix(filePath),
153+ oldContent,
154+ params.Content,
155+ )
156+ if err != nil {
157+ return NewTextErrorResponse(fmt.Sprintf("Failed to get file diff: %s", err)), nil
158+ }
141 p := w.permissions.Request(
159 p := w.permissions.Request(
142 permission.CreatePermissionRequest{
160 permission.CreatePermissionRequest{
143 Path: filePath,
161 Path: filePath,
@@ -146,7 +164,7 @@ func (w *writeTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error
146 Description: fmt.Sprintf("Create file %s", filePath),
164 Description: fmt.Sprintf("Create file %s", filePath),
147 Params: WritePermissionsParams{
165 Params: WritePermissionsParams{
148 FilePath: filePath,
166 FilePath: filePath,
149− Content: GenerateDiff(oldContent, params.Content),
167+ Diff: diff,
150 },
168 },
151 },
169 },
152 )
170 )
@@ -166,5 +184,10 @@ func (w *writeTool) Run(ctx context.Context, call ToolCall) (ToolResponse, error
166 result := fmt.Sprintf("File successfully written: %s", filePath)
184 result := fmt.Sprintf("File successfully written: %s", filePath)
167 result = fmt.Sprintf("<result>\n%s\n</result>", result)
185 result = fmt.Sprintf("<result>\n%s\n</result>", result)
168 result += appendDiagnostics(filePath, w.lspClients)
186 result += appendDiagnostics(filePath, w.lspClients)
169− return NewTextResponse(result), nil
187+ return WithResponseMetadata(NewTextResponse(result),
188+ WriteResponseMetadata{
189+ Additions: stats.Additions,
190+ Removals: stats.Removals,
191+ },
192+ ), nil
170}
193}
internal/tui/components/dialog/permission.go+11−6
@@ -9,6 +9,7 @@ import (
9 tea "github.com/charmbracelet/bubbletea"
9 tea "github.com/charmbracelet/bubbletea"
10 "github.com/charmbracelet/glamour"
10 "github.com/charmbracelet/glamour"
11 "github.com/charmbracelet/lipgloss"
11 "github.com/charmbracelet/lipgloss"
12+ "github.com/kujtimiihoxha/termai/internal/git"
12 "github.com/kujtimiihoxha/termai/internal/llm/tools"
13 "github.com/kujtimiihoxha/termai/internal/llm/tools"
13 "github.com/kujtimiihoxha/termai/internal/permission"
14 "github.com/kujtimiihoxha/termai/internal/permission"
14 "github.com/kujtimiihoxha/termai/internal/tui/components/core"
15 "github.com/kujtimiihoxha/termai/internal/tui/components/core"
@@ -234,7 +235,6 @@ func (p *permissionDialogCmp) render() string {
234 headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
235 headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
235
236
236 // Format the diff with colors
237 // Format the diff with colors
237− formattedDiff := formatDiff(pr.Diff)
238
238
239 // Set up viewport for the diff content
239 // Set up viewport for the diff content
240 p.contentViewPort.Width = p.width - 2 - 2
240 p.contentViewPort.Width = p.width - 2 - 2
@@ -242,7 +242,11 @@ func (p *permissionDialogCmp) render() string {
242 // Calculate content height dynamically based on window size
242 // Calculate content height dynamically based on window size
243 maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
243 maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
244 p.contentViewPort.Height = maxContentHeight
244 p.contentViewPort.Height = maxContentHeight
245+ diff, err := git.FormatDiff(pr.Diff, p.contentViewPort.Width)
246+ if err != nil {
247+ diff = fmt.Sprintf("Error formatting diff: %v", err)
248+ }
245− p.contentViewPort.SetContent(formattedDiff)
249+ p.contentViewPort.SetContent(diff)
246
250
247 // Style the viewport
251 // Style the viewport
248 var contentBorder lipgloss.Border
252 var contentBorder lipgloss.Border
@@ -281,16 +285,17 @@ func (p *permissionDialogCmp) render() string {
281 // Recreate header content with the updated headerParts
285 // Recreate header content with the updated headerParts
282 headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
286 headerContent = lipgloss.NewStyle().Padding(0, 1).Render(lipgloss.JoinVertical(lipgloss.Left, headerParts...))
283
287
284− // Format the diff with colors
285− formattedDiff := formatDiff(pr.Content)
286−
287 // Set up viewport for the content
288 // Set up viewport for the content
288 p.contentViewPort.Width = p.width - 2 - 2
289 p.contentViewPort.Width = p.width - 2 - 2
289
290
290 // Calculate content height dynamically based on window size
291 // Calculate content height dynamically based on window size
291 maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
292 maxContentHeight := p.height - lipgloss.Height(headerContent) - lipgloss.Height(form) - 2 - 2 - 1
292 p.contentViewPort.Height = maxContentHeight
293 p.contentViewPort.Height = maxContentHeight
294+ diff, err := git.FormatDiff(pr.Diff, p.contentViewPort.Width)
295+ if err != nil {
296+ diff = fmt.Sprintf("Error formatting diff: %v", err)
297+ }
293− p.contentViewPort.SetContent(formattedDiff)
298+ p.contentViewPort.SetContent(diff)
294
299
295 // Style the viewport
300 // Style the viewport
296 var contentBorder lipgloss.Border
301 var contentBorder lipgloss.Border