core

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigFileName is the default config file name
	ConfigFileName = "aicof.yaml"
	// AltConfigFileName is the hidden config file name
	AltConfigFileName = ".aicof.yaml"
)
View Source
const DefaultOwner = "ar4mirez"

DefaultOwner is the GitHub owner

View Source
const DefaultRegistry = "https://github.com/ar4mirez/aicof"

DefaultRegistry is the default GitHub repository for AICoF

View Source
const DefaultRepo = "aicof"

DefaultRepo is the GitHub repository name

View Source
const TemplatePrefix = "template/"

TemplatePrefix is the path prefix in the repository where template files are stored This allows the CLI to find source files in the downloaded archive

Variables

View Source
var CoreFiles = []string{
	"CLAUDE.md",
	"AI_INSTRUCTIONS.md",
	".agent/README.md",
	".agent/project.md.template",
	".agent/state.md.template",
	".agent/language-guides/README.md",
	".agent/framework-guides/README.md",
	".agent/workflows/README.md",
	".agent/memory/.gitkeep",
	".agent/tasks/.gitkeep",
}

CoreFiles contains essential files always installed

View Source
var Frameworks = []Component{

	{Name: "react", Path: ".agent/framework-guides/react.md", Description: "React"},
	{Name: "nextjs", Path: ".agent/framework-guides/nextjs.md", Description: "Next.js"},
	{Name: "express", Path: ".agent/framework-guides/express.md", Description: "Express.js"},

	{Name: "django", Path: ".agent/framework-guides/django.md", Description: "Django"},
	{Name: "fastapi", Path: ".agent/framework-guides/fastapi.md", Description: "FastAPI"},
	{Name: "flask", Path: ".agent/framework-guides/flask.md", Description: "Flask"},

	{Name: "gin", Path: ".agent/framework-guides/gin.md", Description: "Gin"},
	{Name: "echo", Path: ".agent/framework-guides/echo.md", Description: "Echo"},
	{Name: "fiber", Path: ".agent/framework-guides/fiber.md", Description: "Fiber"},

	{Name: "axum", Path: ".agent/framework-guides/axum.md", Description: "Axum"},
	{Name: "actix-web", Path: ".agent/framework-guides/actix-web.md", Description: "Actix-web"},
	{Name: "rocket", Path: ".agent/framework-guides/rocket.md", Description: "Rocket"},

	{Name: "spring-boot-kotlin", Path: ".agent/framework-guides/spring-boot-kotlin.md", Description: "Spring Boot (Kotlin)"},
	{Name: "ktor", Path: ".agent/framework-guides/ktor.md", Description: "Ktor"},
	{Name: "android-compose", Path: ".agent/framework-guides/android-compose.md", Description: "Android Compose"},

	{Name: "spring-boot-java", Path: ".agent/framework-guides/spring-boot-java.md", Description: "Spring Boot (Java)"},
	{Name: "quarkus", Path: ".agent/framework-guides/quarkus.md", Description: "Quarkus"},
	{Name: "micronaut", Path: ".agent/framework-guides/micronaut.md", Description: "Micronaut"},

	{Name: "aspnet-core", Path: ".agent/framework-guides/aspnet-core.md", Description: "ASP.NET Core"},
	{Name: "blazor", Path: ".agent/framework-guides/blazor.md", Description: "Blazor"},
	{Name: "unity", Path: ".agent/framework-guides/unity.md", Description: "Unity"},

	{Name: "laravel", Path: ".agent/framework-guides/laravel.md", Description: "Laravel"},
	{Name: "symfony", Path: ".agent/framework-guides/symfony.md", Description: "Symfony"},
	{Name: "wordpress", Path: ".agent/framework-guides/wordpress.md", Description: "WordPress"},

	{Name: "swiftui", Path: ".agent/framework-guides/swiftui.md", Description: "SwiftUI"},
	{Name: "uikit", Path: ".agent/framework-guides/uikit.md", Description: "UIKit"},
	{Name: "vapor", Path: ".agent/framework-guides/vapor.md", Description: "Vapor"},

	{Name: "rails", Path: ".agent/framework-guides/rails.md", Description: "Rails"},
	{Name: "sinatra", Path: ".agent/framework-guides/sinatra.md", Description: "Sinatra"},
	{Name: "hanami", Path: ".agent/framework-guides/hanami.md", Description: "Hanami"},

	{Name: "flutter", Path: ".agent/framework-guides/flutter.md", Description: "Flutter"},
	{Name: "shelf", Path: ".agent/framework-guides/shelf.md", Description: "Shelf"},
	{Name: "dart-frog", Path: ".agent/framework-guides/dart-frog.md", Description: "Dart Frog"},
}

