diff --git a/pkg/rag/treesitter/treesitter.go b/pkg/rag/treesitter/treesitter.go index cb7d6d82e..02dc26830 100644 --- a/pkg/rag/treesitter/treesitter.go +++ b/pkg/rag/treesitter/treesitter.go @@ -1,3 +1,5 @@ +//go:build cgo + package treesitter import ( diff --git a/pkg/rag/treesitter/treesitter_nocgo.go b/pkg/rag/treesitter/treesitter_nocgo.go new file mode 100644 index 000000000..1dacaa937 --- /dev/null +++ b/pkg/rag/treesitter/treesitter_nocgo.go @@ -0,0 +1,24 @@ +//go:build !cgo + +package treesitter + +import ( + "errors" + + "github.com/docker/docker-agent/pkg/rag/chunk" +) + +// DocumentProcessor implements chunk.DocumentProcessor and always returns an +// error when the application is built without CGO and uses RAG. For applications +// that do not use RAG, this allows building without any CGO requirement. +type DocumentProcessor struct{} + +// NewDocumentProcessor creates a new DocumentProcessor. +func NewDocumentProcessor(_, _ int, _ bool) *DocumentProcessor { + return &DocumentProcessor{} +} + +// Process implements chunk.DocumentProcessor. +func (p *DocumentProcessor) Process(_ string, _ []byte) ([]chunk.Chunk, error) { + return nil, errors.New("rag/treesitter: document processor must be built with CGO_ENABLED=1") +}