detection

package
v0.9.0-beta.1 Latest Latest
Warning

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

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

README

Project Detection and Caching

This package provides functionality for detecting project types and caching the results to improve performance.

Caching Mechanism

The caching system in this package implements a two-level caching strategy:

  1. In-memory Cache: Provides fast access to recently detected projects
  2. Disk-based Cache: Ensures persistence across program executions
Cache Structure

The cache stores ProjectInfo objects, which contain information about a project's:

  • Type (Node.js, Python, Go, etc.)
  • Dependencies
  • Configuration
  • Other metadata

Each cache entry includes a timestamp to track when it was created, allowing for automatic invalidation of stale entries.

Cache Operations

The cache supports the following operations:

  • Get: Retrieves project info from cache if available and not expired

    • First checks the in-memory cache
    • Falls back to the disk cache if not found in memory
    • Returns nil if the cache entry is not found or has expired
  • Set: Stores project info in both the in-memory and disk caches

    • Creates a cache entry with the current timestamp
    • Updates the in-memory cache immediately
    • Writes to disk for persistence
  • Invalidate: Removes a specific directory from both caches

    • Useful when the project structure changes and the cache needs to be refreshed
  • Clear: Removes all entries from both caches

    • Useful when the cache format changes or when a full refresh is needed
Cache TTL (Time-to-Live)

Cache entries expire after 24 hours by default. This ensures that the cached information doesn't become stale if the project structure changes.

Error Handling and Logging

The cache implementation includes comprehensive error handling and logging:

  • Logs cache hits and misses for debugging
  • Handles file system errors gracefully
  • Removes corrupted cache files automatically
  • Provides detailed error messages for troubleshooting
Performance Considerations
  • The in-memory cache provides O(1) access time for recently used projects
  • The disk cache minimizes repeated project detection, which can be expensive
  • Cache invalidation is performed automatically for expired entries
  • The cache is thread-safe, allowing concurrent access from multiple goroutines

Usage Example

// Create a new cache
cache := detection.NewCache()

// Try to get project info from cache
info := cache.Get("/path/to/project")
if info == nil {
    // Cache miss, detect project type
    info = detectProject("/path/to/project")
    
    // Store in cache for future use
    cache.Set("/path/to/project", info)
}

// Use the project info
fmt.Printf("Project type: %s\n", info.Type)

Implementation Details

The cache uses a mutex to ensure thread safety when accessing the in-memory cache map. File operations are performed outside the critical section to minimize lock contention.

The disk cache is stored in a .nexlayer directory within each project directory, making it specific to that project and allowing for per-project cache invalidation.

Documentation

Overview

Package detection provides project type detection and configuration generation.

Package detection provides project type detection functionality

Package detection provides project type detection functionality

Index

Constants

View Source
const (
	// CacheDir is the directory where cache files are stored
	CacheDir = ".nexlayer"

	// CacheFile is the name of the cache file
	CacheFile = "detection-cache.json"

	// DefaultCacheTTL is the default time-to-live for cached detection results
	DefaultCacheTTL = 5 * time.Minute

	// MaxCacheTTL is the maximum allowed TTL for any cache entry
	MaxCacheTTL = 24 * time.Hour
)

Variables

View Source
var AIProviders = []AIProvider{
	{
		Name:           "OpenAI",
		EnvKeyPattern:  "OPENAI_API_KEY",
		DependencyName: "openai",
	},
	{
		Name:           "Anthropic",
		EnvKeyPattern:  "ANTHROPIC_API_KEY",
		DependencyName: "anthropic",
	},
	{
		Name:           "Google Gemini",
		EnvKeyPattern:  "GEMINI_API_KEY",
		DependencyName: "@google/generative-ai",
	},
	{
		Name:           "Grok",
		EnvKeyPattern:  "GROK_API_KEY",
		DependencyName: "grok-ai",
	},
	{
		Name:           "DeepSeek",
		EnvKeyPattern:  "DEEPSEEK_API_KEY",
		DependencyName: "deepseek",
	},
	{
		Name:           "Together AI",
		EnvKeyPattern:  "TOGETHER_API_KEY",
		DependencyName: "together-ai",
	},
	{
		Name:           "Ollama",
		EnvKeyPattern:  "OLLAMA_API_KEY",
		DependencyName: "ollama",
	},
}

