43 lines
1.3 KiB
Go
43 lines
1.3 KiB
Go
package agent
|
|
|
|
import (
|
|
"gitea.alexandru.macocian.me/amacocian/sherlock/internal/mcp"
|
|
)
|
|
|
|
func init() { Register(&copilot{}) }
|
|
|
|
// copilot integrates the GitHub Copilot CLI (npm package `@github/copilot`
|
|
// → `copilot` on PATH). MCP config is passed via
|
|
// `--additional-mcp-config @<path>` (the `@` prefix tells Copilot to
|
|
// treat the argument as a file path, not inline JSON). The file uses
|
|
// the canonical `.mcp.json` shape (`{"mcpServers": ...}`) — same as
|
|
// Claude Code.
|
|
//
|
|
// Copilot reads `~/.copilot/mcp-config.json` by default and merges
|
|
// any `--additional-mcp-config` files on top. The merge is additive,
|
|
// so sherlock-injected MCPs coexist with whatever the operator has
|
|
// configured globally.
|
|
type copilot struct{}
|
|
|
|
func (copilot) Name() string { return "copilot" }
|
|
func (copilot) Description() string { return "GitHub Copilot CLI" }
|
|
|
|
func (c copilot) Spawn(ctx Context, args []string) error {
|
|
bin, err := LookPath("copilot")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
mcpPath, err := mcp.Render(c.Name(), ctx.Servers)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
argv := c.buildArgv(bin, mcpPath, args)
|
|
return DefaultExecer.Exec(bin, argv, BuildEnv(nil, nil))
|
|
}
|
|
|
|
func (copilot) buildArgv(bin, mcpPath string, userArgs []string) []string {
|
|
argv := []string{bin, "--additional-mcp-config", "@" + mcpPath}
|
|
argv = append(argv, userArgs...)
|
|
return argv
|
|
}
|