autoconf

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package autoconf provides environment detection for automatic workspace configuration.

Index

Constants

View Source
const ADCContainerPath = "$HOME/.config/gcloud/application_default_credentials.json"

ADCContainerPath is the target path inside the workspace container for the ADC file mount, expressed with the $HOME variable that the runtime expands.

Variables

View Source
var ErrSkipped = errors.New("skipped")

ErrSkipped may be returned by Options.SelectTarget to signal that the user chose not to add the secret to any configuration target.

Functions

This section is empty.

Types

type Autoconf

type Autoconf interface {
	Run(out io.Writer) error
}

Autoconf orchestrates secret detection and application: it scans the environment, prompts for confirmation, creates secrets, and records their references in the chosen configuration target.

func New

func New(opts Options) Autoconf

New returns an Autoconf configured by opts.

type ClaudeVertexAutoconf added in v0.11.0

type ClaudeVertexAutoconf interface {
	Run(out io.Writer) error
}

ClaudeVertexAutoconf orchestrates Vertex AI configuration detection and application for Claude workspaces. It adds env vars and an ADC file mount to either the claude agent config (all Claude workspaces) or the local workspace config.

func NewClaudeVertexAutoconf added in v0.11.0

func NewClaudeVertexAutoconf(opts ClaudeVertexAutoconfOptions) ClaudeVertexAutoconf

NewClaudeVertexAutoconf returns a ClaudeVertexAutoconf configured by opts.

type ClaudeVertexAutoconfOptions added in v0.11.0

type ClaudeVertexAutoconfOptions struct {
	Detector VertexDetector

	// AgentUpdater writes to ~/.kdn/config/agents.json for the "claude" agent.
	AgentUpdater config.AgentConfigUpdater
	// WorkspaceUpdater writes to .kaiden/workspace.json in the current directory.
	// When nil the local target is not offered.
	WorkspaceUpdater config.WorkspaceConfigUpdater

	// AgentLoader is used to check whether Vertex AI is already configured in
	// the claude agent config. May be nil (skips that check).
	AgentLoader config.AgentConfigLoader
	// WorkspaceConfig is used to check whether Vertex AI is already configured
	// in the local workspace config. May be nil (skips that check).
	WorkspaceConfig config.Config

	Yes bool

	// Confirm is called to ask the user whether to proceed.
	Confirm func(prompt string) (bool, error)

	// SelectTarget is called to ask the user where to record the configuration.
	// It may return ErrSkipped to skip without applying.
	SelectTarget func(options []ClaudeVertexConfigTargetOption) (ClaudeVertexConfigTarget, error)
}

ClaudeVertexAutoconfOptions configures a ClaudeVertexAutoconf runner.

type ClaudeVertexConfigTarget added in v0.11.0

type ClaudeVertexConfigTarget int

ClaudeVertexConfigTarget identifies where detected Vertex AI configuration is recorded for Claude workspaces.

const (
	// ClaudeVertexConfigTargetAgent records env vars and the ADC mount in
	// agents.json under the "claude" key (applies to all Claude workspaces).
	ClaudeVertexConfigTargetAgent ClaudeVertexConfigTarget = iota
	// ClaudeVertexConfigTargetLocal records env vars and the ADC mount in
	// the local .kaiden/workspace.json.
	ClaudeVertexConfigTargetLocal
)

type ClaudeVertexConfigTargetOption added in v0.11.0

type ClaudeVertexConfigTargetOption struct {
	Target ClaudeVertexConfigTarget
	Label  string
}

ClaudeVertexConfigTargetOption pairs a ClaudeVertexConfigTarget with a human-readable label for display in selection prompts.

type ConfigTarget

type ConfigTarget int

ConfigTarget identifies where a detected secret's reference is recorded.

const (
	// ConfigTargetGlobal records the secret in the global entry of projects.json
	// (applies to all projects).
	ConfigTargetGlobal ConfigTarget = iota
	// ConfigTargetProject records the secret in the project-specific entry of
	// projects.json (keyed by the computed project ID for the current directory).
	ConfigTargetProject
	// ConfigTargetLocal records the secret in the local .kaiden/workspace.json.
	ConfigTargetLocal
)

type ConfigTargetOption

type ConfigTargetOption struct {
	Target ConfigTarget
	Label  string
}

ConfigTargetOption pairs a ConfigTarget with a human-readable label for display in selection prompts.

type ConfiguredSecret

type ConfiguredSecret struct {
	DetectedSecret
	// Locations lists every config source where the secret is referenced.
	Locations []ConfigTarget
}

