commands

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: MIT Imports: 75 Imported by: 0

Documentation

Overview

P88 Sprint 05: `nself ai chat` — quick chat for verification. Acceptance criteria: `nself ai chat "hello"` returns coherent local response <3s.

P88 Sprint 03: `nself ai pool` — 8 subcommands for Gemini pool management.

P88 Sprint 05: `nself doctor --ai` first-run wizard. Tickets: T-05-01 (wizard), T-05-02 (headless), T-05-03 (idempotency).

Package commands — security.go

`nself security` provides server-level security operations: audit, setup, and status. These commands inspect the host environment (firewall, fail2ban, SSH config) and the running stack for common hardening gaps. They are intentionally non-destructive by default — `setup` requires `--apply` to make changes, otherwise it prints what would be done.

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "nself",
	Short: "nSelf CLI - Serverless hosting, anywhere",
	Long: `nSelf CLI empowers you to deploy a fully-featured, production-ready
backend to any hosting provider with absolute simplicity.

The Golden Path:
  nself init    # Generate your pristine .env configuration
  nself build   # Compose your infrastructure
  nself start   # Boot your stack`,

	RunE: func(cmd *cobra.Command, args []string) error {
		return cmd.Help()
	},

	SilenceUsage:  true,
	SilenceErrors: true,
}

RootCmd represents the base command when called without any subcommands

Functions

func EnsureOutboxDir added in v1.0.6

func EnsureOutboxDir() error

EnsureOutboxDir creates the outbox directory if it does not exist. Called during nself setup to ensure the durable queue is ready.

func Execute

func Execute() error

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main().

Types

type AdminConnection added in v1.0.6

type AdminConnection struct {
	Name       string `json:"name"`
	Host       string `json:"host"`
	User       string `json:"user"`
	Port       int    `json:"port"`
	LocalPort  int    `json:"local_port"`
	RemotePort int    `json:"remote_port"`
}

AdminConnection represents a saved remote admin connection.

type AdminProject added in v1.0.6

type AdminProject struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Path    string `json:"path"`
	Host    string `json:"host"`
	SSHUser string `json:"ssh_user"`
	URL     string `json:"url"`
}

AdminProject represents a project in the multi-project config.

type ClawConfig added in v1.0.6

type ClawConfig struct {
	APIKey    string `yaml:"api_key,omitempty"`
	ServerURL string `yaml:"server_url,omitempty"`
}

ClawConfig holds the CLI-to-claw-server configuration.

type LogSummary

type LogSummary struct {
	Service    string
	TotalLines int
	ErrorCount int
	WarnCount  int
	TopErrors  []string // up to 5 most frequent error messages (deduped)
	LastLine   string
}

LogSummary holds per-service log analysis results.

func CollectLogSummary

func CollectLogSummary(ctx context.Context, workdir string, service string, maxLines int) (*LogSummary, error)

CollectLogSummary fetches and analyses recent logs for a single service.

type LogVolume

type LogVolume struct {
	Service     string
	LinesPerMin float64
	BytesPerMin float64
	ErrorRate   float64 // errors / total lines in sample window
}

LogVolume holds per-service log volume sample data.

func SampleLogVolume

func SampleLogVolume(ctx context.Context, workdir string, service string, sampleDuration time.Duration) (*LogVolume, error)

SampleLogVolume samples docker logs for a service over sampleDuration and computes volume metrics.

type LogsOptions

type LogsOptions struct {
	Search  string
	Grep    string // regex pattern for --grep
	Errors  bool
	Level   string // debug|info|warn|error
	Compact bool
	Quiet   bool
	Tail    int
	Follow  bool
	Since   string // relative (1h, 30m) or absolute RFC3339
	Until   string // relative or absolute RFC3339
	JSON    bool   // structured JSON output per line
	NoColor bool
	Plain   bool // disable highlighting for piping
	Service []string
}

LogsOptions holds parsed flag values for log filtering and formatting.

Jump to

Keyboard shortcuts

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