diff --git a/cmd/src/main.go b/cmd/src/main.go index fa2e234138..b2826f4935 100644 --- a/cmd/src/main.go +++ b/cmd/src/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "encoding/json" "flag" "io" @@ -63,6 +64,7 @@ The commands are: search search for results on Sourcegraph search-jobs manages search jobs serve-git serves your local git repositories over HTTP for Sourcegraph to pull + tool exposes tools for AI agents to interact with Sourcegraph (EXPERIMENTAL) users,user manages users codeowners manages code ownership information version display and compare the src-cli version against the recommended version for your instance @@ -90,6 +92,14 @@ func main() { log.SetFlags(0) log.SetPrefix("") + // "tool" does not use the legacy commander cli framework and uses urfave/cli v3 instead + if len(os.Args) >= 2 && os.Args[1] == "tool" { + if err := toolCmd.Run(context.Background(), os.Args[1:]); err != nil { + log.Fatal(err) + } + return + } + commands.run(flag.CommandLine, "src", usageText, normalizeDashHelp(os.Args[1:])) } diff --git a/cmd/src/tool.go b/cmd/src/tool.go new file mode 100644 index 0000000000..a0c64e1b0f --- /dev/null +++ b/cmd/src/tool.go @@ -0,0 +1,21 @@ +package main + +import ( + "context" + "fmt" + "os" + + "github.com/urfave/cli/v3" +) + +var toolCmd = &cli.Command{ + Name: "src tool", + Usage: "Exposes tools for AI agents to interact with Sourcegraph (EXPERIMENTAL)", + Description: "The tool subcommand exposes tools that can be used by AI agents to perform tasks against Sourcegraph instances.", + Commands: []*cli.Command{}, + Writer: os.Stdout, + Action: func(ctx context.Context, c *cli.Command) error { + fmt.Println("Not implemented") + return nil + }, +} diff --git a/go.mod b/go.mod index ea881257ac..63b72a5a05 100644 --- a/go.mod +++ b/go.mod @@ -29,6 +29,7 @@ require ( github.com/sourcegraph/scip v0.6.1 github.com/sourcegraph/sourcegraph/lib v0.0.0-20240709083501-1af563b61442 github.com/stretchr/testify v1.11.1 + github.com/urfave/cli/v3 v3.6.1 golang.org/x/net v0.44.0 golang.org/x/sync v0.17.0 google.golang.org/api v0.132.0 diff --git a/go.sum b/go.sum index 4a873f16a1..b03900bd3b 100644 --- a/go.sum +++ b/go.sum @@ -451,6 +451,8 @@ github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD github.com/tetratelabs/wazero v1.3.0 h1:nqw7zCldxE06B8zSZAY0ACrR9OH5QCcPwYmYlwtcwtE= github.com/tetratelabs/wazero v1.3.0/go.mod h1:wYx2gNRg8/WihJfSDxA1TIL8H+GkfLYm+bIfbblu9VQ= github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8= +github.com/urfave/cli/v3 v3.6.1 h1:j8Qq8NyUawj/7rTYdBGrxcH7A/j7/G8Q5LhWEW4G3Mo= +github.com/urfave/cli/v3 v3.6.1/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck= github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=