AI provider detection patterns

View Source
var ContentMatchers = map[types.ProjectType]map[string]ContentMatcher{
	types.TypeReact: {
		"package.json": func(content string) bool {
			return strings.Contains(content, `"react"`) ||
				strings.Contains(content, `"@vitejs/plugin-react"`) ||
				strings.Contains(content, `"react-scripts"`)
		},
	},
	types.TypeVue: {
		"package.json": func(content string) bool {
			return strings.Contains(content, `"vue"`) ||
				strings.Contains(content, `"@vue/cli-service"`) ||
				strings.Contains(content, `"nuxt"`)
		},
	},
	types.TypeExpress: {
		"package.json": func(content string) bool {
			return strings.Contains(content, `"express"`)
		},
	},
	types.TypeFlask: {
		"app.py": func(content string) bool {
			return strings.Contains(content, "from flask import")
		},
	},
	types.TypeFastAPI: {
		"main.py": func(content string) bool {
			return strings.Contains(content, "from fastapi import")
		},
	},
	types.TypeSpringBoot: {
		"pom.xml": func(content string) bool {
			return strings.Contains(content, "spring-boot")
		},
	},
}

Framework content matchers for package.json and other files

View Source
var DatabasePatterns = []DatabasePattern{
	{
		Type:        "postgres",
		Dependency:  "pg|postgres|postgresql|sequelize|typeorm|prisma",
		Image:       "postgres:15-alpine",
		Port:        5432,
		MountPath:   "/var/lib/postgresql/data",
		DefaultSize: "10Gi",
	},
	{
		Type:        "mongodb",
		Dependency:  "mongodb|mongoose",
		Image:       "mongo:6-jammy",
		Port:        27017,
		MountPath:   "/data/db",
		DefaultSize: "10Gi",
	},
	{
		Type:        "mysql",
		Dependency:  "mysql|mysql2",
		Image:       "mysql:8",
		Port:        3306,
		MountPath:   "/var/lib/mysql",
		DefaultSize: "10Gi",
	},
	{
		Type:        "redis",
		Dependency:  "redis",
		Image:       "redis:7-alpine",
		Port:        6379,
		MountPath:   "/data",
		DefaultSize: "5Gi",
	},
	{
		Type:        "cassandra",
		Dependency:  "cassandra",
		Image:       "cassandra:latest",
		Port:        9042,
		MountPath:   "/var/lib/cassandra",
		DefaultSize: "20Gi",
	},
}

Database detection patterns

View Source
var Patterns = []FrameworkPattern{

	{
		Type:        types.TypeNextJS,
		FilePattern: "next.config.js",
		Image:       "nexlayer/node-runtime:nextjs-latest",
		Port:        3000,
	},
	{
		Type:        types.TypeNextJS,
		FilePattern: "next.config.ts",
		Image:       "nexlayer/node-runtime:nextjs-latest",
		Port:        3000,
	},

	{
		Type:        types.TypeReact,
		FilePattern: "vite.config.js",
		Image:       "nexlayer/node-runtime:react-latest",
		Port:        3000,
	},
	{
		Type:        types.TypeReact,
		FilePattern: "package.json",
		Image:       "nexlayer/node-runtime:react-latest",
		Port:        3000,
	},

	{
		Type:        types.TypeAngular,
		FilePattern: "angular.json",
		Image:       "nexlayer/node-runtime:angular-latest",
		Port:        4200,
	},

	{
		Type:        types.TypeVue,
		FilePattern: "vue.config.js",
		Image:       "nexlayer/node-runtime:vue-latest",
		Port:        3000,
	},
	{
		Type:        types.TypeVue,
		FilePattern: "package.json",
		Image:       "nexlayer/node-runtime:vue-latest",
		Port:        3000,
	},

	{
		Type:        types.TypeExpress,
		FilePattern: "package.json",
		Image:       "nexlayer/node-runtime:express-latest",
		Port:        3000,
	},

	{
		Type:        types.TypeNestJS,
		FilePattern: "nest-cli.json",
		Image:       "nexlayer/node-runtime:nestjs-latest",
		Port:        3000,
	},

	{
		Type:        types.TypeDjango,
		FilePattern: "manage.py",
		Image:       "nexlayer/python-runtime:django-latest",
		Port:        8000,
	},

	{
		Type:        types.TypeFlask,
		FilePattern: "app.py",
		Image:       "nexlayer/python-runtime:flask-latest",
		Port:        5000,
	},

	{
		Type:        types.TypeFastAPI,
		FilePattern: "main.py",
		Image:       "nexlayer/python-runtime:fastapi-latest",
		Port:        8000,
	},

	{
		Type:        types.TypeGo,
		FilePattern: "go.mod",
		Image:       "nexlayer/go-runtime:latest",
		Port:        8080,
	},

	{
		Type:        types.TypeSpringBoot,
		FilePattern: "pom.xml",
		Image:       "nexlayer/java-runtime:springboot-latest",
		Port:        8080,
	},

	{
		Type:        types.TypeDotNet,
		FilePattern: "*.csproj",
		Image:       "nexlayer/dotnet-runtime:latest",
		Port:        5000,
	},
}

