setup

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package setup — .env.ai generator for P88 Zero-Config AI (Sprint 01, T-01-09).

.env.ai is the canonical home for AI-tier configuration and the master secret used to encrypt OAuth refresh tokens and pooled GCP API keys. It is written once by `nself init` and must never be overwritten by subsequent runs — the master secret is irrecoverable and all encrypted material would become unreadable. Spec: p88-block-a-zero-config-ai-spec.md §8.1 / §8.3 / §8.5.

Package setup implements the nself init wizard: project scaffolding, secret generation, .env file creation, and .nself/ directory setup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureEnvFilePermissions

func EnsureEnvFilePermissions(path string) error

EnsureEnvFilePermissions fixes the permissions of an existing env file to 0600 if they are more permissive. It is a no-op if the file does not exist.

func GenerateSecret

func GenerateSecret(length int) (string, error)

GenerateSecret returns a crypto/rand base64url string of the given length, with URL-unsafe characters stripped. Suitable for passwords and API keys.

func WriteEnvFile

func WriteEnvFile(path string, content []byte) error

WriteEnvFile writes env file content to path with restrictive 0600 permissions (owner read/write only). Parent directories are created as needed.

Types

type Options

type Options struct {
	Fast           bool
	Interactive    bool
	NonInteractive bool
	Template       string
	SkipValidation bool
	Wizard         bool
	Demo           bool
	Full           bool
	Force          bool
	Quiet          bool
	WorkDir        string
	Name           string
	// Domain is the BASE_DOMAIN value. When set (e.g. via --domain flag or
	// interactive wizard), it takes precedence over env vars and defaults.
	Domain string
	// DomainComment is written as a comment above BASE_DOMAIN in the generated
	// .env. It describes the chosen domain pattern for operator clarity.
	DomainComment string
	// NoPgvector skips pgvector extension and RAG scaffold on init (sets
	// PGVECTOR_ENABLED=false). Default (false) enables pgvector.
	NoPgvector bool
}

Options holds all flags and settings for the init command.

type Result

type Result struct {
	ProjectName  string
	BaseDomain   string
	Env          string
	FilesCreated []string
	Demo         bool
}

Result holds the outcome of a successful init run.

func Initialize

func Initialize(opts Options) (*Result, error)

Initialize runs the full init flow: validate inputs, generate secrets, write .env files, create .nself/ directory, and return a Result.

Jump to

Keyboard shortcuts

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