Help us shape the future of Go! Take the 2026 Go Developer Survey

acpconfig

package
v0.0.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package acpconfig 管理 fastgit 配置文件中的 acp: 段: 读取、解析、选择默认 agent,以及供 `ggc acp` 子命令使用的写回操作。

Index

Constants

View Source
const EnvAgentVar = "FASTGIT_ACP_AGENT"

EnvAgentVar 用于临时覆盖选用的 ACP agent 名。

Variables

View Source
var Catalog = map[string]AgentConfig{
	"claude":   {Command: "npx", Args: []string{"-y", "@zed-industries/claude-code-acp"}},
	"codex":    {Command: "npx", Args: []string{"-y", "@zed-industries/codex-acp"}},
	"opencode": {Command: "opencode", Args: []string{"acp"}},
	"gemini":   {Command: "gemini", Args: []string{"--experimental-acp"}},
}

Catalog 是内置的常见 ACP agent 命令,`ggc acp add <name>` 可直接引用。

View Source
var ConfigPathFn = configs.GetConfigPath

ConfigPathFn resolves the fastgit config file path. Tests override it to point at a temp file (xdg paths are fixed at package init in production).

Functions

func AddAgent

func AddAgent(name string, def AgentConfig) error

AddAgent 在配置文件中写入/覆盖 acp.agents.<name>。

func HasExecutable

func HasExecutable(command string) bool

HasExecutable reports whether command resolves on PATH.

func RemoveAgent

func RemoveAgent(name string) error

RemoveAgent 从配置文件删除 acp.agents.<name>;若 default 指向它则一并清除。

func SetDefault

func SetDefault(name string) error

SetDefault 设置 acp.default。name 为空时清除该字段。

Types

type AgentConfig

type AgentConfig struct {
	Command string            `yaml:"command"`
	Args    []string          `yaml:"args,omitempty"`
	Env     map[string]string `yaml:"env,omitempty"`
}

AgentConfig 是配置文件中单个 acp agent 的定义。

type Config

type Config struct {
	Default string                 `yaml:"default,omitempty"`
	Agents  map[string]AgentConfig `yaml:"agents,omitempty"`
}

Config 对应配置文件中的 acp: 段。

func Load

func Load() (*Config, error)

Load 从 fastgit 配置文件读取 acp 段;文件或段不存在时返回空配置。

func (*Config) Resolve

func (c *Config) Resolve(want string) (acpclient.Agent, error)

Resolve picks the agent to use. Precedence: explicit name (want), then FASTGIT_ACP_AGENT env, then config default, then the only configured agent, then an installed catalog agent.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL