project

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package project provides project initialization, detection, and validation for the AE-ADK Go Edition. It implements the core domain logic for the "ae init" CLI command, including language/framework detection, methodology recommendation, directory scaffolding, and configuration generation.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrProjectExists indicates the project root already contains a .ae/ directory.
	ErrProjectExists = errors.New("project already initialized")

	// ErrNoLanguageFound indicates no programming language was detected in the project.
	ErrNoLanguageFound = errors.New("no programming language detected")

	// ErrInvalidRoot indicates the given project root path is invalid or inaccessible.
	ErrInvalidRoot = errors.New("invalid project root path")

	// ErrInitFailed indicates a project initialization step failed.
	ErrInitFailed = errors.New("initialization failed")

	// ErrInvalidDevelopmentMode indicates an unrecognized development mode value.
	ErrInvalidDevelopmentMode = errors.New("invalid development mode: must be ddd or tdd")

	// ErrMethodologyDetection indicates methodology detection failed.
	ErrMethodologyDetection = errors.New("methodology detection failed")
)

Sentinel errors for the project package.

Functions

func BackupExistingProject

func BackupExistingProject(root string) (string, error)

BackupExistingProject moves .ae/ to .ae-backups/{timestamp}/. Returns the backup path or an error.

func FindProjectRoot

func FindProjectRoot() (string, error)

@MX:ANCHOR: [AUTO] Core function for project root discovery. All .ae operations are anchored to the project root. @MX:REASON: [AUTO] fan_in=10+, used for root path discovery in all project operations FindProjectRoot locates the project root directory by searching for .ae directory. It starts from the current working directory and traverses upward until it finds .ae. Returns the absolute path to the project root, or an error if not in a AE project.

This function ensures that all .ae operations (checkpoints, memory, etc.) are anchored to the project root, preventing duplicate .ae directories in subfolders. ~/.ae/ is treated as global state (credentials, cache), not a project root.

func FindProjectRootOrCurrent

func FindProjectRootOrCurrent() (string, error)

FindProjectRootOrCurrent is like FindProjectRoot but returns the current directory instead of an error when not in a AE project. This is useful for operations that can work in non-project contexts.

func MustFindProjectRoot

func MustFindProjectRoot() string

MustFindProjectRoot is like FindProjectRoot but panics on error. Use this in contexts where the project root is guaranteed to exist.

Types

type AlternativeMethodology

type AlternativeMethodology struct {
	Mode    string // "ddd" or "tdd".
	Reason  string // Why this is an alternative.
	Warning string // Warning message if chosen despite recommendation.
}

AlternativeMethodology represents a non-recommended but available option.

type ConsoleReporter

type ConsoleReporter struct{}

ConsoleReporter is a ProgressReporter that outputs to console.

func NewConsoleReporter

func NewConsoleReporter() *ConsoleReporter

NewConsoleReporter creates a new ConsoleReporter.

func (*ConsoleReporter) StepComplete

func (r *ConsoleReporter) StepComplete(message string)

func (*ConsoleReporter) StepError

func (r *ConsoleReporter) StepError(err error)

func (*ConsoleReporter) StepStart

func (r *ConsoleReporter) StepStart(name, message string)

func (*ConsoleReporter) StepUpdate

func (r *ConsoleReporter) StepUpdate(message string)

type Detector

type Detector interface {
	// DetectLanguages scans the project root and returns detected languages
	// sorted by confidence descending.
	DetectLanguages(root string) ([]Language, error)

	// DetectFrameworks scans for known framework configuration files.
	DetectFrameworks(root string) ([]Framework, error)

	// DetectProjectType classifies the project based on structure and files.
	DetectProjectType(root string) (models.ProjectType, error)
}

Detector identifies project characteristics from the filesystem.

func NewDetector

func NewDetector(registry *foundation.LanguageRegistry, logger *slog.Logger) Detector

NewDetector creates a Detector backed by the given language registry.

type Framework

type Framework struct {
	Name       string // Human-readable framework name (e.g., "React", "Gin").
	Version    string // Detected version string, may be empty.
	ConfigFile string // Config file where the framework was detected.
}

Framework represents a detected development framework.

type InitOptions

type InitOptions struct {
	ProjectRoot       string   // Absolute or relative path to the project root.
	ProjectName       string   // Name of the project.
	Language          string   // Primary programming language.
	Framework         string   // Framework name, or "none".
	Features          []string // Selected features (e.g., "LSP", "Quality Gates").
	UserName          string   // User display name for configuration.
	ConvLang          string   // Conversation language code (e.g., "en", "ko").
	DevelopmentMode   string   // "ddd" or "tdd".
	GitMode           string   // Git workflow mode: "manual", "personal", or "team".
	GitProvider       string   // Git provider: "github", "gitlab".
	GitHubUsername    string   // GitHub username (for personal/team modes).
	GitLabInstanceURL string   // GitLab instance URL (for self-hosted instances).
	GitCommitLang     string   // Git commit message language code.
	CodeCommentLang   string   // Code comment language code.
	DocLang           string   // Documentation language code.
	Platform          string   // Target platform ("darwin", "linux", "windows"). Defaults to runtime.GOOS.
	NonInteractive    bool     // If true, skip wizard and use defaults/flags.
	Force             bool     // If true, allow reinitializing an existing project.
	SkipShellConfig   bool     // If true, skip shell environment configuration.
	ModelPolicy       string   // Token consumption tier: "high", "medium", "low".
	CommitScopes      string   // 커밋 scope 목록 (쉼표 구분)
}