Framework detection patterns

View Source
var TechStackDefinitions = map[string]StackDefinition{
	"nextjs": {
		Name:        "Next.js",
		Description: "React framework for production-grade applications",
		Components: Components{
			Frontend: []string{"nextjs"},
		},
		RequiredComponents: []string{"nextjs"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternFile,
				Pattern:    "next.config.js|next.config.mjs",
				Path:       "",
				Confidence: 0.8,
			},
			{
				Type:       PatternDependency,
				Pattern:    "next",
				Path:       "package.json",
				Confidence: 0.8,
			},
		},
		RecommendedRuntime: "nexlayer/node-runtime:next-js-latest",
	},
	"nextjs-typescript": {
		Name:        "Next.js (TypeScript)",
		Description: "Next.js with TypeScript configuration",
		Components: Components{
			Frontend: []string{"nextjs", "typescript"},
		},
		RequiredComponents: []string{"nextjs", "typescript"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternFile,
				Pattern:    "next.config.ts",
				Path:       "",
				Confidence: 0.9,
			},
			{
				Type:       PatternFile,
				Pattern:    "tsconfig.json",
				Path:       "",
				Confidence: 0.7,
			},
		},
		RecommendedRuntime: "nexlayer/node-runtime:next-js-latest",
	},
	"react-vite": {
		Name:        "React with Vite",
		Description: "React application using Vite build tool",
		Components: Components{
			Frontend: []string{"react", "vite"},
		},
		RequiredComponents: []string{"react", "vite"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternFile,
				Pattern:    "vite.config.js|vite.config.ts",
				Path:       "",
				Confidence: 0.8,
			},
			{
				Type:       PatternDependency,
				Pattern:    "react",
				Path:       "package.json",
				Confidence: 0.7,
			},
		},
		RecommendedRuntime: "nexlayer/node-runtime:react-latest",
	},
	"angular": {
		Name:        "Angular",
		Description: "Angular application",
		Components: Components{
			Frontend: []string{"angular"},
		},
		RequiredComponents: []string{"angular"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternFile,
				Pattern:    "angular.json",
				Path:       "",
				Confidence: 0.9,
			},
		},
		RecommendedRuntime: "nexlayer/node-runtime:angular-latest",
	},
	"vue": {
		Name:        "Vue.js",
		Description: "Vue.js application",
		Components: Components{
			Frontend: []string{"vue"},
		},
		RequiredComponents: []string{"vue"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternFile,
				Pattern:    "vue.config.js|vite.config.js",
				Path:       "",
				Confidence: 0.8,
			},
		},
		RecommendedRuntime: "nexlayer/node-runtime:vue-latest",
	},
	"express": {
		Name:        "Express.js",
		Description: "Express.js backend application",
		Components: Components{
			Backend: []string{"express"},
		},
		RequiredComponents: []string{"express"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternFile,
				Pattern:    "server.js|app.js",
				Path:       "",
				Confidence: 0.7,
			},
			{
				Type:       PatternDependency,
				Pattern:    "express",
				Path:       "package.json",
				Confidence: 0.8,
			},
		},
		RecommendedRuntime: "nexlayer/node-runtime:express-latest",
	},
	"nestjs": {
		Name:        "NestJS",
		Description: "NestJS backend application",
		Components: Components{
			Backend: []string{"nestjs"},
		},
		RequiredComponents: []string{"nestjs"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternFile,
				Pattern:    "nest-cli.json",
				Path:       "",
				Confidence: 0.9,
			},
		},
		RecommendedRuntime: "nexlayer/node-runtime:nest-js-latest",
	},
	"gatsby": {
		Name:        "Gatsby",
		Description: "Gatsby static site generator",
		Components: Components{
			Frontend: []string{"gatsby"},
		},
		RequiredComponents: []string{"gatsby"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternFile,
				Pattern:    "gatsby-config.js|gatsby-config.ts",
				Path:       "",
				Confidence: 0.9,
			},
		},
		RecommendedRuntime: "nexlayer/node-runtime:gatsby-latest",
	},
	"nextjs-supabase": {
		Name:        "Next.js + Supabase",
		Description: "Next.js application with Supabase backend",
		Components: Components{
			Frontend: []string{"nextjs"},
			Backend:  []string{"supabase"},
		},
		RequiredComponents: []string{"nextjs", "supabase"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternFile,
				Pattern:    "next.config.js",
				Path:       "",
				Confidence: 0.8,
			},
			{
				Type:       PatternEnvironment,
				Pattern:    "SUPABASE_.+",
				Path:       ".env",
				Confidence: 0.7,
			},
		},
		RecommendedRuntime: "nexlayer/node-runtime:next-js-latest",
	},
	"nextjs-supabase-langchain": {
		Name:        "Next.js + Supabase + LangChain",
		Description: "AI-powered Next.js application with Supabase and LangChain",
		Components: Components{
			Frontend: []string{"nextjs"},
			Backend:  []string{"supabase"},
			AI:       []string{"langchain"},
		},
		RequiredComponents: []string{"nextjs", "supabase", "langchain"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternDependency,
				Pattern:    "langchain",
				Path:       "package.json",
				Confidence: 0.8,
			},
			{
				Type:       PatternEnvironment,
				Pattern:    "LANGCHAIN_.+",
				Path:       ".env",
				Confidence: 0.7,
			},
		},
		RecommendedRuntime: "nexlayer/node-runtime:next-js-latest",
	},
	"python-fastapi-langchain": {
		Name:        "FastAPI + LangChain",
		Description: "Python FastAPI application with LangChain integration",
		Components: Components{
			Backend: []string{"fastapi"},
			AI:      []string{"langchain"},
		},
		RequiredComponents: []string{"fastapi", "langchain"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternDependency,
				Pattern:    "fastapi",
				Path:       "requirements.txt",
				Confidence: 0.8,
			},
			{
				Type:       PatternDependency,
				Pattern:    "langchain",
				Path:       "requirements.txt",
				Confidence: 0.8,
			},
		},
		RecommendedRuntime: "nexlayer/python:langchain-latest",
	},
	"python-fastapi-together": {
		Name:        "FastAPI + Together AI",
		Description: "Python FastAPI application with Together AI integration",
		Components: Components{
			Backend: []string{"fastapi"},
			AI:      []string{"together"},
		},
		RequiredComponents: []string{"fastapi"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternEnvironment,
				Pattern:    "TOGETHER_.+",
				Path:       ".env",
				Confidence: 0.7,
			},
		},
		RecommendedRuntime: "nexlayer/python:together-latest",
	},
	"django-postgres": {
		Name:        "Django + PostgreSQL",
		Description: "Django application with PostgreSQL database",
		Components: Components{
			Backend:  []string{"django"},
			Database: []string{"postgres"},
		},
		RequiredComponents: []string{"django"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternFile,
				Pattern:    "manage.py",
				Path:       "",
				Confidence: 0.9,
			},
			{
				Type:       PatternDependency,
				Pattern:    "psycopg2",
				Path:       "requirements.txt",
				Confidence: 0.7,
			},
		},
		RecommendedRuntime: "nexlayer/python:django-latest",
	},
	"chain-ai-langchain": {
		Name:        "Chain AI + LangChain",
		Description: "Chain AI application with LangChain integration",
		Components: Components{
			AI: []string{"chain-ai", "langchain"},
		},
		RequiredComponents: []string{"chain-ai", "langchain"},
		MainPatterns: []DetectionPattern{
			{
				Type:       PatternDependency,
				Pattern:    "CHAINAI_.+",
				Path:       ".env",
				Confidence: 0.8,
			},
		},
		RecommendedRuntime: "nexlayer/chain-ai:latest",
	},
}

