Documentation
¶
Index ¶
- Variables
- func AppendToAccounts(accountsPath string, account Account) error
- func DeleteAllFromAccounts(accountsPath string) error
- func DeleteAllFromKeyring() error
- func DeleteAllThreads(threadsPath string) error
- func DeleteFromAccounts(accountsPath, name string, service Service) error
- func DeleteFromKeyring(service Service, name string) error
- func DeleteHistoryFile(historyPath string) error
- func EnsureAccounts(accountsPath string) error
- func ExtractApiKey(secretsPath string) (string, error)
- func ExtractClaudeAccountDetails(stored ClaudeStoredCredentials) (email, subscriptionType, accessToken string)
- func KillClaudeProcesses()
- func ReadFromKeyring(service Service, name string) (string, error)
- func ResolveClaudeConfigPath(defaultPath string) string
- func UpdateActiveAccount(accountsPath, name string, service Service) error
- func VerifyClaudeToken(accessToken string) (email, orgName string, err error)
- func WriteToAccounts(accountsPath string, accounts Accounts) error
- func WriteToAmpSecrets(apiKey, secretsPath string) error
- func WriteToClaudeCredentials(stored ClaudeStoredCredentials, claudeConfigPath, claudeCredsPath string) error
- func WriteToKeyring(service Service, name, value string) error
- type Account
- type Accounts
- type AmpSecrets
- type ClaudeStoredCredentials
- type Service
Constants ¶
This section is empty.
Variables ¶
var Viper = viper.New()
Functions ¶
func AppendToAccounts ¶
AppendToAccounts adds a new account entry to the accounts file and updates LastService.
func DeleteAllFromAccounts ¶ added in v0.2.0
DeleteAllFromAccounts clears all accounts from the accounts file.
func DeleteAllFromKeyring ¶
func DeleteAllFromKeyring() error
DeleteAllFromKeyring deletes all keyring entries under the "amped" service.
func DeleteAllThreads ¶
DeleteAllThreads removes all files in the threads directory and recreates it empty.
func DeleteFromAccounts ¶
DeleteFromAccounts removes the named account for the given service from the accounts file.
func DeleteFromKeyring ¶
DeleteFromKeyring removes the keyring entry for the given service and account name.
func DeleteHistoryFile ¶
DeleteHistoryFile removes the history file, if it exists.
func EnsureAccounts ¶
EnsureAccounts creates the accounts JSON file with an empty structure if it doesn't exist.
func ExtractApiKey ¶
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 ¶
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
ResolveClaudeConfigPath returns the path to Claude Code's config file. Newer Claude Code uses ~/.claude.json; older versions use ~/.claude/.claude.json.
func UpdateActiveAccount ¶
UpdateActiveAccount sets the active account for the given service and updates LastService.
func VerifyClaudeToken ¶ added in v0.2.1
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 ¶
WriteToAccounts writes the full accounts structure to the accounts JSON file.
func WriteToAmpSecrets ¶
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
WriteToKeyring stores credentials for the given service and account name.
Types ¶
type Account ¶ added in v0.2.0
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 ¶
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.