ai

package
v0.1.0-alpha.9 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Copyright (c) 2025 Nexlayer. All rights reserved.n// Use of this source code is governed by an MIT-stylen// license that can be found in the LICENSE file.nn

Index

Constants

This section is empty.

Variables

View Source
var (

	// Predefined AI providers
	WindsurfEditor = AIProvider{
		Name:         "Windsurf Editor",
		Description:  "Built-in AI code assistant",
		EnvVarKey:    "WINDSURF_EDITOR_ACTIVE",
		Capabilities: CapCodeGeneration | CapCodeCompletion | CapDeploymentAssistance | CapErrorDiagnosis,
	}

	GitHubCopilot = AIProvider{
		Name:         "GitHub Copilot",
		Description:  "GitHub's AI pair programmer",
		EnvVarKey:    "GITHUB_COPILOT_ACTIVE",
		Capabilities: CapCodeGeneration | CapCodeCompletion,
	}

	ZedEditor = AIProvider{
		Name:         "Zed Editor",
		Description:  "Zed's built-in AI assistant",
		EnvVarKey:    "ZED_AI_ACTIVE",
		Capabilities: CapCodeGeneration | CapCodeCompletion | CapDeploymentAssistance,
	}

	CursorAI = AIProvider{
		Name:         "Cursor AI",
		Description:  "Cursor's AI code assistant",
		EnvVarKey:    "CURSOR_AI_ACTIVE",
		Capabilities: CapCodeGeneration | CapCodeCompletion,
	}

	VSCodeAI = AIProvider{
		Name:         "VS Code AI",
		Description:  "VS Code's AI assistant",
		EnvVarKey:    "VSCODE_AI_ACTIVE",
		Capabilities: CapCodeGeneration | CapCodeCompletion,
	}

	// AllProviders is a list of all available AI providers
	AllProviders = []AIProvider{
		WindsurfEditor,
		GitHubCopilot,
		ZedEditor,
		CursorAI,
		VSCodeAI,
	}
)

Functions

func DetectStack

func DetectStack(dir string) (*detection.ProjectInfo, error)

DetectStack analyzes a directory to determine its stack type, components, and AI environment.

func GenerateTemplate

func GenerateTemplate(ctx context.Context, req TemplateRequest) (string, error)

GenerateTemplate uses AI assistance to generate a valid Nexlayer deployment template.

func NewCommand

func NewCommand() *cobra.Command

NewCommand creates the "ai" command with its subcommands.

Types

type AIProvider

type AIProvider struct {
	Name         string
	Description  string
	EnvVarKey    string
	Capabilities Capability
}

AIProvider represents an AI code assistant provider

func GetPreferredProvider

func GetPreferredProvider(ctx context.Context, requiredCaps Capability) *AIProvider

GetPreferredProvider returns the first configured AI provider with the required capabilities

func (*AIProvider) GenerateText

func (p *AIProvider) GenerateText(ctx context.Context, prompt string) (string, error)

GenerateText generates text using the AI provider

type Application

type Application struct {
	Name          string         `yaml:"name"`
	URL           string         `yaml:"url,omitempty"`
	RegistryLogin *RegistryLogin `yaml:"registryLogin,omitempty"`
	Pods          []Pod          `yaml:"pods"`
}

Application represents the top-level application configuration

type Capability

type Capability int

Capability represents an AI provider's capabilities

const (
	CapCodeGeneration Capability = 1 << iota
	CapCodeCompletion
	CapDeploymentAssistance
	CapErrorDiagnosis
)

type CommandProvider

type CommandProvider struct{}

CommandProvider implements the registry.CommandProvider interface

func NewProvider

func NewProvider() *CommandProvider

NewProvider creates a new AI command provider

func (*CommandProvider) Commands

Commands returns the AI-related commands

func (*CommandProvider) Dependencies

func (p *CommandProvider) Dependencies() []string

Dependencies returns a list of other provider names that this provider depends on

func (*CommandProvider) Description

func (p *CommandProvider) Description() string

Description returns a description of what commands this provider offers

func (*CommandProvider) Name

func (p *CommandProvider) Name() string

Name returns the unique name of this command provider

type Pod

type Pod struct {
	Name         string            `yaml:"name"`
	Type         string            `yaml:"type"`
	Path         string            `yaml:"path,omitempty"`
	Image        string            `yaml:"image"`
	Volumes      []Volume          `yaml:"volumes,omitempty"`
	Secrets      []Secret          `yaml:"secrets,omitempty"`
	EnvVars      map[string]string `yaml:"env_vars,omitempty"`
	ServicePorts []ServicePort     `yaml:"servicePorts"`
}

Pod represents a single pod configuration

type RegistryLogin

type RegistryLogin struct {
	Registry            string `yaml:"registry"`
	Username            string `yaml:"username"`
	PersonalAccessToken string `yaml:"personalAccessToken"`
}

RegistryLogin represents private registry authentication

type Secret

type Secret struct {
	Name      string `yaml:"name"`
	Data      string `yaml:"data"`
	MountPath string `yaml:"mountPath"`
	FileName  string `yaml:"fileName"`
}

Secret represents secret configuration

type ServicePort

type ServicePort struct {
	ContainerPort int    `yaml:"containerPort"`
	ServicePort   int    `yaml:"servicePort"`
	Name          string `yaml:"name"`
}

ServicePort represents port configuration

type Template

type Template struct {
	Application Application `yaml:"application"`
}

Template represents a Nexlayer YAML template

type TemplateRequest

type TemplateRequest struct {
	ProjectName string
	ProjectDir  string
}

TemplateRequest represents a request to generate a Nexlayer deployment template.

type Volume

type Volume struct {
	Name      string `yaml:"name"`
	Size      string `yaml:"size"`
	MountPath string `yaml:"mountPath"`
}

Volume represents persistent storage configuration

Jump to

Keyboard shortcuts

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