claudecode

package
v0.59.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package claudecode manages Claude Code CLI installation and launching.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseClaudeArgs

func ParseClaudeArgs(args []string) (claspArgs, claudeArgs []string)

ParseClaudeArgs separates CLASP args from Claude Code args. Everything after "--" is passed to Claude Code.

func RunWithClaudeCode

func RunWithClaudeCode(cfg ProxyLaunchConfig) error

RunWithClaudeCode starts the CLASP proxy and launches Claude Code in one operation. This is the main entry point for the "clasp" command when used to launch Claude.

func SpawnProxyBackground

func SpawnProxyBackground(port int, provider, model string) (*exec.Cmd, error)

SpawnProxyBackground starts the proxy in a background process.

Types

type InstallOptions

type InstallOptions struct {
	ForceUpdate bool
	SkipCheck   bool
}

InstallOptions configures the installation behavior.

type InstallStatus

type InstallStatus struct {
	Installed     bool   `json:"installed"`
	Version       string `json:"version"`
	Path          string `json:"path"`
	NeedsUpdate   bool   `json:"needs_update"`
	LatestVersion string `json:"latest_version,omitempty"`
	LastChecked   int64  `json:"last_checked"`
	InstallMethod string `json:"install_method"` // npm, npx, binary
}

InstallStatus represents the current Claude Code installation state.

type LaunchOptions

type LaunchOptions struct {
	WorkingDir      string
	Args            []string
	ProxyURL        string
	APIKey          string // Optional: pre-configured API key for the proxy
	Interactive     bool
	PassthroughEnv  bool // Pass through all environment variables
	SkipPermissions bool // Use --dangerously-skip-permissions flag
}

LaunchOptions configures how Claude Code is launched.

type Manager

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

Manager handles Claude Code CLI installation and launching.

func NewManager

func NewManager(proxyURL string, verbose bool) *Manager

NewManager creates a new Claude Code manager.

func (*Manager) CacheStatus

func (m *Manager) CacheStatus(status *InstallStatus) error

CacheStatus saves installation status to cache.

func (*Manager) CheckForUpdates

func (m *Manager) CheckForUpdates(currentVersion string) (bool, string, error)

CheckForUpdates checks if a newer version of Claude Code is available.

func (*Manager) CheckInstallation

func (m *Manager) CheckInstallation() (*InstallStatus, error)

CheckInstallation checks if Claude Code is installed and its version. Priority: 1) Bundled in node_modules 2) Global npm 3) npx fallback

func (*Manager) EnsureInstalled

func (m *Manager) EnsureInstalled() (*InstallStatus, error)

EnsureInstalled checks if Claude Code is installed and installs it if needed.

func (*Manager) GetLatestVersion

func (m *Manager) GetLatestVersion() (string, error)

GetLatestVersion fetches the latest version from npm.

func (*Manager) Install

func (m *Manager) Install() error

Install installs Claude Code using npm.

func (*Manager) Launch

func (m *Manager) Launch(opts LaunchOptions) error

Launch starts Claude Code with the CLASP proxy configuration.

func (*Manager) LaunchWithProxy

func (m *Manager) LaunchWithProxy(proxyPort int, opts LaunchOptions) error

LaunchWithProxy starts CLASP proxy and then launches Claude Code.

func (*Manager) LoadCachedStatus

func (m *Manager) LoadCachedStatus() (*InstallStatus, error)

LoadCachedStatus loads installation status from cache.

func (*Manager) SetInstallOptions

func (m *Manager) SetInstallOptions(opts InstallOptions)

SetInstallOptions sets installation options.

func (*Manager) Update

func (m *Manager) Update() error

Update updates Claude Code to the latest version.

type ProxyLaunchConfig

type ProxyLaunchConfig struct {
	Port            int
	Provider        string
	Model           string
	AutoInstall     bool
	ForceUpdate     bool
	Verbose         bool
	ClaudeArgs      []string
	WorkingDir      string
	BackgroundProxy bool // Run proxy in background
}

ProxyLaunchConfig holds configuration for launching with the proxy.

Jump to

Keyboard shortcuts

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