TechStackDefinitions defines patterns for detecting technology stacks

View Source
var VectorDBPatterns = []VectorDBPattern{
	{
		Type:       "pinecone",
		Dependency: "pinecone-client",
		Image:      "pinecone/server:latest",
		Port:       8080,
		MountPath:  "/data",
	},
	{
		Type:       "milvus",
		Dependency: "pymilvus",
		Image:      "milvusdb/milvus:latest",
		Port:       19530,
		MountPath:  "/var/lib/milvus",
	},
	{
		Type:       "weaviate",
		Dependency: "weaviate-client",
		Image:      "semitechnologies/weaviate:latest",
		Port:       8080,
		MountPath:  "/var/lib/weaviate",
	},
	{
		Type:       "qdrant",
		Dependency: "qdrant-client",
		Image:      "qdrant/qdrant:latest",
		Port:       6333,
		MountPath:  "/qdrant/storage",
	},
}

Vector database detection patterns

Functions

func DetectAIIDE

func DetectAIIDE() string

DetectAIIDE detects the AI-powered IDE in use

func DetectLLMModel

func DetectLLMModel() string

DetectLLMModel detects the LLM model being used

func EmitDeprecationWarning

func EmitDeprecationWarning(detectorName string)

EmitDeprecationWarning logs a deprecation warning for a detector This function should be called at the beginning of the Detect method in deprecated detectors

