internal

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: May 10, 2026 License: MIT Imports: 14 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 ExtractClaudeAccountDetails added in v0.2.1

func ExtractClaudeAccountDetails(stored ClaudeStoredCredentials) (email, subscriptionType, accessToken string)

ExtractClaudeAccountDetails pulls the email and subscriptionType from stored credentials for display purposes, and returns the accessToken for use in live verification.

func KillClaudeProcesses added in v0.2.4

func KillClaudeProcesses()

KillClaudeProcesses finds and terminates any running instances of Claude Code (e.g., 'claude', 'claude-agent-sdk', 'claude-agent-acp') to prevent them from refreshing tokens and corrupting the keychain after an account switch.

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 ResolveClaudeConfigPath added in v0.2.1

func ResolveClaudeConfigPath(defaultPath string) string

ResolveClaudeConfigPath returns the path to Claude Code's config file. Newer Claude Code uses ~/.claude.json; older versions use ~/.claude/.claude.json.

func UpdateActiveAccount

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

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

func VerifyClaudeToken added in v0.2.1

func VerifyClaudeToken(accessToken string) (email, orgName string, err error)

VerifyClaudeToken makes a live request to the Anthropic API to confirm the access token is valid, returning live account email and organization name when available.

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 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 is the oauthAccount JSON section from ~/.claude.json.
	// On switch, this is merged back into the live config, leaving other settings intact.
	OAuthAccount string `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 oauthAccount from the config. 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