Files
iris-context/commands/runner/makefile.go
T
VERSE 94c8af7b1d 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
2026-07-11 15:17:14 +07:00

58 lines
1.3 KiB
Go

package runner
import (
"bufio"
"os"
"path/filepath"
"regexp"
"github.com/versenilvis/iris/spec"
)
func init() {
spec.Register(&spec.Spec{
Name: "make",
Description: "build automation",
Generator: func(tokens []string, prefix string, partial string) []spec.Suggestion {
// Read the 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
}
defer func() { _ = file.Close() }()
var suggestions []spec.Suggestion
seen := make(map[string]bool)
scanner := bufio.NewScanner(file)
// Matches targets like `build:`, ` run :`, etc.
// Ignores lines starting with whitespace followed by command (tab)
targetRegex := regexp.MustCompile(`^[ \t]*([a-zA-Z0-9_-]+)[ \t]*:`)
for scanner.Scan() {
line := scanner.Text()
if matches := targetRegex.FindStringSubmatch(line); len(matches) > 1 {
target := matches[1]
// Ignore standard non-target keywords
if target == "PHONY" || seen[target] {
continue
}
seen[target] = true
cmd := target
if prefix != "" {
cmd = prefix + " " + target
}
suggestions = append(suggestions, spec.Suggestion{
Cmd: cmd,
Desc: "make target",
})
}
}
_ = scanner.Err()
return suggestions
},
})
}