ConfiguredSecret is a detected secret that is already fully set up — present in the store and referenced in at least one configuration source.

type DetectedSecret

type DetectedSecret struct {
	ServiceName string
	EnvVarName  string
	Value       string
}

DetectedSecret represents a secret found in the environment for a specific service.

type FilterResult

type FilterResult struct {
	// NeedsAction contains secrets that are missing from the store or from every
	// known config source and therefore require user action.
	NeedsAction []DetectedSecret
	// Configured contains secrets that are already fully set up. Each entry
	// includes the locations where the secret is referenced.
	Configured []ConfiguredSecret
}

FilterResult is the output of SecretFilter.Filter.

type Options

type Options struct {
	Detector SecretDetector
	Store    secret.Store

	// ProjectUpdater writes to ~/.kdn/config/projects.json.
	ProjectUpdater config.ProjectConfigUpdater
	// WorkspaceUpdater writes to .kaiden/workspace.json in the current directory.
	// When nil the local target is not offered to the user. When non-nil the file
	// is created automatically if the user selects the local target.
	WorkspaceUpdater config.WorkspaceConfigUpdater
	// ProjectID is the project identifier for the current working directory,
	// used when the user selects ConfigTargetProject.
	ProjectID string

	Yes bool

	// Confirm is called (once per secret) to ask whether to create it.
	// Returning false skips the secret entirely.
	Confirm func(prompt string) (bool, error)

	// SelectTarget is called after a secret is created to ask where to record
	// the reference. It may return ErrSkipped to skip adding to any config.
	// Not called when Yes is true (defaults to ConfigTargetGlobal).
	SelectTarget func(secretName string, options []ConfigTargetOption) (ConfigTarget, error)
}

Options configures an Autoconf runner.

type SecretDetector

type SecretDetector interface {
	Detect() (FilterResult, error)
}

SecretDetector scans the environment for secrets belonging to registered services. Detect takes no parameters — services are provided at construction time so that this interface stays consistent with future detectors (language, config-dir, etc.) that also own their own data sources. When the detector was created with NewFilteredSecretDetector, fully-configured secrets are returned in FilterResult.Configured so callers can display their status.

func NewFilteredSecretDetector

func NewFilteredSecretDetector(
	services []secretservice.SecretService,
	store secret.Store,
	loader config.ProjectConfigLoader,
	projectID string,
	workspaceConfig config.Config,
) SecretDetector

NewFilteredSecretDetector returns a SecretDetector that reads from the process environment and removes secrets that are already stored and referenced in any configuration source — callers receive only secrets that require action. projectID is the computed project identifier for the current directory; workspaceConfig is optional and covers the local .kaiden/workspace.json.

func NewSecretDetector

func NewSecretDetector(services []secretservice.SecretService) SecretDetector

NewSecretDetector returns a SecretDetector that reads from the process environment without any filtering of already-configured secrets.

type SecretFilter

type SecretFilter interface {
	Filter(detected []DetectedSecret) (FilterResult, error)
}

SecretFilter classifies DetectedSecrets into those needing action and those already fully configured.

func NewAlreadyConfiguredFilter

func NewAlreadyConfiguredFilter(
	store secret.Store,
	loader config.ProjectConfigLoader,
	projectID string,
	workspaceConfig config.Config,
) SecretFilter

NewAlreadyConfiguredFilter returns a SecretFilter that classifies secrets across all configuration sources. loader.Load("") covers the global config; loader.Load(projectID) covers global + project-specific merged, from which project-specific secrets are derived. workspaceConfig is optional and covers .kaiden/workspace.json.

type VertexConfig added in v0.11.0

type VertexConfig struct {
	// EnvVars maps env var names to their values for the vars that were detected.
	EnvVars map[string]string
	// ADCHostPath is the host-side path to use in the workspace mount entry.
	// It always starts with $HOME. On Linux/macOS this equals ADCContainerPath;
	// on Windows it is computed from %APPDATA% relative to the home directory.
	ADCHostPath string
}

VertexConfig holds the Vertex AI environment variables detected from the environment. A non-nil value means all required env vars are set and the ADC file exists.

type VertexDetector added in v0.11.0

type VertexDetector interface {
	Detect() (*VertexConfig, error)
}

VertexDetector detects Vertex AI configuration in the environment. Detect takes no parameters — data sources are baked in at construction time, consistent with the SecretDetector pattern.

func NewVertexDetector added in v0.11.0

func NewVertexDetector() (VertexDetector, error)

NewVertexDetector returns a VertexDetector that reads from the process environment. Returns an error only if the home directory cannot be determined.

Jump to

Keyboard shortcuts

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