orchestration

package
v1.260504.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RuntimeClaude   = agentruntime.KindClaude
	RuntimeCodex    = agentruntime.KindCodex
	RuntimeOpenCode = agentruntime.KindOpenCode
)

Re-export agentruntime.Kind constants for external callers.

View Source
const (
	PlatformIOS      = "ios"
	PlatformWatchOS  = "watchos"
	PlatformTvOS     = "tvos"
	PlatformVisionOS = "visionos"
	PlatformMacOS    = "macos"
)

Platform constants.

View Source
const (
	WatchShapeStandalone = "watch_only"
	WatchShapePaired     = "paired_ios_watch"
)

Watch project shape constants.

Variables

This section is empty.

Functions

func ComposeAgenticSystemPrompt

func ComposeAgenticSystemPrompt(ac ActionContext, catalogRoot string) string

ComposeAgenticSystemPrompt assembles a single system prompt for agentic mode.

func ComposeFixerAppendPrompt

func ComposeFixerAppendPrompt(platform string) string

ComposeFixerAppendPrompt exposes the coder prompt for CLI flows that repair existing projects outside the full orchestration pipeline.

func CoreAgenticToolsList

func CoreAgenticToolsList() []string

CoreAgenticToolsList returns the core non-MCP tools used by agent runtimes.

func DefaultAgenticTools

func DefaultAgenticTools() []string

DefaultAgenticTools returns the core Claude tools plus all registered MCP tools.

func DetectProjectBuildHints

func DetectProjectBuildHints(projectDir string) (platform string, platforms []string, watchProjectShape string)

DetectProjectBuildHints reads project_config.json and extracts build-relevant hints. Returns ("ios", nil, "") when missing or unreadable (backward compat).

func EnsureProjectConfigsExternal

func EnsureProjectConfigsExternal(projectDir string)

EnsureProjectConfigsExternal writes .mcp.json, settings.json, and settings.local.json if missing.

func ExtractJSON

func ExtractJSON(s string) string

ExtractJSON finds and extracts the first JSON object from a string.

func FilterRuleKeysForPlatform

func FilterRuleKeysForPlatform(platform string, keys []string) ([]string, []string)

FilterRuleKeysForPlatform filters rule_keys for a given platform. Returns the filtered keys and any validation warnings for unsupported keys.

func HasPlatform

func HasPlatform(platforms []string, platform string) bool

HasPlatform returns true if the given platform is in the list.

func IsMacOS

func IsMacOS(platform string) bool

IsMacOS returns true if the platform is macOS.

func IsTvOS

func IsTvOS(platform string) bool

IsTvOS returns true if the platform is tvOS.

func IsVisionOS

func IsVisionOS(platform string) bool

IsVisionOS returns true if the platform is visionOS.

func IsWatchOS

func IsWatchOS(platform string) bool

IsWatchOS returns true if the platform is watchOS.

func ListAvailableSkillKeys

func ListAvailableSkillKeys() []string

ListAvailableSkillKeys returns all available skill keys from the embedded FS.

func LoadSkillContent

func LoadSkillContent(key string) string

LoadSkillContent loads skill/rule content by key for any runtime.

func NewProgressCallbackExported

func NewProgressCallbackExported(progress *terminal.ProgressDisplay) func(agentruntime.StreamEvent)

NewProgressCallbackExported wraps newProgressCallback for use outside orchestration.

func PlatformBuildDestination

func PlatformBuildDestination(platform string) string

PlatformBuildDestination returns the device build destination for a single platform. Device builds are the default — they catch entitlement, architecture, and API issues.

func PlatformDeploymentTargetKey

func PlatformDeploymentTargetKey(platform string) string

PlatformDeploymentTargetKey returns the XcodeGen deployment target key.

func PlatformDisplayName

func PlatformDisplayName(platform string) string

PlatformDisplayName returns a human-friendly name for a platform constant.

func PlatformSimulatorDestination

func PlatformSimulatorDestination(platform string) string

PlatformSimulatorDestination returns the simulator build destination for a single platform. Used for Run() launching and secondary validation.

func PlatformSourceDirSuffix

func PlatformSourceDirSuffix(platform string) string

PlatformSourceDirSuffix returns the source directory suffix for a platform in a multi-platform project. iOS uses "" (the app name dir), watchOS uses "Watch", tvOS uses "TV".

func PlatformXcodegenValue

func PlatformXcodegenValue(platform string) string

PlatformXcodegenValue returns the XcodeGen platform value.

func ReadProjectAppName

func ReadProjectAppName(projectDir string) string

ReadProjectAppName returns the Xcode app name for an existing project. It reads app_name from project_config.json (the canonical source of truth written at build time). Falls back to filepath.Base(projectDir) for projects predating the suffixed-dir feature.

func ReadProjectBundleID

func ReadProjectBundleID(projectDir string) string

ReadProjectBundleID reads bundle_id from project_config.json. Returns empty string if not found.

func RunXcodeGenExternal

func RunXcodeGenExternal(projectDir string) error

RunXcodeGenExternal runs xcodegen generate in the project directory.

func ScaffoldProjectExternal

func ScaffoldProjectExternal(projectDir, appName string, plan *PlannerResult) error

ScaffoldProjectExternal scaffolds the Xcode project: config, yml, assets, dirs, xcodegen.

func SetupIntegrationExternal

func SetupIntegrationExternal(ctx context.Context, providerID, appName, projectDir string) (map[string]any, error)

SetupIntegrationExternal runs the interactive setup flow for a single integration provider. Returns a result map with provider config details on success.

func ValidateExtensionsForPlatform

func ValidateExtensionsForPlatform(platform string, extensions []ExtensionPlan) error

ValidateExtensionsForPlatform validates that extension kinds are supported on the given platform.

func ValidatePlatform

func ValidatePlatform(platform string) error

ValidatePlatform checks that the platform string is a known value.

func ValidatePlatforms

func ValidatePlatforms(platforms []string) []string

ValidatePlatforms validates a list of platform strings. Invalid entries are dropped. Returns only valid platforms. If all are invalid, returns nil (caller should fall back to defaults).

func ValidateWatchShape

func ValidateWatchShape(shape string) error

ValidateWatchShape checks that the watch project shape is valid.

func WriteMCPConfigExternal

func WriteMCPConfigExternal(projectDir string) error

WriteMCPConfigExternal writes .mcp.json for the project using the standard MCP registry.

func WriteMCPConfigWithIntegrationsExternal

func WriteMCPConfigWithIntegrationsExternal(projectDir string, reg *mcpregistry.Registry, integrationConfigs []integrations.MCPServerConfig) error

WriteMCPConfigWithIntegrationsExternal writes .mcp.json including integration MCP servers.

func WriteSettingsSharedExternal

func WriteSettingsSharedExternal(projectDir string) error

WriteSettingsSharedExternal writes .claude/settings.json for the project using the standard MCP registry.

func WriteSettingsWithIntegrationsExternal

func WriteSettingsWithIntegrationsExternal(projectDir string, reg *mcpregistry.Registry, integrationTools []string) error

WriteSettingsWithIntegrationsExternal writes .claude/settings.json including integration tool permissions.

func WriteSkillsForRuntimeExternal

func WriteSkillsForRuntimeExternal(projectDir, platform string, ruleKeys []string, packages []PackagePlan, runtimeKind agentruntime.Kind) error

WriteSkillsForRuntimeExternal writes skill files in the native format for the given runtime.

Types

type ActionContext

type ActionContext struct {
	ProjectDir         string   // empty for new builds
	AppName            string   // empty for new builds (analyzer will name it)
	SessionID          string   // for conversation continuity
	Platform           string   // detected from existing project_config.json
	Platforms          []string // detected from existing project_config.json
	WatchProjectShape  string   // detected from existing project_config.json
	ActiveIntegrations []string // provider IDs with valid configs (e.g. ["supabase", "revenuecat"])
}

ActionContext provides context for the unified pipeline. For new builds, all fields are zero-valued. For edits to existing projects, fields carry existing project info.

func (ActionContext) IsEdit

func (ac ActionContext) IsEdit() bool

IsEdit returns true when acting on an existing project.

type AnalysisResult

