feat: AI suggestion (#34)
## Feat * feat(ai): add AI suggestion engine, context gathering, and ghost text overlay (`v0.3.0`) ## Security & Perf * fix(ai): restrict background `--help` execution to a hardcoded command allowlist to prevent RCE * fix(root): defer context cancellation in goroutine to prevent resource leaks * perf(ai): implement LRU eviction and maximum size limit for `ProviderCache` * perf(ai): truncate command context output (`CommandContextProvider.Gather`) to 1000 characters to save tokens ## Bug Fixes * fix(ai): add mutex synchronization and thread-safe snapshotting to `AIEngine.RegisterProvider` and `GatherDynamicContext` * fix(ai): return a copy of fresh `Suggestion` in `AIEngine.Suggest` to prevent cache mutation * fix(ai): use length-prefixed encoding in `EnvSnapshot.Hash` to prevent delimiter collisions * fix(ai): skip variable assignment lines containing `=` when extracting Makefile targets * fix(runner): check `scanner.Err()` and return `nil` on scan errors in justfile generator * test(ci): rename `git commit` to `git checkout` in overlay test to resolve CI `typos` false positive
This commit is contained in:
@@ -3,6 +3,7 @@ package runner
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
@@ -15,10 +16,11 @@ func init() {
|
||||
Description: "command runner",
|
||||
MaxArgs: 1,
|
||||
Generator: func(tokens []string, prefix string, partial string) []spec.Suggestion {
|
||||
file, err := os.Open("justfile")
|
||||
cwd := spec.GetCWD()
|
||||
file, err := os.Open(filepath.Join(cwd, "justfile"))
|
||||
if err != nil {
|
||||
// try uppercase
|
||||
file, err = os.Open("Justfile")
|
||||
file, err = os.Open(filepath.Join(cwd, "Justfile"))
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
@@ -74,6 +76,9 @@ func init() {
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil
|
||||
}
|
||||
return suggestions
|
||||
},
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@ package runner
|
||||
import (
|
||||
"bufio"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
||||
"github.com/versenilvis/iris/spec"
|
||||
@@ -14,7 +15,8 @@ func init() {
|
||||
Description: "build automation",
|
||||
Generator: func(tokens []string, prefix string, partial string) []spec.Suggestion {
|
||||
// Read the Makefile
|
||||
file, err := os.Open("Makefile")
|
||||
cwd := spec.GetCWD()
|
||||
file, err := os.Open(filepath.Join(cwd, "Makefile"))
|
||||
if err != nil {
|
||||
// No Makefile, don't pretend we have one
|
||||
return nil
|
||||
@@ -48,6 +50,7 @@ func init() {
|
||||
})
|
||||
}
|
||||
}
|
||||
_ = scanner.Err()
|
||||
return suggestions
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user