appwizard

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package appwizard analyses a git repository through a provider file-tree API and returns pre-filled, evidence-backed suggestions for creating an app. Repository text is parsed as data only and env values are never returned.

Index

Constants

View Source
const (
	ConfidenceHigh   = "high"
	ConfidenceMedium = "medium"
	ConfidenceLow    = "low"
)

Confidence levels of a Detection.

View Source
const (
	WarnNoLockfile        = "no_lockfile"
	WarnMultiDockerfile   = "multiple_dockerfiles"
	WarnMalformedManifest = "malformed_manifest"
	WarnDockerfileNoPort  = "dockerfile_no_expose"
	WarnMonorepoNoApp     = "monorepo_no_root_app"
	WarnRailpackNoRust    = "railpack_unsupported"
)

Detection warning codes.

View Source
const (
	WarnNoDockerfile = "no_dockerfile"
	WarnSpecDraft    = "spec_draft_invalid"
)

Warning codes added by the plan view on top of the analysis ones.

View Source
const (
	EnvMaxFiles     = "APP_WIZARD_MAX_FILES"
	EnvMaxFileBytes = "APP_WIZARD_MAX_FILE_BYTES"
	EnvMaxEnvKeys   = "APP_WIZARD_MAX_ENV_KEYS"
)

Env vars bounding one analysis.

View Source
const (
	WarnNothingDetected = "nothing_detected"
	WarnReadBudget      = "read_budget"
	WarnTruncated       = "tree_truncated"
	WarnMonorepo        = "monorepo_choose_app"
	WarnNoPort          = "port_unknown"

	WarnDirectoryMissing = "directory_missing"
)

Warning codes a dashboard can translate.

View Source
const (
	HintNextMultiReplica = "next_multi_replica_cache"
	HintNextNoOutput     = "next_no_standalone_output"
	HintNextSharp        = "next_sharp_missing"
	HintNextTracingRoot  = "next_tracing_root"
	HintNextPublicVars   = "next_public_build_time"
	HintNextExportServer = "next_export_with_middleware"
)

Next.js hint codes. They are advice only and never change a default.

View Source
const EnvMaxNextScanFiles = "APP_WIZARD_NEXT_SCAN_FILES"

EnvMaxNextScanFiles bounds how many source files one Next.js scan reads.

View Source
const MaxAppNameLen = maxNameLen

MaxAppNameLen is the longest name PackageAppName returns.

Variables

This section is empty.

Functions

func PackageAppName

func PackageAppName(repoURL, dir string) string

PackageAppName proposes an app name for one workspace package: the repository name plus the package directory's last segment.

Types

type Analysis

type Analysis struct {
	RepoURL       string               `json:"repo_url"`
	Branch        string               `json:"branch"`
	Monorepo      bool                 `json:"monorepo"`
	AppDirectory  string               `json:"app_directory,omitempty"`
	Name          Text                 `json:"name"`
	Stack         Stack                `json:"stack"`
	Build         Build                `json:"build"`
	Port          Port                 `json:"port"`
	Health        Text                 `json:"health"`
	Memory        Memory               `json:"memory"`
	Domain        Text                 `json:"domain"`
	Env           []EnvKey             `json:"env"`
	Databases     []DatabaseNeed       `json:"databases"`
	Warnings      []Warning            `json:"warnings"`
	Detection     Detection            `json:"detection"`
	Packages      []repolayout.Package `json:"packages"`
	FilesRead     int                  `json:"files_read"`
	TreeTruncated bool                 `json:"tree_truncated"`
}

Analysis is the full set of suggestions for one repository and ref.

func Analyze

func Analyze(ctx context.Context, src repolayout.Source, opts Options) (*Analysis, error)

Analyze lists the repository tree once, reads a bounded set of manifest files, and returns suggestions with evidence. It never clones and never returns env values.

type Build

type Build struct {
	Type           string                  `json:"type"`
	DockerfilePath string                  `json:"dockerfile_path,omitempty"`
	BaseDirectory  string                  `json:"base_directory,omitempty"`
	Evidence       string                  `json:"evidence"`
	Alternatives   []repolayout.Suggestion `json:"alternatives"`
}

Build is the suggested build configuration, relative to the repository root.

type DatabaseNeed

