internal

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Viper = viper.New()

Functions

func AppendToAccounts

func AppendToAccounts(accountsPath string, account Account) error

AppendToAccounts adds a new account entry to the accounts file and updates LastService.

func DeleteAllFromAccounts added in v0.2.0

func DeleteAllFromAccounts(accountsPath string) error

DeleteAllFromAccounts clears all accounts from the accounts file.

func DeleteAllFromKeyring

func DeleteAllFromKeyring() error

DeleteAllFromKeyring deletes all keyring entries under the "amped" service.

func DeleteAllThreads

func DeleteAllThreads(threadsPath string) error

DeleteAllThreads removes all files in the threads directory and recreates it empty.

func DeleteFromAccounts

func DeleteFromAccounts(accountsPath, name string, service Service) error

DeleteFromAccounts removes the named account for the given service from the accounts file.

func DeleteFromKeyring

func DeleteFromKeyring(service Service, name string) error

DeleteFromKeyring removes the keyring entry for the given service and account name.

func DeleteHistoryFile

func DeleteHistoryFile(historyPath string) error

DeleteHistoryFile removes the history file, if it exists.

func EnsureAccounts

func EnsureAccounts(accountsPath string) error

EnsureAccounts creates the accounts JSON file with an empty structure if it doesn't exist.

func ExtractApiKey

func ExtractApiKey(secretsPath string) (string, error)

ExtractApiKey reads the Amp API key from Amp's secrets.json.

func ReadFromKeyring

func ReadFromKeyring(service Service, name string) (string, error)

ReadFromKeyring retrieves stored credentials for the given service and account name. Falls back to the legacy (no-prefix) key format for backward compatibility with old Amp accounts.

func UpdateActiveAccount

func UpdateActiveAccount(accountsPath, name string, service Service) error

UpdateActiveAccount sets the active account for the given service and updates LastService.

func WriteToAccounts

func WriteToAccounts(accountsPath string, accounts Accounts) error

WriteToAccounts writes the full accounts structure to the accounts JSON file.

func WriteToAmpSecrets

func WriteToAmpSecrets(apiKey, secretsPath string) error

WriteToAmpSecrets writes an Amp API key to Amp's secrets.json.

func WriteToClaudeCredentials added in v0.2.0

func WriteToClaudeCredentials(stored ClaudeStoredCredentials, claudeConfigPath, claudeCredsPath string) error

WriteToClaudeCredentials restores Claude Code credentials and oauth account info. On macOS, credentials are written to the system Keychain. On Linux/other, credentials are written to the file at claudeCredsPath.

func WriteToKeyring added in v0.2.0

func WriteToKeyring(service Service, name, value string) error

WriteToKeyring stores credentials for the given service and account name.

Types

type Account added in v0.2.0

type Account struct {
	Name    string  `json:"name"`
	Service Service `json:"service"`
}

Account represents a single saved account entry in amped's accounts file.

type Accounts added in v0.2.0

type Accounts struct {
	Accounts     []Account `json:"accounts"`
	ActiveAmp    string    `json:"activeAmp"`
	ActiveClaude string    `json:"activeClaude"`
	// LastService is used when no --service flag is given, so the last-used service is re-applied automatically.
	LastService Service `json:"lastService"`
}

Accounts is the top-level structure of amped's accounts JSON file.

func ReadFromAccounts

func ReadFromAccounts(accountsPath string) (Accounts, error)

ReadFromAccounts reads and parses the amped accounts JSON file. Migrates legacy single-service format (Active field) to the new per-service format on read.

type AmpSecrets

type AmpSecrets struct {
	APIKeyHTTPSAmpcodeCom string `json:"apiKey@https://ampcode.com/"`
}

AmpSecrets represents the structure of Amp's secrets.json.

type ClaudeOAuthAccount added in v0.2.0

type ClaudeOAuthAccount struct {
	EmailAddress string `json:"emailAddress"`
	AccountUUID  string `json:"accountUuid"`
}

ClaudeOAuthAccount represents the oauthAccount section of ~/.claude/.claude.json, which identifies which account Claude Code considers currently logged in.

type ClaudeStoredCredentials added in v0.2.0

type ClaudeStoredCredentials struct {
	// Credentials is the raw JSON blob from Claude Code's credential storage.
	// On macOS, this comes from the Keychain entry "Claude Code-credentials".
	// On Linux, this comes from ~/.claude/.credentials.json.
	Credentials  string              `json:"credentials"`
	OAuthAccount *ClaudeOAuthAccount `json:"oauthAccount,omitempty"`
}

ClaudeStoredCredentials packages the credentials blob and oauth account info needed to fully restore a Claude Code account.

func ExtractClaudeCredentials added in v0.2.0

func ExtractClaudeCredentials(claudeConfigPath, claudeCredsPath string) (ClaudeStoredCredentials, error)

ExtractClaudeCredentials reads the current Claude Code credentials and oauth account info. On macOS, credentials are read from the system Keychain ("Claude Code-credentials"). On Linux/other, credentials are read from the file at claudeCredsPath.

type Service added in v0.2.0

type Service string

Service identifies which coding tool's accounts are being managed.

const (
	ServiceAmp    Service = "amp"
	ServiceClaude Service = "claude"
)

Jump to

Keyboard shortcuts

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