Frameworks contains all available framework guides

View Source
var Languages = []Component{
	{Name: "typescript", Path: ".agent/language-guides/typescript.md", Description: "TypeScript/JavaScript"},
	{Name: "python", Path: ".agent/language-guides/python.md", Description: "Python"},
	{Name: "go", Path: ".agent/language-guides/go.md", Description: "Go"},
	{Name: "rust", Path: ".agent/language-guides/rust.md", Description: "Rust"},
	{Name: "kotlin", Path: ".agent/language-guides/kotlin.md", Description: "Kotlin"},
	{Name: "java", Path: ".agent/language-guides/java.md", Description: "Java"},
	{Name: "csharp", Path: ".agent/language-guides/csharp.md", Description: "C#/.NET"},
	{Name: "php", Path: ".agent/language-guides/php.md", Description: "PHP"},
	{Name: "swift", Path: ".agent/language-guides/swift.md", Description: "Swift"},
	{Name: "cpp", Path: ".agent/language-guides/cpp.md", Description: "C/C++"},
	{Name: "ruby", Path: ".agent/language-guides/ruby.md", Description: "Ruby"},
	{Name: "sql", Path: ".agent/language-guides/sql.md", Description: "SQL"},
	{Name: "shell", Path: ".agent/language-guides/shell.md", Description: "Shell/Bash"},
	{Name: "r", Path: ".agent/language-guides/r.md", Description: "R"},
	{Name: "dart", Path: ".agent/language-guides/dart.md", Description: "Dart"},
	{Name: "html-css", Path: ".agent/language-guides/html-css.md", Description: "HTML/CSS"},
	{Name: "lua", Path: ".agent/language-guides/lua.md", Description: "Lua"},
	{Name: "assembly", Path: ".agent/language-guides/assembly.md", Description: "Assembly"},
	{Name: "cuda", Path: ".agent/language-guides/cuda.md", Description: "CUDA"},
	{Name: "solidity", Path: ".agent/language-guides/solidity.md", Description: "Solidity"},
	{Name: "zig", Path: ".agent/language-guides/zig.md", Description: "Zig"},
}

Languages contains all available language guides

View Source
var Templates = []Template{
	{
		Name:        "full",
		Description: "All guides and workflows (~160 files)",
		Languages:   getAllNames(Languages),
		Frameworks:  getAllNames(Frameworks),
		Workflows:   []string{"all"},
	},
	{
		Name:        "starter",
		Description: "Core files + common languages (TypeScript, Python, Go)",
		Languages:   []string{"typescript", "python", "go"},
		Frameworks:  []string{},
		Workflows:   []string{"all"},
	},
	{
		Name:        "minimal",
		Description: "Just CLAUDE.md and workflows",
		Languages:   []string{},
		Frameworks:  []string{},
		Workflows:   []string{"all"},
	},
}

Templates contains predefined installation templates

View Source
var ValidConfigKeys = []string{
	"version",
	"registry",
	"installed.languages",
	"installed.frameworks",
	"installed.workflows",
}

ValidConfigKeys lists all valid configuration keys

View Source
var Workflows = []Component{
	{Name: "initialize-project", Path: ".agent/workflows/initialize-project.md", Description: "Project setup"},
	{Name: "create-rfd", Path: ".agent/workflows/create-rfd.md", Description: "Technical decision documents"},
	{Name: "create-prd", Path: ".agent/workflows/create-prd.md", Description: "Requirements documents"},
	{Name: "generate-tasks", Path: ".agent/workflows/generate-tasks.md", Description: "Task breakdown"},
	{Name: "code-review", Path: ".agent/workflows/code-review.md", Description: "Pre-commit quality review"},
	{Name: "security-audit", Path: ".agent/workflows/security-audit.md", Description: "Security assessment"},
	{Name: "testing-strategy", Path: ".agent/workflows/testing-strategy.md", Description: "Test planning"},
	{Name: "cleanup-project", Path: ".agent/workflows/cleanup-project.md", Description: "Prune unused guides"},
	{Name: "refactoring", Path: ".agent/workflows/refactoring.md", Description: "Technical debt remediation"},
	{Name: "dependency-update", Path: ".agent/workflows/dependency-update.md", Description: "Safe dependency updates"},
	{Name: "update-framework", Path: ".agent/workflows/update-framework.md", Description: "AICoF version updates"},
	{Name: "troubleshooting", Path: ".agent/workflows/troubleshooting.md", Description: "Debugging workflow"},
	{Name: "generate-agents-md", Path: ".agent/workflows/generate-agents-md.md", Description: "Cross-tool compatibility"},
	{Name: "document-work", Path: ".agent/workflows/document-work.md", Description: "Capture patterns"},
}