type DatabaseNeed struct {
	Engine        string `json:"engine"`
	Version       string `json:"version"`
	SuggestedName string `json:"suggested_name"`
	EnvVar        string `json:"env_var"`
	Field         string `json:"field"`
	Evidence      string `json:"evidence"`
}

DatabaseNeed is a managed database the app appears to need.

type Detection

type Detection struct {
	Framework    string    `json:"framework"`
	Language     string    `json:"language"`
	BuildType    string    `json:"build_type"`
	Confidence   string    `json:"confidence"`
	Reasons      []Reason  `json:"reasons"`
	Port         PortGuess `json:"port"`
	StartCommand string    `json:"start_command,omitempty"`
	BuildCommand string    `json:"build_command,omitempty"`
	OutputDir    string    `json:"output_dir,omitempty"`
	// SPA is true for a client routed single page app: serve index.html for unknown paths.
	SPA            bool          `json:"spa"`
	HealthPath     string        `json:"health_path"`
	RuntimeVersion Sourced       `json:"runtime_version"`
	EnvVars        []EnvVarGuess `json:"env_vars"`
	Warnings       []Warning     `json:"warnings"`
	// Next is set only for Next.js apps.
	Next *NextProfile `json:"next,omitempty"`
}

Detection explains what a repository is and how it would be built.

func Detect

func Detect(in Input) Detection

Detect names the framework, build type and run settings of a repository and lists every signal behind each choice. It is pure: no network, no clone.

type DirSource

type DirSource struct{ Root string }

DirSource lists and reads an already checked out source directory read-only. Real env files, symlinks and paths outside root are never listed or read.

func (DirSource) Paths

func (d DirSource) Paths(ctx context.Context) ([]string, bool, error)

Paths lists regular files below Root, sorted, relative with slashes.

func (DirSource) Read

func (d DirSource) Read(_ context.Context, p string, limit int) ([]byte, error)

Read returns at most limit bytes of one listed file.

type EnvKey

type EnvKey struct {
	Key        string `json:"key"`
	Required   bool   `json:"required"`
	Secret     bool   `json:"secret"`
	Source     string `json:"source"`
	ProvidedBy string `json:"provided_by,omitempty"`
	HasDefault bool   `json:"has_default"`
}

EnvKey is one environment variable the repository declares. It never carries a value.

type EnvVarGuess

type EnvVarGuess struct {
	Name        string `json:"name"`
	Source      string `json:"source"`
	Required    bool   `json:"required"`
	SecretGuess bool   `json:"secret_guess"`
}

EnvVarGuess is one variable the repository declares, never with a value.

type Input

type Input struct {
	Paths []string
	Read  func(p string) (string, bool)
	// Dir is the app directory inside the repository, "" for the root.
	Dir    string
	Layout *repolayout.Result
}

Input is a repository tree, from a checkout or a provider listing. Read returns false for anything missing, unreadable or binary.

type Memory

type Memory struct {
	Bytes    int64  `json:"bytes"`
	Evidence string `json:"evidence"`
}

Memory is the suggested memory limit.

type NextProfile

type NextProfile struct {
	Version          string   `json:"version,omitempty"`
	Major            int      `json:"major,omitempty"`
	Output           string   `json:"output"`
	CacheHandler     bool     `json:"cache_handler"`
	CacheMaxMemory   int64    `json:"cache_max_memory_size,omitempty"`
	CacheComponents  bool     `json:"cache_components"`
	Experimental     []string `json:"experimental"`
	Middleware       string   `json:"middleware,omitempty"`
	Sharp            bool     `json:"sharp"`
	Monorepo         bool     `json:"monorepo"`
	TracingRoot      bool     `json:"tracing_root"`
	PublicVars       int      `json:"public_vars"`
	UsesRevalidate   bool     `json:"uses_revalidate"`
	MultiReplicaRisk bool     `json:"multi_replica_risk"`
}

NextProfile is what static scanning learned about a Next.js app. Config files are read as text and never executed.

type Options