Types

type AIProvider

type AIProvider struct {
	Name           string
	EnvKeyPattern  string
	DependencyName string
}

AIProvider represents an AI provider detection pattern

type BaseDetector

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

BaseDetector provides common functionality for all detectors

func NewBaseDetector

func NewBaseDetector(name string, confidence float64) *BaseDetector

NewBaseDetector creates a new base detector with the given name and confidence

func NewStackBaseDetector

func NewStackBaseDetector(name string, confidence float64) *BaseDetector

NewStackBaseDetector creates a new base detector with the given name and confidence

func (*BaseDetector) Detect

func (d *BaseDetector) Detect(ctx context.Context, dir string) (*ProjectInfo, error)

Detect implements the Detector interface for the BaseDetector This is a base implementation that should be overridden by specific detectors

func (*BaseDetector) Name

func (d *BaseDetector) Name() string

Name returns the detector name

type Cache

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

Cache provides simple file-based caching for project detection results

func NewCache

func NewCache() *Cache

NewCache creates a new detection cache

func (*Cache) Clear

func (c *Cache) Clear()

Clear removes all cache entries

func (*Cache) Get

func (c *Cache) Get(dir string) *types.ProjectInfo

Get retrieves project info from cache if available and not expired. It first checks the in-memory cache, then falls back to the disk cache. Returns nil if the cache entry is not found or has expired.

func (*Cache) Invalidate

func (c *Cache) Invalidate(dir string)

Invalidate removes a specific cache entry

func (*Cache) Set

func (c *Cache) Set(dir string, info *types.ProjectInfo, ttl ...time.Duration) error

Set stores project info in cache with an optional TTL

type Components

type Components struct {
	Frontend   []string
	Backend    []string
	Database   []string
	AI         []string
	Deployment []string
}

Components represents the components of a technology stack