Workflows contains all available workflows

Functions

func ConfigExists

func ConfigExists(dir string) bool

ConfigExists checks if a config file exists in the directory

func CopyFromCache

func CopyFromCache(cachePath, destPath, filePath string) error

CopyFromCache copies a single file from the cache source directly The filePath is the destination path; source is found in template/ subdirectory

func EnsureCacheDir

func EnsureCacheDir() (string, error)

EnsureCacheDir creates the cache directory if it doesn't exist

func GetAllFrameworkNames

func GetAllFrameworkNames() []string

GetAllFrameworkNames returns all framework names

func GetAllLanguageNames

func GetAllLanguageNames() []string

GetAllLanguageNames returns all language names

func GetAllWorkflowNames

func GetAllWorkflowNames() []string

GetAllWorkflowNames returns all workflow names

func GetCachePath

func GetCachePath() (string, error)

GetCachePath returns the path to the cache directory

func GetComponentPaths

func GetComponentPaths(languages, frameworks, workflows []string) []string

GetComponentPaths returns all paths for a given set of components

func GetGlobalConfigPath

func GetGlobalConfigPath() (string, error)

GetGlobalConfigPath returns the path to the global config directory

func GetSourcePath

func GetSourcePath(destPath string) string

GetSourcePath returns the source path in the repository for a given destination path This prepends the TemplatePrefix to locate files in the downloaded archive

func GetSourcePaths

func GetSourcePaths(destPaths []string) []string

GetSourcePaths returns source paths for a slice of destination paths

Types

type Component

type Component struct {
	Name        string
	Path        string
	Description string
}

Component represents an installable component

func FindFramework

func FindFramework(name string) *Component

FindFramework finds a framework by name

func FindLanguage

func FindLanguage(name string) *Component

FindLanguage finds a language by name

func FindWorkflow

func FindWorkflow(name string) *Component

FindWorkflow finds a workflow by name

type ComponentType

type ComponentType string

ComponentType represents the type of component

const (
	ComponentTypeLanguage  ComponentType = "language"
	ComponentTypeFramework ComponentType = "framework"
	ComponentTypeWorkflow  ComponentType = "workflow"
)

type Config

type Config struct {
	Version   string         `yaml:"version"`
	Installed InstalledItems `yaml:"installed"`
	Registry  string         `yaml:"registry,omitempty"`
}

Config represents the project's AICoF configuration

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads config from the current directory

func LoadConfigFrom

func LoadConfigFrom(dir string) (*Config, error)

LoadConfigFrom loads config from a specific directory

func NewConfig

func NewConfig(version string) *Config

NewConfig creates a new config with defaults

func (*Config) AddFramework

func (c *Config) AddFramework(name string)

AddFramework adds a framework to the installed list

func (*Config) AddLanguage

func (c *Config) AddLanguage(name string)

AddLanguage adds a language to the installed list

func (*Config) AddWorkflow

func (c *Config) AddWorkflow(name string)

AddWorkflow adds a workflow to the installed list

func (*Config) GetAllValues added in v1.1.0

func (c *Config) GetAllValues() map[string]interface{}

GetAllValues returns all config values as a map

func (*Config) GetValue added in v1.1.0

func (c *Config) GetValue(key string) (interface{}, error)

GetValue retrieves a configuration value by key

func (*Config) HasFramework

func (c *Config) HasFramework(name string) bool

HasFramework checks if a framework is installed

func (*Config) HasLanguage

func (c *Config) HasLanguage(name string) bool

HasLanguage checks if a language is installed

func (*Config) HasWorkflow

func (c *Config) HasWorkflow(name string) bool

HasWorkflow checks if a workflow is installed

func (*Config) RemoveFramework

func (c *Config) RemoveFramework(name string)

RemoveFramework removes a framework from the installed list

func (*Config) RemoveLanguage

func (c *Config) RemoveLanguage(name string)

RemoveLanguage removes a language from the installed list

func (*Config) RemoveWorkflow

func (c *Config) RemoveWorkflow(name string)