type Options struct {
	RepoURL string
	Branch  string
	// BaseDirectory, DockerfilePath and BuildType override the recommended
	// build suggestion when the operator picked an alternative.
	BaseDirectory  string
	DockerfilePath string
	BuildType      string
	Name           string
	// AppsBaseDomain, when set with DomainFor, yields a suggested domain.
	AppsBaseDomain string
	DomainFor      func(name, base string) string
	// DefaultVersion returns an engine's default version, "" when unknown.
	DefaultVersion func(engine string) string
}

Options carries per-request inputs and environment hooks.

type PlanBuild

type PlanBuild struct {
	Type           string `json:"type"`
	DockerfilePath string `json:"dockerfile_path,omitempty"`
	BaseDirectory  string `json:"base_directory,omitempty"`
	BuildCommand   string `json:"build_command,omitempty"`
	StartCommand   string `json:"start_command,omitempty"`
	OutputDir      string `json:"output_dir,omitempty"`
	Evidence       string `json:"evidence"`
}

PlanBuild is how the app would be built and started.

type PlanEnv

type PlanEnv struct {
	Name        string `json:"name"`
	Source      string `json:"source"`
	Required    bool   `json:"required"`
	LooksSecret bool   `json:"looks_secret"`
	HasDefault  bool   `json:"has_default_hint"`
}

PlanEnv is one env var name the repository documents. It has no value field on purpose: values are never read into the plan.

type PlanHealth

type PlanHealth struct {
	Path     string `json:"path"`
	Evidence string `json:"evidence"`
}

PlanHealth is the guessed health probe path.

type PlanNext

type PlanNext struct {
	Method string `json:"method"`
	Path   string `json:"path"`
}

PlanNext points at the existing action that applies a reviewed plan. The plan itself never applies anything.

type PlanPort

type PlanPort struct {
	Value    int    `json:"value"`
	Evidence string `json:"evidence"`
}

PlanPort is a guessed port or health path with its evidence.

type PlanSpec

type PlanSpec struct {
	Name string `json:"name"`
	YAML string `json:"yaml"`
}

PlanSpec is the draft app spec in the declarative spec format.

type PlanStack

type PlanStack struct {
	Runtime    string   `json:"runtime"`
	Framework  string   `json:"framework,omitempty"`
	Language   string   `json:"language,omitempty"`
	Confidence string   `json:"confidence"`
	Evidence   []Reason `json:"evidence"`
}

PlanStack is the detected stack and the files or signals behind it.

type PlanView

type PlanView struct {
	RepoURL      string     `json:"repo_url"`
	Ref          string     `json:"ref"`
	AppDirectory string     `json:"app_directory,omitempty"`
	Monorepo     bool       `json:"monorepo"`
	Stack        PlanStack  `json:"stack"`
	Build        PlanBuild  `json:"build"`
	Port         PlanPort   `json:"port"`
	Health       PlanHealth `json:"health"`
	Env          []PlanEnv  `json:"env"`
	Spec         PlanSpec   `json:"spec"`
	Warnings     []Warning  `json:"warnings"`
	Next         PlanNext   `json:"next"`
}

PlanView is the read-only, reviewable plan for one repository.

func BuildPlanView

func BuildPlanView(a *Analysis, next PlanNext) PlanView

BuildPlanView turns an analysis into a reviewable plan. next is the existing apply action to link to.

type Port

type Port struct {
	Value    int    `json:"value"`
	Evidence string `json:"evidence"`
}

Port is the suggested listening port.

type PortGuess

type PortGuess struct {
	Value  int    `json:"value"`
	Source string `json:"source"`
}

PortGuess is the listening port and where it came from.

type Reason

type Reason struct {
	Signal string `json:"signal"`
	Detail string `json:"detail"`
}

Reason is one signal that led to a detected value.

type Sourced

type Sourced struct {
	Value  string `json:"value"`
	Source string `json:"source"`
}

Sourced is a value with the place it came from.

type Stack

type Stack struct {
	Runtime   string `json:"runtime"`
	Framework string `json:"framework,omitempty"`
	Evidence  string `json:"evidence"`
}

Stack is the detected runtime and framework.

type Text

type Text struct {
	Value    string `json:"value"`
	Evidence string `json:"evidence"`
}

Text is a suggested string with the evidence behind it.

type Warning

type Warning struct {
	Code    string `json:"code"`
	Message string `json:"message"`
}

Warning is a note to show before deploying.

Jump to

Keyboard shortcuts

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