refactor(instruction): remove project instruction handling and related tests
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package instruction
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
runtimetooling "cs-agent/internal/ai/runtime/tooling"
|
||||
@@ -10,56 +8,6 @@ import (
|
||||
"cs-agent/internal/pkg/toolx"
|
||||
)
|
||||
|
||||
type ProjectInstructionProvider struct {
|
||||
fileName string
|
||||
}
|
||||
|
||||
func NewProjectInstructionProvider() *ProjectInstructionProvider {
|
||||
return &ProjectInstructionProvider{fileName: "AGENTS.md"}
|
||||
}
|
||||
|
||||
func (p *ProjectInstructionProvider) Resolve() string {
|
||||
if text := p.loadFromFile(); text != "" {
|
||||
return text
|
||||
}
|
||||
return strings.TrimSpace(DefaultProjectInstruction)
|
||||
}
|
||||
|
||||
func (p *ProjectInstructionProvider) loadFromFile() string {
|
||||
path := p.resolvePath()
|
||||
if path == "" {
|
||||
return ""
|
||||
}
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return strings.TrimSpace(string(data))
|
||||
}
|
||||
|
||||
func (p *ProjectInstructionProvider) resolvePath() string {
|
||||
fileName := "AGENTS.md"
|
||||
if p != nil && strings.TrimSpace(p.fileName) != "" {
|
||||
fileName = strings.TrimSpace(p.fileName)
|
||||
}
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
dir := wd
|
||||
for {
|
||||
candidate := filepath.Join(dir, fileName)
|
||||
if stat, statErr := os.Stat(candidate); statErr == nil && !stat.IsDir() {
|
||||
return candidate
|
||||
}
|
||||
parent := filepath.Dir(dir)
|
||||
if parent == dir {
|
||||
return ""
|
||||
}
|
||||
dir = parent
|
||||
}
|
||||
}
|
||||
|
||||
type ToolAppendixProvider struct{}
|
||||
|
||||
func NewToolAppendixProvider() *ToolAppendixProvider {
|
||||
|
||||
Reference in New Issue
Block a user