Documentation
¶
Overview ¶
Package integrations manages the local configuration and skill files owned by Kivgraph for supported MCP clients. It deliberately keeps each client's schema behind this package so the CLI only deals in targets and scopes.
Index ¶
- Constants
- Variables
- func InstructionsAgentNames() []string
- func InstructionsFileForTarget(target Target) (string, error)
- type Action
- type Endpoint
- type InstructionsPlan
- type Manager
- func (manager Manager) DetectHookTargets(scope Scope) ([]TargetDetection, error)
- func (manager Manager) DetectInstructionsTargets() ([]TargetDetection, error)
- func (manager Manager) DetectMCPTargets(scope Scope) ([]TargetDetection, error)
- func (manager Manager) DetectSkillTargets(scope Scope) ([]TargetDetection, error)
- func (manager Manager) InstallHook(target Target, scope Scope, dryRun, force bool) (Plan, error)
- func (manager Manager) InstallInstructions(file string, dryRun, force bool) (InstructionsPlan, error)
- func (manager Manager) InstallInstructionsForTarget(target Target, dryRun, force bool) (InstructionsPlan, error)
- func (manager Manager) InstallMCP(target Target, scope Scope, dryRun, force bool) (Plan, error)
- func (manager Manager) InstallSkill(target Target, scope Scope, dryRun, force bool) (Plan, error)
- func (manager Manager) InstructionsDestination(file string) (string, error)
- func (manager Manager) InstructionsDestinationForTarget(target Target) (string, string, error)
- func (manager Manager) RemoveHook(target Target, scope Scope, dryRun, force bool) (Plan, error)
- func (manager Manager) RemoveMCP(target Target, scope Scope, dryRun, force bool) (Plan, error)
- func (manager Manager) RemoveSkill(target Target, scope Scope, dryRun, force bool) (Plan, error)
- func (manager Manager) StatusHook(target Target, scope Scope) (Plan, error)
- func (manager Manager) StatusMCP(target Target, scope Scope) (Plan, error)
- func (manager Manager) StatusSkill(target Target, scope Scope) (Plan, error)
- type Options
- type Plan
- type Scope
- type Target
- type TargetDetection
Constants ¶
const ( // InstructionsFileAgents is the legacy selector for AGENTS.md-based clients. InstructionsFileAgents = "AGENTS.md" // InstructionsFileClaude is the legacy selector for Claude clients. InstructionsFileClaude = "CLAUDE.md" // InstructionsFileOhMyPi is the legacy selector for Oh My Pi. InstructionsFileOhMyPi = ".omp/AGENTS.md" // InstructionsCanonicalFile is the Kivgraph-owned source referenced by an // agent's user configuration. InstructionsCanonicalFile = "KIVGRAPH.md" )
const ( TargetClaudeCode = "claude-code" TargetClaudeDesktop = "claude-desktop" TargetCodex = "codex" TargetOpenCode = "opencode" TargetOhMyPi = "oh-my-pi" ScopeUser = "user" ScopeProject = "project" )
Variables ¶
var ErrCanonicalSkillEdited = errors.New("the canonical skill differs from the one this build ships")
ErrCanonicalSkillEdited reports a canonical file this build did not write.
var ErrEndpointNeedsUserScope = errors.New("an endpoint entry carries a token, so it is written only in user scope")
ErrEndpointNeedsUserScope reports an attempt to write a daemon's token into a file that lives in the repository.
var ErrIncompleteEndpoint = errors.New("an endpoint needs both a url and a token")
ErrIncompleteEndpoint reports an endpoint missing one of its two halves.
Functions ¶
func InstructionsAgentNames ¶ added in v0.9.9
func InstructionsAgentNames() []string
InstructionsAgentNames is the accepted --agent vocabulary. Short aliases keep the command convenient while the existing integration names remain valid for scripts that already use them.
func InstructionsFileForTarget ¶ added in v0.9.9
InstructionsFileForTarget maps a coding agent to its legacy instruction filename. OpenCode retains AGENTS.md as its legacy selector even though its native instruction list lives in opencode.json.
Types ¶
type Endpoint ¶ added in v0.6.0
type Endpoint struct {
// URL is the streamable HTTP endpoint a client connects to.
URL string
// Token goes into the entry as an `Authorization: Bearer` header. It is
// written literally, because no client reads a token out of a file for us,
// and that is why an endpoint entry refuses project scope: a project file
// is committed.
Token string
}
Endpoint is a running daemon's HTTP endpoint.
When it is set, a plan points clients at that url instead of telling each one to spawn `serve`. That is the difference the daemon was built for, and this is the transport it is reachable over. At the load a real editor produces -- most often none at all: 48 of 51 servers in a real event log were asked nothing -- N clients spawning `serve` cost `10 MB` of private pages each against a slope indistinguishable from zero on one daemon, `10`-`13` against `77`-`81 MB` at eight clients. Answering questions is what costs now: `39 MB` per client at 8 calls, `60`-`62` against `323`-`330` at eight. The peak is the widest gap: `179`-`186` against `26`-`29 MB`, because eight editors starting at once pay eight processes. Measured in `benchmarks/daemon-cost`, after ADR 0067 moved the graph read to the first query that needs it.
The two transports are indistinguishable: `9,8`-`10,6 MB` per client over HTTP against `10,0`-`10,7` over the socket. HTTP costs more only under sustained traffic, and no real session produces it.
type InstructionsPlan ¶ added in v0.9.9
type InstructionsPlan struct {
Action Action
File string
Path string
SourcePath string
Status string
// Changed says whether applying the plan would change a file.
Changed bool
DryRun bool
Detail string
}
InstructionsPlan describes an agent-instructions installation. Path is the file read by the selected agent; SourcePath is the owned prompt it references.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager applies integration plans for one local user and one project.
func (Manager) DetectHookTargets ¶ added in v0.8.1
func (manager Manager) DetectHookTargets(scope Scope) ([]TargetDetection, error)
DetectHookTargets reports which clients can host a gate and appear installed.
func (Manager) DetectInstructionsTargets ¶ added in v0.9.9
func (manager Manager) DetectInstructionsTargets() ([]TargetDetection, error)
DetectInstructionsTargets reports which user instruction integration files already exist. A shared Claude file marks each client that reads it.
func (Manager) DetectMCPTargets ¶
func (manager Manager) DetectMCPTargets(scope Scope) ([]TargetDetection, error)
DetectMCPTargets returns every MCP target supported by the requested scope, marking the targets whose local configuration or installation markers exist.
func (Manager) DetectSkillTargets ¶
func (manager Manager) DetectSkillTargets(scope Scope) ([]TargetDetection, error)
DetectSkillTargets returns every local skill target supported by the requested scope, marking the targets whose local installation markers exist.
func (Manager) InstallHook ¶ added in v0.8.1
InstallHook registers the gate with one client.
func (Manager) InstallInstructions ¶ added in v0.9.9
func (manager Manager) InstallInstructions(file string, dryRun, force bool) (InstructionsPlan, error)
InstallInstructions adds Kivgraph instructions through a deprecated --file selector. Existing content remains in place, while the owned source is never overwritten unless it still matches the bundled prompt or --force is set.
func (Manager) InstallInstructionsForTarget ¶ added in v0.9.10
func (manager Manager) InstallInstructionsForTarget(target Target, dryRun, force bool) (InstructionsPlan, error)
InstallInstructionsForTarget installs the owned source and registers it by the mechanism the selected coding agent actually reads.
func (Manager) InstallMCP ¶
InstallMCP registers the local MCP server, or returns an idempotent plan if the exact Kivgraph-managed entry already exists.
func (Manager) InstallSkill ¶
InstallSkill copies the canonical embedded skill to a client-native path.
func (Manager) InstructionsDestination ¶ added in v0.9.9
InstructionsDestination resolves a deprecated --file selector to the matching primary user-configuration file. New callers should select a target with InstructionsDestinationForTarget.
func (Manager) InstructionsDestinationForTarget ¶ added in v0.9.10
InstructionsDestinationForTarget resolves the user-level file whose native configuration makes the Kivgraph prompt available to one selected client.
func (Manager) RemoveHook ¶ added in v0.8.1
RemoveHook removes only the entry Kivgraph owns.
func (Manager) RemoveMCP ¶
RemoveMCP removes only an exact Kivgraph-managed MCP entry. An incompatible entry requires force, even when the target name is the same.
func (Manager) RemoveSkill ¶
RemoveSkill removes only the exact canonical skill installed by Kivgraph.
func (Manager) StatusHook ¶ added in v0.8.1
StatusHook inspects one client's gate.
type Options ¶
type Options struct {
HomeDir string
ProjectDir string
Executable string
GOOS string
// CodexDir and OhMyPiDir override their clients' user configuration roots.
// Empty values resolve their documented environment variables once in New.
CodexDir string
OhMyPiDir string
// Endpoint, when set, makes plans point at a running daemon over HTTP
// rather than at this executable over stdio.
Endpoint Endpoint
// PreviousEndpoint is the endpoint persisted by the daemon before an
// update restarted it. It is ownership evidence for replacing a stale
// endpoint entry; a URL and bearer header alone are not enough to prove
// that Kivgraph wrote a user-scoped client configuration.
PreviousEndpoint Endpoint
}
Options identifies the filesystem roots used by a Manager. HomeDir and ProjectDir are injectable to make safety checks testable without touching a real client configuration.
type Plan ¶
type Plan struct {
Action Action
Target Target
Scope Scope
Path string
Status string
Changed bool
DryRun bool
Detail string
}
Plan describes an inspected or applied integration operation.
type Target ¶
type Target string
func HookTargets ¶ added in v0.8.1
func HookTargets() []Target
HookTargets are the clients that can host a pre-tool-use gate.
It is kept separate from KnownTargets because Claude Desktop still has no project scope even though it can host a user-scoped gate.
func InstructionsTargets ¶ added in v0.9.9
func InstructionsTargets() []Target
InstructionsTargets are the coding agents whose user context can carry the Kivgraph instructions.
func KnownTargets ¶ added in v0.3.6
func KnownTargets() []Target
KnownTargets is the vocabulary of clients this package can register, in the order detection reports them. It is a function rather than a slice so no caller can reorder or truncate the list for the next one.
func SkillTargets ¶ added in v0.8.2
func SkillTargets() []Target
SkillTargets are the clients an Agent Skill can be installed into.
It is shorter than KnownTargets and has to be said separately because Claude Desktop reads no local skill directory, while hook targets include its user-scoped gate.
type TargetDetection ¶
TargetDetection reports whether a supported client appears to be installed in the requested scope.