type AnalysisResult struct {
	AppName      string        `json:"app_name"`
	Description  string        `json:"description"`
	Features     []Feature     `json:"features"`
	CoreFlow     string        `json:"core_flow"`
	Deferred     []string      `json:"deferred"`
	BackendNeeds *BackendNeeds `json:"backend_needs,omitempty"`
}

AnalysisResult is the parsed output from the analyzer phase.

type BackendNeeds

type BackendNeeds struct {
	Auth             bool     `json:"auth"`
	AuthMethods      []string `json:"auth_methods,omitempty"` // "email", "apple", "google", "anonymous"
	DB               bool     `json:"db"`
	Storage          bool     `json:"storage"`
	Realtime         bool     `json:"realtime,omitempty"`          // enable Supabase Realtime on tables
	Monetization     bool     `json:"monetization,omitempty"`      // in-app purchases / subscriptions needed
	MonetizationType string   `json:"monetization_type,omitempty"` // "subscription", "consumable", "hybrid"
}

BackendNeeds indicates which backend capabilities an app requires.

func (*BackendNeeds) NeedsBackend

func (b *BackendNeeds) NeedsBackend() bool

NeedsBackend returns true if any backend capability is required.

type BuildResult

type BuildResult struct {
	AppName           string
	Description       string
	ProjectDir        string
	BundleID          string
	DeviceFamily      string
	Platform          string
	Platforms         []string
	WatchProjectShape string
	Features          []Feature
	FileCount         int
	PlannedFiles      int
	CompletedFiles    int
	CompletionPasses  int
	SessionID         string
	TotalCostUSD      float64
	InputTokens       int
	OutputTokens      int
	CacheRead         int
	CacheCreated      int
}

BuildResult is the final output of a successful Build pipeline.

type CuratedPackage

type CuratedPackage struct {
	Key         string   // lookup key, e.g. "kingfisher"
	Name        string   // display name, e.g. "Kingfisher"
	Category    string   // category key matching PackageCategory.Key
	Description string   // what it enables beyond native frameworks
	RepoURL     string   // full GitHub URL
	RepoName    string   // last path component of URL (XcodeGen packages: key)
	Products    []string // SPM product names from Package.swift (import + product: in XcodeGen)
	MinVersion  string   // minimum version to use with from:
}

CuratedPackage describes a pre-validated SPM package in the registry.

func AllPackages

func AllPackages() []CuratedPackage

AllPackages returns a copy of the full curated package list.

func LookupPackage

func LookupPackage(key string) *CuratedPackage

LookupPackage returns the curated package for a given key, or nil if not found.

func LookupPackageByName

func LookupPackageByName(name string) *CuratedPackage

LookupPackageByName tries to find a curated package by its display name (case-insensitive). This is used when the planner outputs a name like "Kingfisher" instead of the key "kingfisher".

func PackagesByCategory

func PackagesByCategory(category string) []*CuratedPackage

PackagesByCategory returns all curated packages in a category.

type DesignSystem

type DesignSystem struct {
	Navigation   string  `json:"navigation"`
	Palette      Palette `json:"palette"`
	FontDesign   string  `json:"font_design"`
	CornerRadius int     `json:"corner_radius"`
	Density      string  `json:"density"`
	Surfaces     string  `json:"surfaces"`
	AppMood      string  `json:"app_mood"`
}

DesignSystem holds the visual design specification.

type ExtensionPlan

type ExtensionPlan struct {
	Kind         string            `json:"kind"`
	Name         string            `json:"name"`
	Purpose      string            `json:"purpose"`
	Platform     string            `json:"platform,omitempty"`
	InfoPlist    map[string]any    `json:"info_plist,omitempty"`
	Entitlements map[string]any    `json:"entitlements,omitempty"`
	Settings     map[string]string `json:"settings,omitempty"`
}

ExtensionPlan describes a secondary Xcode target (widget, live activity, etc.)

type Feature

type Feature struct {
	Name        string `json:"name"`
	Description string `json:"description"`
}

Feature is a single app feature from the analyzer.

type FileCompletionReport

type FileCompletionReport struct {
	TotalPlanned int
	ValidCount   int
	Missing      []PlannedFileStatus
	Invalid      []PlannedFileStatus
	Complete     bool
}

FileCompletionReport summarizes completion coverage for planned files.

func VerifyPlannedFilesExternal