type ContentMatcher

type ContentMatcher func(content string) bool

ContentMatcher represents a function that matches content in a file

type DatabasePattern

type DatabasePattern struct {
	Type        string
	Dependency  string
	Image       string
	MountPath   string
	DefaultSize string
	Port        int
}

DatabasePattern represents a database detection pattern

type DetectionManager

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

DetectionManager handles asynchronous detection operations

func NewDetectionManager

func NewDetectionManager(registry *DetectorRegistry) *DetectionManager

NewDetectionManager creates a new detection manager with default settings

func (*DetectionManager) DetectAsync

func (dm *DetectionManager) DetectAsync(ctx context.Context, dir string) <-chan *DetectionResult

DetectAsync runs all registered detection tasks asynchronously

func (*DetectionManager) DetectProject

func (dm *DetectionManager) DetectProject(ctx context.Context, dir string) (*ProjectInfo, error)

DetectProject performs detection and returns a project info This is a synchronous version of DetectAsync for backward compatibility

func (*DetectionManager) GetConfidenceThreshold

func (dm *DetectionManager) GetConfidenceThreshold(detectionType string) float64

GetConfidenceThreshold gets the confidence threshold for a detection type

func (*DetectionManager) RegisterDefaultTasks

func (dm *DetectionManager) RegisterDefaultTasks()

RegisterDefaultTasks registers all the default detection tasks

func (*DetectionManager) RegisterDetectionTask

func (dm *DetectionManager) RegisterDetectionTask(detector Detector, weight float64, timeout time.Duration)

RegisterDetectionTask adds a new detection task to the manager

func (*DetectionManager) SetCacheTTL

func (dm *DetectionManager) SetCacheTTL(ttl time.Duration)

SetCacheTTL sets how long detection results should be cached

func (*DetectionManager) SetConfidenceThreshold

func (dm *DetectionManager) SetConfidenceThreshold(detectionType string, threshold float64)

SetConfidenceThreshold sets the confidence threshold for a specific detection type

type DetectionPattern

type DetectionPattern struct {
	Type       PatternType
	Pattern    string // Regex pattern or exact match
	Path       string // Where to look (package.json, requirements.txt, etc.)
	Confidence float64
}

DetectionPattern defines a pattern to match in a project

type DetectionResult

type DetectionResult struct {
	ProjectTypes map[string]float64     // Map of project type to confidence level
	Editors      map[string]float64     // Map of editors to confidence level
	ProjectInfo  *ProjectInfo           // Consolidated project info
	Metadata     map[string]interface{} // Additional metadata from detection
	CompletedAt  time.Time              // When the detection completed
	// contains filtered or unexported fields
}

DetectionResult represents the result of multiple asynchronous detections

type DetectionTask

type DetectionTask struct {
	Detector Detector
	Weight   float64
	Timeout  time.Duration
}

DetectionTask represents a detection operation that can run asynchronously

type Detector

type Detector interface {
	// Detect analyzes a directory to detect project information
	Detect(ctx context.Context, dir string) (*ProjectInfo, error)
	// Name returns the detector name
	Name() string
}

Detector defines the interface for project detectors

func NewDockerDetector

func NewDockerDetector() Detector

NewDockerDetector creates a new detector for Docker projects

func NewGoDetector

func NewGoDetector() Detector

NewGoDetector creates a new detector for Go projects

func NewJetBrainsDetector

func NewJetBrainsDetector() Detector

NewJetBrainsDetector creates a new detector for JetBrains IDEs

func NewLLMDetector

func NewLLMDetector() Detector

NewLLMDetector creates a new detector for AI/LLM-powered IDEs

func NewNodeJSDetector

func NewNodeJSDetector() Detector

NewNodeJSDetector creates a new detector for Node.js projects

func NewPythonDetector

func NewPythonDetector() Detector

NewPythonDetector creates a new detector for Python projects

func NewVSCodeDetector

func NewVSCodeDetector() Detector

NewVSCodeDetector creates a new detector for VS Code

type DetectorRegistry

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

DetectorRegistry holds all registered project detectors

func NewDetectorRegistry