InitOptions configures the project initialization.

type InitResult

type InitResult struct {
	CreatedDirs     []string // Directories that were created.
	CreatedFiles    []string // Files that were created.
	DevelopmentMode string   // Selected development methodology.
	BackupPath      string   // Non-empty if --force was used and backup was created.
	Warnings        []string // Non-fatal warnings during initialization.
	ShellConfigured bool     // Whether shell environment was configured.
	ShellConfigFile string   // Path to the shell config file that was modified.
}

InitResult summarizes the outcome of project initialization.

type Initializer

type Initializer interface {
	// Init creates a new AE project with the given options.
	Init(ctx context.Context, opts InitOptions) (*InitResult, error)
}

Initializer handles project scaffolding and setup.

func NewInitializer

func NewInitializer(deployer template.Deployer, manifestMgr manifest.Manager, logger *slog.Logger) Initializer

NewInitializer creates an Initializer with the given dependencies.

type Language

type Language struct {
	Name       string  // Human-readable language name (e.g., "Go", "Python").
	Confidence float64 // 0.0–1.0 ratio based on file count.
	FileCount  int     // Number of source files for this language.
}

Language represents a detected programming language with confidence scoring.

type MethodologyDetector

type MethodologyDetector interface {
	// DetectMethodology analyzes test coverage and recommends a development mode.
	DetectMethodology(root string, languages []Language) (*MethodologyRecommendation, error)
}

MethodologyDetector analyzes project test coverage to recommend a development methodology.

func NewMethodologyDetector

func NewMethodologyDetector(logger *slog.Logger) MethodologyDetector

NewMethodologyDetector creates a new MethodologyDetector.

type MethodologyRecommendation

type MethodologyRecommendation struct {
	Recommended      string                   // "ddd" or "tdd".
	Confidence       float64                  // 0.0–1.0.
	Rationale        string                   // Human-readable explanation.
	ProjectType      string                   // "greenfield" or "brownfield".
	TestFileCount    int                      // Number of test files found.
	CodeFileCount    int                      // Number of source code files found.
	CoverageEstimate float64                  // Estimated coverage percentage (0–100).
	Alternatives     []AlternativeMethodology // Non-recommended but available options.
}

MethodologyRecommendation provides a recommended development methodology with rationale.

type NoOpReporter

type NoOpReporter struct{}

NoOpReporter is a ProgressReporter that does nothing (used when no UI is needed).

func (*NoOpReporter) StepComplete

func (r *NoOpReporter) StepComplete(message string)

func (*NoOpReporter) StepError

func (r *NoOpReporter) StepError(err error)

func (*NoOpReporter) StepStart

func (r *NoOpReporter) StepStart(name, message string)

func (*NoOpReporter) StepUpdate

func (r *NoOpReporter) StepUpdate(message string)

type PhaseExecutor

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

PhaseExecutor orchestrates the full project initialization workflow by running detection, validation, and initialization phases in sequence.

func NewPhaseExecutor

func NewPhaseExecutor(
	detector Detector,
	methodologyDetector MethodologyDetector,
	validator ProjectValidator,
	initializer Initializer,
	logger *slog.Logger,
) *PhaseExecutor

NewPhaseExecutor creates a PhaseExecutor with all required dependencies.

func (*PhaseExecutor) Execute

func (pe *PhaseExecutor) Execute(ctx context.Context, opts InitOptions) (*InitResult, error)

Execute runs the full initialization workflow:

  1. PhaseDetect: Detect languages, frameworks, and project type.
  2. PhaseMethodology: Auto-detect recommended development methodology.
  3. PhaseValidate: Validate project structure (check existing .ae/).
  4. PhaseInit: Create directories, configs, templates.
  5. PhaseComplete: Return results.

func (*PhaseExecutor) SetReporter

func (pe *PhaseExecutor) SetReporter(reporter ProgressReporter)

SetReporter sets the progress reporter for UI updates.

type ProgressReporter

type ProgressReporter interface {
	// StepStart indicates the beginning of a step.
	StepStart(name, message string)

	// StepUpdate provides a status update for the current step.
	StepUpdate(message string)

	// StepComplete marks the current step as successfully completed.
	StepComplete(message string)

	// StepError marks the current step as failed with an error.
	StepError(err error)
}

ProgressReporter reports progress during project initialization. Implemented by UI components to show real-time status updates.

type ProjectValidator

type ProjectValidator interface {
	// Validate checks the overall project structure.
	Validate(root string) (*ValidationResult, error)

	// ValidateAE checks AE-specific configuration and file integrity.
	ValidateAE(root string) (*ValidationResult, error)
}

ProjectValidator checks project structure integrity.

func NewValidator

func NewValidator(logger *slog.Logger) ProjectValidator

NewValidator creates a new ProjectValidator.

type ValidationResult

type ValidationResult struct {
	Valid    bool     // True if no errors found.
	Errors   []string // Critical issues that prevent operation.
	Warnings []string // Non-critical issues.
}

ValidationResult holds project validation outcomes.

Jump to

Keyboard shortcuts

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