func VerifyPlannedFilesExternal(projectDir, appName string, plan *PlannerResult) (*FileCompletionReport, error)

VerifyPlannedFilesExternal checks whether all planned files exist and are valid.

type FilePlan

type FilePlan struct {
	Path       string   `json:"path"`
	TypeName   string   `json:"type_name"`
	Purpose    string   `json:"purpose"`
	Platform   string   `json:"platform,omitempty"`
	Components string   `json:"components"`
	DataAccess string   `json:"data_access"`
	DependsOn  []string `json:"depends_on"`
}

FilePlan describes a single file in the build plan.

func (*FilePlan) UnmarshalJSON

func (f *FilePlan) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts small planner-output variations (e.g. components as []string) and normalizes them into the canonical FilePlan schema used by the pipeline.

type IntentDecision

type IntentDecision struct {
	Operation             string   `json:"operation"`
	PlatformHint          string   `json:"platform_hint"`
	PlatformHints         []string `json:"platform_hints"`
	DeviceFamilyHint      string   `json:"device_family_hint"`
	WatchProjectShapeHint string   `json:"watch_project_shape_hint"`
	HasASCIntent          bool     `json:"has_asc_intent"`
	Confidence            float64  `json:"confidence"`
	Reason                string   `json:"reason"`
	UsedLLM               bool     `json:"used_llm"`
}

IntentDecision is the parsed output from the pre-analysis intent router. Hints are advisory only; analyzer/planner may override based on explicit user intent.

type ModelPlan

type ModelPlan struct {
	Name       string         `json:"name"`
	Storage    string         `json:"storage"`
	Properties []PropertyPlan `json:"properties"`
}

ModelPlan describes a data model in the build plan.

func (*ModelPlan) UnmarshalJSON

func (m *ModelPlan) UnmarshalJSON(data []byte) error

UnmarshalJSON handles both object form {"name":"Foo",...} and bare string "Foo".

type MonetizationPlan

type MonetizationPlan struct {
	Model       string        `json:"model"` // "subscription", "consumable", "hybrid"
	Products    []ProductPlan `json:"products"`
	Entitlement string        `json:"entitlement"`  // e.g., "premium"
	FreeCredits int           `json:"free_credits"` // initial free amount (0 = none)
}

MonetizationPlan describes the in-app purchase / subscription setup.

type PackageCategory

type PackageCategory struct {
	Key         string // e.g. "images"
	Label       string // e.g. "Image Loading & Caching"
	Description string // when to use this category
}

PackageCategory groups packages under a human-readable label.

func AllCategories

func AllCategories() []PackageCategory

AllCategories returns the category definitions in display order.

type PackagePlan

type PackagePlan struct {
	Name   string `json:"name"`
	Reason string `json:"reason"`
}

PackagePlan describes an SPM package suggested by the planner.

type Palette

type Palette struct {
	Primary    string `json:"primary"`
	Secondary  string `json:"secondary"`
	Accent     string `json:"accent"`
	Background string `json:"background"`
	Surface    string `json:"surface"`
}

Palette holds the 5-color hex palette.

type Permission

type Permission struct {
	Key         string `json:"key"`
	Description string `json:"description"`
	Framework   string `json:"framework"`
}

Permission describes a required iOS permission.

type Pipeline

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

Pipeline orchestrates the multi-phase app generation process.

func NewPipeline

func NewPipeline(runtimeClient agentruntime.Runtime, runtimeKind agentruntime.Kind, cfg *config.Config, model string) *Pipeline

NewPipeline creates a new pipeline orchestrator.

func (*Pipeline) ASCFull

func (p *Pipeline) ASCFull(ctx context.Context, prompt, projectDir, sessionID string) (*asc.Result, error)

ASCFull runs a full App Store Connect operation with pre-flight checks, guided auth setup, agreement verification, app selection, and HITL confirmations for destructive actions.

func (*Pipeline) ComposeASCSystemPrompt

func (p *Pipeline) ComposeASCSystemPrompt(projectDir string, preflight *asc.PreflightResult) string

ComposeASCSystemPrompt builds the system prompt for ASC operations by composing from embedded skill files. Only the core role, safety rules, and pre-flight context are inline — all workflow knowledge lives in skills.