func NewDetectorRegistry() *DetectorRegistry

NewDetectorRegistry creates a new registry with all available detectors

func (*DetectorRegistry) ClearCache

func (r *DetectorRegistry) ClearCache()

ClearCache clears the detection cache

func (*DetectorRegistry) DetectProject

func (r *DetectorRegistry) DetectProject(dir string) (*types.ProjectInfo, error)

DetectProject attempts to detect project type using all registered detectors

func (*DetectorRegistry) GetDetectors

func (r *DetectorRegistry) GetDetectors() []ProjectDetector

GetDetectors returns all registered detectors

type DjangoDetector

type DjangoDetector struct{}

DjangoDetector detects Django projects

func (*DjangoDetector) Detect

func (d *DjangoDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*DjangoDetector) Priority

func (d *DjangoDetector) Priority() int

type DockerDetector

type DockerDetector struct{}

DockerDetector detects Docker projects

func (*DockerDetector) Detect

func (d *DockerDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*DockerDetector) Priority

func (d *DockerDetector) Priority() int

type DockerImageVerificationResult

type DockerImageVerificationResult struct {
	Message     string
	Registry    string
	Repository  string
	Tag         string
	Suggestions []string
	Valid       bool
	IsPrivate   bool
}

DockerImageVerificationResult contains the result of a Docker image verification

func VerifyDockerImage

func VerifyDockerImage(ctx context.Context, image string) (*DockerImageVerificationResult, error)

VerifyDockerImage checks if a Docker image is valid and accessible It returns a verification result with details about the image

type FastAPIDetector

type FastAPIDetector struct{}

FastAPIDetector detects FastAPI projects

func (*FastAPIDetector) Detect

func (d *FastAPIDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*FastAPIDetector) Priority

func (d *FastAPIDetector) Priority() int

type FrameworkDetector

type FrameworkDetector struct{}

FrameworkDetector implements project type detection

func (*FrameworkDetector) Detect

func (d *FrameworkDetector) Detect(dir string) (*types.ProjectInfo, error)

Detect attempts to determine the project type and metadata

type FrameworkPattern

type FrameworkPattern struct {
	Type        types.ProjectType
	FilePattern string
	Image       string
	Port        int
}

FrameworkPattern represents a framework detection pattern

type GenericDetector

type GenericDetector struct{}

GenericDetector uses simple file existence checks to detect project types

func (*GenericDetector) Detect

func (d *GenericDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*GenericDetector) Priority

func (d *GenericDetector) Priority() int

type GoDetector

type GoDetector struct{}

GoDetector detects Go projects

func (*GoDetector) Detect

func (d *GoDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*GoDetector) Priority

func (d *GoDetector) Priority() int

type LLMDetector

type LLMDetector struct{}

LLMDetector detects AI-powered IDEs or LLM-based coding assistants

func (*LLMDetector) Detect

func (d *LLMDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*LLMDetector) Priority

func (d *LLMDetector) Priority() int

type LangchainNextJSDetector

type LangchainNextJSDetector struct{}

LangchainNextJSDetector detects Next.js projects with Langchain integration

func (*LangchainNextJSDetector) Detect

func (*LangchainNextJSDetector) Priority

func (d *LangchainNextJSDetector) Priority() int

type LlamaPythonDetector

type LlamaPythonDetector struct{}

LlamaPythonDetector detects Python projects using Llama

func (*LlamaPythonDetector) Detect

func (d *LlamaPythonDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*LlamaPythonDetector) Priority

func (d *LlamaPythonDetector) Priority() int

type MEANDetector

type MEANDetector struct{}

MEANDetector detects MEAN stack projects (MongoDB + Express + Angular + Node.js)

func (*MEANDetector) Detect

func (d *MEANDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*MEANDetector) Priority

func (d *MEANDetector) Priority() int

type MERNDetector

type MERNDetector struct{}

MERNDetector detects MERN stack projects (MongoDB + Express + React + Node.js)

func (*MERNDetector) Detect

func (d *MERNDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*MERNDetector) Priority

func (d *MERNDetector) Priority() int

type NestJSDetector

