claudeprofile

package
v0.93.0-rc.14 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package claudeprofile keeps more than one Claude Code account on one machine. A profile is a config directory of its own (CLAUDE_CONFIG_DIR) holding its own `claude auth login`, so every account runs with its full login rather than an inference-only token. The default profile, Personal, is whatever Claude Code reads without lich's help: CLAUDE_CONFIG_DIR from lich's environment, else ~/.claude.

A profile directory is never moved once it exists. On macOS Claude Code files the login in the Keychain under a service named after a hash of the directory string (internal/quota/claude_storage.go), so Dir must return the same bytes for a slug on every call, and renaming a profile changes its display name only.

Index

Constants

View Source
const Personal = profilestore.Personal

Personal is the slug of the default profile. It is reserved: no profile lich creates can take it, which is what lets a project setting name Personal explicitly where an empty value means "inherit the global one".

Variables

View Source
var ErrProfileGone = profilestore.ErrGone

ErrProfileGone is the error a spawn returns for a session born in a profile that was deleted since. The window matches it to offer a new session in the project's own profile instead.

Functions

func ConfigDir

func ConfigDir(slug string) (string, error)

ConfigDir is a profile's config directory, Personal's included. A profile that does not exist answers ErrProfileGone.

func Delete

func Delete(slug string) error

Delete removes a profile's directory and its login with it. Personal cannot be deleted.

func Dir

func Dir(slug string) (string, error)

Dir is the CLAUDE_CONFIG_DIR of a profile lich created. It does not check that the profile exists; ConfigDir does.

func EnsureShared

func EnsureShared(slug string) error

EnsureShared links into a profile the shared entries Personal gained since the profile was made, which runs before every spawn into it.

func Env

func Env(base []string, dir string) []string

Env is base with a profile's directory as CLAUDE_CONFIG_DIR and the variables that would override its login removed.

func GlobalFile

func GlobalFile(dir string) (string, error)

GlobalFile is the global config of Claude Code run with its config in dir, Personal's for "": where it keeps its user and local MCP servers.

func InheritTrust

func InheritTrust(dir, top, origin string) error

InheritTrust records in the global config of the profile whose directory is dir that the checkout top is trusted, when the person trusted it or origin, the main checkout top is a worktree of, in Personal. Personal ("") is the source and has nothing to inherit. Nothing is written when the profile already trusts either, has no global config yet, or Personal trusts neither: it never trusts a folder nobody trusted.

A profile's global config is a copy of Personal's made once (layout.go), so every folder trusted in Personal after that asks again in the profile. Claude Code finds the answer for a subfolder in its checkout's top and for a linked worktree in its main checkout (measured on 2.1.302), which is why the two are all this asks about.

Claude Code re-reads the file before each write of its own (measured on 2.1.302), so a running session keeps the entry. What one writes between this read and the rename is lost; the same window its own writes have.

func IsPersonal

func IsPersonal(slug string) bool

IsPersonal reports whether slug names the default profile. Empty does too: it is what every session row born before profiles carries.

func MoveConversation

func MoveConversation(conversationID, toSlug string) error

MoveConversation moves everything Claude Code keyed by a conversation id from one profile to another: the transcript, its subagent directory and any file a hook filed beside it under the same name, and the per-conversation state directories. The conversation resumes in the target with its history and its checkpoints (measured round trip on 2.1.296). A hook's file the target already holds is replaced: an async hook outlives Claude Code (its SessionEnd hook runs in a session of its own, measured on 2.1.304), so one can file again in the profile the conversation just left.

What stays behind is what is not keyed by the id: the prompt history (history.jsonl) and the project's lastSessionId, which `claude --continue` in the source profile then points at a conversation it no longer holds.

func PersonalDir

func PersonalDir() (string, error)

PersonalDir is the default profile's config directory: what Claude Code resolves from lich's own environment, CLAUDE_CONFIG_DIR else ~/.claude.

func PluginStore

func PluginStore(dir string) string

PluginStore is the store of the profile at dir, which sits under lich's Claude profiles root like every profile lich creates.

func PluginsDir

func PluginsDir(slug, dir string) string

PluginsDir is the plugins directory of the profile slug whose config directory is dir. Personal's follows pluginsDirVar from lich's environment; a profile's is always inside its own, since its spawn drops the variable.

func Root

func Root() (string, error)

Root is where lich keeps its Claude profiles.

func SweepPluginStore added in v0.91.0

func SweepPluginStore() error

SweepPluginStore deletes each version in the store that no profile names, Personal included, and that no running Claude Code marks in use. It runs at lich start, before any session spawns: a session of an earlier run that ran a version its profile has since moved past ended with that run, and a Claude Code run outside lich with a profile's directory is kept off its versions by their markers. A record it cannot read stops the sweep, since the versions it names are unknown.

func Trusts added in v0.87.0

func Trusts(dir, cwd, top, origin string) (bool, error)

Trusts reports whether Claude Code, run with its config in dir (Personal for ""), finds cwd already trusted: by its own entry, its checkout top's or its main checkout's (see InheritTrust), so it opens at its prompt without asking.