func (*Pipeline) SetManager

func (p *Pipeline) SetManager(m *integrations.Manager)

SetManager sets the integration manager for provider-based integrations.

func (*Pipeline) SetStreamHook

func (p *Pipeline) SetStreamHook(hook func(agentruntime.StreamEvent))

SetStreamHook sets an optional callback invoked for every streaming event. Used by the web UI to mirror CLI progress in the browser.

type PlannedFileStatus

type PlannedFileStatus struct {
	PlannedPath  string
	ResolvedPath string
	ExpectedType string
	Exists       bool
	Valid        bool
	Reason       string
}

PlannedFileStatus tracks validation state for a planned file.

type PlannerResult

type PlannerResult struct {
	Design            DesignSystem      `json:"design"`
	DeviceFamily      string            `json:"device_family"`
	Platform          string            `json:"platform"`
	Platforms         []string          `json:"platforms"`
	WatchProjectShape string            `json:"watch_project_shape"`
	Files             []FilePlan        `json:"files"`
	Models            []ModelPlan       `json:"models"`
	Permissions       []Permission      `json:"permissions"`
	Extensions        []ExtensionPlan   `json:"extensions"`
	Localizations     []string          `json:"localizations"`
	RuleKeys          []string          `json:"rule_keys"`
	Packages          []PackagePlan     `json:"packages"`
	Integrations      []string          `json:"integrations,omitempty"`
	MonetizationPlan  *MonetizationPlan `json:"monetization_plan,omitempty"`
	BuildOrder        []string          `json:"build_order"`
}

PlannerResult is the parsed output from the planner phase.

func (*PlannerResult) GetDeviceFamily

func (p *PlannerResult) GetDeviceFamily() string

GetDeviceFamily returns the device family, defaulting to "iphone" for iOS. Non-iOS platforms (macOS, tvOS, visionOS, watchOS) return "" when unset.

func (*PlannerResult) GetPlatform

func (p *PlannerResult) GetPlatform() string

GetPlatform returns the target platform, defaulting to "ios".

func (*PlannerResult) GetPlatforms

func (p *PlannerResult) GetPlatforms() []string

GetPlatforms returns the list of target platforms. Falls back to [Platform] if Platforms is empty.

func (*PlannerResult) GetWatchProjectShape

func (p *PlannerResult) GetWatchProjectShape() string

GetWatchProjectShape returns the watch project shape, defaulting to "watch_only" when watchOS.

func (*PlannerResult) HasRuleKey

func (p *PlannerResult) HasRuleKey(key string) bool

HasRuleKey returns true if the plan includes the given rule key.

func (*PlannerResult) IsMultiPlatform

func (p *PlannerResult) IsMultiPlatform() bool

IsMultiPlatform returns true when the plan targets more than one platform.

type ProductPlan

type ProductPlan struct {
	Identifier  string `json:"identifier"` // e.g., "premium_monthly", "credits_50"
	Type        string `json:"type"`       // "subscription", "consumable"
	DisplayName string `json:"display_name"`
	Price       string `json:"price"`              // e.g., "9.99"
	Credits     int    `json:"credits,omitempty"`  // for consumable credit packs
	Duration    string `json:"duration,omitempty"` // ISO 8601: "P1M", "P1Y", "P1W"
}

ProductPlan describes a single in-app purchase product.

type PromptDiagnostics

type PromptDiagnostics struct {
	CoreRulesLoaded     int // rules from data/core/
	AlwaysRulesLoaded   int // rules from data/always/
	PlatformRulesLoaded int // rules from data/always-{platform}/
	CoreRulesChars      int // total chars from all rules
	Platform            string
}

PromptDiagnostics reports what was injected into the agentic system prompt.

func LoadCoreRulesDiagnostics

func LoadCoreRulesDiagnostics(platform string) PromptDiagnostics

LoadCoreRulesDiagnostics returns diagnostics about what rules would be injected for the given platform, without building the full content string.

type PropertyPlan

type PropertyPlan struct {
	Name         string `json:"name"`
	Type         string `json:"type"`
	DefaultValue string `json:"default_value"`
}

PropertyPlan describes a single property on a model.

Jump to

Keyboard shortcuts

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