RemoveWorkflow removes a workflow from the installed list

func (*Config) Save

func (c *Config) Save(dir string) error

Save writes the config to the specified directory

func (*Config) SetValue added in v1.1.0

func (c *Config) SetValue(key, value string) error

SetValue sets a configuration value by key

type Downloader

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

Downloader handles downloading and extracting framework files

func NewDownloader

func NewDownloader() (*Downloader, error)

NewDownloader creates a new downloader

func (*Downloader) CheckForUpdates

func (d *Downloader) CheckForUpdates(currentVersion string) (*github.VersionInfo, error)

CheckForUpdates checks if a newer version is available

func (*Downloader) ClearCache

func (d *Downloader) ClearCache() error

ClearCache removes all cached downloads

func (*Downloader) DownloadFile

func (d *Downloader) DownloadFile(version, path string) ([]byte, error)

DownloadFile downloads a single file from a version

func (*Downloader) DownloadVersion

func (d *Downloader) DownloadVersion(version string) (string, error)

DownloadVersion downloads a specific version to the cache If version is "dev", downloads from main branch

func (*Downloader) GetCacheSize

func (d *Downloader) GetCacheSize() (int64, error)

GetCacheSize returns the total size of the cache in bytes

func (*Downloader) GetLatestVersion

func (d *Downloader) GetLatestVersion() (string, error)

GetLatestVersion fetches the latest version number Returns "dev" if no releases exist

type ExtractResult

type ExtractResult struct {
	FilesCreated []string
	DirsCreated  []string
	FilesSkipped []string
	Errors       []error
}

ExtractResult contains the result of an extraction

type Extractor

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

Extractor handles extracting framework files to a destination

func NewExtractor

func NewExtractor(sourcePath, destPath string) *Extractor

NewExtractor creates a new extractor

func (*Extractor) BackupFile

func (e *Extractor) BackupFile(path, backupDir string) error

BackupFile creates a backup of a file

func (*Extractor) Extract

func (e *Extractor) Extract(paths []string, force bool) (*ExtractResult, error)

Extract copies specific files from source to destination The paths parameter contains destination paths (e.g., ".agent/language-guides/go.md") Source paths are calculated by prepending TemplatePrefix (e.g., "template/.agent/language-guides/go.md")

func (*Extractor) ExtractAll

func (e *Extractor) ExtractAll(force bool) (*ExtractResult, error)

ExtractAll extracts all framework files from the template/ directory

func (*Extractor) FileExists

func (e *Extractor) FileExists(path string) bool

FileExists checks if a file exists in the destination

func (*Extractor) GetDestPath

func (e *Extractor) GetDestPath() string

GetDestPath returns the destination path

func (*Extractor) GetSourcePath

func (e *Extractor) GetSourcePath() string

GetSourcePath returns the source path

func (*Extractor) ReadFile

func (e *Extractor) ReadFile(path string) ([]byte, error)

ReadFile reads a file from the destination

func (*Extractor) RemoveFile

func (e *Extractor) RemoveFile(path string) error

RemoveFile removes a file from the destination

func (*Extractor) RestoreBackup

func (e *Extractor) RestoreBackup(backupDir string) error

RestoreBackup restores files from a backup directory

func (*Extractor) ValidateExtraction

func (e *Extractor) ValidateExtraction(paths []string) []string

ValidateExtraction checks if extracted files are valid

func (*Extractor) WriteFile

func (e *Extractor) WriteFile(path string, content []byte) error

WriteFile writes content to a file in the destination

type GlobalConfig

type GlobalConfig struct {
	DefaultTemplate   string   `yaml:"default_template,omitempty"`
	DefaultLanguages  []string `yaml:"default_languages,omitempty"`
	DefaultFrameworks []string `yaml:"default_frameworks,omitempty"`
	CachePath         string   `yaml:"cache_path,omitempty"`
}

GlobalConfig represents global CLI settings stored in ~/.config/aicof/

type InstalledItems

type InstalledItems struct {
	Languages  []string `yaml:"languages,omitempty"`
	Frameworks []string `yaml:"frameworks,omitempty"`
	Workflows  []string `yaml:"workflows,omitempty"`
}

InstalledItems tracks what components are installed

type Template

type Template struct {
	Name        string
	Description string
	Languages   []string
	Frameworks  []string
	Workflows   []string
}

Template represents a predefined set of components

func FindTemplate

func FindTemplate(name string) *Template

FindTemplate finds a template by name

Jump to

Keyboard shortcuts

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