Types

type BinResolver

type BinResolver interface {
	ProviderBin(providerID, projectID string) string
}

BinResolver supplies the Claude Code binary: the configured one, or "" for the default name on PATH. The store implements it.

type Info

type Info = api.ProfileInfo

type LoginEvent

type LoginEvent = api.ProfileLogin

type Plugin

type Plugin = api.ProfilePlugin

type PluginResult

type PluginResult = api.ProfilePluginResult

type Profile

type Profile = profilestore.Profile

Profile is one Claude Code account lich knows about.

func ConfigDirs

func ConfigDirs() []Profile

ConfigDirs is every profile's config directory keyed by slug, Personal first. Every reader of Claude Code's transcripts scans all of them: a conversation lives in exactly one, and which one is what says the profile it belongs to.

func Create

func Create(name string) (Profile, error)

Create makes a profile named name: its directory, laid out against Personal (layout.go), and its sidecar. It does not log in.

func List

func List() ([]Profile, error)

List is every profile, Personal first and the rest in the order they were created.

func Owner

func Owner(conversationID string) (Profile, string, bool)

Owner is the profile holding a Claude Code conversation, and the path of its transcript there. A conversation id is a UUID and lives in exactly one profile, so the first match is the only one.

func Update added in v0.75.0

func Update(slug string, u profilestore.Update) (Profile, error)

Update changes a profile's name, color or image. The slug and the directory stay.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the window's door to the profiles: listing them with their accounts, creating, renaming and deleting them, logging one in, and porting plugins between them.

func New

func New(bins BinResolver, emit func(name string, data any)) *Service

New returns a Service that runs the Claude Code binary bins resolves and reports a login's progress through emit.

func (*Service) CancelLogin

func (s *Service) CancelLogin(_ context.Context, opts api.ProfileSlugOptions) (api.None, error)

CancelLogin answers cancelLogin over RPC.

func (*Service) CreateProfile

func (s *Service) CreateProfile(_ context.Context, opts api.CreateProfileOptions) (Profile, error)

CreateProfile makes a profile and lays it out against Personal. The window logs it in next (Login).

func (*Service) DeleteProfile

func (s *Service) DeleteProfile(ctx context.Context, opts api.ProfileSlugOptions) (api.None, error)

DeleteProfile removes a profile and its login, and clears every setting that named it, so a project set to it falls back to the global profile. It refuses while a session runs in it. A parked session born in it fails to resume with ErrProfileGone.

func (*Service) InstallPlugins

func (s *Service) InstallPlugins(_ context.Context, opts api.InstallPluginsOptions) ([]PluginResult, error)

InstallPlugins installs each plugin@marketplace into a profile through Claude Code's own `plugin install`, run as that profile so its account's policy applies and Claude Code writes its own paths. One result per key, in order; one refusal does not stop the rest. Run it after the profile is logged in.

A plugin installed by running a command its marketplace declares is refused rather than confirmed: lich never answers that question for the user.

func (*Service) Login

func (s *Service) Login(_ context.Context, opts api.ProfileSlugOptions) (api.None, error)

Login runs `claude auth login --claudeai` as a profile. The CLI opens the browser itself; what it prints, the fallback address included, arrives as LoginEvent output, and a code the page shows can be handed back through LoginCode. When the CLI exits, `claude auth status` decides whether the login took, and a logged-in profile gets the lich plugin. It returns once the CLI is started.

func (*Service) LoginCode

func (s *Service) LoginCode(_ context.Context, opts api.LoginCodeOptions) (api.None, error)

LoginCode hands a running login the code the sign-in page showed, for a browser that could not reach the CLI on its own.

func (*Service) LoginCommand

func (s *Service) LoginCommand(_ context.Context, opts api.ProfileSlugOptions) (string, error)

LoginCommand is the command line that logs a profile in from a terminal, for a user who would rather run it in a shell card than through Login.

func (*Service) Plugins

func (s *Service) Plugins(_ context.Context, opts api.ProfileSlugOptions) ([]Plugin, error)

Plugins lists the plugins a profile has installed at user scope, the ones a port can carry to another profile. The lich plugin is not among them.

func (*Service) Profiles

func (s *Service) Profiles(_ context.Context, _ api.None) ([]Info, error)

Profiles lists every profile with its account. The statuses are asked for at once, one CLI each.

func (*Service) SetLichPlugin

func (s *Service) SetLichPlugin(install func(slug string) error, key string)

SetLichPlugin wires the lich plugin: install puts it into a profile and key is the plugin@marketplace it installs. Startup wiring.

func (*Service) SetSessions

func (s *Service) SetSessions(inUse func(slug string) int, forget func(slug string) error)

SetSessions wires the two questions a delete asks: how many live sessions run in a profile, and how to forget the settings that name it. Startup wiring.

func (*Service) UpdateProfile added in v0.75.0

func (s *Service) UpdateProfile(_ context.Context, opts api.UpdateProfileOptions) (Profile, error)

UpdateProfile changes a profile's name, color or image and returns it; its directory never moves.

Jump to

Keyboard shortcuts

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