type NestJSDetector struct{}

NestJSDetector detects NestJS projects

func (*NestJSDetector) Detect

func (d *NestJSDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*NestJSDetector) Priority

func (d *NestJSDetector) Priority() int

type NextjsDetector

type NextjsDetector struct{}

NextjsDetector implements project type detection for Next.js projects

func (*NextjsDetector) Detect

func (d *NextjsDetector) Detect(dir string) (*types.ProjectInfo, error)

Detect attempts to determine if this is a Next.js project

func (*NextjsDetector) Priority

func (d *NextjsDetector) Priority() int

type NodeDetector

type NodeDetector struct{}

NodeDetector detects Node.js projects

func (*NodeDetector) Detect

func (d *NodeDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*NodeDetector) Priority

func (d *NodeDetector) Priority() int

type PERNDetector

type PERNDetector struct{}

PERNDetector detects PERN stack projects (PostgreSQL + Express + React + Node.js)

func (*PERNDetector) Detect

func (d *PERNDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*PERNDetector) Priority

func (d *PERNDetector) Priority() int

type PatternType

type PatternType string

PatternType defines the type of pattern to match

const (
	PatternDependency  PatternType = "dependency"
	PatternFile        PatternType = "file"
	PatternImport      PatternType = "import"
	PatternContent     PatternType = "content"
	PatternEnvironment PatternType = "environment"
)

type ProjectDetector

type ProjectDetector interface {
	// Detect attempts to determine the project type and gather relevant info
	Detect(dir string) (*types.ProjectInfo, error)
	// Priority returns the detection priority (higher runs first)
	Priority() int
}

ProjectDetector defines the interface for project detection

type ProjectInfo

type ProjectInfo struct {
	Dependencies map[string]string
	Metadata     map[string]interface{}
	Scripts      map[string]string
	LLMModel     string
	Framework    string
	Language     string
	Path         string
	Version      string
	Editor       string
	LLMProvider  string
	Type         string
	ImageTag     string
	Name         string
	Port         int
	Confidence   float64
	HasDocker    bool
}

ProjectInfo contains detected information about a project

type PythonDetector

type PythonDetector struct{}

PythonDetector detects Python projects

func (*PythonDetector) Detect

func (d *PythonDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*PythonDetector) Priority

func (d *PythonDetector) Priority() int

type ReactDetector

type ReactDetector struct{}

ReactDetector detects React projects

func (*ReactDetector) Detect

func (d *ReactDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*ReactDetector) Priority

func (d *ReactDetector) Priority() int

type StackDefinition

type StackDefinition struct {
	Name               string
	Description        string
	RecommendedRuntime string
	Components         Components
	RequiredComponents []string
	OptionalComponents []string
	MainPatterns       []DetectionPattern
	ExtraPatterns      []DetectionPattern
}

StackDefinition defines a technology stack and its detection patterns

type StackDetector

type StackDetector struct {
	BaseDetector
	// contains filtered or unexported fields
}

StackDetector is a unified detector for common technology stacks

func NewStackDetector

func NewStackDetector() *StackDetector

NewStackDetector creates a new detector for common technology stacks

func (*StackDetector) Detect

func (d *StackDetector) Detect(dir string) (*types.ProjectInfo, error)

Detect analyzes a project to determine its technology stack

func (*StackDetector) Priority

func (d *StackDetector) Priority() int

Priority returns the detection priority

type TechStack

type TechStack struct {
	Name          string
	Frontend      string
	Backend       string
	Database      string
	Deployment    string
	AIIntegration []string
	Confidence    float64
}

TechStack represents a complete technology stack

type VectorDBPattern

type VectorDBPattern struct {
	Type       string
	Dependency string
	Image      string
	MountPath  string
	Port       int
}

VectorDBPattern represents a vector database detection pattern

type VueDetector

type VueDetector struct{}

VueDetector detects Vue.js projects

func (*VueDetector) Detect

func (d *VueDetector) Detect(dir string) (*types.ProjectInfo, error)

func (*VueDetector) Priority

func (d *VueDetector) Priority() int

Jump to

Keyboard shortcuts

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